Skip to content

Instantly share code, notes, and snippets.

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 / 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 / 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
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)
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 / LICENSE
Last active Apr 10, 2018
This license applies to all public gists
MIT License
Copyright (c) 2018 Anthony Najjar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: