Skip to content

Instantly share code, notes, and snippets.

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
@vallettea
vallettea / sdk.py
Created June 26, 2014 14:07
script to clean SDK log
locations = filter(lambda line: line.split("|")[-1] == "loc-bg\r\n", open("log.csv"))
def extract(line):
items = line.split(",")
timestamp = items[0].split("|")[0]
lon = items[1]
lat = items[2]
return ";".join([timestamp, lon, lat])
locations = map(extract, locations)
@vallettea
vallettea / closest.py
Created June 26, 2014 14:18
closest neighbour in python postgis
import psycopg2
import pandas
from collections import defaultdict
data = pandas.read_csv("learning_dataset.csv", sep=";", names="gid,borough,block,lot,zipcode,firecomp,policeprct,ltdheight,bldgclass,landuse,easements,ownertype,lotarea,bldgarea,comarea,resarea,officearea,retailarea,garagearea,strgearea,factryarea,otherarea,areasource,numbldgs,numfloors,unitsres,unitstotal,lotfront,lotdepth,bldgfront,bldgdepth,ext,proxcode,irrlotcode,lottype,bsmtcode,assessland,assesstot,exemptland,exempttot,yearbuilt,builtcode,yearalter1,yearalter2,histdist,landmark,builtfar,residfar,commfar,facilfar".split(","))
# Connect to an existing database
conn = psycopg2.connect("dbname=tahar user=vallette")
# Open a cursor to perform database operations
cur = conn.cursor()
# useful
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas
# check if camera is enable and connected
vcgencmd get_camera
# if not use sudo raspi-config
# install picamera modules
sudo apt-get update
@vallettea
vallettea / server.py
Created July 23, 2014 07:48
a python simple server with headers
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
PORT = 8003
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()