Skip to content

Instantly share code, notes, and snippets.

anthonynsimon / btree.go
Last active Apr 7, 2016
Simple Binary Tree in Go
View btree.go
package btree
import (
type BinaryTree struct {
Root *Node
NumberOfIterations int
anthonynsimon / binary_tree.rb
Last active Apr 7, 2016
Simple Binary Tree in Ruby
View binary_tree.rb
class Node
attr_accessor :value, :left, :right
def initialize(value=nil)
@value = value
class BinaryTree
attr_accessor :root, :num_loops
anthonynsimon / linkedList.c
Last active Apr 12, 2016
Quick and dirty linked list in C
View linkedList.c
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int value;
struct node* next;
} node_t;
typedef struct list {
node_t* head;
View pubsub.go
package main
import (
anthonynsimon /
Created Mar 8, 2017
Bash script preprend timestamp to filename
for f in *; do mv -- "$f" "$(stat -f "%Sm_%N" -t "%Y%m%d" "$f")"; done
View Dockerfile
FROM openjdk:8
RUN mkdir -p /usr/local/spark && \
cd /usr/local/spark && \
curl -O && \
tar -vxf spark-2.1.0-bin-hadoop2.7.tgz
ENV SPARK_HOME /usr/local/spark/spark-2.1.0-bin-hadoop2.7
COPY ./ /etc/
anthonynsimon / gen_sbt_project
Last active Jun 23, 2017
Generate sbt project structure
View gen_sbt_project
# Usage: script [project name]
mkdir -p $PROJECT_NAME
touch build.sbt
View EventualPromise.scala
import java.util.concurrent.atomic.AtomicReference
import scala.collection.mutable
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success, Try}
trait Eventual[A] {
def get: Try[A]
def onComplete(f: Try[A] => Unit): Unit
anthonynsimon / SortedMergeJoin.scala
Created Mar 6, 2018
Sorted Merge Join in both FP and OOP
View SortedMergeJoin.scala
import scala.collection.mutable
object SortedRelation {
def apply[A, B](seq: Seq[A], key: (A) => B)(implicit ordering: Ordering[B]): SortedRelation[A, B] = new SortedRelation(seq, key)
class SortedRelation[A, B](val seq: Seq[A], val key: (A) => B)(implicit ordering: Ordering[B]) {
private val sorted = seq.sortBy(key)
anthonynsimon /
Created Apr 6, 2018
Signal pool thread pool example
import threading
from threading import Thread, Lock
import sys
import time
class Q:
def __init__(self):
self._items = []