Skip to content

Instantly share code, notes, and snippets.

View tobstarr's full-sized avatar

Tobias Schwab tobstarr

View GitHub Profile
begin
require 'thinking_sphinx/0.9.8'
require 'thinking_sphinx/tasks'
require 'thinking_sphinx/deltas/datetime_delta/tasks'
rescue LoadError
end
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :type
t.string :email
t.timestamps
end
end
def find_cmd(*commands)
dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/
full_path_command = nil
found = commands.detect do |cmd|
dir = dirs_on_path.detect do |path|
full_path_command = File.join(path, cmd)
File.executable? full_path_command
end
# ~/Projects/simfy $ bundle -v
Bundler version 1.1.rc
# ~/Projects/simfy $ time bundle exec ./script/runner "puts 1"
1
real 0m12.492s
user 0m10.768s
sys 0m1.602s
# ~/Projects/simfy $ time bundle exec ./script/runner "puts 1"
1
real 0m12.963s
@tobstarr
tobstarr / ruby_testing_framework_benchmark.rb
Created March 17, 2012 08:10
Ruby Testing Framework Benchmark
require "fileutils"
require "ostruct"
class Runner
class << self
attr_accessor :type
def run(tests_per_file, max_number_of_files, method = nil)
method ||= :total_time
tupels = (max_number_of_files / 50).times.map do |i|
#
# add this to your Gemfile
#
# gem "ruby-debug-base19", "0.11.26"
#
# and run this script:
#
test -e /tmp/linecache19-0.5.13.gem || wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem -O /tmp/linecache19-0.5.13.gem
test -e /tmp/ruby-debug-base19-0.11.26.gem || wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem /tmp/ruby-debug-base19-0.11.26.gem
@tobstarr
tobstarr / snippets.md
Created April 13, 2012 08:12
Snippets

Snippets

@tobstarr
tobstarr / theme.html
Created April 13, 2012 16:52 — forked from soemarko/theme.html
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
require "redis"
Redis.current.del("test")
def do_set!
did_set = nil
Redis.current.pipelined do
did_set = Redis.current.setnx("test", "ja")
Redis.current.expire("test", 3600)
@tobstarr
tobstarr / .bookmarks
Created August 31, 2012 14:40
Bookmark System
first,link: http://www.some.url
second,link: http://www.someother.url