<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>This is the technical scribble pad of Kit Sunde, a freelance software developer doing web things. I’m for hire: kitsunde@gmail.com</description><title>The scribble pad of doom</title><generator>Tumblr (3.0; @scribblepadofdoom)</generator><link>http://scribblepadofdoom.tumblr.com/</link><item><title>when we finish up a project that was trouble from day one</title><description>&lt;p&gt;&lt;a href="http://thisadvertisinglife.tumblr.com/post/31811533901/when-we-finish-up-a-project-that-was-trouble-from-day" class="tumblr_blog"&gt;thisadvertisinglife&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&lt;a href="http://imgur.com/632St"&gt;&lt;img alt="" src="http://i.imgur.com/632St.gif" title="Hosted by imgur.com"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/31889494928</link><guid>http://scribblepadofdoom.tumblr.com/post/31889494928</guid><pubDate>Thu, 20 Sep 2012 07:59:46 +0800</pubDate></item><item><title>Getting the EC2 DNS names registered to an ELB</title><description>&lt;p&gt;I wanted to get all the addresses registered to the ELB so I could work with fabric on the servers based on them being in the LoadBalancer. It&amp;#8217;s a bit cumbersome. I ended up with this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    import boto
    from boto import regioninfo
    from boto import ec2

    ACCESS_KEY_ID = '*****************'
    SECRET_ACCESS_KEY = '*************'

    elb_region = boto.regioninfo.RegionInfo(
        name='ap-southeast-1', 
        endpoint='elasticloadbalancing.ap-southeast-1.amazonaws.com')

    elb_connection = boto.connect_elb(
        aws_access_key_id=ACCESS_KEY_ID, 
        aws_secret_access_key=SECRET_ACCESS_KEY, 
        region=elb_region)

    ec2_region = ec2.get_region(aws_access_key_id=ACCESS_KEY_ID,
        aws_secret_access_key=SECRET_ACCESS_KEY, 
        region_name='ap-southeast-1')

    ec2_connection = boto.ec2.connection.EC2Connection(
        aws_access_key_id=ACCESS_KEY_ID, 
        aws_secret_access_key=SECRET_ACCESS_KEY,
        region=ec2_region)

    load_balancer = elb_connection.get_all_load_balancers(load_balancer_names=['MediaPopClients'])[0]
    instance_ids = [ instance.id for instance in load_balancer.instances ]
    reservations = ec2_connection.get_all_instances(instance_ids)
    instance_addresses = [ i.public_dns_name for r in reservations for i in r.instances ]
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/24777861347</link><guid>http://scribblepadofdoom.tumblr.com/post/24777861347</guid><pubDate>Sun, 10 Jun 2012 08:00:00 +0800</pubDate><category>aws</category><category>ec2</category><category>ELB</category></item><item><title>Enabling bz2 support and compiling python for a virtualenv</title><description>&lt;p&gt;Like last time another issue was a &lt;code&gt;bz2&lt;/code&gt; not being available even though on the system it was.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;yum bzip2-devel
wget &lt;a href="http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz"&gt;http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz&lt;/a&gt;
tar -zxvf Python-2.7.2.tgz
cd Python-2.7.2/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then configure python to be built absolute path of the virtualenv:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;./configure --prefix=/var/lib/jenkins/.virtualenvs/clients/
make
make install
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/18600834699</link><guid>http://scribblepadofdoom.tumblr.com/post/18600834699</guid><pubDate>Fri, 02 Mar 2012 17:40:34 +0800</pubDate><category>bzip2</category><category>Python</category></item><item><title>Enabling sqlite3 support and recompiling python for virtualenv</title><description>&lt;p&gt;We&amp;#8217;ve set up a new build server at work and for some perplexing reasons the virtualenv python was missing support for sqlite3, even though the system python had it. Although the system python still had sqlite3. We need to make sure the dev package of sqlite3 is installed before compiling.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;yum sqlite3-devel
wget &lt;a href="http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz"&gt;http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz&lt;/a&gt;
tar -zxvf Python-2.7.2.tgz
cd Python-2.7.2/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then configure python to be built absolute path of the virtualenv:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;./configure --prefix=/var/lib/jenkins/.virtualenvs/clients/
make
make install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Done. :)&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/15294518812</link><guid>http://scribblepadofdoom.tumblr.com/post/15294518812</guid><pubDate>Wed, 04 Jan 2012 22:04:00 +0800</pubDate><category>Python</category><category>sqlite3</category></item><item><title>Chrome Extensions - Working around being unable to resize a maximized window</title><description>&lt;p&gt;The chrome API lets you manipulate the size of a window through the &lt;code&gt;chrome.windows.update&lt;/code&gt; method, however there&amp;#8217;s a bug (&lt;a href="http://code.google.com/p/chromium/issues/detail?id=50138"&gt;#50138&lt;/a&gt;) where if a window is maximized then it won&amp;#8217;t resize and there doesn&amp;#8217;t appear to be a way to unmaximize a window.&lt;/p&gt;

&lt;p&gt;The only solution I can think of is to create a new window which start unmaximized with the desired dimensions and then moving the tabs over to the new window. Here&amp;#8217;s some example code I threw together which should maintain the state from one window to the new one:&lt;/p&gt;

&lt;script src="https://gist.github.com/1074629.js"&gt; &lt;/script&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/7456707800</link><guid>http://scribblepadofdoom.tumblr.com/post/7456707800</guid><pubDate>Sun, 10 Jul 2011 23:51:00 +0800</pubDate><category>Chrome</category><category>Chrome Extension</category><category>Chrome Extension Development</category></item><item><title>Ubuntu - Installing Sun JDK instead of OpenJDK on Natty</title><description>&lt;p&gt;I previously wrote how to do this under &lt;a href="http://scribblepadofdoom.tumblr.com/post/4776590305/ubuntu-installing-sun-jdk-instead-of-openjdk-on-maverick"&gt;Maverick&lt;/a&gt;. Another Ubuntu release is out with OpenJDK, here&amp;#8217;s how to replace it with Oracles JDK:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo add-apt-repository "deb &lt;a href="http://archive.canonical.com/"&gt;http://archive.canonical.com/&lt;/a&gt; natty partner"
sudo apt-get update

sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre sun-java6-plugin

sudo update-java-alternatives -s java-6-sun
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/7222111713</link><guid>http://scribblepadofdoom.tumblr.com/post/7222111713</guid><pubDate>Mon, 04 Jul 2011 16:00:00 +0800</pubDate><category>Ubuntu</category><category>11.04</category><category>Ubuntu 11.04</category><category>OpenJDK</category></item><item><title>Django - Setting up mod_wsgi with a relative rather than absolute path.</title><description>&lt;p&gt;The configuration example both on the &lt;a href="http://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/"&gt;Django&lt;/a&gt; website and on the &lt;a href="http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango"&gt;mod_wsgi&lt;/a&gt; site itself shows a configuration where you set up the wsgi script to refer to an absolute path. That seemed like unnecessary configuration to be done every time I&amp;#8217;m going to setup a &lt;a href="http://www.djangoproject.com/"&gt;Django&lt;/a&gt; site. Instead I created one where the path names are relative to the file instead. In my case the file resides under &lt;code&gt;/etc/myproject/mydjangoproject/apache/django.wsgi&lt;/code&gt;, so I ended up with this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;import os
import sys

""" For safetys sake we don't want to import just 'settings' so we add the
parent dir for safer a safer import."""

paths = [
    os.path.normpath( os.path.join( os.path.dirname(__file__), "../" ) ), 
    os.path.normpath( os.path.join( os.path.dirname(__file__), "../../" ) )
]

sys.path.extend( paths )

os.environ['DJANGO_SETTINGS_MODULE'] = 'deals.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/5213849981</link><guid>http://scribblepadofdoom.tumblr.com/post/5213849981</guid><pubDate>Thu, 05 May 2011 16:00:05 +0800</pubDate><category>mod_wsgi</category><category>Django</category></item><item><title>Fixing the remote host identification has changed error.</title><description>&lt;p&gt;Every once in a while I run into an issue where the remote host server identification has changed because of a re-install or other reasons. This comes with an error like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh root@127.0.0.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
2c:af:ca:27:89:36:c0:03:c6:9f:43:74:1e:8e:3a:0d.
Please contact your system administrator.
Add correct host key in /home/kit/.ssh/known_hosts to get rid of this message.
Offending key in /home/kit/.ssh/known_hosts:44
RSA host key for 127.0.0.1 has changed and you have requested strict checking.
Host key verification failed.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In Ubuntu you can fix this by running &lt;code&gt;ssh-keygen&lt;/code&gt; with the &lt;code&gt;-R&lt;/code&gt; flag, removing the key causing the problem.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh-keygen -R 127.0.0.1
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/5203117843</link><guid>http://scribblepadofdoom.tumblr.com/post/5203117843</guid><pubDate>Thu, 05 May 2011 08:00:06 +0800</pubDate><category>SSH</category><category>Security</category></item><item><title>How to change the title in IE7 and 8.</title><description>&lt;p&gt;I had an issue where I was building fade transitions between pages for a client, so I needed to update the title. I was using &lt;a href="http://jquery.com"&gt;jQuery&lt;/a&gt; for a bunch of things so naturally I would do something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$("title").text("Wooo. New title!");
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This works great in Chrome, Firefox and IE9, but not in IE7 or 8. Thankfully IE9 has a debugger so it was easy switch the browser into compatibility mode and trace the exception.&lt;/p&gt;

&lt;p&gt;Turns out in older versions of IE the title element is magical and wasn&amp;#8217;t letting jQuery appendChild (I&amp;#8217;m also a bit surprised they aren&amp;#8217;t checking this condition.) Instead old DOM0 comes to the rescue, which lets you set a title like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;document.title = "Woo. New title!";
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/5174566409</link><guid>http://scribblepadofdoom.tumblr.com/post/5174566409</guid><pubDate>Wed, 04 May 2011 08:00:06 +0800</pubDate><category>Internet Explorer</category></item><item><title>Ubuntu - Installing Sun JDK instead of OpenJDK on Maverick</title><description>&lt;p&gt;I&amp;#8217;m a bit frustrated that Canonical decided to use OpenJDK, even though OpenJDK still seem to have issues with some software. In my case I was trying to run PyCharm a popular Python IDE, but it wasn&amp;#8217;t rendering properly. Lets tell Ubuntu to use Sun JDK instead:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo add-apt-repository "deb &lt;a href="http://archive.canonical.com/"&gt;http://archive.canonical.com/&lt;/a&gt; maverick partner"
sudo apt-get update

sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre

sudo update-java-alternatives -s java-6-sun
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Until the next Ubuntu upgrade. :)&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/4776590305</link><guid>http://scribblepadofdoom.tumblr.com/post/4776590305</guid><pubDate>Wed, 20 Apr 2011 22:16:39 +0800</pubDate><category>OpenJDK</category><category>PyCharm</category><category>Java</category><category>Ubuntu 10.10</category><category>Maverick</category></item><item><title>Getting raw MySQL selection data via the command line.</title><description>&lt;p&gt;I&amp;#8217;ve been stuffing a MySQL database with JSON and I wanted to output it to a file. One way is to write a script that makes a connection and saves it to a file, but that seems a bit excessive. The default format MySQL outputs a selection from the console is with headers and some cruft around it, with the &lt;code&gt;-sN&lt;/code&gt; options you get it all of and get the raw output, then just pipe it into a file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mysql -sN -uroot -e "select json from my_table;" my database &amp;gt;&amp;gt; myjson.json
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/4661936379</link><guid>http://scribblepadofdoom.tumblr.com/post/4661936379</guid><pubDate>Sun, 17 Apr 2011 00:11:10 +0800</pubDate><category>MySQL</category></item><item><title>Auto updating node.js on Ubuntu</title><description>&lt;p&gt;With node.js 0.4.5 out it&amp;#8217;s well over due to get aptitude to keep up with the updates:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:jerome-etienne/neoip

sudo apt-get update

sudo apt-get install nodejs
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/4282472624</link><guid>http://scribblepadofdoom.tumblr.com/post/4282472624</guid><pubDate>Sat, 02 Apr 2011 21:26:00 +0800</pubDate><category>Node.js</category><category>JavaScript</category><category>Aptitude</category><category>Ubuntu</category></item><item><title>Copying a MySQL database between servers over SSH</title><description>&lt;p&gt;Usually when I need to copy a database from one spot to the other I log into the server that has the original database and then SSH the data to the server that is supposed to have it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mysqldump source_database source_table | ssh user@host mysql target_databases
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;However in this case I couldn&amp;#8217;t get the server to connect to another server via SSH, so the command changes slightly. Instead we log into the receiving server and change our command to pull the data to us from the original database.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ssh user@host "mysqldump source_database source_table" | mysql target_database
&lt;/code&gt;&lt;/pre&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/4146252301</link><guid>http://scribblepadofdoom.tumblr.com/post/4146252301</guid><pubDate>Mon, 28 Mar 2011 07:16:06 +0800</pubDate><category>Database</category><category>MySQL</category><category>SQL</category><category>SSH</category></item><item><title>Setting up a SMTP server for debugging</title><description>&lt;p&gt;I wrote a client that was sending emails over SMTP server and needed to debug it, but didn&amp;#8217;t want muddle my way through setting up an actual SMTP server. Instead I found two convenient options. The first is to use python where you can starts a dummy SMTP service that prints to stdout with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo python -m smtpd -n -c DebuggingServer localhost:25
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Another option is to sign up for &lt;a href="http://dummysmtp.com"&gt;http://dummysmtp.com&lt;/a&gt; that offers a free dummy SMTP server, showing the emails on the web interface.&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/4146150461</link><guid>http://scribblepadofdoom.tumblr.com/post/4146150461</guid><pubDate>Mon, 28 Mar 2011 07:12:07 +0800</pubDate><category>Debugging</category><category>DummySMTP</category><category>Email</category><category>Python</category><category>SMTP</category></item><item><title>WordPress - Setting WordPress up on an alternative port in apache2.</title><description>&lt;p&gt;Since I&amp;#8217;ve been fiddling around with OpenCart lately and needed to run WordPress as well for another project I wanted to run WordPress on a different port than 80.&lt;/p&gt;

&lt;h1&gt;Step 1 - Download WordPress from WordPress.org.&lt;/h1&gt;

&lt;p&gt;Go to &lt;a href="http://wordpress.org/"&gt;http://wordpress.org/&lt;/a&gt; and download the latest version. Unpack it wherever you need it. I unpacked mine to /home/celc/Dropbox/www/wordpress.&lt;/p&gt;

&lt;h1&gt;Step 2 - Make the apache user the owner of the wordpress folder&lt;/h1&gt;

&lt;p&gt;This always seems to be a bit of trouble when I run WordPress in Ubuntu thats caused by apache not having enough privileges to create files and do other things it needs. I&amp;#8217;ve blogged about this &lt;a href="http://scribblepadofdoom.tumblr.com/post/2128526488/wordpress-it-doesnt-need-ftp-access-it-needs-a-writable"&gt;before&lt;/a&gt; in relation to installing plugins.&lt;/p&gt;

&lt;script src="https://gist.github.com/805851.js?file=setwordpressowner.sh"&gt;&lt;/script&gt;&lt;h1&gt;Step 3 - Create a database&lt;/h1&gt;

&lt;p&gt;We need to create a database for WordPress. In Ubuntu we can just run.&lt;/p&gt;

