Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
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
# 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 |
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' | |
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.
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 '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 |
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
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 |
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 |