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
$ irb -rterraformer -ruri -rlaunchy | |
>> Terraformer::Circle.new([-122.6764, 45.5165], 100).to_feature.geojson_io | |
=> #<Thread:0x007fd313f05fd0 sleep> | |
>> Terraformer::Circle.new([-122.6764, 45.5165], 100, 16).to_feature.geojson_io | |
=> #<Thread:0x007fd313040fb8 sleep> | |
>> Terraformer::Circle.new([-122.6764, 45.5165], 100, 8).to_feature.geojson_io | |
=> #<Thread:0x007fd313dcfb20 sleep> |
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
# load up waldo | |
wc = Terraformer.parse 'test/examples/waldocanyon.geojson' | |
# grab the line string of the outer polygon ring | |
ls = wc.geometry.polygons[0].line_strings[0] | |
# new array to hold new outer ring | |
scs = [] | |
# only put every 5th coordinate in the new 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
require 'bigdecimal' | |
t1 = Thread.new { 5.times { puts "(1) limit: #{BigDecimal.limit}"; sleep 1 } } | |
sleep 2 | |
BigDecimal.limit BigDecimal.double_fig | |
puts "(main) limit: #{BigDecimal.limit}" | |
t2 = Thread.new { 5.times { puts "(2) limit: #{BigDecimal.limit}"; sleep 1 } } | |
t1.join | |
t2.join |
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 | |
class DefMethard | |
define_method :go do |&block| | |
5.times {|n| yield n} | |
end | |
define_method :yo do |&block| | |
5.times {|n| block[n]} | |
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
$ mkdir -p ~/.weechat/themes | |
$ cd ~/.weechat/python | |
$ curl -O http://weechat.org/files/temp/theme/theme.py | |
$ cd ../themes | |
# find a theme at http://weechat.org/themes/ and curl -O it into ~/.weechat/themes | |
$ weechat | |
/help theme |
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/bigo' | |
def b(size) | |
[size + 5] | |
end | |
Benchmark.bigo do |x| | |
x.generator do |size| | |
(0...size).to_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
$ curl -H 'X-Foo: bar' -d @reel.rb -v http://127.0.0.1:4567/ http://127.0.0.1:4567/ | |
* Hostname was NOT found in DNS cache | |
* Trying 127.0.0.1... | |
* Connected to 127.0.0.1 (127.0.0.1) port 4567 (#0) | |
> POST / HTTP/1.1 | |
> User-Agent: curl/7.37.1 | |
> Host: 127.0.0.1:4567 | |
> Accept: */* | |
> X-Foo: bar | |
> Content-Length: 165 |
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
$ ruby reel.rb | |
E, [2014-12-03T16:03:19.939500 #53590] ERROR -- : Actor crashed! | |
Reel::StateError: already processing a request | |
/opt/ruby/2.1.5/lib/ruby/gems/2.1.0/gems/reel-0.5.0/lib/reel/connection.rb:55:in `request' | |
/opt/ruby/2.1.5/lib/ruby/gems/2.1.0/gems/reel-0.5.0/lib/reel/connection.rb:72:in `each_request' | |
reel.rb:6:in `block in <main>' | |
... |
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
task :command do |p| | |
case p | |
when Proc; p[] | |
when Hash; p[:time] = Time.now.to_i | |
else; p.inspect | |
end | |
end | |
get '/' do | |
redirect 'index.html' |
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 'sinatra/base' | |
require 'celluloid' | |
class Nmapper | |
include Celluloid | |
def nmap opts = '' | |
`nmap #{opts}` | |
end | |
end |