&lt;script src="https://gist.github.com/805851.js?file=createdatabase.sh"&gt;&lt;/script&gt;&lt;h1&gt;Step 4 - Change apache2 settings&lt;/h1&gt;

&lt;p&gt;We need a new config file in /etc/apache2/sites-available which will handle the connection on 8080.&lt;/p&gt;

&lt;script src="https://gist.github.com/805851.js?file=wordpress"&gt;&lt;/script&gt;&lt;p&gt;Then we need to change /etc/apache2/ports.conf and make apache listen to 8080 by adding the following two lines.&lt;/p&gt;

&lt;script src="https://gist.github.com/805851.js?file=ports.conf"&gt;&lt;/script&gt;&lt;h1&gt;Step 5 - Enable the site and restart apache&lt;/h1&gt;

&lt;p&gt;We need to enable the site and restart the server before it&amp;#8217;ll run properly.&lt;/p&gt;

&lt;script src="https://gist.github.com/805851.js?file=enable-wordpress.sh"&gt;&lt;/script&gt;&lt;h1&gt;Done&lt;/h1&gt;

&lt;p&gt;Navigate to your site at &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt; and WordPress will step you through the installation process. Just follow the instructions on the screen and your site will be enabled on &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;.&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/3048397589</link><guid>http://scribblepadofdoom.tumblr.com/post/3048397589</guid><pubDate>Tue, 01 Feb 2011 22:16:00 +0800</pubDate><category>Ubunutu</category><category>WordPress</category><category>Http</category><category>Webserver</category><category>WordPress 3</category><category>MySQL</category></item><item><title>OpenCart - Setting up cURL on Ubuntu for installation.</title><description>&lt;p&gt;During installation of OpenCart you are required to have certain PHP extensions active one of them is cURL, if it&amp;#8217;s not then install it like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then we need to restart apache&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;apache2ctrl restart
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Refresh the page if you are still on it and it should be working. I think OpenCart could offer up a more pleasant installation process by offering suggestions in the installation process itself on how to go about fixing minor issues like this.&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/2311915890</link><guid>http://scribblepadofdoom.tumblr.com/post/2311915890</guid><pubDate>Tue, 14 Dec 2010 20:26:24 +0800</pubDate><category>cURL</category><category>OpenCart</category><category>Ubuntu</category><category>Apache2</category></item><item><title>WordPress - It doesn't need FTP access, it needs a writable wp-content directory.</title><description>&lt;p&gt;If you&amp;#8217;ve ever attempted to install WordPress on your own you might find that it&amp;#8217;s asking for your FTP/SFTP credentials. A seemingly absurd prospect since it&amp;#8217;s running on the server, and should be perfectly capable. What is happening is that the apache user doesn&amp;#8217;t have write access to wordpress/wp-content, and WordPress is trying to get around that problem by using the FTP. So we need to find the user that is running apache:
&lt;script src="https://gist.github.com/731421.js?file=gistfile1.bat"&gt;&lt;/script&gt;
Which gives:
&lt;script src="https://gist.github.com/731421.js?file=results.txt"&gt;&lt;/script&gt;
Now lets set the owner to the apache user
&lt;script src="https://gist.github.com/731421.js?file=gistfile3.bat"&gt;&lt;/script&gt;
Now you should be able to install plugins without having to set up an FTP.&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/2128526488</link><guid>http://scribblepadofdoom.tumblr.com/post/2128526488</guid><pubDate>Tue, 07 Dec 2010 11:49:00 +0800</pubDate><category>WordPress</category><category>WordPress 3.0</category></item><item><title>Chrome Extensions - Unexpected Token ILLEGAL</title><description>&lt;p&gt;I wrote a chrome extension uploaded it to the Google extension gallery earlier today, and after installation it refused to work. Investigating showed an Unexpected Token ILLEGAL message, which if I trusted chrome occurred right after the DOCTYPE in the background page (yeah right).&lt;/p&gt;

