Todays post is about creating a mirrored effect on images appearing on a website. Looking around, there are already a few people who have attempted to do this, however, I would like to tackle the problem myself and provide an in depth post about how to actually do it. At the end of this post we should have a fully functioning jQuery plugin which allows us to mirror images. We can approach this two ways, using Canvas or SVG. I have opted to use Canvas, however I did create a neat SVG file which is able to mirror arbitrary images, passed in by a query parameter. The first part if this post will address creating a reflection of an image. Once we have the ability to do this, we can roll it into a jQuery plugin to provide reflections for images which we specify. Read the rest of this entry »
In the past I have played around with JRuby and accessing some of the Java framework from Ruby. Its fantastic and I have raved about it infront of my friends in the past. Microsoft as well now have a product called IronRuby which runs Ruby inside Microsofts Dynamic Language Runtime (DLR). IronRuby is a Ruby interpereter which runs in the DLR and as a byproduct gives Ruby access to the .NET framework (yay, power to the programmer!). Read the rest of this entry »
I am changing my hosting around at the moment and have a new server, that is completely managed by myself. One of my first requirements is to setup up mail hosting for my domains. Since I am not using any sort of control panel or packaged software, I have to configure this by hand. My needs are simple: virtual users, TLS/SSL security and to run with a small footprint. Further down the track, I also plan on adding virus and spam filtering. Read the rest of this entry »
Greg recently offered a challenge: Python Golf. The idea, to create a parser for Apache’s Common Log Format, to aggregate the amount of data sent to each IP address. The challenge being to do it with the least amount of characters. Soon after this challenge was issued, Sam and Greg were both convinced (before even talking to me) that I would attempt a Ruby solution. How could I dissapoint them? :).
I tried a number of things, however I eventually settled on this solution (63 chars):
m=Hash.new(0);STDIN.map{|l|m[l[/^\S+/]]+=l[/\d+\s+$/].to_i};p m
A slightly longer version, with a slightly prettier printing can be accomplished with inject (78 chars):
STDIN.inject(Hash.new(0)){|m,l|m[l[/^\S+/]]+=l[/\d+\s+$/].to_i;m}.each{|v|p v}
Not to brag, but the winning Python entry was 121 characters. So the Ruby solution managed to be almost half this count!
Reading Steve’s blog today I saw his post on accessing the current functions name in python. This could end up being a useful thing to know if you are playing with some unfamiliar code and need this sort of information, or are doing something nasty. So without anymore fuss here’s how to do the same thing in Ruby and JavaScript! Read the rest of this entry »