- Email: me@example.com
- Twitter: @example
- Website or Blog: http://example.com
- Company: Example Ltd.
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 'benchmark' | |
| N = 10000 | |
| STRING = "cat" | |
| DAT = "cat" | |
| puts "#{STRING} vs #{DAT}" | |
| Benchmark.bmbm do |x| |
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 'benchmark' | |
| ARRAY = (0..1000).to_a | |
| N = 100000 | |
| Benchmark.bmbm do |x| | |
| x.report('each') { N.times { | |
| array = [ ] |
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
| array = [ ] | |
| [1,2,3,4].each { |c| array << c } |
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
| ## solve this | |
| # | |
| # max 3 lignes, benche avec Benchmark (http://ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.html) | |
| # | |
| # "34,6".to_f -> 34 ; comment faire pour obtenir 34.6 comme un Float/Decimal ? | |
| # |
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
| namespace :iron do | |
| desc "queue clockwork job at Iron worker" | |
| task :queue_clockwork => :environment do | |
| require "iron_worker_ng" | |
| client = IronWorkerNG::Client.new(Settings.iron_worker.token, Settings.iron_worker.project_id) | |
| # ...and upload it to iron.io cloud | |
| # :host, :port, :ssl, :payload, :url, :token, :username | |
| options = {:start_at => 30.seconds.since, :run_every => 300} | |
| options[:run_times] = ENV['COUNT'].to_i if ENV["COUNT"] |
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
| $ gem list | |
| *** LOCAL GEMS *** | |
| bundler (1.0.22) | |
| iron_worker_ng (0.1.5) | |
| json (1.6.5) | |
| mime-types (1.17.2) | |
| rake (0.9.2) | |
| rest (0.2.0) |
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 "iron_worker_ng" | |
| code = IronWorkerNG::Code::Ruby.new | |
| code.merge_worker "#{Rails.root}/app/workers/test_iron.rb" | |
| # ...and upload it to iron.io cloud | |
| client = IronWorkerNG::Client.new(Settings.iron_worker.token, Settings.iron_worker.project_id) | |
| client.codes.create(code) | |
| # :host, :port, :ssl, :payload, :url, :token, :username | |
| client.tasks.create('TestIron', 'foo' => 42) |
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
| # encoding: UTF-8 | |
| class String | |
| def to_iso | |
| Iconv.conv('ISO-8859-1', 'utf-8', self) | |
| end | |
| end |
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
| @request.env["CONTENT_TYPE"] = "multipart/form-data;" | |
| image = Rack::Test::UploadedFile.new("#{Rails.root}/tmp/issue.jpg") | |
| post :create, :image => image |