You access https sites. Chrome, in its secu­rity genius, warns you. Every. Sin­gle. Time.

No more. You can make it remem­ber that you trust a certificate.

When on a secure site, click the warn­ing icon on the loca­tion bar. The pre­cise icon may change, but at the time of writ­ing, it's a red cross.

Google Chrome - remember SSL certificate and trust site

Then click on the "Cer­tifi­cate Infor­ma­tion". This will bring up a small popup win­dow like this:

Google Chrome - remember SSL certificate and trust site 2

The cer­tifi­cate icon there. Just drag it to your desktop.

Double-click the .crt file on the desktop.

Then click on "Accept Certificate".

This may ask for your admin pass­word. Enter it, and you're done. Revis­it­ing this site will never show you the omi­nous red page again.

Very use­ful for work­ing with our own CPanel/WHM sites, for instance.

Read More

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.]

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

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

When you start up Ter­mi­nal, does it take over 10 sec­onds or so before the prompt appears?

Turns out the stores logs of pre­vi­ous ses­sions and over time this grows. Even apps like Main­Menu, that delete the "User Cache", do not delete these files.

These files are stored in an eso­teric loca­tion, hid­den from the reg­u­lar user. The files have the .asl file extension.

Here's the command.

sudo rm -f /private/var/log/asl/*.asl

Exe­cute that in a Ter­mi­nal win­dow. Then quit and restart Ter­mi­nal. No more delays or lags. Much faster Ter­mi­nal. The lack of logs to seek really speeds up Terminal.

This has been tried and tested in Snow Leop­ard, Leop­ard and OSX Lion. Won­der why Macs don't come with this already!

Read More

Any ded­i­cated server host­ing some web­sites that get mean­ing­ful traf­fic will quickly our­grow Cpanel's default /tmp folder size of 512MB. It houses PHP ses­sion files, tem­po­rary file uploads, your data­base tem­po­rary files, your web server's cache includ­ing the one from caches such as APC or eAc­cel­er­a­tor, and other such stuff.

With the tmp par­ti­tion full, the server will expe­ri­ence many ran­dom issues such as server crashes. Your sites will quickly go down and leave you head-scratching.

For­tu­nately, it's quite easy to resize the /tmp par­ti­tion on cPanel servers — espe­cially if it is the default one cre­ated by cPanel installs. There's a handy script at /scripts/securetmp.

Open this file:

pico /scripts/securetmp

And find this line:

my $tmpdsksize = 512000; # Must be larger than 250000

Change it to a larger num­ber than 512 MB. Say you want it to be 2 GB:

my $tmpdsksize = 2097152; # 2GB for the /tmp folder

Now close and save the file.

We need to stop all ser­vices that may be using this folder. For me, this includes MySQL, Apache and Nginx.

service mysql stop
service nginx stop
service httpd stop

Now we will sim­ply unmount the /tmp folder and recre­ate it. Here's the sequence of com­mands to cre­ate it:

lsof /tmp
umount -l /tmp
umount -l /var/tmp
rm -fv /usr/tmpDSK

Done. You can ver­ify the size of the /tmp folder among others:

df -h

This should show you some­thing like this:

/usr/tmpDSK ext3 2.0G 996M 1.1G 51% /tmp

NOTE: If you have any prob­lems, for instance, the size of the recre­ated /tmp folder is not really 2GB despite that code in the /scripts/securetmp we changed, it may be because of some set­tings you have in the /etc/fstab file. Take a look at it and com­ment out any lines that inter­fere with the LABEL for /tmp mount.

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.

 $$[\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

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';
(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';

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?

TABLE "public.TABLE1"
COLUMN  |  TYPE                 | Modifiers

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