Recently in Memo Category

Snow Leopard came in the mail today (finally). Thank you Apple, for killing a small tree to deliver me one DVD. Using a box large enough to house at least 16 retail packages to ship 1 single disc to an end line consumer is definitely the right choice!! Seriously, if I'm paying you $40 for the rights to kill a tree, I better be the one doing the killing, not you!

IMG_0101.JPGIMG_0102.JPGIMG_0103.JPG

The upgrade took just about 1 hour from inserting disc to the green check mark with "Install Succeeded" text...  Maybe they could've done it faster, I don't know. But what's important is I am now on Snow Leopard.

The upgrade was, unfortunately, not quirk free.  Read on for a few problems that I encountered and how I fixed them.

I'm creating yet another URL shortener script.  Why?  Because I'm not keen on over paying for simple scripts -- because, well, I'd be over paying -- and I'm not too keen on using open source scripts -- because the more people using the same script, the more likely people will find exploits in it.  So with all that in mind, I set out to create my own script.
With the 3.0 iPhone OS, new baseband, and everything, there are several problems floating about.  First, there are a large handful of users plagued by the rapid battery drain problem.  How do you know if you have this problem?  Well, its quite simple actually.  Before upgrading to 3.0, your battery is good for 12 hours, 8 hours, whatever.  After upgrading to 3.0, it discharges even if you have the phone plugged in, and you're generally looking at no more than 3 hours idle time.  Second, if you hacktivate your iPhone, you don't get youtube and you don't get push notifications.

I've found that the battery depletion problem is usually to do with activating using an official SIM, and then hacktivating the device, because apparently it leaves some messed up APN settings on the phone.  As for the push notifications, hacktivating it directly is not going to work because you're not going to get the certificates required for push notification.

Luckily for me, having an official SIM card and a third party SIM card means I can have the best of both worlds, and not have to worry about either problems.  Unfortunately, though, it does mean restoring the phone is a bit more time consuming.

Now, I must note that this is a memo for myself, and nothing but. Don't complain if you do not have an official SIM card so you cannot get it to work. Don't ask me for my certificates, because I don't want to share my pushed email messages and risk getting banned.  With that said, let's start.

I have a NAS with four 400GB harddrives running a RAID 5 installation, which means I won't lose data on there unless two of the drives go bad. It's done through my TS-409 (shown to the right). Since I have all these space, I might as well use it to backup my MacBook regularly so I don't lose any of my important data. OS X users know, Time Machine is awesome. It helps you take hourly, daily, and weekly snapshots of your computer. But unfortunately, it only works with additional harddrives attached to the machine, OR Time Capsule on your network... right? Wrong. Today, we will sideways hack Time Machine, and make it work with your SMB (Windows) share folder.

Before you get started, counter intuitive as it may seem, please be sure to have your data backed up before proceeding. While the memo is written with the best of intentions to help people make backups, I will not be responsible for any data loss as result of you following through this memo of my. You have been warned.

I started using RTM a while ago, and it works great.  It helps me keep all my to-dos together in one place, and allows me to set different deadlines so I don't forget them. But the problem is, there is no way to manage my to-do list while I'm on the go... you know, the boring bus commute, and things like that...  Until I ran into an article on how to use Fluid, an OSX application that converts webpages into small Applications for you. Fluid is nice because it offers both userscript (Greasemonky) and Google Gears (offline syncing) support.  But this is where my problem begin...

There is a really nice GM script I want to use, but it seems to cause problems with the Google Gear synchronization.  Whenever I have the script enabled, and Google Gear tries to sync, everything goes wonky and the page refuse to load.  I must disable the script, have Gears sync, and then re-enable the script.

If anyone knows how to make these work in harmony, please do leave a comment to let me know how!  In the mean time, I'll have to keep the script disabled...

Making Your OSX Run Faster

user-pic
Vote 0 Votes
As you guys are aware of, I just got my MacBook, and I'm still experiencing the should-not-exist-learning-curve...  Anyways, today, I noticed something funny, and I figured I'd share with all of you.

Earlier today, I was unable to start any applications...  I'd type the application name via QS, and QS would go away, but no app.  I'd use Finder to go to /Applications and attempt to manually launch it, and nothing would happen.  Finally, when I tried to start iTerm, it told me it was unable to fork.  Linux instincts kicked in and told me that the problem came from lack of resources or PIDs.  So I quickly quit a few apps (I had upwards to 30 applications running at that time), and long and behold, I was able to start applications again.  I checked my processes list via terminal, and noticed a bunch of idle perl processes -- It's still a mystery to me as to what they are, as I was unable to kill them individually, nor through killall, nor could I see them via Activity monitor, but that's besides the point.  I rebooted the system, and it seems to be running fine now (and the idle perl processes have yet to return *touch wood*).

