Skip to content

Instantly share code, notes, and snippets.

View mstahl's full-sized avatar
🤪

max thom stahl mstahl

🤪
View GitHub Profile
@mstahl
mstahl / reinstall_all_the_things.sh
Created October 23, 2015 17:08
Use this snippet to uninstall and reinstall all the things you've installed via homebrew
brew list > /tmp/brew_list
for package in $(cat /tmp/brew_list); do
brew uninstall --force $package
brew install $package
done
rm -f /tmp/brew_list
@mstahl
mstahl / README.md
Last active December 21, 2015 16:58

Fallout 3 terminal hacker

Enter all the words as arguments on the command line,

user$ fallout_3 clustered mentioned stationed convinces eliminate convinced \
      convicted criminals challenge chemicals considers carriages cardinals \
      rearguards hurriedly continued consisted messianic gladiator chemistry
  0:  clustered
  1:  mentioned

2: stationed

@mstahl
mstahl / time_fixnum_monkeypatch.rb
Created July 3, 2013 17:24
Quick ActiveSupport-style monkey patch for fixnums when you're describing periods of time (in seconds)
class Fixnum
def seconds
self
end
alias :second :seconds
def minutes
self * 60.seconds
end
alias :minute :minutes
@mstahl
mstahl / LucasLehmer.hs
Last active December 16, 2015 20:58 — forked from anonymous/README.md
{-
- LucasLehmer
-
- An implementation of the Lucas-Lehmer primality test for prime numbers of
- the form p = 2^k - 1 (Mersenne primes).
-
- (c) 2013 Max Thom Stahl. Released under the MIT public license.
-}
module LucasLehmer where
@mstahl
mstahl / find_capitals.rb
Last active December 16, 2015 00:29
For analyzing Voynich transcriptions and also maybe for other cryptanalytical purposes, it'd be nice to have a script that can intelligently guess which letters of an unknown alphabet are capital letters so that corpora can be normalized.
#!/usr/bin/env ruby -wKU
@words = File.open("moby_dick_long.txt", "r").read.strip.split(/\W+/).compact.reject{|w| w.length <= 1}
@alphabet = @words.map{|w| w.split(//)}.flatten.uniq
letters_at_beginning_of_word = @words.map{|w| w[0]}
letters_in_tail_of_word = @words.map{|w| w[1..-1].split(//)}.flatten
# p letters_at_beginning_of_word
# p letters_in_tail_of_word
@mstahl
mstahl / Timelapse.ino
Last active December 14, 2015 12:48
Camera intervalometer Arduino code
#define FOCUS 11
#define SHUTTER 13
/*
* Pins 11 and 13 go to two reed relays, which connect the ring pin of a
* headphone jack to the other two pins. These are connected to the camera via
* a 2.5mm phone patch cord. Set your camera ISO and aperture to expose well
* in the darkest conditions you anticipate occurring during the timelapse. The
* camera should be set to auto-expose on aperture-priority mode, so that the
* focus and depth of field remain constant from frame to frame. Delay is
module Main where
import Control.Parallel
import Control.Parallel.Strategies
import Data.Maybe
import MillerRabin
-- import ONeillPrimes
@mstahl
mstahl / time_steps.rb
Created October 7, 2011 18:28
Simple Cucumber test steps for using Delorean for time travel
When /^(?:I )?travel (?:forward|backward) in time to (\d+) (years?|months?|weeks?|days?) (from now|ago)$/ do |amount, unit, direction|
Delorean.time_travel_to (amount.to_i).send(unit.to_sym).send(direction.gsub(/\s/, "_").to_sym)
end
Then /^(?:I )?travel in time to the present$/ do
Delorean.back_to_the_present
end
@mstahl
mstahl / alphabetagaga.rb
Created August 31, 2011 02:58
Alpha Beta Gaga - An alphabetization reverse-engineerer whatchamajiggiddypoo.
#!/usr/bin/env ruby -wKU
#
# alphabetagaga.rb
#
# Takes a text file as input, with terms on lines sorted by some mysterious
# alphabet. Returns a string representing the ordering of the alphabet by
# which the file was sorted.
#
# max thom stahl <max@villainousindustri.es>
# github.com/mstahl
@mstahl
mstahl / befunginatr.rb
Created February 10, 2011 04:54
A Befunge interpreter written in Ruby
#!/usr/bin/ruby
require 'pp'
@core = {}
@hello_world = <<__END_HELLO_WORLD__
> v
v ,,,,,"Hello"<
>48*, v