Archive of articles classified as' "general"

Back home

Eurovision 2010 review (of sorts)

31/05/2010

It’s widely known amongst my friends that I absolutely love the Eurovision song contest. Growing up with a father that was obsessed with war movies my early formative years tended to view europe like this:

Europe for me as a young child was world war Europe. I’d always thought of the many different countries as totally separate and thought the huge amount of cultural difference a difficult thing to placate, especially growing up in Northern Ireland where even people in the same country hated each other.

Then one evening my parents put on BBC1 and bemoaned that “Eurovision” was coming on. I’d no idea what it was and after being told “it’s a singing competition for countries in Europe” I was significantly intrigued enough to demand to watch it. After a few hours I’d decided that this programme alone was responsible for the prevention of world war 3 and began to see Europe more like this:

The reason I believe what many consider a giant waste of time to be the reason we’re not all living under the fourth Reich is simple. If you actually watch the show it’s hard to not get a sense of communal euro-love throughout. Read the rest of this article »

2 Comments

Pro dominos ordering 101

9/05/2010

As a coder I tend to not eat as well as I could. I grew up on a diet of home made stews, casseroles, soups and lots more irishy “proper” food. Then I moved to London and got a job. At one point, when I actually lived with other people, I would occasionally cook, but since I moved in on my own I end up eating out a hell of a lot more than I probably should.

Anyway, for sunday style coding sessions I tend to like just zoning out with a pizza and a bottle of pepsi max. I don’t rate pizza hut and papa johns don’t deliver here so dominos is my preferred major pizza chain retailer. Anyone that’s ever bought a pizza from them will know that they’re fucking expensive! It can easily run you £16+ for a “large” pizza. But only a total internet noob would order straight up without checking out the many voucher sites. I say many, I only ever check retailmenot.com (or voucherhub as its UK site is known). This gem just got me the pizza + more for less than the actual pizza SGBLFENR.

It can seem a bit of a waste but you might as well have the money than dominos. And if you’re a social type that has someone else in the house you can be all sharing and get a warm glow inside.

No Comments

Zen in Kate: Getting zencoding & lessCSS as filters in Kate

3/05/2010

There’s been a fair amount of buzz surrounding the Zen Coding plugin’s for various editors. In one line, it lets you write out HTML via css selector syntax. So something like

table#calendar.clear>tr#week-$.week*4>td#day-$.day[valign=top]*7

Would transform into the appropiate HTML table:

<table id="calendar" class="clear" cellspacing="0">
	<tr id="week-1" class="week">
		<td id="day-1" class="day" valign="top"></td>
		<td id="day-2" class="day" valign="top"></td>
		<td id="day-3" class="day" valign="top"></td>
		<td id="day-4" class="day" valign="top"></td>
		<td id="day-5" class="day" valign="top"></td>
		<td id="day-6" class="day" valign="top"></td>
		<td id="day-7" class="day" valign="top"></td>
	</tr>
	<!--- ETC... 3 more rows of class week ---></tbody>
</table>

I use KDE's Kate editor for my main dev setup. I'm really used to its setup and find it a powerful tool for coding web apps. It's minimal compared to a full on IDE but I'm one of those developers that doesn't really like the whole IDE concept. For web development at least, if I was building on OS-X or Windows I'd probably be using Xcode or Visual Studio but for web-dev, I find Kate + a shell + Firefox with Firebug/Webdev/HttpFox is more than enough.

Unfortunately there isn't a plugin to give native Zen Coding support in Kate. Some googling found me this obscure reference to a "Insane HTML plugin" for the development trunk of Kate but when I checked out the git repo and compiled it I couldn't find it. Then I came across Sparkup. It's a similar thing to Zen (its based of its syntax and is compatible) and they provide it as a python script. Kate provides you the means to pipe text through a shell command, I use this to format or parse text through awk & sed quite a bit and so dropping in the sparkup python script to /usr/local/bin I could write out some CSS→HTML markup and just pipe it through.

It's not quite as slick as having a single hit plugin but it works enough to make it part of my toolchain now when creating templates. I've also been looking at things like Less CSS for adding variables and calculations to CSS files. You write your CSS in a more programming style markup (colors assigned to variables for example) and then Less compiles it out to actual CSS. I wanted to do something similar for sparkup for less so installed the ruby gem for it. Alas it takes a file as input and gives a file as output so I couldn't just pipe through selected text in Kate to lessc. Fortunately it only takes a little bit of bash to allow me to write abbreviated CSS, pipe it through lessc and have Kate drop back in the "compiled" version. Here's the bash (gist):