I decided I want to pay attention to my resources usage, and make sure my system doesn't lock up on me.  I have the habit of leaving commonly used applications running...  this is even the case when I was still on Windows.  This is when I started to notice a funny trend.  It'd appear that applications on OSX suffers even more evident memory leak/consumption problem than their Windows counter part!  Here's a quick break down of memory usage oddities after around 12 hours of me working:
iTunes - Real Memory: 220.8MB, Virtual Memory: 2.0GB
Firefox - Real Memory: 208.4MB, Virtual Memory: 1.7GB
Mail - Real Memory: 150.2MB, Virtual Memory: 1.4GB
Last.fm - Real Memory: 92.7MB, Virtual Memory: 1023.49MB
uTorrent - Real Memory: 16.28MB, Virtual Memory: 973.33MB

iTunes I understand, I have tons of music (library of 1699 tracks, 14.13 GB total) and most of them are tagged with album art, so it takes resource to load when I play songs.  But on Windows, my iTunes usually floats at around 150MB of memory usage, not 220MB!  So I quickly quit iTunes and restarted it.  Surely, it dropped down to 70MB of real memory, and arond 1GB of virtual memory -- though, as I wrote these, it grew slowly to 85.52MB and 1.07GB already.

Firefox I understand...  The prefetching "feature" and caching of tabs etc. does eat up quite a bit of resources...  On Windows I've seen it gone up to as much as 600MB of memory, too... So I just killed it and restarted.  It's coasting at around 107MB right now...

Mail - I wonder if it downloaded all my mails from gmail, even though I said IMAP, and tries to load them into memory over time... Mail is now consuming only 51MB and 1.0GB after quit and relaunch.

Last.fm - WHY?!  It's a tiny icon that does nothing but scrob my musics! ... and I don't even listen to music from it.  Restarted it and its now only eating 21MB and 986.49MB of memory.

uTorrent - This one is tiny, but still worth mentioning...  Because I didn't do anything with it!  I simply decided to download it to see if it is exactly the same as the Windows counter part.  Forgot about it, and left it idling.  No downloading, no seeding, no hash checking, nothing.   Main window isn't even open (so I don't see it on expose)!   Restarting it seem to have make it go down to 13.17MB, and 966.61MB though.

So, yeah...  tip to make your OSX run faster?  Just quit your apps and restart them every now and then!  It's surprising to see their memory grows so rapidly, even if you're not doing anything with them...

Getting into the Mac world, I encountered two awesome tools from the same author; Nocturne, a tool which allows you to invert screen colors so your eyes doesn't go blind in dark places, and Quicksilver, a rapid application launcher allowing you to perform complex tasks with just a few key strokes. However, they don't integrate well together.... I can't seem to use Quicksilver to toggle Nocturne.... not until I wrote a quick AppleScript for it... And you can do it too!

Here's how I did it.

First, start Nocturne normally, and go to the preferences panel. Disable sensor auto switch... that will bump you right out of invert mode if you are in a bright enough place.

Then, enter night mode, and quit the application... it will auto revert back to day mode upon exit, but when you launch it again, it will start in night mode, which is what we want.

Next, go to script editor (Quicksilver > Script Editor, Enter) and create this script (copy & paste should do the trick):

Apple Script
property Disabled : false
tell application "System Events"
set TheList to get name of every process
repeat with i from 1 to the count of TheList
if item i of TheList contains "Nocturne" then
tell application "Nocturne" to quit
set Disabled to true
end if
end repeat
if Disabled is false then
tell application "Nocturne" to activate
end if
end tell

Save the script you've just created into ~/Library/Application Support/Quicksilver/Actions as Nocturne.scpt and you're almost ready to rock! Trigger your Quicksilver, use Command + R to force refresh of your catalog, and type Nocturne into the first box of Quicksilver. Because Quicksilver weights the application more heavily than your script, you need to hit down a few times to find the script instead of launching the application directly. I gave it three times and then Quicksilver learned that I want to use the script instead of real app... it might take you lesser or more, depending on how many times you've launched Nocturne via Quicksilver. But once it learns that, its all good.

Now, each time you want to toggle mode, just trigger Quicksilver, type Nocturne, and it'll switch day and night mode for you. Pretty neat huh?

Got it to work? Please let me know how things are working out for you via comments section :)

So I had to let a co-worker use my computer yesterday.  He needed to activate his Google account, so he could activate his Google calendar, so we can manage our time better -- more like I can track him down easier :p

All is fine and good, until he click the "never for this site" button for remember password on our campus central authentication system...  Apparently, some how that translated to Chrome as "remove the current entry that auto loaded on page load" (my personal login), "and never ask user whether or not Chrome should remember the login information for this domain"...  This was very problematic, because now I cannot get Google to remember MY login on MY computer which I use on a regular basis and want to be lazy on!!

I poked around the options, and forms, but was unable to find a way to un-do that forsaken button click he did, so I realized I had to dig further. After much searching around and poking around, i the profile settings directory of Google Chrome, I found a sqlite3 database, which contained all the login information.  This file can be read with any sqlite3 db manager.  Luckily, I was able to remove the block from here manually.  As a memo for self -- in case if people clicks the evil button on me again -- here are the procedures to un-do that click.

