This file contains hidden or 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
| def load_from_cache | |
| unless File.exists?(cache_path) | |
| return false | |
| end | |
| toload = YAML.load_file(cache_path) | |
| created = {} | |
| models.each do |model| | |
| toload[model.name].each do |id, attributes| | |
| atts = {} | |
| attributes.each do |k,v| |
This file contains hidden or 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
| From 767031e6fc1f313b29a982dc2f315596ac97bf47 Mon Sep 17 00:00:00 2001 | |
| From: Jacob Burkhart & Martin Emde <[email protected]> | |
| Date: Mon, 19 Aug 2013 16:25:02 -0700 | |
| Subject: [PATCH] Optimize more by not using normalized_ methods | |
| --- | |
| Rakefile | 9 ++++++--- | |
| lib/gitable/scp_uri.rb | 10 +++++----- | |
| lib/gitable/uri.rb | 5 ++--- | |
| 3 files changed, 13 insertions(+), 11 deletions(-) |
This file contains hidden or 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
| def setup_engineyard | |
| configure 'deploy', 'provider' => 'engineyard' do |config| | |
| eyrc = File.expand_path(".eyrc", Dir.home) | |
| if File.exists?(eyrc) | |
| config['api_key'] = YAML.load_file(eyrc)["api_token"] | |
| end | |
| env = ask("Environment (optional): ").to_s | |
| config['environment'] = env unless env.empty? | |
| if agree("Run migrations on deploy? ") { |q| q.default = 'yes' } |
This file contains hidden or 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
| while true; do find . -name '*service*' | head -1 | while read filename ; do echo $filename; mv $filename ${filename/service/addon}; done; done |
This file contains hidden or 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
| git remote add upstream https://github.com/resque/resque.git | |
| git fetch upstream | |
| git checkout master | |
| git merge upstream/master | |
| git push origin master |
This file contains hidden or 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 'rubygems' | |
| require 'nokogiri' | |
| str = "<select id=\"cluster_configuration_data_snapshot_id\" name=\"cluster_configuration[data_snapshot_id]\"></select>" | |
| #This one fails | |
| failing = Proc.new do | |
| innards = "<option data-size=\"15\" value=\"\" volume_size=\"\">New volume</option>\n<option class=\"time\" data-html-suffix=\" (snap-f2e4f551) (Application Master) [64-bit]\" data-size=\"15\" datetime=\"2013-06-20T20:29:32+00:00\" value=\"8\" volume_id=\"14\" volume_size=\"15\" selected>\nThu Jun 20 20:29:32 2013 (snap-f2e4f551) (Application Master) [64-bit]\n</option>" | |
| x = Nokogiri::XML::Element.new('select', Nokogiri::XML(str)) | |
| x.inner_html = innards |
This file contains hidden or 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
| class BlockRefinement | |
| def self.refines(*classes_refined) | |
| @classes_refined = classes_refined | |
| end | |
| def self.refines_method(method_refined, &new_method) | |
| @classes_refined.each do |class_refined| | |
| old_method = class_refined.instance_method(method_refined) | |
| @reverts ||= [] |
This file contains hidden or 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
| class BlockRefinement | |
| def self.refines(*classes_refined) | |
| @classes_refined = classes_refined | |
| end | |
| def self.refines_method(method_refined, &new_method) | |
| @classes_refined.each do |class_refined| | |
| old_method = class_refined.instance_method(method_refined) | |
| @reverts ||= [] |
This file contains hidden or 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 'celluloid' | |
| class Worker | |
| include Celluloid | |
| def work(x) | |
| sleep 0.2; puts x*x | |
| end | |
| end | |
| worker_pool = Worker.pool(size: 10) | |
| (0..99).to_a.each{|x| worker_pool.async.work x } | |
| sleep 2 #how do I wait the right amount of time before terminating? |
This file contains hidden or 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
| DataMapper.repository(@repository).adapter.extend(SQL::Mysql) | |
| DataMapper.repository(@repository).adapter.recreate_database |