#!/bin/bash
input=''
while read data
do
	input=${input}${data}
done
echo $input > /tmp/ccss.tmp.less
/var/lib/gems/1.9.1/bin/lessc /tmp/ccss.tmp.less /tmp/ccss.css
cat /tmp/ccss.css

All it's doing is putting the input into a variable, outputting that to a file and then calling lessc on it. The output is then cat'd back to standard output which means Kate will dump it out over our selection. Combining these two gives Kate a fair bit more power as my main (pretty much only) coding environment, and means I don't have to switch out to use something else to give zen/less css a go. I quite like the concept of Less CSS, for complicated projects using it from the outset would be a pretty good idea I think, for now I'm using it as a sort of shorthand. Your path to the lessc binary might be different but probably not by a lot.

Finally, the default binding for "pipe text to shell command" is CTRL+|, which, as I tend to use the left control key makes it a little constrictive to fluidly type. I also tend to end up hitting z or a instead which gets annoying so I remapped it to CTRL+#, which is a lot easier to hit with both hands fully extended. I think its a better mapping if you use it a lot. Which you will when you look up a few sed 1 liners :)

2 Comments

Google’s results plotted for repeated character strings

14/02/2010

Don’t ask why but out of interest I googled for the string “AAAAAAAA” earlier and after looking at the millions of pages that came back and thinking “wtf”, I searched again only making the string much longer. I was expecting it to just keep going down but at around 20 characters there was a significant jump in returned results. I scratched my beard and proclaimed this interesting (as you can probably tell I have no distractions on valentines day). To skip over further bullshit, this is the graph of 3,328 searches – that is, the number of results for every character (A-Z) repeated one to 128 times. Some of the peaks are interesting.

Why 128 and not something higher? Google wont let you, at least via the query string. The raw data for this graph was generated by a simple python script. If you aren’t coding in python already, please do look into it, its jolly nice.

#!/usr/bin/python
 
from urllib import FancyURLopener
from BeautifulSoup import BeautifulSoup
import csv
import string 
 
BASE = "http://www.google.com/search?q="
 
class MozOpener(FancyURLopener):
    version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1;' +
' it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'
ff = MozOpener()
 
out = csv.writer(open('out.csv', 'w'))
 
headers = ['count',]
for l in string.ascii_uppercase:
    headers.append(l)
out.writerow(headers)
 
for x in range(1, 128): # 128 is the max length of chars allowed
    results = [x,]
    for l in string.ascii_uppercase:
        qry = l*x
        raw_data = ff.open(BASE+qry).read()
        soup = BeautifulSoup(raw_data)
        result = soup.find(id='resultStats').findAll('b')[2]
        result = int(result.contents[0].replace(',', ''))
        results.append(result)
        print [result, qry]
    out.writerow(results)

When that had finished I simply loaded it up into OpenOffice calc (3.2 is out by the way) and plotted it with the result count set to a logarithmic scale so result #1 doesn’t just skew the thing into one boring L shape. The first thing I noticed was a very visible spiking at length 100.

This isn’t so hard to imagine, 100 is a “nice” number. It’s not hard to imagine someone using 100x a character as a test input or just a “long” string. Every character string of length 100 exhibits this spike. The much bigger blue curve is for the letter x. This is used by children and adults alike to mark kisses, and everyone knows the more x’s the more someone loves you. If you look at many of the results for 100 or 101 character X searches it seems to be when people are using it in this context. Could it be that the much bigger spike for the 101 character string X is simply because its 100 + 1 kisses?? Towards the start of the graph there are a number of interesting spikes, I’ve marked some of them along with the length.

Some of these spikes are easy to explain, the biggest number of results returned for a single repeated character phrase is a by product of DNS, yep, its “WWW”. This accounts for the slightly higher result count than the simple “A” with 17,090,000,000 pages returned versus 12,260,000,000. Another easy one is 6 F’s – the hex code for white. I am totally stumped by F’s latter behaviour though, there is a spike at F-31 and F-33 but not F-32. There is a big jump for X-12 and X-34. International mobiles have 12 digits, as do UPC codes but I feel like I’m clutching at straws :) trying to explain that. Down the other end of the graph, between 115 and 128 the characters P, H, A, M and O all have significant spikes for specific counts. For M & O when you browse many of the first few pages of google’s results many of the pages are using them as part of exaggerated speech. It’s almost like the collective conciousness of the world has decided that 120 characters is just right to describe a particularly tasty dinner.

