Skip to content

Instantly share code, notes, and snippets.

@espeed
espeed / neo4j-fulltext-gremlin.groovy
Created January 4, 2012 04:41
Using Neo4j Fulltext Index with Gremlin
// Example using the Neo4j Fulltext Index with Gremlin-Groovy
// by James Thornton, http://jamesthornton.com
import com.tinkerpop.blueprints.pgm.impls.neo4j.util.Neo4jVertexSequence;
import com.tinkerpop.blueprints.pgm.impls.neo4j.util.Neo4jEdgeSequence;
Graph g = new Neo4jGraph('/tmp/neo4jmovies');
indexManager = g.getRawGraph().index();
indexConfig = ["provider":"lucene", "type":"fulltext"]
@matteobertozzi
matteobertozzi / encoding.py
Created December 26, 2011 19:09
Zig-Zag/VInt Encoding
#!/usr/bin/env python
def encodeZigZag32(n): return (n << 1) ^ (n >> 31)
def encodeZigZag64(n): return (n << 1) ^ (n >> 63)
def decodeZigZag32(n): return (n >> 1) ^ -(n & 1)
def decodeZigZag64(n): return (n >> 1) ^ -(n & 1)
def encodeVInt(n):
data = ''
while n >= 0x80:
@sr
sr / Gemfile
Created December 19, 2011 13:55
Janky on Heroku
source "http://rubygems.org"
gem "janky", "~>0.9"
gem "pg"
gem "thin"
@pdobrev
pdobrev / gist:1391654
Created November 24, 2011 15:51
Testing Neo4j shortestPath vs allSimplePaths
import java.util.Collection;
import org.neo4j.graphalgo.PathFinder;
import org.neo4j.graphalgo.impl.path.AllSimplePaths;
import org.neo4j.graphalgo.impl.path.ShortestPath;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Expander;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
@srw
srw / hnsearch.py
Created November 12, 2011 12:19
Avoiding HNSearch API limits
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Done under Visual Studio 2010 using the excelent Python Tools for Visual Studio
# http://pytools.codeplex.com/
#
# Article on ideas vs execution at: http://blog.databigbang.com/ideas-and-execution-magic-chart/
import urllib2
import json
@davidrupp
davidrupp / jetty.clj
Created October 29, 2011 03:43 — forked from minimal/jetty.clj
Websockets with clojure + jetty
;; Copyright (c) James Reeves. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns compojure.server.jetty
"Clojure interface to start an embedded Jetty server."
@masayuki038
masayuki038 / gist:1209689
Created September 11, 2011 15:09
Serializing HashMap By MessagePack for Java.
@Test
public void testSerliazingMapByMessagePack(){
Map<String, Object> map = new HashMap<String, Object>();
map.put("int", 1);
map.put("long", 1L);
map.put("date", new Date());
map.put("string", "test");
byte[] buffer = MessagePack.pack(map);
for (byte b : buffer) {
@mhermans
mhermans / neo4R_example.R
Created August 29, 2011 09:50
Neo4j-Cypher-R
# Requirements
#sudo apt-get install libcurl4-gnutls-dev # for RCurl on linux
#install.packages('RCurl')
#install.packages('RJSONIO')
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
@michiakig
michiakig / ants.clj
Created July 19, 2011 22:37
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
;;(require 'copterj.git-version) ;; Pick up DRY'd version numbers
(require 'clojure.contrib.io) ;; Needed to locate newrelic
(let [java-agent (str "-javaagent:" (clojure.contrib.io/pwd) "/lib/newrelic.jar")]
(defproject apij ~(copterj.git-version/git-describe)
:description "Hotelicopter's API"
:dependencies
[[com.hotelicopter/copterj "1.0.0-SNAPSHOT"]