May 23 2009

Iphone Lag Fixes

I’ve been spending way to much time on my iphone lately and It’s been becoming a little unresponsive. When I scroll I notice the refresh rate is delayed and loading programs like phone, sms and safari are delayed. At first I thought that my theme was the cause but even after turning off all winterboard effects I still have the same problem. I decided to research the issue and here are my results.

  • The iphone is said to never shut a program down so the memory of the device is getting saturated. To cure this you need to reset the device.You would think that powering down and back up again would do this but apparently you need to hold the power button and the home button at the same time until the iphone shuts down.
  • Remove unused programs. As soon as I got rid of a few of the apps that I never use the phone started responding a lot quicker but still not quick enough.
  • Turn off ssh. Running the ssh daemon in the background is using resources. If you’re not scp’d or ssh’d into the phone at the moment then why do you have it running?
  • Turn off the GPS services. If you need it then turn it back on. In Settings => General click “Location Services” to off. This will also help with battery life on the iphone.
  • If you’re suffering from SMS lag I’ve read that opening and closing the app store solves the problem on the iphone.

Mostly straight forward but still useful. I’ve found that Winterboard does not cause any lag whatsoever. I’ve tried multiple themes and played around with each and they don’t seem to lag the phone out at all.


May 21 2009

Best Windows Hotkey

I found a couple new windows hotkeys that I don’t think I’ve ever used before.  Decided to put up a poll to see what most people use on a day to day basis. All the useful windows hotkeys with explanations are right under the poll.

Whats the Best Windows Hotkey?

View Results

Loading ... Loading ...

CTRL and A             Select All
CTRL and C             Copy
CTRL and F             Find
CTRL and G             Go To
CTRL and N             New
CTRL and O             Open
CTRL and P             Print
CTRL and S             Save
CTRL and V             Paste
CTRL and X             Cut
CTRL and Z             Undo
CTRL and F4             Close
CTRL+ESC             Start menu

ALT+ENTER             View Properties
ALT+F4                 Close Item
ALT+SPACEBAR             Open Shortcut Menu
ALT+TAB             Switch Programs
ALT+ESC             Cycle Through Programs

F1 key                 Help
F2 key                 Rename in Windows Explorer
F3 key                 Search (Same as CTRL and F)
F4 key                 Display Address Bar
F5 key              Update/Refresh
F10 key             Activate Menu Bar

Windows Key             Display or hide the Start menu
Windows Key+BREAK         Display the System Properties dialog box
Windows Key+D             Display the desktop
Windows Key+M             Minimize all of the windows
Windows Key+SHIFT+M         Restore the minimized windows
Windows Key+E             Open My Computer
Windows Key+F             Search for a file or a folder
Windows Key+CTRL+F         Search for computers
Windows Key+F1             Display Windows Help
Windows Key+ L             Lock the keyboard
Windows Key+R              Open the Run dialog box
Windows Key+U             Open Utility Manager

TAB                 Move forward through the options
SHIFT+TAB             Move backward through the options
CTRL+TAB             Move forward through the tabs
CTRL+SHIFT+TAB             Move backward through the tabs

If I missed any then let me know


May 20 2009

unzip and unrar bash script

Do you ever download those files that are comprised of multiple zip files that always seem to extract individual rar files to their own folders. This would normally require the user to cut and paste all these rar files back into the original folder and then unrar them. This is very tedious, especially when there is lots of these files and folders. I’ve written this little shell script to automate this task for myself and figured that I would share. This script is extremely simple but it has worked great for every double archive that I have tried it on. As always any improvements and comments are welcome.

Call this script from the command line when your current working directory is the folder with all the zip files in it. To get your current working directory use the command ‘pwd’.

unzip -o \*.zip
for f in *.rar;do unrar -o- e “$f”;done
rm *.rar
rm *.zip

You may be asking why I was forced to escape the ‘*’ in the first line. If I didn’t do this then I got a lot of “caution: filename not matched:” errors on the unzip line. Not sure why and if anyone can shed some light on that it would be great. As for the option to the commands, read the man pages. And the for loop is pretty self explanatory.

Enjoy those giant image sets.


May 19 2009

Auto Increment in Postgres like Mysql

