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 'terraformer' | |
require 'geotrigger' | |
require 'launchy' | |
# create a new FeatureCollection | |
# | |
fc = Terraformer::FeatureCollection.new | |
# create a Geotrigger Application session with credentials stored in ~/.geotrigger under the :foo key | |
# |
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 'reel' | |
require 'json' | |
require 'pry' | |
class Server < Reel::Server::HTTP | |
include Celluloid::Logger | |
def initialize host = '127.0.0.1', port = 4567 | |
info "listening on #{host}:#{port}" | |
super host, port, &method(:on_connection) |
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 Symbol | |
def method_missing meth, *args | |
if self == :st | |
Sequel.function(:"st_#{meth}", *args) | |
else | |
super | |
end | |
end | |
end |
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
$ 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 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 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 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 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 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 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 |