Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'rake'
require 'rake/gempackagetask'
LEGS_GEMSPEC = eval(File.read('mtest.gemspec'))
Rake::GemPackageTask.new(LEGS_GEMSPEC) do |pkg|
pkg.need_tar_bz2 = true
end
task :default => "pkg/#{LEGS_GEMSPEC.name}-#{LEGS_GEMSPEC.version}.gem" do
@madx
madx / gsub
Created October 31, 2008 13:03
Little personal snippets and tools
#!/usr/bin/env ruby
puts $stdin.read.gsub(Regexp.new(ARGV[0]), ARGV[1])
@madx
madx / js3.js
Created November 19, 2008 21:59
A simple JS slideshow
/*
* js3 - javascript simple slideshow system
*
*/
js3 = {
"current": 0,
require 'rubygems'
require 'sinatra'
class Jaxer
class << self
def json_to_png(json)
# producing image data
File.open('foo', 'w+') do |f|
cmd = "echo"
raise "Failed to convert canvas to PNG." unless system(cmd)
str, t = "", nil
b, bt = "", nil
c = nil
vc = 0
Shoes.app :height => 500, :width => 450 do
background rgb(77, 77, 77)
stack :margin => 10 do
para span("TEXT EDITOR", :stroke => red, :fill => white), " * USE ALT-Q TO QUIT", :stroke => white
bt = para "Select: ", :margin => 1, :font => "10px", :stroke => white
c = para "Cursors (r|v): ", :margin => 1, :font => "10px", :stroke => white
class Term
def method_missing(meth, *args)
cmd = args.unshift(meth).collect! {|a| a.to_s }.join(' ')
puts `tput #{cmd}`
end
end
$HTTP["host"] == "yapok.org" {
server.document-root = "/home/madx/yapok.org/"
$HTTP["url"] =~ "^/.*" {
expire.url = ("" => "access plus 10 years")
}
}
$HTTP["host"] == "www.yapok.org" {
url.redirect = ( "^/(.*)" => "http://yapok.org/$1" )
}
int fib(n) {
if(n <= 1)
return 1;
else
return fib(n-1)+fib(n-2);
}
int main() {
fib(30);
return 0;
module Xup#:nodoc:
module Helpers#:nodoc:
module Typography
def parse_typography
# Unbreakable spaces before double punctuations
parse_unbreakable_punctuation ':'
parse_unbreakable_punctuation ';'
parse_unbreakable_punctuation '!'
parse_unbreakable_punctuation '?'
#include "main.h"
Line * Line_new(int id, int city_c, int travel_c) {
int i;
Line * line = malloc(sizeof(Line));
assert(line != NULL);
line->id = id;
line->city_c = city_c;
line->travel_c = travel_c;