Skip to content

Instantly share code, notes, and snippets.

View cndreisbach's full-sized avatar
🍕
eatin' pizza

Clinton N. Dreisbach cndreisbach

🍕
eatin' pizza
View GitHub Profile
@cndreisbach
cndreisbach / compareNumeric.js
Last active July 11, 2019 17:09
JavaScript examples
function compareNumeric(a, b) {
if (a > b) return 1;
if (a == b) return 0;
if (a < b) return -1;
}
let arr = [ 2, 1, 15 ];
arr.sort(compareNumeric);

Setting up your Mac for development

Getting your tools right is an important step in becoming a developer. This guide will walk you through every step you need to take.

There are multiple options that can be used when setting up your computer. This guide is opinionated about those options. Our guidelines are:

  • When possible, use what you already have instead of installing something new.
  • Use the most common development tool unless it is deficient.
  • Less setup is better.
Verifying my Blockstack ID is secured with the address 1Lf1AViZaQ2qPHVjHtbGhseFW1AJW7iPnN https://explorer.blockstack.org/address/1Lf1AViZaQ2qPHVjHtbGhseFW1AJW7iPnN
#!/usr/bin/env python3
"""
Game of Sticks is based on an assignment from Stanford's Nifty Assignments.
http://nifty.stanford.edu/2014/laaksonen-vihavainen-game-of-sticks/handout.html
"""
import random
from collections import Counter
from math import gcd
@cndreisbach
cndreisbach / maze.rkt
Last active December 19, 2015 14:29
Our Maze Jam from Lambda Jam 2013
#lang racket
(require json)
(define (get-maze-cell maze x y)
(list-ref
(list-ref maze y)
x))
(define (neighbors x y)
(list (list x (sub1 y))
(ns monger.key-compression)
(def select (comp first filter))
(defn- trie-add
[trie words]
(reduce
(fn [trie word]
(assoc-in trie (concat word [::val]) word))
trie
#lang racket
;; Instructions on how to play Hunt the Wumpus.
(define *instructions* "
Welcome to Hunt the Wumpus!
The wumpus lives in a cave of 20 rooms. Each room has three tunnels
leading to other rooms. (Look at a dodecahedron to see how this works.
If you don't know what a dodecahedron is, ask someone or get thee to
a Wikipedia.
@cndreisbach
cndreisbach / nv.pl
Created August 8, 2011 02:11
Console-based Notational Velocity
#!/usr/bin/perl -w
use strict;
use Curses::UI;
use Curses::UI::Common;
use File::Basename;
use String::Approx 'amatch';
my $notedir = "~/Dropbox/Notes";
$notedir =~ s{ ^ ~ ( [^/]* ) } { $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7] ) }ex;
public class Floor {
enum State { NO_ONE_WAITING, PASSENGERS_WAITING, LOADING }
private int passengersWaiting = 0;
private State state = State.NO_ONE_WAITING;
synchronized public void waitForElevator(String msg) {
if (state == State.LOADING) {
try {
wait();
class Car:
acceleration = 2
braking = 3
desired_speed = 30 # mps = 108 km/hr
minimum_spacing = 15
slowing_prob = 0.2
def __init__(self, speed=0, location=0):
self.speed = speed
self.location = location