March 1, 2010

Open up your WiFi

Posted in Society, Software at 01:28 by Graham King

A few months back, I took the password off my WiFi router, and opened it up to the world, with SSID yes_we_are_sharing. Why?

The best answers are given by security expert Bruce Shneier – why open wireless. The second best answer is that Tor hacker Jacob Applebaum also runs open WiFi.

Here are my answers, and the reasons why you should join us.

Read the rest of this entry »

Setting up Monit on Ubuntu

Posted in Software at 00:18 by Graham King

Monit tells you if something goes wrong on your server, and tries to fix it. It can, for example, alert you:

  • When a process dies.
  • When a machine stops responding to network requests
  • When your machine has too high load average, memory consumption, or CPU usage.
  • When a file changes, hasn’t changed for a period of time, or grows beyond a certain size.

It can run a script of your choosing to attempt to fix the problem. It has an HTTP interface that shows you essential stats about the services you are monitoring. For detailed graphs, I recommend Munin.

Here’s how to get it working on Ubuntu:

Read the rest of this entry »

February 17, 2010

Setting up Munin on Ubuntu

Posted in Software at 06:50 by Graham King

Munin is a system monitoring tool. It produces graphs for Apache, MySQL, Nginx, CPU, Memory, Disk, etc. Example munin installation – Live.

Here are my notes from setting it up, they are brief, but should help you get going.

All the monitored machines run a small daemon called munin-node. One machine is the central server. Every few minutes it gathers data from all the nodes (including itself), generates the graphs, and writes out some HTML files.

Read the rest of this entry »

February 14, 2010

Restarting MySQL master-master replication

Posted in Software at 21:24 by Graham King

If your MySQL (5.0+) replication is broken, there’s two ways to fix it: The easy way, and the right way.

Run commands starting with $ on Unix. Run commands starting with mysql> in the MySQL client.

The easy way: Skip the problem

If you hit both databases at the same time, with the same INSERT, they will create their own record, and try and replicate to the other, which already has that record, causing a duplicate error.

In a simple case like that, you just want to skip the offending statement:

:noclick


mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;

More details on skipping MySQL duplicate errors

Most of the time, you skip one statement, and replication breaks again straight away, because there’s a whole queue of problem statements coming up.

The right way: Rebuild

If you are not sure that you can skip the duplicate, or if replication has been broken long enough that your two servers are out of synch, pick one database to be the master, and rebuild the other from a copy of that master.

Read the rest of this entry »

October 20, 2009

Memcached: List all keys

Posted in Software at 17:50 by Graham King

In the general case, there is no way to list all the keys that a memcached instance is storing. You can, however, list something like the first 1Meg of keys, which is usually enough during development. Here’s how:

Telnet to your server:

telnet 127.0.0.1 11211

Read the rest of this entry »

August 10, 2009

Choosing a message queue for Python on Ubuntu on a VPS

Posted in Software at 06:05 by Graham King

More and more, my web apps need to run things in the background: Sending email, re-calculating values, fetching website thumbnails, etc. In short, I need a message queue in my toolbox.

Luckily for me, message queues are this years Hot New Thing, so there’s some good options. I looked at RabbitMQ, Gearman, Beanstalkd and StompServer.

Read the rest of this entry »

June 16, 2009

Django dynamic forms and formsets

Posted in Software at 02:08 by Graham King

A couple of great posts which explain Django dynamic forms and advanced formset usage very clearly:

June 11, 2009

How and Why to extend Firefox in Javascript

Posted in Software at 04:29 by Graham King

I will be giving this talk on Friday 12th June, at Open Web Vancouver 2009.

June 10, 2009

Unix shared directory permissions: GUID and umask

Posted in Software at 20:11 by Graham King

I setup my Mercurial repository in the same way we used to do CVS, then SVN: A directory owned by a group, with the GUID bit, and all users who need to commit are in that group.

The steps are, create the group and add relevant users to it: :noclick


    sudo groupadd topsecretgroup
    sudo usermod -a -G topsecretgroup graham

Read the rest of this entry »

May 17, 2009

Speaking at Open Web Vancouver 2009 in June

Posted in Future of Web Apps, Software at 22:30 by Graham King

I will be speaking at Open Web Vancouver on Thursday, June 11, 2009 and Friday, June 12, 2009.
That’s in Vancouver, B.C., Canada. There’s a very interesting speaker lineup, and the whole conference is reasonably priced, so come along, learn, interact, and enjoy Vancouver in the summertime.

My talk will be entitled How and Why to Extend Firefox in Javascript (and Thunderbird, Komodo, and Songbird). I will post the slides here in June.

See you there!

May 10, 2009

Micro-Zooids: A story

Posted in Ideas, Misc, Software, Strategy at 23:23 by Graham King

When I was 16, I wrote a computer game, called Micro Zooides. It was called that partly because on Windows .EXE files all start with the two characters MZ, and partly because it was about small creatures. Micro-Zooides was going to be about humanity’s progress, it was going to be Civilization, which didn’t exist yet.

The game had a splash screen of a Far Side comic, then a short video of me tromping through the woods like a Neanderthal, which my Dad filmed and which I digitized with a very early video capture card.