Z-Rox Walkthrough

user-pic
Vote 0 Votes
Because of personal interest, I waste a lot of time on random silly flash games.  Today, Z-Rox caught my attention because it was linked on some boards I regular. 

Objective of the game is simple, you look at the cross section image provided to you, and you try to figure out what you're actually seeing. It's quite an unique idea which we haven't seen before, you should give it a try sometime. If it gets too difficult, read on for walk through (or a list of answers)...
I tried to install APF (Advanced Policy Firewall) on my Debian 4 server just now, and found out that most tutorials I've seen online doesn't work "out-of-the-box", so I'm writing this one for myself in the future.  Anyone reading this entry and have no idea what APF is, you can read more about it here: http://www.rfxnetworks.com/apf.php

You should be warned; before we continue, if you mess up your configurations, you can and WILL lock yourself out of your server.  Be very careful when you continue with the rest of this memo.  Make sure you have someone who is physically at the server, and can help you regain access to it should you mess up.  Management services are usually expensive, I'm not responsible for any bills incurred as result of this.  You have been warned.

1) Login to your server via SSH, root preferred.

2) Go to a directory where you can download, save, and keep things organized (in my case: ~/installs/ ), and issue these command:
SSH Command
wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz
tar -zxvf apt-current.tar.gz

3) Now go into the directory you just extracted, in my case, with this command:
SSH Command
cd apf-0.9.6-3/

4) We'd need to edit a few files now before we install it:
i) because Debian does not have /etc/rc.d/init.d/..., but just /etc/init.d/ we'd need to remove the rc.d reference from the files.  There are five instances of them in the version I'm working with, may be more in the future:
SSH Command
./apf.init:. /etc/rc.d/init.d/functions
./cron.daily:/etc/rc.d/init.d/apf restart >> /dev/null 2>&1
./install.sh:        if [ -f "/etc/rc.d/init.d/apf" ]; then
./install.sh:                cp -f apf.init /etc/rc.d/init.d/apf
./install.sh:                cp -f apf.init /etc/rc.d/init.d/apf


ii) because there is no /etc/init.d/functions (or /etc/rc.d/init.d/functions for that matter) in Debian, we need to comment that line in apf.init out; simply add a # infront of it would do.

5) Run the install script:
SSH Command
./install.sh

You should eventually see something like these:
SSH Command
Installing APF 0.9.5-1: Completed. Installation Details:
  Install path:         /etc/apf/
  Config path:          /etc/apf/conf.apf
  Executable path:      /usr/local/sbin/apf
  AntiDos install path: /etc/apf/ad/
  AntiDos config path:  /etc/apf/ad/conf.antidos
  DShield Client Parser:  /etc/apf/extras/dshield/

6) Configure the firewall by editing /etc/apf/conf.apf
SSH Command
nano /etc/apf/conf.apf

Few things you want to note:
  • DEVM = "1" is good for now, but you should change it to DEVM = "0" when you're done all the edits so it doesn't clear the bans every 5 minutes.
  • I found that my server did not have iptables configured as a kernel module, so I needed to set SET_MONOKERN="1"
  • Common TCP Ingress (incoming) ports on cPanel servers are: 21,22,25,53,80,110,143,443,2082,2083, 2086,2087, 2095, 2096,3000_3500
  • Common TCP Ingress (incoming) ports on Ensim servers are: 21,22,25,53,80,110,143,443,19638
  • Common UDP Ingress (incoming) ports are: 53
  • You can choose to filter Egress (outbound) by setting EGF="1", but I prefer to not do it so I don't find myself puzzled when I'm trying to wget / ftp / torrent things.
When you're done the usual Ctrl X, Y will exit and save.

7) Start the firewall:
SSH Command
/usr/local/sbin/apf -s

Other available parameters can be seen here:
SSH Command
usage /usr/local/sbin/apf [OPTION]
-s|--start ......................... load all firewall rules
-r|--restart ....................... stop (flush) & reload firewall rules
-f|--stop........ .................. stop (flush) all firewall rules
-l|--list .......................... list all firewall rules
-t|--status ........................ output firewall status log
-e|--refresh ....................... refresh & resolve dns names in trust rules
-a HOST CMT|--allow HOST COMMENT ... add host (IP/FQDN) to allow_hosts.rules and
                                     immediately load new rule into firewall
-d HOST CMT|--deny HOST COMMENT .... add host (IP/FQDN) to deny_hosts.rules and
                                     immediately load new rule into firewall
-u|--remove HOST ................... remove host from [glob]*_hosts.rules
                                     and immediately remove rule from firewall
-o|--ovars ......................... output all configuration options

8) Check and make sure everything is working...  Test your firewall by banning a friend's IP (or another server you've got access to's IP), and verify that it is actually banned, you can remove the ban with -u afterwards.

9) When you're ready, set the DEVM="1" to DEVM="0"

10) Make it so APF launches automagically when your server starts:
SSH Command
update-rc.d apf defaults

And you should be set!