A spreadsheet with the data I gathered is available via google docs if you’d like to investigate yourself. I should note that the python script above gets its data from .com, if you are using the site to look up some searches it will more than likely switch to your local domain. Depending on your cookies google may also perform extra filtering (e.g. safe searches) so you’re numbers may not be the exact same as mine. I’d be interested in any theories as to some of the more prominent spikes. The OpenOffice spreadsheet with the charts done is also available for download here.

If you are going to play around then save your fingers & sanity and use python to create you’re test strings, just drop into a python shell and use “X”*120 etc or perl -e ‘print “X”x100′ from the command line etc.

4 Comments

GIMP, Photoshop and this fucking multi-window “problem”

14/02/2010

I really like GIMP, I use it all the time at work along with Photoshop. The great thing about computers is that you can install whatever the fuck you want. If you fancy driving yourself crazy go google for “photoshop vs gimp” and try and read more than a page of banal arguments bouncing back and forth with very few people piping up to say “use whatever the fuck you want”. A lot of people seem to think that if you don’t use photoshop you’re just an amatuer. Very often these are the same people that are using PS simply to open a photo, click “auto-levels” and then resize it.

If you’ve never used GIMP and you are one of these “pro’s” then I suggest you install it anyway and at very least checkout the selection tools. I know you can transform a selection with Photoshop but I find the marquee tools vastly superior in GIMP and its something I hope finds its way into Adobe’s offering. I’ve gone off on a tangent here, the real purpose of this post is all down to the number fucking one reason people using GIMP complain about it – the multi window interface. This is so much of a PR problem for the GIMP team that they’ve finally started coding a single window mode for the upcoming 2.8.x branch. I have never understood the trouble this causes people. I understand it even less because many people then say Photoshop’s UI is so much better. This winds me up further because whenever I think of PS I think of something like this:

When I think of GIMP I see this:

Do you know what I see here? I see a floating toolbox, a floating image and another fucking set of floating panels. I see the same fucking thing. Ok, Photoshops menu is right at the top since its a mac but I really have never understood what the hell is so wrong with this. Very often even the linux users complain about this, when really what they should do is maximise the image and then mark the two floating panels as “always on top”. I get that’s not ideal but hey, you’re using a free OS, with a free desktop with a free graphics app. Work with us 1 fucking minute!

No doubt I am simply delusional but I really have never found the GIMP UI, especially when compared to the PS UI on a mac, to be such a problem that you literally couldn’t fucking use it.

1 Comment

Brought to you by hallmark

14/02/2010

So it’s valentines day again. Most of the people I know purport to be doing fuck all when really they are doing something only they’re telling themselves that they just happen to be out on a Sunday evening. At a restaurant. With 200 other pricks. As I have not written a haiku for some time and since I noticed I was getting a few keyword hits for “love haiku” I aim to deliver. So here, a love/valentine themed poem from the desk of jaymz… It’s only mid-February.

No Comments

Working from home and not having it suck balls

10/02/2010

This is my typical desktop (well one of them) when I’m doing work at home. I really like kate as my code editor. It does pretty much everything I need and I like the built in terminal and the extensions & scripts you can use with it. But I’m not here to proclaim another holy war begun, instead I want to outline some of the tools I’m using in the background to avoid ripping out my hair and generally being more productive as a *nix based developer. For the most part, half of this shit works fine on a mac too out of the box. Something my good friend ServeBlunted will happily remind me of.

I say “some” tools. I really only mean one. SSH. Thats it. As a linux user both at home & at work I spend a lot of my time in X. It can be handy to have a GUI app I’ve got on my work machine running at home if I’m working so when I ssh into work I always tunnel through X. You can do this by just adding “-X” as an option.

ssh -X jaymz@work.company.com