In Borland’s Turbo C++ 3.0 I wrote a basic graphics engine to display the tiles of the world, and an event loop so I could move the main character around the world. I drew sprites for a proto-human (the micro zooid), dirt, rocks and sticks. He could walk around the world, and pick up and put down rocks or sticks.

Then I took a break to plan. I have a proto-human, rocks, and sticks. How do I get to civilization?

May 8, 2009

Turn on debug output in SVN

Posted in Software at 00:02 by Graham King

After a desktop and server upgrade, my subversion client stopped working. I am using Digest authentication, and it kept asking me for the username and password. Wireshark showed me that the SVN client wasn’t sending the Authentication header. To find out more, I turned on Subversion’s debug output. Here’s how you do it:

Edit /etc/subversion/servers
Add this line at the end: neon-debug-mask = 511

That showed me this error: auth: '/' is inside auth domain: 0.

This means that the path I was requesting (the root of the repo) was not considered inside the AuthDigestDomain I had set in Apache.

It turns out that at some point in the upgrade of Apache, Subversion, or a library, the AuthDigestDomain requires a scheme. I had
AuthDigestDomain svn.myserver.com
whereas it should of been
AuthDigestDomain http://svn.gkgk.org.

So now you know.

April 7, 2009

Foxden – your life on one page

Posted in Software at 01:21 by Graham King

Update: There is now a user group for Foxden: http://groups.google.com/group/foxden-users

Foxden is a Firefox extension that allows you to tile all the web applications you use on one page. Imagine being able to see your email, your calendar, your bug tracker, feeds, twitter, whatever you use, on one page. Take a look at my setup:


Foxden screenshot

As you can see, I have (counter clockwise from top left) my email, calendar, feed reader, todo list and a local text file for taking notes.

It’s free, should work wherever Firefox 3 works, and it could be yours right now.

Download the Foxden Firefox extension

March 18, 2009

Eddit: Reddit without the Rrrr!

Posted in Software at 17:06 by Graham King

Eddit is a bookmarklet for Reddit, which gives you more signal and less of the noise that makes you go Rrrr! Here’s how it improves reddit:

Read the rest of this entry »

March 17, 2009

Flex internals: Setting a button label

Posted in Software at 00:50 by Graham King

Most ActionScript / Flash applications have a main event loop, triggered by Event.ENTER_FRAME. This is where the animation moves along to the next frame, or the sprites of the game are re-drawn in their new places.

In the Flex framework, you are expected to call invalidateDisplayList on the framework to say you need an update, and actually do the update when the framework calls your updateDisplayList method. This is the invalidation / validation pattern.

I went searching in the Flex code to understand how this invalidation / validation step ties in with Flash’s event model. I ignored properties and sizing, and edited the code down to the bare essentials.

Here is what happens when you change the label of a button:

Read the rest of this entry »

March 15, 2009

Choosing the best Flex book – Flex book reviews

Posted in Software at 23:05 by Graham King

UPDATE March 19th: Added First Steps in Flex, and Learning Flex 3.

You’re an experienced server-side programmer, with a background in C/C++/Java/C# or Python, but no Flash experience. You want to learn Flex. Which book should you buy to learn Flex 3? I have speed-read the following, so that you don’t have to:

Read the rest of this entry »

Math Dodger: A Flash game

Posted in Misc, Software at 02:26 by Graham King

Los Angeles is under attack, by trigonometric functions! OMG! Trigo-what? If I wanted to do maths, I’d go to San Francisco!! You, like, totally gotta save L.A man. Enter your name, then move your tank.

Use the left and right arrow keys to rotate, the forward and back arrow keys to move.
The barrel of the tank is the little black line. That’s the front.

No, your tank can’t fire. Avoid the mathematical blobs. YEAH!
The longer you live, the more points you get. A score above 100 is, like, totally AWESOME! Good luck Bro.
Let me know in the comments how much you score.


Read the rest of this entry »

February 23, 2009

Javascript objects: And what is this?

Posted in Software at 03:06 by Graham King

When writing object-oriented Javascript, there are two occasions when you need to be careful that this is set correctly: In inner functions and in callbacks.

this in inner functions

  1. If you are not in an object, this refers to the global window object.
  2. If you are in an object’s method, this refers to that object,
  3. except in an inner function, when this refers to the global window object again.

Number 3 is what you need to watch for. It is considered a bug in Javascript. Here is an illustration of the three cases:

Read the rest of this entry »

January 23, 2009

Easy object-oriented Javascript the Python way

Posted in Software at 00:47 by Graham King

Javascript is not an opinionated language. At it’s heart it is a hash map. You can layer pretty much any idiom you want on top of it. I’d like to make it look like Python, and it’s pretty easy to do. They both are dynamically typed, have functions as first class objects, and can treat most types as hash maps.

Let's observe this moose

Let’s assume code for a whimsical Moose Observation Project, and translate it from Python to Javascript.

Read the rest of this entry »

November 11, 2008

Plebis.Net. Speak your mind.

Posted in Society, Software at 02:34 by Graham King

I have just launched Plebis.net. It’s a wall on the Internet you can write on, for all to see.

You can write anything you want. There’s no censor and nothing is recorded, so feel free to scream shout and wail. Tell the world how you feel. Get it off your chest. Go on, it’s good for you. Head over to Plebis.net, and say something!

« Previous entries Next Page » Next Page »