Skip to content

Instantly share code, notes, and snippets.

View mistidoi's full-sized avatar

Brandon Hamilton mistidoi

  • Relevant Healthcare, Inc.
View GitHub Profile
@mistidoi
mistidoi / implementing_curry_with_y_combinator.rb
Last active December 27, 2015 06:59
Taking off from Jeff's curry exercise, Brandon tries to implement curry while using a Y combinator for the recursion.
# Jeff's setup:
def pc(arg, offset = 0)
file, line = caller.first.split(":")
actual_line = line.to_i - 1 + offset
code = File.read(file).split("\n")[actual_line].strip.sub("pc ", "")
result = arg.is_a?(String) ? arg : arg.inspect
puts "Line ##{actual_line}:"
puts " #{[code, result].join(" # => ")}"
puts
@mistidoi
mistidoi / rvm_empty_path_error_cmds_and_debug_output
Created November 2, 2014 19:06
[rvm] Empty path passed to certificates update - (Ruby 2.1.4 - OSX 10.9.4) #3116
mistidoi-macbook:~ mistidoi$ rvm get head
Downloading https://get.rvm.io
Downloading https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer.asc
Verifying /Users/mistidoi/.rvm/archives/rvm-installer.asc
gpg: Signature made Thu Oct 30 15:27:39 2014 EDT using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3
Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17
@mistidoi
mistidoi / make.log
Created November 2, 2014 22:35
[rvm] make.log
[2014-11-02 16:29:46] __rvm_make
__rvm_make ()
{
\make "$@" || return $?
}
current path: /Users/brandonhamilton/.rvm/src/ruby-2.1.4
GEM_HOME=/Users/brandonhamilton/.rvm/gems/ruby-2.1.4
PATH=/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Users/brandonhamilton/.rvm/gems/ruby-2.1.4/bin:/Users/brandonhamilton/.rvm/gems/ruby-2.1.4@global/bin:/Users/brandonhamilton/.rvm/rubies/ruby-2.1.4/bin:/Users/brandonhamilton/.rvm/bin:/opt/local/include/gtk-2.0/gtk:/opt/local/bin:/opt/local/sbin:/Library/PostgreSQL/9.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/MacGPG2/bin
GEM_PATH=/Users/brandonhamilton/.rvm/gems/ruby-2.1.4:/Users/brandonhamilton/.rvm/gems/ruby-2.1.4@global
command(3): __rvm_make -j 1
var memoize;
memoize = function(func) {
var cache;
cache || (cache = {});
return function() {
var key;
key = JSON.stringify(arguments);
if (cache[key]) {
return cache[key];
@mistidoi
mistidoi / memoize.js
Created January 26, 2016 05:10
One of my favorite little functions
var memoize;
memoize = function(func) {
var cache;
cache || (cache = {});
return function() {
var key;
key = JSON.stringify(arguments);
if (cache[key]) {
return cache[key];
@mistidoi
mistidoi / arguments.js
Created January 26, 2016 05:26
Demonstrating arguments
showArguments = function () {
console.log(arguments);
}
showArguments("hey", "I","thought", "this", "function", "didn't", "take", "any", "arguments");
@mistidoi
mistidoi / using memoize.js
Last active January 26, 2016 05:43
putting it to use!
var memoize;
memoize = function(func) {
var cache;
cache || (cache = {});
return function() {
var key;
key = JSON.stringify(arguments);
if (cache[key]) {
return cache[key];
File.open("input.txt").readlines.each do |line|
moves_from_file = line.chomp.split("")
moves1 = []
moves2 = []
moves_from_file.each_with_index do |element, index|
if index % 2 == 1
moves1 << element
@mistidoi
mistidoi / day-3.js
Last active January 30, 2016 17:16
Advent of Code - Day 3 - Part 2
"use strict";
let _ = require('lodash');
let fs = require('fs');
fs.readFile('input.txt', 'utf8', function (err, input) {
let moves1 = [];
let moves2 = [];
let starting_coords = [0, 0];
@mistidoi
mistidoi / input.txt
Created January 30, 2016 04:10
Advent of Code - Day 3 with Immutable.js
^^<<v<<v><v^^<><>^^<v<v^>>^^^><^>v^>v><><><<vv^^<^>^^<v^>v>v^v>>>^<>v<^<v^><^>>>>><<v>>^>>^>v^>><<^>v>v<>^v^v^vvv><>^^>v><v<><>^><^^<vv^v<v>^v>>^v^>v><>v^<vv>^><<v^>vv^<<>v>>><<<>>^<vv<^<>^^vv>>>^><<<<vv^v^>>><><^>v<>^>v<v^v<^vv><^v^><<<<>^<>v>^v>v<v<v<<>v<^<<<v>>>>>^^v>vv^^<>^<>^^^^<^^^v<v^^>v<^^v^^>v>^v^^^^>><<v<>v<>^v^<v<>><>^^><<^^<^^>vv<>v^<^v<vv<<<>^>^^>^<>v^^vv<>>v><<<>vvv<>v<>><^<^v<>^vv>^^v<v<v><^<>>vv<^>>^>>vv^v<vv^vv<^<<>>^v^<>^>>>>vv>^^>v>vv>v><^vv^<<v>^<<^^<v<v>vv<v^^<>^^v>^>>v><^<<vv<<v^vv^^^v>>v<<v^><vv^><vv<^vv<<vv^v<<^v<^^v>><<v^>>^^<>v>><<v<>>^^<v>>^^>>vvv^><<<<<^<^vv<^<><v<<>^^^<<<^>^^^<v<<vv>vv<>^<>v<^v>^<<<v<v<v>>^v<>>v<<^<<v<<>^<<<><><>^>>>>^>v^v<<v<v<<>>vv<^vvv^^^^<vv>vv>^v^^v^<v^v><^vv<^vv>v<^>vv<>>^>^><vv<><^>v>^v>vvv<>^>^v<><>vv>><^v^<><><v>>v^v^><^<^>vv>v<^>vvv>v<<<<<^<v<<vv<^^^<<>>^v<vv<^<>v>^<v<>><><>^<<v>v^>^<vv>><><>>^>^>><^<v>^^>^^>^^v^^<^v^^>v^^>>><<><v<v<<v^vv<><><>^<v>^<<^^v^>v>><>^^^><^vvv<^^^^^v><<><v<^^v><><>>^>vv<vvvv<<>>><v<^^^^v<<^><v>^vv<v^^v^vv<^^>^^<v>><<v^>v<^^>^<^