Skip to content

Instantly share code, notes, and snippets.

View chrisvest's full-sized avatar
🍉

Chris Vest chrisvest

🍉
View GitHub Profile
void push( Object value ) {
Node node = new Node( value );
node.next = stack.getAndSet( node );
}
class Handover {
private static class Node {
final Object value;
volatile Node next;
Node( Object value ) {
this.value = value;
}
}
use "files"
use "collections"
actor Main
new create(env: Env) =>
let collector = Collector(env)
let parser = Parser(collector)
let caps = recover val FileCaps.set(FileRead).set(FileStat) end
try
// Using Rust 0.9:
#[feature(struct_variant)];
enum X {
Y { y: ~str }
}
impl X {
@chrisvest
chrisvest / test.js
Last active December 29, 2015 08:49
var tx;
try {
tx = database.beginTx();
var homer = database.createNode();
var marge = database.createNode();
var wedding = inTransaction(tx, function() {
var married = homer.createRelationshipTo(marge, 'MARRIED_WITH');
tx.success();
});
import org.junit.Test;
import org.neo4j.graphdb.*;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.test.TestGraphDatabaseFactory;
import javax.transaction.TransactionManager;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
neo4j-sh (?)$ create (a:Person {x:1}), (b:Person {x:2}), (c:Person {x:3});
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 3
Properties set: 3
Labels added: 3
1079 ms
neo4j-sh (?)$ profile match (p:Person {x:2}) return p;

+--------------+

@chrisvest
chrisvest / gist:7304432
Last active December 27, 2015 09:29
Notes from my talk on Py2Neo.
@chrisvest
chrisvest / SipHash.snip.scala
Created October 15, 2013 09:29
Keyless SipHash snippet
// In this snippet, `buf`, `size` and `index` are provided by the containing class.
// The implementation is adapted from https://131002.net/siphash/siphash24.c
def computeChecksum = {
// SipHash implementation, but without cryptographic key initialisation.
val s = size - 8
val bodyend = 8 * (s / 8)
var v0 = 0x736f6d6570736575L
var v1 = 0x646f72616e646f6dL
@chrisvest
chrisvest / git-pancakes.md
Last active December 16, 2015 12:49
Git Pancakes

A Git repository is like a stack of pancakes. A really weird stack of pancakes.

The top pancake is the most recent revision of your code.

The index is the cake batter you have baking in your pan. It'll become a beatiful pancake when you think it is done, and be added to the top of your stack. The cake batter in your bowl are the changes you have neither committet nor added to the index.

A commit is when a pancake is done baking, and you commit it and place it on the top of your stack.

A branch is when you impale your stack with two steel wires, such that you can start two new stacks on top of your current stack. Actually, though, a branch is just the name you give to "the top pancake" of a stack, so it's like a pointer in that sense, and a tag is a pointer to a specific pancake placed somewhere in the middle of it all.