X tunelling is handy, it sure beats trying to work via the likes of a VNC session, but the best thing about SSH for me is sshfs. Using that you can create a folder on your local machine and then mount a remote folder over SSH to it. Then you fire up your editor and work away. If you’re like “yeah, whatever, I can edit my files via FTP in my editor and it syncs” then shut up, go give it a go and get back to me. It’s a lot more flexible, you almost forget its a remote filesystem. To mount a remote folder as if it’s sitting on your home machine its typically done like this:

sshfs /tmp/local jaymz@work.company.com:/var/www/dev-code

Where you’d replace the names of the folders with whatever works for you. This lets me mount my code and work on it from within any application as if it was totally local. In the above screenshot I’m actually working on code on my work computer a few miles away. I’ve also ssh’d in via the built in terminal so for all intents and purposes its just like I’m working at the office. The final thing that ssh makes easy for me is port tunneling. I don’t use this as much but it can be handy. The basic command is:

ssh -L 8080:10.10.91.1:445 jaymz@bowser.worknetwork.com

The red number is the local port. This is what you are going to be using in any config or browser screen on your workstation. The green IP address is the machine you’re actually interested in connecting to and finally the orange port is the port in question that you want to connect to. Then you give it your login credentials as you would normally. This is really useful for when you have dev servers that are locked down to only local network connections (like a mysql setup to only connect via localhost for example). The above is what I would use if I wanted to connect to the firewall’s web interface. This is only accesible to my workstation in the office but using tunnelling I can bring it up from home without tunnelling X and loading firefox (which would also work :) ).

There are a whole lot of ways to set tunnels up with SSH, the -L means you are wanting the connection to go from your local machine to the SSH box and then to the destination. You can also use -R which goes from the SSH box to your local machine and then to the destination. You might need to read that a few times :) There’s a whole lot more info on tunneling here.

No Comments

I’m moving

19/01/2010

Greets! I am moving all my sites to webfaction. They seriously rock. You should probably go check them out or something. Meanwhile I will need to migrate all my data over. Which knowing me will take a couple of weeks til I sort it all out.

Still, looking forward to the amount of python I can run easily. Webfaction make putting up a new django app easy or pushing different blogs to various urls. I cannot understate just how cool they’re hosting is compared to “regular” offerings.

Anywayz, til then, this is all you got. Hit me up on twitter or something.

No Comments

Trials 2 : Stats comparator

7/04/2009

I absolutely LOVE Trials2 from Indie developer Red Lynx. In fact, its the first game I’ve actually “gone out” and bought in a long time. I say “gone out”, its available on Steam. Anyway, one minor annoyance I had was that although the scores for people are available online and per-track in-game I found it a bit annoying clicking through each page when I got home to see if any of my scores had been beaten by friends.

So I knocked this up. Its quite simple, it uses a combination of cURL & xpath to grab the page for the 2 profiles you’re interested in and then simply loads those up into an array. I thought I’d beautify it a bit to fit in more with the Trials 2 site. You can check it out here (/code/comparetrialsprofile.php). It does what I’m most interested in – compare your global ranking per track with a mate. With bank holiday weekend coming up I might flesh it out a bit.

Some things I’d like to add would be over-all summaries and the ability to compare more than one person side by side – maybe grabbing the team members from the team page etc. Hopefully red lynx dont change the layout/format on their site :) Once again, kudos guys on an incredibly addictive/challenging/beautiful game.

I’ve defaulted it to me on the left & my mate that introduced me to Trials on the right (he’s jolly good).

Note: occasionally you might get a timeout and your browser will try and let you save the file – just reload

DOUBLE NOTE! As i’ve moved hosts I need to reconfigure this to run. So sorry, at the minute I need to dig out the old hdd as my helpful ex-host nuked my site when whilst they locked me out.

No Comments

Why people that work with computers seem to have a lot of spare time

23/02/2009

So I posted this to reddit yesterday (hello there people from the internet) and got a fairly good response :) I ‘drew’ this at 4am whilst rather stoned and it is perhaps no surprise that I read xkcd thrice-weekly so I was expecting a comparison to that.

I have new found respect for how quick things spread on the internet :

I should point out that a) the 3d artist is not jewish. That was my attempt to ‘liven’ it up by adding a crude chunk of hair, not a skullcap. And… b) the IT consultant is not christian, again, that was my attempt to doodle a middle finger gesture. Anwyayz, as sad as it is, I was rather warmed by how all that played out. It made for a fairly memorable 26th birthday…

No Comments