Skip to content

Instantly share code, notes, and snippets.

@kouphax
kouphax / README.md
Last active August 29, 2015 13:57
Ungisting Files and Tidying up Metadata

This gist covers

  • some of the snippets of code that was used to remove the gists from generated pages.
  • The tidying up of metadata and project strcuture
@mbroecheler
mbroecheler / gist:1450d1f7fa5d3dc75aab
Last active August 29, 2015 14:07
Making sure cache is faster than embedded BDB
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> mgmt = g.getManagementSystem();
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@27c04377
gremlin> id = mgmt.makePropertyKey("uid").dataType(Long.class).make()
==>uid
gremlin> mgmt.buildIndex('byUID',Vertex.class).addKey(id).buildCompositeIndex()
==>com.thinkaurelius.titan.graphdb.database.management.TitanGraphIndexWrapper@14f3c6fc
gremlin> mgmt.commit()
gremlin> for (int i=0;i<200;i++) { v = g.addVertex([uid:(int)Math.floor(i/2)])}
import java.util.Enumeration;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DEREncodable;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DERTaggedObject;
;;(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"]
@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()
@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) {
@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:
@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"]
@michalmarczyk
michalmarczyk / new-trace-ns.clj
Created February 17, 2012 00:46
Mass tracing utilities for Clojure
;;; See the inspirational SO question: http://stackoverflow.com/questions/3346382
;;; My old Gist with my first take on this: https://gist.github.com/492764
;;; Don Jackson's Gist based on the above: https://gist.github.com/1846993
;;; Licence: EPLv1, the same as Clojure
(in-ns 'clojure.tools.trace)
(defn trace-var
"If the specified Var holds an IFn and is not marked as a macro, its
@subelsky
subelsky / imagemagick_snippets.sh
Created August 20, 2012 14:45
Useful ImageMagick snippets
# Flatten a transparent image with a white background:
convert -flatten img1.png img1-white.png
# Make an image transparent
convert -transparent '#FFFFFF' nontransparent.gif transparent.png
# convert an image into tiles
convert -size 3200x3200 tile:single_tile.png final.png
# making a montage from a collection of images