Sud­denly, after the upgrade from Snow Leop­ard to the much vaunted OSX Lion, my wire­less trans­fers over a home LAN net­work became slug­gish. It was tak­ing a few *min­utes* to trans­fer a sim­ple file.

Appar­ently I am not the only one with these issues.

I tried a few fixes gleaned from a bunch of sep­a­rate threads on the Apple forum, and off the web. Not every­thing is a smart sug­ges­tion. Here's what finally works, so hope this saves some peo­ple with sim­i­lar prob­lems the time:

[You need root access for the "sudo" bits of the fol­low­ing code to work, of course.]

1
2
3
sudo bash -c "echo 'net.inet.tcp.delayed_ack=0' >> /etc/sysctl.conf"
sudo bash -c "echo 'net.inet.tcp.recvspace=40960' >> /etc/sysctl.conf"
sudo bash -c "echo 'net.inet.tcp.rfc1323=0' >> /etc/sysctl.conf"

Make sure the sin­gle quotes remain sin­gle quotes in the above code share. These new sysctl set­tings will take effect after a reboot.

Another use­ful sug­ges­tion is to dis­able the IPV6 stuff. Not needed for now. Done using:


System Preferences ->
Network ->
Airport (or your WiFi listing) ->
Advanced (button) ->
TCP/IP (tab)

Change the IPV6 to "Link — Local".

Read More

So I updated to OSX Lion 10.7. Very cool, espe­cially with the easy gestures.

Biggest prob­lem: my bank web­site, which uses Java applets for secure logins, stopped work­ing. In the area where the login form should have been I saw a mes­sage that said: "Inac­tive Plug-in". Same prob­lem across Fire­fox, Safari, Chrome — all updated to their lat­est versions.

I installed the lat­est Java for OSX Lion from the Apple web­site. In hind­sight, this was not nec­es­sary as the "Soft­ware Update" from the Apple menu, as usual, takes care of every­thing includ­ing updat­ing the lat­est Java.

So the prob­lem was clearly not with the browsers. The list­ing of plu­g­ins in Fire­fox showed me that "Java Applet Plu­gin" is in fact active.

The prob­lem was annoy­ingly sim­ple: the update to OSX Lion 10.7 and above often (not always, appar­ently) dis­ables Java inside browsers for some odd secu­rity reason.

All I had to do was go into "Java Pref­er­ences" and enable this back again. Apple hasn't made it easy, but it's a sim­ple com­mand in Terminal:

/Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences

This will bring up a win­dow as in the screen­shot below. Just enable the bit that says to allow applets in browsers, and you're all set. (It will work when you restart your browser.)

Java Preferences on Mac OSX Lion

(Edit: You can also search in Spot­light for "Java Preferences".)

Read More

A sim­ple app ought to do it.

iRinger - Free app

Down­load iRinger. It used to be a Win­dows app, but is now avail­able for Mac OSX!

A very intu­itive appli­ca­tion. Select a song (mp3 for exam­ple), it clips it and shows you the ringtone-worthy seg­ment of it, you basi­cally export it as a ".m4r" file.

When done, just open the file and iTunes will auto­mat­i­cally open it. Done.

Read More

This reg­exp worked for me.

