Skip to content

Instantly share code, notes, and snippets.

-- create an index for your tables, this will create a rtree
CREATE INDEX idx_ny_fires ON NYC_FireAccidents USING GIST(geom);
CREATE INDEX idx_ny_building ON mappluto_13v2 USING GIST(wkb_geometry);
-- check if one single association is fast
EXPLAIN ANALYZE SELECT f.unique_key, b.ogc_fid
FROM NYC_fireaccidents f, mappluto_13v2 b
WHERE ST_Distance_Sphere( ST_Transform(f.geom,4269), ST_Transform(b.wkb_geometry,4269)) < 50
class GeomJsonSerializer extends JsonSerializer[T <: Geometry] {
def serialize[T <: Geometry](geom: T, json: JsonGenerator, provider: SerializerProvider) {
json.writeString(jtsToGeoJson(geom))
}
}
[error] /Users/vallette/projects/safesignal/util-core/src/main/scala/net/snips/util/StringUtils.scala:63: ']' expected but '<:' found.
[error] class GeomJsonSerializer extends JsonSerializer[T <: Geometry] {
[error] ^
# Install VirtualBox https://www.virtualbox.org/wiki/Downloads
# create your home bin dir & add it to your PATH
mkdir -p ~/bin
curl -o ~/bin/boot2docker -k "https://raw.github.com/boot2docker/boot2docker/master/boot2docker"
export PATH=$HOME/bin:$PATH
mkdir -p ~/.boot2docker
# create the vm in ~/VirtualBox VMs and the disk in ~/.boot2docker
boot2docker init
# load the VM in the background, call `boot2docker down` when done, password is "tcuser"
boot2docker up
# connect to the db
psql -d idf -U postgres
# get first few nodes having tags
select * from nodes where array_length(akeys(tags),1) >0 limit 5;
# get nodes having tag key "highway"
select * from nodes where tags ? 'highway' limit 10;
conf = new BaseConfiguration()
conf.setProperty('storage.backend', 'persistit')
conf.setProperty('storage.directory', '/tmp/titangraph')
g=TitanFactory.open(conf)
g.V.count()
wget http://s3.thinkaurelius.com/downloads/titan/titan-all-0.4.2.zip
unzip titan-all-0.4.2.zip
cd titan-all-0.4.2
bin/gremlin.sh
conf = new BaseConfiguration()
conf.setProperty('storage.backend', 'persistit')
conf.setProperty('storage.directory', '/tmp/titangraph')
g=TitanFactory.open(conf)
## wifi config
sudo iwconfig wlan0 essid freebox_vallem key s:xxxx
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
sudo apt-get install python-pip
sudo apt-get install screen
pip install rpi.gpio ipython
@vallettea
vallettea / spray-json
Last active August 29, 2015 14:02
json protocol for spray
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import spray.json._
import spray.json._
scala> import DefaultJsonProtocol._
@vallettea
vallettea / ssh_conf
Created June 12, 2014 17:12
to set remote ssh access without password
# on my laptop:
scp ~/.ssh/id_rsa.pub vallette@server_ip
# in ~/.ssh/config
Host linode
User vallette
Hostname server_ip
ServerAliveCountMax 3
ServerAliveInterval 10
@vallettea
vallettea / ubuntu_basic
Created June 12, 2014 17:13
basic setup of ubuntu
apt-get update
# basics
apt-get -y install git git-flow curl unzip zsh
# zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.zshrc ~/.zshrc.orig
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
chsh -s /bin/zsh