Skip to content

Instantly share code, notes, and snippets.

@greneholt
greneholt / hack_c_instr
Created February 21, 2012 09:11
Hack assembly C instruction regex
\A
(?:(?=[AMD])(A?M?D?)=)? # destination
(
[AMD][+\-&|][AMD1] | # binary operations
[\-!]?[AMD01] # unary operations
)
(?:;J([GL][ET]|EQ|NE|MP))? # jump
\Z
@greneholt
greneholt / vmtranslator.rb
Created February 29, 2012 21:52
File IO for vm translator
begin
raise VMTranslatorError.new("Only enter the name of one .vm file or the name of a directory") if ARGV.length > 1
raise VMTranslatorError.new("File does not exist") unless File.exists?(ARGV.first)
if File.directory? ARGV.first
files = Dir.glob(File.join(ARGV.first, '*.vm'))
raise VMTranslatorError.new("No .vm files in #{ARGV.first}") unless files.length > 0
outfile = File.join(ARGV.first, File.basename(ARGV.first))
else
raise VMTranslatorError.new("Not a .vm file") unless ARGV.first =~ /\A(.+)\.vm\Z/i
@greneholt
greneholt / private.xml
Last active October 2, 2015 00:17
Semicolon home row arrow mode and keyboard flip with KeyRemap4MacBook
<?xml version="1.0"?>
<root>
<item>
<name>Home Row Arrow Mode</name>
<list>
<item>
<name>What's "Home Row Arrow Mode"?</name>
<appendix>Single Key Press Semicolon turns on "Home Row Arrow Mode"</appendix>
<appendix>Then you can use JKIL as Left/Down/Up/Right.</appendix>
<appendix>Also, U = home, O = end, H = page up, and N = page down.</appendix>
@greneholt
greneholt / Random.jack
Created March 27, 2012 03:35
Jack pseudorandom number generator
/*
Random Number Generator
Original author: Taylor Wacker
Modified by: Connor McKay
This is a pseudo random number generator that uses the
Linear Congruential Generator (LCG) to generate random
numbers.
*/
class Random {
@greneholt
greneholt / AutoHotkey.ahk
Last active September 14, 2020 20:35
AutoHotkey semicolon arrow keys and capslock to ctrl/escape
#SingleInstance force
; Necessary for semicolon arrow to work, since it can send semicolon.
#InstallKeybdHook
; Better performance.
SendMode Input
; Kill CapsLock.
SetCapsLockState AlwaysOff
@greneholt
greneholt / .gitconfig
Last active August 4, 2017 00:06
Git config
[alias]
ci = commit
cia = commit --amend
cian = commit --amend --no-edit
st = status
pl = pull
cp = cherry-pick
cps = cherry-pick --strategy=subtree -x
co = checkout
df = diff
@greneholt
greneholt / .bash_common
Created May 24, 2013 03:57
Useful bash configuration
#if [ -f ~/.bash_common ]; then
# . ~/.bash_common
#fi
export CLICOLOR=1
export PS1="\[\e[7;32m\]\u\[\e[0m\] \[\e[7;36m\]\w\[\e[27;32m\]\$ \[\e[0m\]"
export EDITOR=vim
alias ll="ls -lh"
@greneholt
greneholt / threader.rb
Last active June 3, 2020 19:20
Ruby threaded task manager
class Threader
def initialize(max_threads = 50)
@max_threads = max_threads
@wait_queue = Queue.new
@tasks = []
@running_tasks = Set.new
@done_tasks = Set.new
end
# Add a task.
@greneholt
greneholt / .profile
Created December 4, 2013 17:31
Semicolon arrow keys
if [ "$DISPLAY" ]
then
xmodmap - <<-EOF
! semicolon held movement commands:
! j = left
! k = down
! l = right
! i = up
! u = home
@greneholt
greneholt / dark_pastels_bold.reg
Last active May 8, 2017 18:47
Dark pastels colorscheme for putty. Intended to be used with bold fonts.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"Colour0"="220,220,205"
"Colour1"="220,220,205"
"Colour2"="44,44,44"
"Colour3"="44,44,44"
"Colour4"="44,44,44"
"Colour5"="220,220,205"
"Colour6"="112,144,128"