1
2
3
4
5
6
7
8
9
10
11
12
SELECT * FROM TABLE
WHERE NOT COLUMN ~ ( '^('||
 $$[\09\0A\0D\x20-\x7E]|$$||               -- ASCII
 $$[\xC2-\xDF][\x80-\xBF]|$$||             -- non-overlong 2-byte
  $$\xE0[\xA0-\xBF][\x80-\xBF]|$$||        -- excluding overlongs
 $$[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|$$||  -- straight 3-byte
  $$\xED[\x80-\x9F][\x80-\xBF]|$$||        -- excluding surrogates
  $$\xF0[\x90-\xBF][\x80-\xBF]{2}|$$||     -- planes 1-3
 $$[\xF1-\xF3][\x80-\xBF]{3}|$$||          -- planes 4-15
  $$\xF4[\x80-\x8F][\x80-\xBF]{2}$$||      -- plane 16
 ')*$' )
;

Or, if you have iconv on your sys­tem, as most UNIX vari­ants do, you can pg_dumpall a data­base and run the fol­low­ing com­mand on it:

if (@iconv($input, 'UTF-8', 'UTF-8') == $input) echo "Good UTF-8!"; else echo "Nope."

Then take a plain text pg_dump of the data­base in UTF-8. Let's call it "db.orig.dmp". Strip all prob­lem characters:

iconv -f UTF-8 -t UTF-8 -c <db .orig.dmp >db.stripped.sql
</db>

Com­pare both files:

diff -u db.orig.dmp db.stripped.sql

That out­put will show all lines con­tain­ing a prob­lem char­ac­ter. Now the tedious part: Use "db.orig.dmp" to find out which tables they belong to, locate the records in the data­base by pri­mary key and fix them. Alter­na­tively, you can use iconv's auto-repair if you know which bytes give you a problem.

For exam­ple, if you know that the trou­ble stems only from 0×80 bytes that should be Euro sym­bols, you could:

iconv -f UTF-8 -t UTF-8 --byte-subst="&lt;0x%x>" < db.orig.sql | sed -e 's/&lt;0x80>/EUR/g' >db.fixed.sql

The result­ing "db.fixed.sql" could then be loaded into the new database.

Read More

If you use Fire­fox (and if not, what are you wait­ing for?) you are famil­iar with use­ful exten­sions such as Video Down­loader, which allow you to save local copies of the videos you watch on web­sites such as Youtube or Vimeo. You can then watch these videos when­ever you please.

But this doesn't account for those rare but pos­si­ble times when you are not on your machine, or don't have access to a browser set up to your tastes. No exten­sions available.

That's where "Keep­Vid" comes in. Just enter your URL and it auto­mat­i­cally extracts any video(s) found on that web­site and allows you to down­load in both FLV and MP4 for­mats. The MP4 would play on your Nokia, iPhone, or Black­berry too. The FLV file is a flash viewer file, and eas­ily played using com­mon video play­ers – if you don't have VLC, get it pronto.

Here's a straight­for­ward screenshot:

KeepVid screenshot saving a Youtube video

Read More

You use Post­greSQL. You find that a col­umn you have in a table is of a smaller length than you now wish. In my case, this was a varchar(20) that I now wished to make varchar(35). Noth­ing else. I just want to change the size, keep­ing the data intact.

The ALTER TABLE ...ALTER COLUMN...TYPE... com­mand is use­ful only if you want to alter the data some­how, or change the data type. Oth­er­wise, it'll be an aeon before this fin­ishes even inside a trans­ac­tion on a data­base of any mean­ing­ful size.

Until now, I was not famil­iar with any sen­si­ble mech­a­nism to sim­ply change the size in PG. But yes­ter­day, Tom Lane him­self sug­gested some­thing uber­cool in the list.

Let's assume for the sake of sim­plic­ity that your table is called "TABLE1" and your col­umn is "COL1". You can find the size of your "COL1" col­umn by issu­ing the fol­low­ing query on the sys­tem tables:

SELECT atttypmod FROM pg_attribute
WHERE attrelid = 'TABLE1'::regclass
AND attname = 'COL1';
 
atttypmod
-----------
24
(1 ROW)

This means that the size is 20 (4 is added for legacy rea­sons, we're told). You can now con­ve­niently change this to a varchar(35) size by issu­ing this command:

UPDATE pg_attribute SET atttypmod = 35+4
WHERE attrelid = 'TABLE1'::regclass
AND attname = 'COL1';
 
UPDATE 1

Note that I man­u­ally added the 4 to the desired size of 35..again, for some legacy rea­sons inside PG. Done. That's it. Should we check?

d TABLE1
 
TABLE "public.TABLE1"
COLUMN  |  TYPE                 | Modifiers
--------+-----------------------+-----------
COL1    | CHARACTER VARYING(35) |

Such a sim­ple yet effec­tive trick. Of course it'd be nicer if this is some­how included in a more proper way in the data­base, but this does the job.

Read More

So you've been vis­ited by the much dreaded CRC — Cycli­cal Redun­dancy Check error, most likely encoun­tered while copy­ing files between hard disks. On Mac OSX, this will usu­ally appear as some cryp­tic per­mis­sions mes­sage with an Error –36.

To cut the geek-speak, this sim­ply means that you hard disk may have cer­tain files that may have "bad sec­tors", or are cor­rupted in other words.

For­tu­nately, this is a com­mon enough prob­lem in our tech­ni­cally advanced world of exter­nal stor­age. I rec­om­mend solv­ing this on Win­dows (I use both XP and OSX Leop­ard at the time of this writing).

Step 1: CHKDSK

Use what Win­dows offers you by default. The chkdsk com­mand. Just open an MS-DOS com­mand prompt win­dow and go to the drive you wish to check (I'm hop­ing you already know your way around a com­mand prompt; if you don't please con­sider Step 2 below). With the com­mand prompt show­ing the drive let­ter of the disk you wish to check, enter this command:

e:> chkdsk /R

Here, "e:" is my drive to be checked. The "/R" attribute asks the chkdsk com­mand to "recover" what­ever bad sec­tors it finds dur­ing its scan. In most cases, and if you're lucky, this ought to do it.

Step 2: CDCheck (Free)

Only if the prob­lem you were fac­ing still remains after you have run the chkdsk com­mand, should you con­sider doing this. This is a free­ware pro­gram that makes it super-easy to check/recover your disk. It can be any disk – your cur­rent hard disk, a CD or a DVD, or even an exter­nal hard disk. The inter­face is pretty sim­ple as you can see in the screen­shots here.

Step 3: Spin­Rite (US$ 90)

If all else has failed, just save your­self some heart­burn and go straight to Spin­Rite. This is hands-down the best soft­ware for this pur­pose, as any­one in a dire need of data recov­ery will con­firm. I would trust any piece of soft­ware from GRC. Only catch: it's not free, but when you use it you know why it's worth every last cent. It gives you a sim­ple option to save an ISO file, which you can then eas­ily burn on to a CD using any CD writer tool (includ­ing Win­dows' own right-click). Then reboot your machine so it starts from the CD. Spin­Rite will auto­mat­i­cally report and recover what­ever is recoverable.

Next Steps

Basi­cally, a CRC error is the begin­ning of the end. If this is on an exter­nal hard disk, I highly rec­om­mend that you con­sider back­ing up the data immediately.

Read More

Fire­fox 3 has a "fea­ture" that auto-fills a web­site that you wish to go to as you're typ­ing in the Loca­tion bar.

I wanted to turn this off, but with­out turn­ing off other auto com­plete functionality:

  • I want to retain the auto­com­plete in forms (which can be man­aged from Tools -> Options -> Privacy)
  • I also want to retain the auto­com­plete in the search box on the right (which can be turned off by right-clicking inside the box, and then check­ing off "Show Suggestions")

But the Loca­tion Bar is a some­what more involved beast. After hunt­ing in the innards of "about:config" I dis­cov­ered that this was pos­si­ble. Just fol­low these steps:

  1. In the loca­tion bar, type about:config. The loca­tion bar is of course the place where you type URLs. Note that this is your inter­nal Fire­fox con­fig­u­ra­tion. Don't mess with it.
  2. In the text box that appears at the top of this page, enter browser.urlbar.maxRichResults as the pref­er­ence name. (Tip: copy it from here and paste it into that box.)
  3. Set the value to 0 if you wish to dis­able the auto-complete alto­gether. I have it set to 2 so I get some sug­ges­tions but it doesn't crowd up the experience.
Read More

If you're here, you know what I'm talk­ing about. The Safari plu­gin sounds like a neat lit­tle tool but is a pesky cus­tomer on any com­puter. Not the way to win hearts. Delet­ing it doesn't work, not do the instruc­tions on their website.

Here is how I did.

  1. First, close Safari. This is VERY impor­tant, as it does not work otherwise.
  2. Start Ter­mi­nal. (Go to Appli­ca­tions -> Util­i­ties -> Ter­mi­nal, or type Ter­mi­nal in Spotlight).
  3. Under Ter­mi­nal type "sudo –s" with­out the quo­ta­tion marks to log in as root.
  4. Then enter:
    defaults write com.apple.finder AppleShowAllFiles TRUE
  5. Go to the blue (or gray) apple at the top left of the screen, then select Force Quit. From the menu of items, click on "Saft" and click on the Force Quit button.
  6. Then, in the same Force Quit win­dow, click on "Finder" and click the "Relaunch" button.
  7. In the Finder win­dow, on the top right bar (the Fil­ter spot­light bar), type "saft" with­out the quotes. Delete with delight any file called Saft. Note: This may reveal a few other files that may con­tain the word "Saft" such as threads.py in my case (a Python file). Nat­u­rally, you want to NOT delete these. Just get rid of the Saft files.
  8. Empty the trash. If there is a file that won't delete because it's in use, then Force Quit "Saft" again as in Step 5 above, and then Empty Trash again.
  9. Go back into Ter­mi­nal, and type "sudo –s" again with­out quo­ta­tion marks. Then enter:
     defaults write com.apple.finder AppleShowAllFiles FALSE

    This will set the Finder back to the way it was before. Then type "exit" and it will exit out of the root.

  10. Now nav­i­gate to the folder: /Library/InputManagers. Note that this is NOT the "Library" folder in your Users folder. This is the Library folder from the root. Inside Input­Man­agers is the "saft" folder — get rid of it.
  11. Empty Trash (again). If it says Saft is in use, reboot the machine and empty it then. Or if you use some excel­lent util­ity like Main­Menu you can "Force Empty Trash".

Go back to your happy, prob­lem free Mac!  :)

Read More

I use the Nokia e61i as my mobile. Instead of my telco's data plan (which offers me a mea­gre 1GB per month) I sim­ply pre­fer to use my home wire­less LAN when I am at home. Until recently I used the wire­less "access point" with­out any secure set­tings, but have had to move to WEP now due to cheeky neighbors.

Prob­lem: Nokia's WLAN option kept prompt­ing me for the WEP key *every­time* I would con­nect to my email or any website.

After googling for a good many days and bum­bling around on Nokia's forums, I have finally fig­ured out how to make Nokia remem­ber the cotton-picking pass­word. Sim­ple answer: you need to lose your cached WLAN entry, which may be stored as a non-WEP access point.

Here are the more detailed steps:

  1. Delete your cur­rent WLAN access point you've cre­ated for the E61i. This is the secret sauce.
  2. Now, under

    Tools > Settings > Connection > Access Points

    Select Options and cre­ate a new access point using "default set­tings". We'll tweak them below.

  3. Under Con­nec­tion Name, pick a name for your con­nec­tion. This doesn't have to be your wire­less network's SSID, but you can keep it under the same name.
  4. Under Data Bearer, select WLAN.
  5. Under WLAN Net­work Name, select man­ual entry and type in your SSID name.
  6. Under Net­work Sta­tus mark "Hidden".
  7. Net­work Mode will be the default: "Infrastructure".
  8. Under WLAN Secu­rity Mode, choose your secu­rity type. For instance, mine is WEP, so that's what I selected.
  9. Under WLAN Secu­rity Set­tings, go to WEP key set­tings and define your encryp­tion level, for­mat, and key. For instance, for WEP you might have 64 bit, ASCII, and "xyz­abc" as your level, for­mat, and key respec­tively. If you don't know this stuff, this entire tuto­r­ial is per­haps not for you, oth­er­wise you know what these val­ues are. (You can always login as admin user into your wire­less router and recon­firm these set­tings for your spe­cific case.)

That's it. You can now con­nect to some web­site or your email server on your mobile phone, select the WLAN with the name you chose in Step 3 above, and your Nokia e-series phone will remem­ber your WEP pass­word for good. Finally.

Read More