Why isn’t there a ‘auto increment’ type in postgres?
When I was creating a table in postgres earlier today I needed a unique identifier to use as a foreign key in other tables. There were no unique fields in the postgres table so I wanted to create an auto increment column type. I was surprised after browsing the field types in pgAdmin III that there is no ‘auto increment’ data type in postgres. I was expecting one because I’m so used to using mysql for the actual creation of databases. It seems that when using postgres we are expected to use either sequences for the very specifics or the serial data type for the basic +1 auto increment integer.
Here’s an example of using sequences :
First create the sequence:
CREATE SEQUENCE codys_sequence;

Then create the postgres table:
CREATE TABLE some_postgres_table (
id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval(‘codys_sequence”),
some_field VARCHAR(50),
some_other_field VARCHAR(100)
It is a lot easier to just let the postgres database handle the creation and automation by specifying the field as a SERIAL type. Sequences are mostly useful when you want to increment the integer by a certain value like if you’re using master-master replication and don’t want to worry about race conditions.
With either a sequence or a serial field type it is much easier to insert data than with manually updated integer because you don’t need to include anything about the field in your insert statements.
INSERT into some_postgres_table (some_field,some_other_field) values (“auto”,”increment”);

Technorati Profile


May 18 2009

Google Query Syntax Explanations: Part 2

Here are a few more little known tricks that can be used to get better results from the google search engine. Save some bandwidth and tell your friends.

You can add all sorts of arguments to your google search query. The most useful that I’ve found so far is filetype. This allows you to specify the type of file that you want to search for.
If I type :
“iphone” filetype:pdf
into the google search engine then I only get pdf files in my search results, most of which are useful instructional manuals on the iphone.

There are many other arguments that can be useful:

intitle:”tech stuff”
inanchor:”tech stuff”

Stop Words

Google automatically removes certain words from searches. These are called stop words and consist of words like ‘I’, ‘a’, ‘the’, and ‘of’. To force google to use these words then add a ‘+’ to the begining of the word. So searching for a statement with ‘+the’ in it would force the query to look for the ‘the’. If you don’t care wheter these words are included in the search then why even enter them?

Order and repetition matter.

“codytaylor” scp
emphasizes the “codytaylor” and produces different results than searching
scp “codytaylor”
The keywords to the left are always given higher precedence in the query.

“codytaylor” scp
produces different results than searching
“codytaylor” scp scp

So if you’re looking for a page that is saturated with a specific keyword then you’ll have much more luck if you type it in more than once.


May 17 2009

Google Query Syntax Explanations: Part 1

Basic Google Syntax Explanations

Ever see someone spending hours trying to find something in google and just giving up due to the enormous amount of content for any given keyword? I’m amazed at how little everyone knows about using the Google search engine. Most of the population uses google every day but are still unaware of  some very basic but extremely simple and effective syntax rules for google queries. This takes energy and bandwidth. In the following I try and outline two of the most common methods of narrowing your search results down to only what you want.

  • Basic Boolean: Use ‘AND’ and ‘OR’ in your query. The ‘AND’ will require the result to include both keywords and the ‘OR’ will allow results that have either keywords in them. You can also use the ‘|’ (pipe) character to specify ‘OR’. To make sure that none of the results include a specific word then use the ‘-‘ character in front of the word. So searching ‘cody AND taylor AND -yoyo’ will return results for cody taylor that do not include yoyo.
  • Quotes: Use quotes on a query to specify that you only want to search results that are exactly as you write them. If I google codytaylor most of my results are for cody taylor but if I google “codytaylor” then I get results only containing codytaylor without any spaces. Googles forethought in displaying results and splitting up words is very useful but a lot of the time you will want your results to be exactly as you specified. Quotes are also used to specify keyword order. If I wanted results for only the useful and not some sentence or combination of words that include those three words then I would specify “only the useful”. Try it and you’ll notice a huge difference. Try a couple queries to see how much more specific your results become.

These two basic features are surprisingly little known yet so straight forward. Save everyone some bandwidth and explain this to the people around you.

Yes, Google is a verb.

Check out Part 2


May 17 2009

SSH Tunneling for Privacy and Trickery.

If you have access to a ssh server you can easily tunnel your web browsing and newsgroup/IRC activity to make sure that your IP is never associated with that ..stuff you do. You can basically tunnel any port through the any ssh server. These methods can be used to build up complex chains that are almost impossible to track.

To tunnel your basic browsing through a ssh “proxy” use this command:

ssh -D 8080 -p 22

I used port 8080 instead of the default 80 becuase I run a webserver on my local machine and I didn’t want to mess that up.

The -D in the command specifies a local dynamic application-level port forwarding which creates a socket to listen to the specified port on the local machine. Ancy connections made to this local port are forwarded over the secure channel.

This makes it easily possible to forward all web traffic on the local system through the secure channel by setting up a simple iptables rule:
–iptables -A PREROUTING -t nat -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 8080

If you want to set up a secure ssh tunnel to connect to a specific newsgroup server you can use this command:

sudo ssh -N -p 22 -f -L 443:

The -L specifies that the given port on the local client is to be forwarded to the given host and port on the remote side. This is basically a very specific instruction that tells all traffic that is directed to localhost at port 443 (119 if you don’t like double encryption) to go to the ip address Note: I couldn’t get this to work with domains for some reason.

The -N tells ssh to not execute any remote commands. So you do not get the annoying ssh session stuff that makes you leave the terminal open.

The -f tells ssh to go into the background.


May 15 2009

Read PDF’s Locally on the Iphone With Safari. No More Emails or URI Hacks

Read PDF’s Locally on the Iphone With Safari. No More Emails or URI Hacks

Essentially you can browse your entire iphone filesystem using this method but I just want to read PDF files as easily as possible.

I’ve been trying recently to find a proper PDF reader for the iphone that doesn’t really screw up the formatting or require very manual conversions and it seems that safari’s built in pdf reader is better than stanza and other readers.
Because safari on the iphone is not able to view files that are local on the device we need to do some quick work to make safari on the iphone read local files.
For this to work you will need to be able to access the iphone file system from a personal computer somehow. Check out how to get SCP on the iphone working.

First you will need to install the lighttpd program from cydia. It was under the networking section. Lighttpd is a tiny webserver for the iphone or ipod touch.
Once you’ve got lighttpd installed you will need to connect your iphone to your pc and open up SCP or a program similar over either wifi or through USB.

The version of lighttpd that I got from cydia didn’t have a default configuration file. So I created a file called lighttpd.conf which is extremely simple.
I chose not to put anything specific in the file because I never plan on accessing this iphone webserver from anywhere other than localhost.

server.document-root = “/var/www/”

server.port = 80

mimetype.assign = (
“.html” => “text/html”,
“.txt” => “text/plain”,
“.jpg” => “image/jpeg”,
“.png” => “image/png”

dir-listing.activate = “enable”

To check that your syntax is ok, log into the iphone with ssh or use a terminal app locally on the iphone and locate the lighttpd.conf file. I put mine in /etc.
Type this at the iphone prompt.

lighttpd -t -f lighttpd.conf

You should get “Syntax OK” after typing that into your iphone.

To start lighttpd:

lighttpd -D -f lighttpd.conf

Your document root on the iphone is now /var/www (if you used my configuration file) so start putting pdfs in there and you’ll now be able to read all those pirated ebooks that have been just sitting there taking up hard drive space for so long.
When you point safari to you will now see a list of the pdfs (or whatever else you want to put in there).


May 15 2009

Dojo Examples and Demos

The best resource for browsing all the features of dojo javascript is here. It not only displays all the features of dojo javascript but it also allows you to get any code for any feature you want. Check out here what you can do with it.


May 14 2009

Give Website a Custom Icon for the Iphone

To put a custom icon for a website on the home screen of your iphone or ipod touch you will need a PNG file which is 45×45 pixels.
Call this icon apple-touch-icon.png and store it in the root of the website. Not sure how to add a custom icon to other peoples websites yet.

Of course, to create the link, you will want to go the page in safari and select the ‘+’ button and then select the “add to home screen” option.

Check the icon at this iphone web application example.

If you want to add an icon image that is located somewhere else then use this

<link rel=”apple-touch-icon” href=”/images/iphone-icon.png” />