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 A | |
def b | |
'b' | |
end | |
end | |
module X | |
def b |
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 pdx_maps.rb | |
irb(main):001:0> lot = get_lot -122.6769435581849, 45.5488853183137 | |
=> #<Terraformer::Feature:0x007fb778cb1df8 @geometry=#<Terraformer::Polygon:0x007fb778c48128 @coordinates=[[#<Terraformer::Coordinate lon=-122.6767446408871 lat=45.54882332280822 >, #<Terraformer::Coordinate lon=-122.6771349121657 lat=45.54882481627093 >, #<Terraformer::Coordinate lon=-122.6771338692216 lat=45.54896194793751 >, #<Terraformer::Coordinate lon=-122.6767436024346 lat=45.5489604538493 >, #<Terraformer::Coordinate lon=-122.6767446408871 lat=45.54882332280822 >]]>> | |
irb(main):002:0> puts JSON.pretty_generate lot.to_hash | |
{ | |
"type": "Feature", | |
"properties": { | |
}, | |
"geometry": { | |
"type": "Polygon", |
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 App | |
def call env = {} | |
r = Rack::Request.new env | |
if r.session[:hi] | |
STDERR.puts "found in session: #{r.session[:hi]}" | |
else | |
r.session[:hi] = 'hello' | |
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
require 'angelo' | |
class BG < Angelo::Base | |
websocket '/' do |ws| | |
websockets << ws | |
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
#!/usr/bin/env ruby | |
require 'angelo' | |
# require 'httpclient' | |
class Worker | |
include Celluloid | |
def fib n = 40 | |
n <= 1 ? n : fib(n-1) + fib(n-2) |
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 'rack' | |
require 'puma' | |
class Fib | |
def call env | |
request = Rack::Request.new env | |
s = [] | |
case request.path |
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
source 'https://rubygems.org' | |
gem 'mapbox-sdk', github: 'kenichi/mapbox-sdk', branch: 'to_sym' | |
gem 'terraformer' |
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
set-option -g default-path . | |
neww -t 1 -n web 'bin/tracklet' | |
neww -t 2 -n psql 'psql tracklet' | |
neww -t 3 -n irb 'ruby -rirb -r./lib/tracklet -e "Bundler.require :dev; IRB.start"' | |
neww -t 4 -n tig 'tig' | |
neww -t 5 -n workers 'bundle exec sidekiq -r ./lib/tracklet.rb -c 8' | |
bind T neww -t 0 -n bash 'bash' | |
bind Y neww -t 1 -n web 'bin/tracklet' |
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
$ echo foo=bar | nghttp -d - -t 0 -vu http://127.0.0.1:8080/ | |
[ 0.003] Connected | |
[ 0.005] HTTP Upgrade request | |
OPTIONS * HTTP/1.1 | |
Host: 127.0.0.1:8080 | |
Connection: Upgrade, HTTP2-Settings | |
Upgrade: h2c | |
HTTP2-Settings: AAMAAABkAAQAAP__ | |
Accept: */* | |
User-Agent: nghttp2/1.1.3-DEV |
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 'webrick' | |
require 'zlib' | |
require 'stringio' | |
s = WEBrick::HTTPServer.new Port: 4567, BindAddress: '127.0.0.1' | |
s.mount_proc '/' do |req, res| | |
puts "unzipped_body:\n" + Zlib::GzipReader.new(StringIO.new(req.body)).read | |
res.status = 200 | |
res.content_length = 0 | |
end |