Skip to content

Instantly share code, notes, and snippets.

@halferty
halferty / megaten_fusion_calculator.html
Created January 25, 2012 17:42
Simple javascript frontend for an interactive calculator in a blog post
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SMT: Imagine Demon Fusion Calculator</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var numbered_list_of_demons=[{"trifusion":"false","level":"46","family":"0","name":"Hel","family_name":"The Reaper","cutoff":"91"},{"trifusion":"false","level":"62","family":"0","name":"Chernobog","family_name":"The Reaper","cutoff":"200"},{"trifusion":"false","level":"85","family":"0","name":"Mot","family_name":"The Reaper","cutoff":"169"},{"trifusion":"true","level":"93","family":"0","name":"Beiji Weng","family_name":"The Reaper","cutoff":"200"},{"trifusion":"false","level":"28","family":"1","name":"Setanta","family_name":"The Demigod","cutoff":"55"},{"trifusion":"false","level":"36","fam
@halferty
halferty / xmonad.hs
Created January 25, 2012 20:01
my xmonad config
import XMonad
import XMonad.Config.Gnome
import XMonad.Util.EZConfig
main = xmonad $ gnomeConfig
{ terminal = "gnome-terminal"
, modMask = mod4Mask
}
`additionalKeysP`
@halferty
halferty / mips_assembly_lights-out.asm
Created October 23, 2012 07:07
MIPS assembly lights-out
.data
newline: .asciiz "\n"
.text
j Main
#############################
# Display_Board
# Outputs the board to the screen
@halferty
halferty / fnd.rb
Last active December 21, 2015 21:29
Ruby find in files
#!/usr/bin/ruby
TOTAL_COLS = `tput cols`
FILENAME_WIDTH = 70
LINENUM_WIDTH = 5
TEXTSAMPLE_WIDTH = TOTAL_COLS.to_i - 90
search = ARGV[0]
if search
@halferty
halferty / gist:6368646
Created August 28, 2013 17:18
Ruby metaprogramming awesomeness
class Foo
def method_missing(method_name, *args)
puts "There's no method here by the name #{method_name}. You suck!\n\n"
singleton_class.superclass.send :define_method, method_name do |*args|
puts "I lied. This method was totally here all along."
puts "Look, I can see the arguments: #{args.join ' '}\n\n"
end
end
@halferty
halferty / kill_procs.rb
Last active December 23, 2015 13:48
Commit Unix process genocide (Or just kill jetty when ctrl-c doesn't work)
#!/usr/bin/env ruby
require 'colorize'
search = ARGV[0]
if search
results = `ps aux | grep -i #{search} | grep -v grep | grep -v ruby`.split("\n")
if results.size > 0
puts "Kill these processes???".red
@halferty
halferty / matrix_mult.rb
Last active August 29, 2015 13:57
3x3 matrix multiplication - one way to do it
A = [[1,2,3],[4,5,6],[7,8,9]]
B = [[0,-10,20],[-30,40,-50],[60,-70,80]]
C = Array.new(A.size) { Array.new(B.size) }
B.size.times do |row|
B.first.size.times do |col|
column = B.map { |r| r[col] }
results = column.map.with_index { |item, index| item * A[(row) % B.first.size][index] }
C[(row) % B.size][col] = results.map { |item| item }.inject(&:+)
end
@halferty
halferty / homepage.feature
Last active August 29, 2015 14:02
cucumber thing
Feature: View the Homepage
In order for visitors to feel welcome
We must go out of our way
With a kind greeting
Scenario: Homepage
Given I am viewing /
Then I shall see "Welcome to This Site"
.
─────────▄──────────────▄
────────▌▒█───────────▄▀▒▌
────────▌▒▒▀▄───────▄▀▒▒▒▐
VERY-──▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌
──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌WOW
──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌
module Foo
def hello
super + ' mom'
end
end
class Bar
prepend Foo
def hello