Skip to content

Instantly share code, notes, and snippets.

View raskchanky's full-sized avatar

Josh Black raskchanky

View GitHub Profile
use std::collections::HashMap;
use std::io;
use std::num::ParseFloatError;
use std::rc::Rc;
/*
Types
*/
#[derive(Clone)]
### Keybase proof
I hereby claim:
* I am raskchanky on github.
* I am raskchanky (https://keybase.io/raskchanky) on keybase.
* I have a public key ASDzqYUXe_xOTO2umVIxRP6wzC5iL7TikgIcjowGiCibLQo
To claim this, I am signing this object:
#!/bin/bash
# The purpose of this script is to download the latest stable version of every
# package in the core-plans repo, tar them up, and upload to S3. It also supports
# downloading the archive from S3, extracting it, and uploading to a new depot.
#
# There are some environment variables you can set to control the behavior of this
# script:
#
# HAB_ON_PREM_BOOTSTRAP_BUCKET_NAME: This controls the name of the S3 bucket where
@raskchanky
raskchanky / timeout.js
Created January 20, 2016 16:28
node.js HTTP server for simulating timeouts
var http = require('http');
var timeout = 100000;
http.createServer(function (req, res) {
setTimeout((function() {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Success");
}), timeout);
}).listen(8080);
@raskchanky
raskchanky / gist:9645530
Created March 19, 2014 16:30
Shell script for pre-defined tmux split arrangements
#!/bin/bash
set -e
name=`date | md5`
tmux new-session -d -s $name
tmux split-window -h -p 40
if [ "$1" = "2" ]
then
@raskchanky
raskchanky / gist:9601815
Last active August 29, 2015 13:57
On the difference between functions and objects, FP and OOP, tiny things and big things
"what are functions if not tiny, mostly stateless objects? (Honest question)"
Classic OOP says you should break things down as small as possible. It's better to have 10 classes, each
doing 1 specific thing, then it is to have 1 class doing 10 different things. Methods should be very small.
I've seen guidelines on how many lines your methods should be.
What I've noticed about OO projects that involve lots of tiny classes, is that as the number of classes
increases, it becomes increasingly difficult to keep track of how the system as a whole works, because
there are so many individual components of it. Figuring out how the system performs some task X is a
spelunking expedition, as you need to dig through sometimes dozens of classes before finally finding the
@raskchanky
raskchanky / Version 1
Created March 15, 2014 03:29
Different Clojure styles
(defn hamming-distance [a b]
(->>
(map #(= %1 %2) a b)
(filter false?)
count))
@raskchanky
raskchanky / gist:8445845
Created January 15, 2014 22:19
Make a screensaver your desktop background
#!/bin/sh
if [ "$1" == "" ]; then
echo "usage: ssbg [start|stop]"
exit
fi
if [ "$1" == "start" ]; then
echo STARTING
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &
@raskchanky
raskchanky / gist:6241981
Last active December 21, 2015 03:28
Section 3.4 from The Tao of Programming, by Geoffrey James
A manager went to the master programmer and showed him the requirements document for a new application.
The manager asked the master: "How long will it take to design this system if I assign five programmers
to it?"
"It will take one year," said the master promptly.
"But we need this system immediately or even sooner! How long will it take if I assign ten programmers
to it?"
The master programmer frowned. "In that case, it will take two years."
# Copyright 2012 Erlware, LLC. All Rights Reserved.
#
# This file is provided to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,