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 --git a/app/models/users_audit_search.rb b/app/models/users_audit_search.rb | |
index 74f0a24..52d9c0f 100644 | |
--- a/app/models/users_audit_search.rb | |
+++ b/app/models/users_audit_search.rb | |
@@ -9,7 +9,7 @@ class UsersAuditSearch | |
self.last_name = params[:last_name] | |
self.action = params[:action] | |
self.start_time = parse_audit_date(params, :start_time) | |
- self.end_time = parse_audit_date(params, :end_time) || Date.current | |
+ self.end_time = parse_audit_date(params, :end_time) |
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
#======== Ruby 1.9.3 ======================== | |
# Order of items with duplicated values will change if array contains items with other values | |
1.9.3-p547 :036 > arr = [{:id=>1, :val=>30}, {:id=>2, :val=>30}, {:id=>1002, :val=>82}] | |
=> [{:id=>1, :val=>30}, {:id=>2, :val=>30}, {:id=>1002, :val=>82}] | |
1.9.3-p547 :037 > arr.sort{|x,y| x[:val] <=> y[:val]}.map{|x| x[:id]} | |
=> [1, 2, 1002] | |
1.9.3-p547 :038 > arr.sort{|x,y| y[:val] <=> x[:val]}.map{|x| x[:id]} | |
=> [1002, 2, 1] |
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
def check_stability | |
result = [] | |
1000.times{ result << yield } | |
raise Exception, 'function is unstable' if result.uniq!.size > 1 | |
p "Result: #{result}" | |
end | |
arr = [{:id=>1, :val=>30}, {:id=>2, :val=>30}, {:id=>1002, :val=>82}] | |
check_stability do |
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
def check_stability | |
result = [] | |
1000.times{ result << yield } | |
raise Exception, 'function is unstable' if result.uniq!.size > 1 | |
p "Result: #{result}" | |
end | |
arr = [{:id=>1, :val=>30}, {:id=>2, :val=>30}, {:id=>1002, :val=>82}] | |
check_stability do |
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
var obj = (function() { | |
var func1 = function(options) { | |
... | |
}, | |
func2 = function(options) { | |
... | |
}, | |
func3 = function(options) { |
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
#config/initializers/websocket_handler.rb | |
EM.next_tick do | |
@channel = EM::Channel.new | |
#Simulate messages. | |
EM::PeriodicTimer.new(3) do | |
random_string = rand(100_000).to_s | |
@channel.push random_string | |
end |