&lt;p&gt;What in reality is happening is that whenever JSON.parse encounters something which it can&amp;#8217;t parse it throws that rather perplexing message (hey Google, at least tell me it&amp;#8217;s the native JSON causing the error and not my own code). In my case I was using localStorage to store JSON strings and when there wasn&amp;#8217;t a key (like when I uploaded my extension to the gallery for the first time and forgot to set default values) JSON.parse() will receive undefined and fail.&lt;/p&gt;

&lt;p&gt;Though curiously it&amp;#8217;s implemented so that it returns null on JSON.parse( null ), because the ECMA-262 Edition 5 standard says so, but JSON.parse( undefined ) throws. This also means that JSON.parse() fails in the same way with both getting a bad string like JSON.parse( &amp;#8220;BADSTRING&amp;#8221; ) as it does on JSON.parse( undefined ).&lt;/p&gt;

&lt;p&gt;Doing a try..catch seems like the only reasonable way to avoid shooting yourself in the foot on bad/undefined data. I really don&amp;#8217;t think it&amp;#8217;s a good idea for a language that blows the stack every other second to use exceptions.&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/2091149417</link><guid>http://scribblepadofdoom.tumblr.com/post/2091149417</guid><pubDate>Sat, 04 Dec 2010 21:54:51 +0800</pubDate><category>Chrome Extension</category><category>JSON</category></item><item><title>ImageMagick - Scaling and padding a screenshot for the Chrome extension gallery in Ubuntu</title><description>&lt;p&gt;Google has a new policy for the chrome extension gallery where screenshots need to be 400x275 (or some larger multiple of that). I soon found out that ImageMagick -came to the rescue again with the extent command which when scaling a picture to a larger size will add padding to the image (you can use -gravity to decide where). So I ended up with this for producing the screenshot of an appropriate size:
&lt;script src="https://gist.github.com/728163.js?file=gistfile1.bat"&gt;&lt;/script&gt;&lt;/p&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/2090854068</link><guid>http://scribblepadofdoom.tumblr.com/post/2090854068</guid><pubDate>Sat, 04 Dec 2010 21:03:59 +0800</pubDate><category>ImageMagick</category><category>Chrome Extension Gallery</category><category>Ubuntu</category><category>Linux</category></item><item><title>Chrome Extensions - Content script are unable to access frames.</title><description>&lt;p&gt;There&amp;#8217;s a bug (&lt;a href="http://code.google.com/p/chromium/issues/detail?id=20773"&gt;#20773&lt;/a&gt;) in chromium that causes content scripts to be unable to access frames. If you run the following snippet and the initial condition is true.&lt;/p&gt;

&lt;script src="https://gist.github.com/727433.js?file=gistfile1.js"&gt;&lt;/script&gt;&lt;p&gt;Then we get the output:&lt;/p&gt;

&lt;script src="https://gist.github.com/727433.js?file=gistfile2.txt"&gt;&lt;/script&gt;&lt;p&gt;This was a bit of a bother since I was trying to find what the activeElement on a page was and that property sits on the document. So to be able to get the activeElement on pages with iframes I needed to do:&lt;/p&gt;

&lt;script src="https://gist.github.com/727433.js?file=gistfile3.js"&gt;&lt;/script&gt;&lt;p&gt;Instead I had to inject my script in all frames, which if you are using executeScript can be done like this:&lt;/p&gt;

&lt;script src="https://gist.github.com/727433.js?file=gistfile4.js"&gt;&lt;/script&gt;&lt;p&gt;So I changed the code to only check the current document and tell me when the bug is fixed:&lt;/p&gt;

&lt;script src="https://gist.github.com/727433.js?file=gistfile5.js"&gt;&lt;/script&gt;</description><link>http://scribblepadofdoom.tumblr.com/post/2084347063</link><guid>http://scribblepadofdoom.tumblr.com/post/2084347063</guid><pubDate>Sat, 04 Dec 2010 03:43:00 +0800</pubDate><category>JavaScript</category><category>Chrome</category><category>Chrome Extension</category><category>Chromium</category><category>Chrome Bug</category></item></channel></rss>
