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 ConcurrentHashMap < Hash; end | |
| ConcurrentHashMap.send(:include,(Module.new do | |
| def []=(key,value) | |
| warn 'This method is slow' | |
| super(key,value) | |
| end | |
| end)) | |
| h = ConcurrentHashMap.new |
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
| { | |
| "7fb0d9"=>6028200, | |
| "366d16"=>6035040, | |
| "57d44a"=>6020760, | |
| "d32228"=>6019140, | |
| "027d29"=>6043620, | |
| "cbc570"=>6000600, | |
| "5f0756"=>6029820, | |
| "798c69"=>6043860, | |
| "803566"=>6024780, |
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
| url = "http#{schemes.sample}://#{ | |
| #subdomains | |
| tlds.sample(1 + rand(3)).join('.') | |
| }.#{ | |
| #host | |
| host | |
| }.#{ | |
| #tlds | |
| tlds.sample | |
| }#{ |
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
| source 'http://rubygems.org' | |
| gem 'sinatra' | |
| gem 'erubis' | |
| gem 'shotgun' |
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
| Form.count | |
| (0.4ms) SELECT forms.id, forms.name, forms.created, forms.user_id, forms.category_id, forms.active_status, forms.read_only, forms.example_interview_id, COUNT(*) FROM `forms` | |
| => 1 | |
| > Form.unscoped.count | |
| (0.2ms) SELECT COUNT(*) FROM `forms` | |
| => 4 | |
| > Form.unscoped.select("name").count | |
| (0.3ms) SELECT COUNT(`forms`.`name`) FROM `forms` | |
| => 4 |
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
| @samples = 10.times.map do rand(10) end | |
| result = @samples.inject( Hash.new(0) ) do |hash,element| | |
| hash[element] += 1 | |
| hash | |
| end.to_a # => [[6, 3], [3, 1], [1, 1], [9, 2], [4, 2], [8, 1]] | |
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
| module MetaSearch | |
| module Helpers | |
| module UrlHelper | |
| def order_indicator_for(order) | |
| if order == 'asc' | |
| '▲' # replace this with a string or nil | |
| elsif order == 'desc' | |
| '▼' # replace this with a string or nil | |
| else |
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
| (rdb:1) pp o | |
| #<Arel::Nodes::SelectCore:0x000001056b0638 | |
| @groups=[], | |
| @having=nil, | |
| @projections= | |
| [#<struct Arel::Attributes::Attribute | |
| relation= | |
| #<Arel::Table:0x000001056aea68 | |
| @aliases=[], | |
| @columns=nil, |
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 SupportSubdomain | |
| def self.subdomain | |
| @@request.subdomain.to_sym rescue :not_found | |
| end | |
| def self.matches?(request) | |
| @@request = request | |
| request.path_parameters[:controller] = request.subdomain | |
| Rails.logger.info request.path_parameters[:controller] |
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
| #include <CoreServices/CoreServices.h> | |
| static void callback(ConstFSEventStreamRef streamRef, | |
| void *clientCallBackInfo, | |
| size_t numEvents, | |
| void *eventPaths, | |
| const FSEventStreamEventFlags eventFlags[], | |
| const FSEventStreamEventId eventIds[]) { | |
| exit(0); | |
| } |