Skip to content

Instantly share code, notes, and snippets.

View kenichi's full-sized avatar

Kenichi Nakamura kenichi

  • Portland, Oregon
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kenichi on github.
  • I am kenichi (https://keybase.io/kenichi) on keybase.
  • I have a public key whose fingerprint is EFC6 3195 D624 70E1 90FD 2816 41AA 0C27 16BC E95F

To claim this, I am signing this object:

@kenichi
kenichi / test.rb
Created March 25, 2014 16:07
minitest "server gets a post" example with timeout and server thread
require 'minitest/autorun'
require 'httpclient'
require 'socket'
require 'timeout'
describe 'server gets post' do
it 'gets a post' do
timeout = Timeout.timeout 5 do
@kenichi
kenichi / angelo app output
Created April 2, 2014 22:26
using sinatra/puma to test long-wait calls to other services from angelo/reel
$ be ruby concurrency_test_app.rb -p 5000
I, [2014-04-02T15:15:12.467887 #1602] INFO -- : Angelo 0.1.5
I, [2014-04-02T15:15:12.468080 #1602] INFO -- : listening on 127.0.0.1:5000
D, [2014-04-02T15:15:27.794593 #1602] DEBUG -- : 127.0.0.1 - - "GET /asynch_test HTTP/1.1" 200 11
D, [2014-04-02T15:15:28.887823 #1602] DEBUG -- : 127.0.0.1 - - "GET /asynch_test HTTP/1.1" 200 11
@kenichi
kenichi / bk_points.geojson
Last active August 29, 2015 13:59
full GPS of bike ride over sellwood/hawthorne bridges
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
kzerza:terraformer-ruby $ irb -I./lib -rterraformer
>> f = Terraformer::Feature.new
=> #<Terraformer::Feature:0x00000000d90468>
>> f.geometry = Terraformer::Coordinate.new(-122.6764, 45.5165).buffer 100; nil
=> nil
>> puts f.to_json
{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-122.67550601034951,45.516562033665174],[-122.67551894559217,45.51662290132699],[-122.67554036587042,45.51668278727813],[-122.67557006489525,45.51674070977981],[-122.67560775664884,45.516796668829606],[-122.67565307813899,45.51684968268687],[-122.67570559289496,45.516899751348255],[-122.67576479517095,45.51694491133269],[-122.67583011481669,45.51698614437468],[-122.67590092276828,45.51702345047074],[-122.67597653710642,45.51705486613829],[-122.67605622962373,45.51708137311326],[-122.67613923283767,45.517101989652815],[-122.67622474738195,45.51711769749451],[-122.67631194970474,45.517126533156244],[-122.6764,45.517129478376944],[-122.67648805029526,45.517126533156244],[-122.67657525261805,45.51711769749
# geographic postgis
>> DB.get :st.distance( :st.geogfromwkb( :st.makepoint(-122.6764, 45.5165) ), :st.geogfromwkb( :st.makepoint(-122.6864, 45.5265) ) )
=> 1358.549604392
# geomteric postgis (?)
>> DB.get :st.distance( :st.transform(:st.setsrid(:st.makepoint(-122.6764, 45.5165), 4326), 3857), :st.transform(:st.setsrid(:st.makepoint(-122.6864, 45.5265), 4326), 3857) )
=> 1939.9894392485
@kenichi
kenichi / chat.rb
Created May 12, 2014 21:35
websocket "chat" with angelo!
require 'angelo'
require 'tilt'
require 'angelo/tilt/erb'
class Chat < Angelo::Base
include Angelo::Tilt::ERB
@@views = '.'
get '/' do
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require 'ruby-prof'
class Array
def a_slice_exists? ary
raise ArgumentError unless Array === ary
each_index.select {|i| at(i) == ary[0]}.any? {|i| self[i,ary.length] == ary}
end
def b_slice_exists? slice
FROM ubuntu:precise
MAINTAINER Kenichi Nakamura <knakamura@esri.com>
# set locale
RUN locale-gen --no-purge en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
RUN echo 'LANG="en_US.UTF-8"' >> /etc/default/locale