Skip to content

Instantly share code, notes, and snippets.

View paigeruten's full-sized avatar

Paige Ruten paigeruten

View GitHub Profile
@paigeruten
paigeruten / phi.php
Created August 30, 2009 08:34
look up php function synopses from the command line
#!/usr/bin/php
<?php
// v v
// \\O//
$RED = 31;
$GREEN = 32;
$BLUE = 34;
$MAGENTA = 35;
$CYAN = 36;
One morning I looked out my bedroom window to see an enormous moving van parked
in front. A crew of twenty movers waited on the street for the one guy to open
the latch on the back. Once done, they immediately got to work. Desks, beds,
sofas, and chairs made their way up my sidewalk and into the front door, one by
one, one tireless mover at each end.
And on the string of deluxe handcrafted furniture flowed. It just never ended. I
lost count after 24 beds.
It was at this point that I grew suspicious. Where was mom? Why did she order
# Substitution with Hash (Ruby 1.9, not documented)
":(".gsub(/./, ':' => ';', '(' => ')') #=> ";)"
# The “assign first” operator
caterpillar_part ,= ["head", "body"]
caterpillar_part #=> "head"
@paigeruten
paigeruten / java-repl.rb
Created January 30, 2011 03:42
A very simple and rough and slow REPL for Java
# A very simple and rough and slow REPL for Java, but it's better than making a
# new Java program every time you want to test something.
class JavaREPL
def initialize(filename = "JavaREPL")
@filename = filename
reset
end
def repl
loop { java_print java_eval java_read }
@paigeruten
paigeruten / why-daemon.rb
Created January 6, 2013 20:46
take a snapshot of whytheluckystiff.net whenever it updates
begin
require "terminal-notifier"
rescue LoadError
end
require "open-uri"
WHO = "whytheluckystiff.net"
WHAT = "http://"
WHERE = "/"
WHY = WHAT + WHO + WHERE
# whyspooler.rb
# mostly a translation of _why's OCaml script to Ruby
#
# polls whytheluckystiff.net for new printouts, converts to pdf, saves them into ./SPOOL, and prints them
#
# usage: `ruby whyspooler.rb http://whytheluckystiff.net`
#
# OS X install instructions:
# 1. `gem install open4`
# 2. download MacPCLtoPDF.zip from http://www.columbia.edu/~em36/pcltopdf.html
@paigeruten
paigeruten / rit.rb
Last active December 19, 2015 18:18
play an audio file at a particular speed
#!/usr/bin/env ruby
# rit.rb - play an audio file at a particular speed
#
# usage: ruby rit.rb <speed> <path_to_audio_file>
#
# <speed> is a float which acts as a multiplier. 1.0 is normal speed, 2.0
# is double speed, 0.5 is half speed, and so on.
#
# put 0 for <speed> for a fun easter egg.
@paigeruten
paigeruten / alarm.rb
Created October 30, 2013 05:09
a simple command line alarm clock, I use it to play some music when the alarm goes off.
#!/usr/bin/ruby
#
# Usage: ruby alarm.rb <time>
#
# <time> is either a number of seconds (e.g. "50"), minutes and seconds
# (e.g. "5:30"), or hours minutes and seconds (e.g. "7:30:00"). After the
# specified amount of time has passed, ring_alarm will be called and the
# program will exit.
#
@paigeruten
paigeruten / avconcat.rb
Created April 18, 2014 14:22
wrapper for a messy avconv command to concatenate audio files.
#!/usr/bin/env ruby
#
# Concatenates audio files together using avconv.
#
# Usage: avconcat -o <output> <inputs...>
#
output = nil
output_arg = false
#include <stdio.h>
#include <openssl/evp.h>
int main(void) {
unsigned char plaintext[] = "AAAAAAAAAAAAAAAA";
unsigned char key[] = "BBBBBBBBBBBBBBBB";
unsigned char iv[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
unsigned char res[32];
// Encrypting