Wednesday, March 10, 2010

rescue off-screen windows with applescript

i work with dual screens a lot on my macbook specially when i’m at home. every once in a while i would be in too much of a hurry to remove my vga display adapter or return windows to the main screen before putting my macbook to sleep. as a result, i have some windows that are off-screen when my macbook wakes up.

it happened to me again this morning so i finally decided to do something about it. i asked my friend google to see if there was a quick solution i could use. turns out it’s a pretty common occurrence and this mac rumors thread i found had some possible solutions:

  • use Windows -> Zoom
    • doesn’t work if the application did not implement this like keepass and opera (my problem window)
  • gather windows button
    • this only appears when you have a second display attached. if that were the case, i wouldn’t be having this problem in the first place :)
  • spaces + expose
    • doesn’t really work. even if you are able to drag the preview window from one space to another, once you revert to the normal view the window returns off screen only this time in the current space you dragged it into.
so no solutions so far, at least none that worked for me.

fortunately, at end of the same thread someone wrote that it was possible to do it using applescript. he had actually posted some script but he mentioned that running the script had some sort of side effect that could be only be cleared by a reboot. i rarely reboot my macbook so this was not an option for me but it did get me thinking that i could probably write a quick script that would solve my problem. it won’t be a generic solution but it will be a quick an easy solution.

after a bit of research i was able to write a very short applescript that solved the problem and here it is:
tell application "Opera"
activate
set the bounds of the first window to {100, 100, 500, 500}
end tell
it doesn’t really matter what the bounds were as long as they were within the main screen. after running the script my opera window was finally on-screen and all that was left to do was resize the window. problem solved :)

Labels:

Monday, November 02, 2009

can't type in firefox

i've been using firefox for a while now, since firefox 2.x if i remember correctly, and i've been very happy with it. in fact, it has been my browser of choice for years be it for linux, windows, or mac. i even had portable firefox ready in one of my thumb drives just in case i'm on some machine without firefox installed. sadly, i can't say the same for version 3.5. so much so that google chrome is now starting to spend more time on my dock.

being a user of bleeding edge open source software for sometime now, i'm used to playing around with buggy apps. when something goes awry i know that solving it usually just involves at least one of 3 r's: restart, reboot (usually with windows), or reinstall. but for software like firefox which is now on 3.5, this shouldn't have to be the case. unlike beta or alpha software of which i am more forgiving, i expect much more from a product of this level of maturity. were not talking 1.0 here, it's version freakin' 3.5 already!

anyways, enough of my firefox rant let me get to the actual point of this post!

since 3.5 (at least that's when i started noticing it) my firefox, after running smoothly (more or less) for some hours would occasionally stop working. to be more specific, it would just suddenly stop receiving input from my keyboard. i could close tabs just fine, but i couldn't type on any text field! not on any text field in the current page i'm on nor the url or search fields of the actual browser. in the past, i would just shutdown firefox (kill/force quit mostly since it more often than not stops responding as well), but today i just got fed up and started looking for a solution. also, i didn't want to kill firefox because there were some tabs that i haven't bookmarked yet.

determined not to let this get the better of me, i turned to our friend google for a solution to my problem. with google chrome and a bit of google-fu, i got these results using the following keywords: firefox can't type. the first page of the search results alone told me that i was not alone. there were actually 24,200,00 results and although this is not necessarily an indicator of how prevalent the problem is, the results on the first page sure are. with results such as these, i was confident that the solution was just a click or two away.

the first result was actually all i needed. a very helpful post from pengunassasin said:

i wasn't actually running greasemonkey, but this post was a very good hint at the problem: javascript.

i'm not sure if it's the web programmer's fault for using window.stop() or the firefox (or firefox add on) developers fault for mishandling the interpretation of the code but i think both of them are at fault. the web programmer for not knowing better, and the firefox developers for not handling it properly. i mean, firefox developers, why would you allow an arbitrary piece of javascript code to stop the whole browser from receiving input? even if you say that window.stop() shouldn't really be used, it's there so you should be prepared to handle it!

dang, went into another rant there.

so what is the solution, very simple actually, just disable and then re-enable javascript in preferences. easy.

for those not familiar with how to do that here's a screen cap:

hope this post helps someone out there.

oh and one more thing... woohoo! another blog post after almost a year! well at least, it wasn't 2 years like the last time =)

Labels: , ,

Thursday, November 13, 2008

Trash on Leopard Stopped Working

don't you just hate it when you can't empty your trash bin on your mac? happens to me all the time, i trash some locked file (or something) and the next thing you know, empty trash no longer works, at least not for that file. it's not really a problem, just annoying. i mean sure the next time i restart my mac my trash bin would be empty but how often do you restart your mac? if you're like me, probably only after a software update that requires a restart =) and in the meantime the trash bin looks like it's full of trash, it just really gets on my nerves after a while. so here's what i did to solve that little annoyance:
  1. launch terminal
  2. make sure you are at your home directory. do a pwd just to be sure
  3. execute: rm -rf .Trash
  4. execute: mkdir -m07000 .Trash
