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 / .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 / 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 / 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"
@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
#!/bin/bash
while getopts "c" opt; do
case "$opt" in
c)
color=1
;;
?)
exit 1
esac
@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.colorscheme
Last active November 23, 2019 19:20
Dark pastels colorscheme for Konsole
[Background]
Color=44,44,44
Transparency=false
[BackgroundIntense]
Bold=true
Color=44,44,44
Transparency=false
[Color0]