This script uses RCurl and RJSONIO to download data from Google's API to get the latitude, longitude, location type, and formatted address
library(RCurl)
library(RJSONIO)
library(plyr)
Press minus + shift + s
and return
to chop/fold long lines!
# set up flags for Numpy C extentions compiling | |
export CFLAGS="-arch i386 -arch x86_64" | |
export FFLAGS="-m32 -m64" | |
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64" | |
export CC=gcc-4.2 | |
export CXX="g++ -arch i386 -arch x86_64" | |
pip install numpy | |
# success! |
This GraphGist will begin to explore how stock option data can be modeled as a graph, some simple Cypher queries for calculating payout at expiration for an options contract and a very basic look at finding profitable options trades given a specific forecast. Please note that some of the concepts here have been simplified and are only meant as an educational overview of exploring Neo4j and graph data modeling.
These code snippets have been tested on R 3.1.0 and Mac OS 10.9.3. They presumably do *not* work on R 2.X! | |
## Enter these commands in the Mac OS Terminal | |
# use faster vecLib library | |
cd /Library/Frameworks/R.framework/Resources/lib | |
ln -sf /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/Current/libBLAS.dylib libRblas.dylib | |
# return to default settings | |
cd /Library/Frameworks/R.framework/Resources/lib |
right_of(X, Y) :- X is Y+1. | |
left_of(X, Y) :- right_of(Y, X). | |
next_to(X, Y) :- right_of(X, Y). | |
next_to(X, Y) :- left_of(X, Y). | |
solution(Street, FishOwner) :- | |
Street = [ | |
house(1, Nationality1, Color1, Pet1, Drinks1, Smokes1), | |
house(2, Nationality2, Color2, Pet2, Drinks2, Smokes2), |
import json | |
import urlparse | |
from itertools import chain | |
flatten = chain.from_iterable | |
from nltk import word_tokenize | |
from gensim.corpora import Dictionary | |
from gensim.models.ldamodel import LdaModel | |
from gensim.models.tfidfmodel import TfidfModel |
""" | |
Example code for connecting to Stardog (http://stardog.com/) with | |
Python's RDFLib (http://github.com/rdflib). | |
See longer description: http://lawlesst.github.io/notebook/rdflib-stardog.html | |
""" | |
# Returns a reactive that debounces the given expression by the given time in | |
# milliseconds. | |
# | |
# This is not a true debounce in that it will not prevent \code{expr} from being | |
# called many times (in fact it may be called more times than usual), but | |
# rather, the reactive invalidation signal that is produced by expr is debounced | |
# instead. This means that this function should be used when \code{expr} is | |
# cheap but the things it will trigger (outputs and reactives that use | |
# \code{expr}) are expensive. | |
debounce <- function(expr, millis, env = parent.frame(), quoted = FALSE, |