This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on http://www.ruby-doc.org/stdlib/libdoc/delegate/rdoc/index.html | |
require 'delegate' | |
class SimpleDelegator < Delegator | |
def initialize(obj) | |
super # pass obj to Delegator constructor, required | |
@_sd_obj = obj # store obj for future use | |
end | |
def __getobj__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize git | |
git :init | |
git :submodule => "init" | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/code/rails/rails rails' } | |
# Generate Simple controller | |
generate :controller, :simple | |
route "map.site '/:action/:id', :controller => 'simple'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/sha1' | |
class String | |
def hash | |
Digest::SHA1.hexdigest self | |
end | |
def bit | |
"%0160b" % to_i(16) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace 'sync' do | |
desc "Sync data from server with client" | |
task :client do | |
host, user = credentials | |
puts `rsync -rlpgtvz --delete #{user}@#{host}:#{remote_project}/public/system/ public/system` | |
puts 'Transfering data.yml' | |
Net::SSH.start host, user do |cmd| | |
cmd.exec! 'rake RAILS_ENV=production db:data:dump' | |
cmd.scp.download! "#{remote_project}/db/data.yml", 'db/data.yml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application_name = root.split('/').last | |
initializer 'session_store.rb', <<-END | |
ActionController::Base.session = { | |
:key => '_#{application_name}_session', | |
:secret => '#{ActiveSupport::SecureRandom.hex(64)}' | |
} | |
# ActionController::Base.session_store = :active_record_store | |
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur old/src-ILU/ilur/ilur.c new/src-ILU/ilur/ilur.c | |
--- old/src-ILU/ilur/ilur.c 2009-09-08 05:31:29.000000000 +0400 | |
+++ new/src-ILU/ilur/ilur.c 2009-09-07 07:32:33.000000000 +0400 | |
@@ -1,6 +1,6 @@ | |
#include <string.h> | |
#include <stdio.h> | |
-#include <malloc.h> | |
+#include <malloc/malloc.h> | |
#include <IL/il.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usually you want to stick with git rebase --onto, but if you have conflicts, you can use this script instead | |
raise 'You need to specify a commit' unless ARGV.first | |
commit = ARGV.first | |
following_commits = `git rev-list #{commit}..`.split.reverse | |
def info(commit, format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full transformation: | |
Matrix[ | |
[(((((((((cos(θ0)*cos((45.0+θ1)))*cos((177.6141+θ2)))+(((-sin(θ0))*-1.0)*sin((177.6141+θ2))))*cos((2.3859+θ3)))+((((cos(θ0)*cos((45.0+θ1)))*(-sin((177.6141+θ2))))+(((-sin(θ0))*-1.0)*cos((177.6141+θ2))))*sin((2.3859+θ3))))*cos(θ4))+((((((cos(θ0)*cos((45.0+θ1)))*cos((177.6141+θ2)))+(((-sin(θ0))*-1.0)*sin((177.6141+θ2))))*(-sin((2.3859+θ3))))+((((cos(θ0)*cos((45.0+θ1)))*(-sin((177.6141+θ2))))+(((-sin(θ0))*-1.0)*cos((177.6141+θ2))))*cos((2.3859+θ3))))*sin(θ4)))*cos(θ5))+(((cos(θ0)*(-sin((45.0+θ1))))*-1.0)*sin(θ5))), (((((((((cos(θ0)*cos((45.0+θ1)))*cos((177.6141+θ2)))+(((-sin(θ0))*-1.0)*sin((177.6141+θ2))))*cos((2.3859+θ3)))+((((cos(θ0)*cos((45.0+θ1)))*(-sin((177.6141+θ2))))+(((-sin(θ0))*-1.0)*cos((177.6141+θ2))))*sin((2.3859+θ3))))*cos(θ4))+((((((cos(θ0)*cos((45.0+θ1)))*cos((177.6141+θ2)))+(((-sin(θ0))*-1.0)*sin((177.6141+θ2))))*(-sin((2.3859+θ3))))+((((cos(θ0)*cos((45.0+θ1)))*(-sin((177.6141+θ2))))+(((-sin(θ0))*-1.0)*cos((177.6141+θ2))))*cos((2.3859+θ3))))*sin(θ4)))*(-sin(θ5)))+(( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rvm 1.8.6,1.8.7,1.9.1,1.9.2 ruby benchmark.rb | |
ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [x86_64-darwin10.2.0] | |
benchmarking Create 100,000 times | |
------------------------------------------------- | |
proc 0.718 | | |
lambda 0.724 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1.8.7 | |
R18n | Rails I18n | R18n/I18n | | |
---------------------------------------------------- | |
load 3.136 | 0.774 | 4.05x | | |
get 0.069 | 0.155 | 0.45x | | |
variables 0.074 | 0.145 | 0.51x | | |
pluralize 0.250 | 0.129 | 1.94x | | |
localize 0.156 | 0.361 | 0.43x | | |
default 0.073 | 0.247 | 0.30x | | |
fallback 0.048 | 0.064 | 0.75x | |