Skip to content

Instantly share code, notes, and snippets.

require 'rbosa'
OSA.utf8_strings = true
itunes = OSA.app('iTunes')
library = itunes.sources.find {|source| source.name == 'Library' }.playlists[0].tracks
library.each do |track|
count = (track.played_count + track.skipped_count).to_f
stat = track.played_count / count
comment = track.comment
0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.foobar.conf -a -r /var/log/lighttpd/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=foobar -update >/dev/null
#!/usr/bin/env ruby
puts ARGV[0].split(/\s*/).inject([]) {|n,i|
n << ((%w[+ - * /].include?(i)) ? (b,a=n.pop,n.pop; "(#{a} #{i} #{b})") : i)
}[0]
#!/usr/bin/env ruby
str = ARGV[0].split(/\s+/).join('_')
while str.include?('_')
str.sub!(/([^_]+)_([^_]+)_([+\-*\/])/, '(\1 \3 \2)')
end
puts str
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")
$ ./roll 2d6 + 3d4
2d6 7 2, 5
3d4 11 3, 4, 4
18
$ ./roll 2d6 + 3d4
2d6 5 4, 1
3d4 6 3, 1, 2
11
$ ./roll 2d6 + 3d4
2d6 5 4, 1
#include <stdio.h>
int main()
{
int x = 10;
while( x --> 0 ) // x goes to 0
{
printf("%d ", x);
}
}
class Maze
class Node
attr_accessor :x, :y, :distance
def initialize(x, y, distance=0)
@x = x
@y = y
@distance = distance
end
#!/usr/bin/env ruby
require 'rubygems' # Since I"m too lazy to set the RUBYOPTS
# environment variable for NetNewsWire
require 'hpricot'
require 'open-uri'
doc = Hpricot.XML(open('http://themoment.blogs.nytimes.com/feed/atom/'))
$HTTP["host"] =~ "xmarks.foobar.com" {
server.document-root = "/path/to/xmarks/dir"
webdav.activate = "enable"
webdav.is-readonly = "disable"
webdav.sqlite-db-name = "/var/run/lighttpd/lighttpd.webdav_lock.db"
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/path/to/xmarks/dir/.passwd"
auth.require = ( "" => ( "method" => "digest",
"realm" => "webdav",
"require" => "valid-user" ) )