Skip to content

Instantly share code, notes, and snippets.

@treed
treed / keybase.md
Created July 13, 2015 23:31
keybase.md

Keybase proof

I hereby claim:

  • I am treed on github.
  • I am treed (https://keybase.io/treed) on keybase.
  • I have a public key whose fingerprint is 2B09 9C4F F8EA A104 A437 1806 3E8A F4C1 FD14 B29B

To claim this, I am signing this object:

@treed
treed / Util.hs
Last active August 29, 2015 14:09
import Data.List
import Text.PrettyPrint.Boxes as B
print_table :: [Alignment] -> [String] -> [[String]] -> IO ()
print_table aligns titles rows = printBox $ hsep 2 B.left (map (\(align, title, col) -> vcat center2 [text title, vcat align $ map text col]) $ zip3 aligns titles (transpose rows))
left = B.left
right = B.right
center = B.center2
@treed
treed / gist:0c60029b53b4fc193181
Created October 4, 2014 09:39
Add go type to airline next to tagbar
call airline#parts#define_function('goinfo', 'go#complete#GetInfo')
call airline#parts#define_condition('goinfo', '&ft =~ "go"')
function! AirlineInit()
" Ended up not having virtualenv here since for some reason it insisted on having that as a bare string
let g:airline_section_x = airline#section#create_right(['goinfo', 'tagbar', 'filetype'])
endfunction
autocmd VimEnter * call AirlineInit()
start on runlevel [2345]
respawn
respawn limit 10 60
chdir /home/mcgrue/sexymans
exec ./sexymans
treed@eunice:~/code/ore$ runghc ore.hs
Mercoxit 335.67
Arkonor 276.15
Bistot 214.30
Hemorphite 213.88
Jaspet 205.37
Crokite 204.10
Hedbergite 200.69
Pyroxeres 180.26
Dark_Ochre 170.34
@treed
treed / php5-CVE-2011-4885.patch
Created January 14, 2012 05:59
Patch for CVE-2011-4885
--- A/main/php_variables.c 2011/12/22 13:28:01 321334
+++ B/main/php_variables.c 2011/12/22 15:31:41 321335
@@ -191,9 +191,14 @@
}
if (zend_symtable_find(symtable1, escaped_index, index_len + 1, (void **) &gpc_element_p) == FAILURE
|| Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
+ if (zend_hash_num_elements(symtable1) <= PG(max_input_vars)) {
+ if (zend_hash_num_elements(symtable1) == PG(max_input_vars)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ }
@treed
treed / try-sse.c
Created September 26, 2011 09:59
Using packed string compare from SSE4.2 to search for certain characters
#include <smmintrin.h>
typedef union __attribute__((aligned(16))) {
unsigned char bytes[16];
__m128i vec;
} vec_bytes_128;
int main() {
int length = 3;
vec_bytes_128 in = { 'a', 'e', 'e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@treed
treed / gist:1103695
Created July 25, 2011 07:20
An Idea
#!/usr/bin/perl
use Modern::Perl;
use Coro;
sub do_a_thing {
my @args = @_;
my $cb = pop @args;
async {
for my $thing (@args) {
say "Thing $thing";
@treed
treed / gist:1075186
Created July 11, 2011 01:31
Legend of Zelda Conversation Loading Code
The code that actually loads this is executed from $882B
LDA $045F
STA $0303
INC $045F
LDY $0415 ; $0415 apparently contains the conversation to be loaded
LDA $8000,Y
STA $00
INY
LDA $8000,Y
token ip_address { [<octet> '.'] ** 3 <octet> }
token octet {
| 25<[0..5]>
| 2<[0..4]><[0..9]>
| 1<[0..9]><[0..9]>
| <[1..9]><[0..9]>
| <[0..9]>
}