and voila! my trash was now empty. there was just one little problem... my Trash bin stopped working altogether! now, whenever i did a move to trash using finder it just said that it was going to be deleted permanently. not good... so how did i solve this problem? it was simple really, Finder was able to detect that the .Trash folder had been deleted, unfortunately, it could not detect that the .Trash folder was recreated. a simple restart of Finder did the trick. you can do that by either:
  1. doing a force quit:
    1. press command + alt + esc
    2. select Finder
    3. click Relaunch
    4. click Yes to force quit

  2. doing a kill using the console:
    1. launch Terminal
    2. execute: killall Finder
    3. relaunch Finder using your Dock icon
was this really the best way to solve the trash problem? well, it would have been better if i didn't delete the .Trash folder. besides, the problem was with the contents of the trash bin not the actual trash bin. below would be the better way of doing it:
  1. launch terminal
  2. make sure you are at your home directory. do a pwd just to be sure
  3. execute: rm -rf .Trash/*
well, you know what they say... learn by doing :)

Labels: ,

Tuesday, October 21, 2008

A MESSAGE FROM THE QUEEN

thought this was hilarious :D

----------
To the citizens of the United States of America from Her Sovereign Majesty Queen Elizabeth II

In light of your failure in recent years to nominate competent candidates for President of the USA and thus to govern yourselves, we hereby give notice of the revocation of your independence, effective immediately.

(You should look up 'revocation' in the Oxford English Dictionary.)



Her Sovereign Majesty Queen Elizabeth II will resume monarchical duties over all states, commonwealths, and territories (except Kansas, which she does not fancy).



Your new Prime Minister, Gordon Brown, will appoint a Governor for America without the need for further elections.



Congress and the Senate will be disbanded. A questionnaire may be circulated next year to determine whether any of you noticed.



To aid in the transition to a British Crown dependency, the following rules are introduced with immediate effect:

-----------------------

1. The letter 'U' will be reinstated in words such as 'colour,' 'favour,' 'labour' and 'neighbour.' Likewise, you will learn to spell 'doughnut' without skipping half the letters, and the suffix '-ize' will be replaced by the suffix '-ise.' Generally, you will be expected to raise your vocabulary to acceptable levels. (look up 'vocabulary').

------------------------

2. Using the same twenty-seven words interspersed with filler noises such as ''like' and 'you know' is an unacceptable and inefficient form of communication. There is no such thing as U.S. English. We will let Microsoft know on your behalf. The Microsoft spell-checker will be adjusted to take into account the reinstated letter 'u'' and the elimination of '-ize.'

-------------------

3. July 4th will no longer be celebrated as a holiday.

-----------------

4. You will learn to resolve personal issues without using guns, lawyers, or therapists. The fact that you need so many lawyers and therapists shows that you're not quite ready to be independent. Guns should only be used for shooting grouse. If you can't sort things out without suing someone or speaking to a therapist,then you're not ready to shoot grouse.

----------------------

5. Therefore, you will no longer be allowed to own or carry anything more dangerous than a vegetable peeler. Although a permit will be required if you wish to carry a vegetable peeler in public.

----------------------

6. All intersections will be replaced with roundabouts, and you will start driving on the left side with immediate effect. At the same time, you will go metric with immediate effect and without the benefit of conversion tables. Both roundabouts and metrication will help you understand the British sense of humour.

--------------------

7. The former USA will adopt UK prices on petrol (which you have been calling gasoline) of roughly $10/US gallon. Get used to it.

-------------------

8. You will learn to make real chips. Those things you call French fries are not real chips, and those things you insist on calling potato chips are properly called crisps. Real chips are thick cut, fried in animal fat, and dressed not with catsup but with vinegar.

-------------------

9. The cold, tasteless stuff you insist on calling beer is not actually beer at all. Henceforth, only proper British Bitter will be referred to as beer, and European brews of known and accepted provenance will be referred to as Lager. South African beer is also acceptable, as they are pound for pound the greatest sporting nation on earth and it can only be due to the beer. They are also part of the British Commonwealth - see what it did for them. American brands will be referred to as Near-Frozen Gnat's Urine, so that all can be sold without risk of further confusion.

---------------------

10. Hollywood will be required occasionally to cast English actors as good guys. Hollywood will also be required to cast English actors to play English characters. Watching Andie Macdowell attempt English dialogue in Four Weddings and a Funeral was an experience akin to having one's ears removed with a cheese grater.

---------------------

11. You will cease playing American football. There is only one kind of proper football; you call it soccer. Those of you brave enough will, in time, be allowed to play rugby (which has some similarities to American football, but does not involve stopping for a rest every twenty seconds or wearing full kevlar body armour like a bunch of nancies).

---------------------

12. Further, you will stop playing baseball. It is not reasonable to host an event called the World Series for a game which is not played outside of America. Since only 2.1% of you are aware there is a world beyond your borders, your error is understandable. You will learn cricket, and we will let you face the South Africans first to take the sting out of their deliveries.

--------------------

13. You must tell us who killed JFK. It's been driving us mad.

-----------------

14. An internal revenue agent (i.e. tax collector) from Her Majesty's Government will be with you shortly to ensure the acquisition of all monies due (backdated to 1776).

---------------

15. Daily Tea Time begins promptly at 4 p.m. with proper cups, with saucers, and never mugs, with high quality biscuits (cookies) and cakes; plus strawberries (with cream) when in season.

God Save the Queen!

PS: Only share this with friends who have a good sense of humour (NOT humor)!

Labels:

Wednesday, October 01, 2008

Ten commandments for bloggers

i'm sure you've read quite a few commandment type articles on the web (of web design, of cellphone etiquette, of facebook to name a few) but what makes these commandments interesting is that these were based on the actual 10 commandments. these were even said to be engraved on cyberspace tablets!

the times online writes "Church leaders have drawn up a new set of the Ten Commandments aimed at delivering “God bloggers” from the temptations of the blogosphere."


Ten commandments for bloggers

1 You shall not put your blog before your integrity
2 You shall not make an idol of your blog
3 You shall not misuse your screen name by using your anonymity to sin
4 Remember the Sabbath day by taking one day off a week from your blog
5 Honour your fellow-bloggers above yourselves and do not give undue significance to their mistakes
6 You shall not murder someone else's honour, reputation or feelings
7 You shall not use the web to commit or permit adultery in your mind
8 You shall not steal another person's content
9 You shall not give false testimony against your fellow-blogger
10 You shall not covet your neighbour's blog ranking. Be content with your own content


source: http://www.timesonline.co.uk/tol/comment/faith/article4833275.ece

Labels: ,