Skip to content

Instantly share code, notes, and snippets.

View glejeune's full-sized avatar

Gregoire Lejeune glejeune

View GitHub Profile
// Usage :
//
// @import "BrowserWindow.j"
// ...
// [BrowserWindow show];
@import <AppKit/CPWindowController.j>
@import <AppKit/CPWebView.j>
@implementation BrowserWindow : CPWindowController
t = ["vert", "jaune", "rouge"]
puts t.push( t.shift )[-1]
# => "vert"
puts t.push( t.shift )[-1]
# => "jaune"
puts t.push( t.shift )[-1]
# => "rouge"
puts t.push( t.shift )[-1]
# => "vert"
require 'net/http'
require 'rubygems'
#I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2=true
require 'nokogiri'
# This class allow you to retrive "lorem ipsum" placeholder text from lipsum.com.
#
# == What is "lorem ipsum"?
#
@glejeune
glejeune / ar-test.rb
Created November 7, 2009 19:53
ActiveRecord without Rails
require 'rubygems'
require 'ar'
class DBSchema < AR::Schema 1.0
def self.up
create_table :users do |t|
t.string :login
t.string :password
end
end
@glejeune
glejeune / sq-test.rb
Created November 13, 2009 09:12
Sequel without... sequel
require 'rubygems'
require 'sq'
class CreateUsers < SQ::Schema 1.0
def up
create_table :users do
String :login
String :password
end
end
# (The MIT License)
#
# Copyright (c) 2009 Grégoire Lejeune
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# 'Software'), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
@glejeune
glejeune / timer.rb
Created December 22, 2009 17:46
A very very simple timer
require 'rubygems'
require 'eventmachine'
class Timer
def initialize
@run = false
@timeout_proc = nil
end
# Run <tt>blk</tt> every <tt>every</tt> seconds during <tt>during</tt> seconds
require 'java'
require 'rubygems'
rb_root = File.dirname(__FILE__)
app_root = File.dirname(__FILE__)+'/..'
Dir[app_root+"/*.jar"].each { |jar| require jar }
require 'rack'
Dir[app_root+"/Java/jetty/*.jar"].each { |jar| require jar }
<img src="http://dotgraph.net/embed/[mysite]/image/?src=http://mysite.com/my_graph.dot">
require "shortcut"
require 'hotcocoa'
class Application
include HotCocoa
def start
application :name => "Shortcut" do |app|
app.delegate = self