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
select pg_terminate_backend(pid) | |
from ( | |
SELECT | |
pid | |
FROM pg_stat_activity | |
WHERE query <> '<insufficient privilege>' | |
AND state <> 'idle' | |
AND pid <> pg_backend_pid() | |
AND query_start < now() - interval '1 minute' | |
ORDER BY query_start DESC) t; |
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
@navigator.geolocation.watchPosition = (callback) -> | |
setInterval(-> | |
callback | |
coords: | |
latitude: 39.286031201326416, | |
longitude: -76.61204230156727 | |
, 5000) |
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
(defn foldr [f acc coll] | |
(if (first coll) | |
(f (first coll) (foldr f acc (rest coll))) | |
[])) |
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
require 'irb/completion' | |
# History | |
#require 'irb/ext/save-history' #wirble does history | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
IRB.conf[:AUTO_INDENT] = true | |
# use HIRB if available |
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 foo(x: wtf) | |
end | |
puts "wtf did not get called when the method was defined" | |
foo x: 1 | |
puts "wtf did not get called when we passed a value for x" | |
begin |
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
class Foo | |
instance_eval <<-end_eval, __FILE__, __LINE__ | |
def bar | |
"class method" | |
end | |
end_eval | |
class_eval <<-end_eval, __FILE__, __LINE__ | |
def bar | |
"instance method" |
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
require 'json' | |
run -> (env) { | |
body = JSON.pretty_generate(env) + "\n" | |
puts body | |
[ 200, { 'Content-Type' => 'application/json', | |
'Content-Length' => body.length.to_s }, [body] ] | |
} |
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
require "benchmark" | |
test = "hi man" | |
m = test.method(:length) | |
n = 100000 | |
Benchmark.bmbm {|x| | |
x.report("meth") { n.times { test.length } } | |
x.report("call") { n.times { m.call } } | |
x.report("send") { n.times { test.send(:length) } } | |
x.report("eval") { n.times { eval "test.length" } } | |
} |
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
$ cat ~/.irbrc | |
cat: /Users/pbarry/.irbrc: No such file or directory | |
$ rails c | |
Loading development environment (Rails 4.0.0) | |
irb(main):001:0> Subscription.first | |
Subscription Load (2.5ms) SELECT "subscriptions".* FROM "subscriptions" ORDER BY "subscriptions"."id" ASC LIMIT 1 | |
=> nil | |
irb(main):002:0> puts ENV.keys.sort | |
Apple_PubSub_Socket_Render | |
Apple_Ubiquity_Message |
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
<html> | |
<body> | |
<div style="text-decoration: underline; font-weight: bold"> | |
I am underlined | |
<div style="text-decoration: none; font-weight: normal"> | |
I am not | |
</div> | |
</div> | |
</body> | |
</html> |
NewerOlder