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
| a = Simulation.where(user_id: 1, visibility: 0).where_values.reduce(:and) | |
| a.to_sql | |
| => "\"simulations\".\"user_id\" = $1 AND \"simulations\".\"visibility\" = $2" | |
| b = Simulation.where(visibility: 1).where_values.reduce(:and) | |
| b.to_sql | |
| => "\"simulations\".\"visibility\" = $1" | |
| Simulation.where(a.or(b)).to_sql | |
| => "SELECT \"simulations\".* FROM \"simulations\" WHERE (\"simulations\".\"user_id\" = AND \"simulations\".\"visibility\" = OR \"simulations\".\"visibility\" = )" |
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
| list = [128, 110, 60, 126] | |
| list2 = [60, 110, 126] | |
| res = list.each_with_index.each_with_object({}) {|(k,id), res| res[k] = id} | |
| list 3 = list2.sort_by {|a| res[a]} |
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
| Failures: | |
| 1) UserSessionsController#create with correct credentials with device_id and device_type set someone else is logged in with the same devic | |
| e_id adds AddDeviceToken to the queue | |
| Failure/Error: expect{ | |
| expected result to have changed by 1, but was changed by 0 | |
| # ./spec/controllers/user_sessions_controller_spec.rb:91:in `block (6 levels) in <top (required)>' | |
| Finished in 1.45 seconds (files took 2.33 seconds to load) | |
| 13 examples, 1 failure |
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
| Schemas | |
| An update_call of the item_classification | |
| Processing ItemClassificationsController#update (for 127.0.0.1 at 2015-03-23 11:15:54) [PUT] |
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
| params = {:id=>"5", :jurisdiction=>{:place_attributes=>{:name=>"Allen County15", :short_name=>"Allen County15", :id=>"5"}}} | |
| @jurisdiction = PlaceEntity.jurisdictions.excluding_unassigned.find(params[:id]) | |
| @jurisdiction.place | |
| @jurisdiction.update_attributes(params[:jurisdiction]) | |
| @jurisdiction.place.valid? |
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 AddIndexToLineItems < ActiveRecord::Migration | |
| def change | |
| add_index :line_items, [:user_id, :product_id], unique: true | |
| 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
| #!/usr/bin/env ruby | |
| ## modified, working version | |
| APP_PATH = File.expand_path('../../config/application', __FILE__) | |
| require_relative '../config/boot' | |
| require 'rails/commands' |
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
| #!/usr/bin/env ruby | |
| APP_PATH = File.expand_path('../../config/application', __FILE__) | |
| require_relative '../config/boot' | |
| require 'rails/commands' |
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' | |
| hsh = {} | |
| 1000.times {|i| hsh[i.to_s] = i.succ.to_s} | |
| Benchmark.bm do |x| | |
| x.report("Hash[]") {1000.times{Hash[hsh.values.zip(hsh.keys)]}} | |
| x.report("invert") {1000.times{hsh.invert}} | |
| x.report("each_with_object") {1000.times{hsh.each_with_object({}){|(k,v),h| h[v] = k}}} | |
| 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
| curl -X POST -H "Content-Type: application/json" -d '[]' http://localhost:3000/manifest.json |