Skip to content

Instantly share code, notes, and snippets.

# Ruby 1.8.7
$ cat foo.rb;gem environment;(for i in {1..10} ; do ruby foo.rb ; done)|awk '{print $1;s+=$1} END {print "avg:", s/NR}'
st=Time.now.to_f
#$:.replace($:[-9,9])
require 'rubygems'
Gem::LoadError
puts Time.now.to_f-st
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
@jiangmiao
jiangmiao / gist:1219633
Created September 15, 2011 15:53
File Monitor and auto F5
#!/usr/bin/env ruby
require 'rubygems'
require 'rb-inotify'
require 'getoptlong'
class Monitor
def initialize(project_dir)
@notifier = INotify::Notifier.new
@project_dir = project_dir
@jiangmiao
jiangmiao / hello.cc
Created October 4, 2011 05:32
run gtk main loop in sub thread
// hello.cc
// g++ -std=c++0x hello.cc `pkg-config --libs --cflags gtk+-2.0` && ./a.out
#include <thread>
#include <functional>
#include <gtk/gtk.h>
bool done = false;
@jiangmiao
jiangmiao / copy-dir.js
Created December 20, 2011 07:17
copy-dir
(function() {
var confirm, copy, copyDir, copyFile, copyFileByLoop, copyFileByPipe, copyFileByPump, fs, path, print, puts, readline, strError, util;
fs = require('fs');
path = require('path');
util = require('util');
readline = require('readline').createInterface(process.stdin, process.stdout);