Improved Twitter Stats in Ruby

Posted by Alpha Thu, 03 Jan 2008 07:36:00 GMT

The previous method was a bit messy, so I’ve cleaned it up a bit.

Download twitter_stats.tar.gz

Read more...

Posted in , ,  | no comments | no trackbacks

Twitter stats using Ruby

Posted by Alpha Wed, 02 Jan 2008 17:40:00 GMT

I saw Damon Cortesi’s Twitter Stats script last night, and decided to make a Ruby version. This was before he released his code, so it’s reverse-engineered rather than ported. I’ll take a look later tonight to see how much the logic differs.

Edit: This code is rather inelegant, and I’ve replaced the clunky CSV files with an Sqlite3 database. You can find the new and improved scripts here. The following should still work, and I’m leaving it here for posterity’s sake.

Read more...

Posted in , ,  | 2 comments | no trackbacks

Generating animated GIFs using RMagick

Posted by Alpha Sun, 30 Dec 2007 20:38:00 GMT

anim = Magick::ImageList.new(*Dir["/some/path/*.jpg"])
anim.each {|img| img.resize!(200,200) }
anim.delay = 10
anim.unshift Magick::Image.read("/some/image.jpg")[0].resize(200,200)
anim << Magick::Image.read("/some/other/image.jpg")[0].resize(200,200)
anim.write("animated.gif")

Example image:

Gloria making a funny face.

Posted in ,  | no comments | no trackbacks

Centering image links using CSS

Posted by Alpha Sun, 30 Dec 2007 18:05:58 GMT

It took me no small amount of time to figure out how to horizontally and vertically center image links, so here it is for posterity’s sake. Note that this doesn’t work in IE and is rather specific to my purposes in creating thumbnail links for a bunch of pictures.

HTML:
<div class="thumbnail">
    <a href=/some/link>
        <img src=/some/image>
    </a>
</div>
CSS:
.thumbnail {
    height:150px;
    width:150px;
    line-height:150px;
    text-align:center;
}

.thumbnail img {
    vertical-align:middle;
}

Posted in ,  | no comments | no trackbacks

Ultraviolet syntax highlighting test

Posted by Alpha Sat, 01 Dec 2007 22:53:00 GMT

Ruby:

class Foo
  def bar
    puts "hello world"
  end
end

C with linenumbers using the blackboard theme:

   1  void bar() {
   2    printf("hello world\n");
   3  }

Objective-C with the twilight theme:

#import <Foundation/NSObject.h>

@interface Fraction: NSObject {
    int numerator;
    int denominator;
}

-(void) print;
-(void) setNumerator: (int) d;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
@end

Python with linenumbers and using the pastels_on_dark theme:

   1  class MyClass:
   2      "A simple example class"
   3      i = 12345
   4      def f(self):
   5          return 'hello world'

Done using Ultraviolet.

Posted in  | no comments | no trackbacks