Skip to content

Instantly share code, notes, and snippets.

s = Time.now
e = s + 100.days
i = s
dates = []
dates << s
while i < e
i += 1.week
dates << i
end
#!/usr/bin/env ruby
require 'tempfile'
require 'rubygems'
require 'mojombo-grit'
include Grit
PATH_TO_DIFFMERGE = "/usr/bin/diffmerge"
print "Hello, perl world!\n";
0;
{ scopeName = 'source.ruby';
comment = '
TODO: unresolved issues
text:
"p << end
print me!
end"
symptoms:
not recognized as a heredoc
BLOWIN UP YOUR SPOT
def foo
puts 'hello world'
end
foo
require 'benchmark'
puts Benchmark.measure {
(2..100).select { |n| '_' * n !~ /\A(__+)\1+\z/ }
}
puts ">_<X"
puts ">_<X"
puts ">_<X"
puts ">_<X"
@nowelium
nowelium / gist:2608
Created July 26, 2008 05:48
js like apply, bind, curry...
Block apply := method(target, args,
args = if(args isNil, list(), args)
target = if(target isNil, scope, target)
self setScope(target)
self performWithArgList("call", args)
)
Block bind := method(
args := call message argsEvaluatedIn(call sender)
target := args at(0)
args = args slice(1)
@ashwin
ashwin / boost_dfs_example.cpp
Created July 26, 2008 06:12
Example of boost DFS on an undirected graph
// Boost DFS example on an undirected graph.
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <iostream>
using namespace std;
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS> MyGraph;
typedef boost::graph_traits<MyGraph>::vertex_descriptor MyVertex;
begin
require 'rubygems'
require 'readline/history/restore/auto_save'
Readline::History::Restore::AutoSave.scriptname
#require 'active_support'
rescue Exception
end
module Kernel
def r(arg)