Skip to content

Instantly share code, notes, and snippets.

View futureperfect's full-sized avatar

Erik Hollembeak futureperfect

View GitHub Profile
@futureperfect
futureperfect / README.md
Last active August 29, 2015 14:23
Ruby Implementation of Heap's algorithm for generating all permutations of a collection

Permutations

This is an implementation of Heap's algorithm for generating the permutations of a collection.

  1. General Background and Overview
class RapperNameGenerator
def initialize
@first = ["Young", "Lil'", "Notorious", "MC"]
@last = ["Jeezy", "Chris", "Escher", "Wayne", "Dicky"]
srand
end
def generate
first_index = rand(@first.length)
@futureperfect
futureperfect / guessing-game.rkt
Created July 11, 2016 20:43
Ch2 Realm of Racket
#lang racket
(define lower-bound 1)
(define upper-bound 100)
(define (start n m)
(set! lower-bound (min n m))
(set! upper-bound (max n m))
(guess))
@futureperfect
futureperfect / Gemfile
Last active July 18, 2017 06:19
Reverse a string, but preserve position of any "special" character
source "https://rubygems.org"
gem "minitest"
@futureperfect
futureperfect / Gemfile
Created August 17, 2017 00:48
Trapping Rain Water
source "https://rubygems.org"
gem "minitest"
@futureperfect
futureperfect / stripes.asm
Created September 14, 2017 02:45
Atari 2600 - Draw colored stripes to screen
; stripes.asm
;
; Example Atari 2600 program - paints
; colored stripes to the screen
;
; dasm stripes.asm -f3 -ostripes.bin
;
;
processor 6502
// https://tour.golang.org/methods/22
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
func (reader MyReader) Read(b []byte) (int, error) {
count := 0
for i, _ := range b {
@futureperfect
futureperfect / gist:066c6c320c9d0930fe648990a86ba4f4
Created January 9, 2018 03:41
A couple handy idioms for exploring ruby classes/objects and the methods they implement
# What methods does a class implement?
> Time.methods
=> [:!, :!=, :!~, :<, :<=, :<=>, :==, :===, :=~, :>, :>=, :__id__, :__send__, :allocate, :ancestors, :at, :autoload, :autoload?, :class, :class_eval, :class_exec, :class_variable_defined?, :class_variable_get, :class_variable_set, :class_variables, :clone, :const_defined?, :const_get, :const_missing, :const_set, :constants, :define_singleton_method, :deprecate_constant, :display, :dup, :enum_for, :eql?, :equal?, :extend, :freeze, :frozen?, :gm, :hash, :include, :include?, :included_modules, :inspect, :instance_eval, :instance_exec, :instance_method, :instance_methods, :instance_of?, :instance_variable_defined?, :instance_variable_get, :instance_variable_set, :instance_variables, :is_a?, :itself, :kind_of?, :local, :method, :method_defined?, :methods, :mktime, :module_eval, :module_exec, :name, :new, :nil?, :now, :object_id, :prepend, :private_class_method, :private_constant, :private_instance_methods, :private_method_defined?, :private_methods, :protected_