Skip to content

Instantly share code, notes, and snippets.

View DavidEGrayson's full-sized avatar

David Grayson DavidEGrayson

View GitHub Profile
@DavidEGrayson
DavidEGrayson / boolean_with_reason_ugly_example.rb
Created October 20, 2011 05:55
Wouldn't it be cool if we could make a BooleanWithReason Class in ruby
ugly_hair = false
ugly_nose = true.because "the nose is too small."
ugly_glasses = false
ugly_face = ugly_hair.or(ugly_nose).or(ugly_glasses)
if ugly_face.true?
puts "The face is ugly because " + ugly_face.reason # => "The face is ugly because the nose is too small."
end
@DavidEGrayson
DavidEGrayson / profile_rbx1.2.4.txt
Created November 12, 2011 19:32
Rubinius 1.2.4 hash collision profiling
Thread 0: total running time: 10.186666s
% cumulative self self total
time seconds seconds calls ms/call ms/call name
------------------------------------------------------------
23.05 7.49 2.35 526336 0.00 0.01 Thread.detect_recursion
14.79 2.94 1.51 552960 0.00 0.01 Struct::eql?<243> {}
10.32 8.72 1.05 522240 0.00 0.02 Struct#eql?
6.94 9.55 0.71 522245 0.00 0.02 Hash::Entry#match?
5.42 3.67 0.55 530441 0.00 0.01 Array#each
@DavidEGrayson
DavidEGrayson / setup.iss
Created February 28, 2012 02:40
From as5installer-stable-5.1.208-full.exe, the installer for Atmel AVR Studio 5.1.
[InstallShield Silent]
Version=v7.00
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{D574D18C-9D52-4B4B-9647-AE6B89FD3F70}-DlgOrder]
Dlg0={D574D18C-9D52-4B4B-9647-AE6B89FD3F70}-SdWelcome-0
Count=5
Dlg1={D574D18C-9D52-4B4B-9647-AE6B89FD3F70}-SdLicense2-0
Dlg2={D574D18C-9D52-4B4B-9647-AE6B89FD3F70}-SdAskDestPath-0
@DavidEGrayson
DavidEGrayson / avr-device.c
Created March 1, 2012 00:40
from AVR GCC 4.6.2
/* Copyright (C) 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Anatoly Sokolov (aesok@post.ru)
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@DavidEGrayson
DavidEGrayson / utf8_parser.rb
Created May 3, 2012 17:37
Ruby UTF8 parser (for fun)
# -*- coding: utf-8 -*-
# TODO: throw exceptions if bytes.next returns an unexpected type of byte
def utf8_parse(string)
return enum_for(:utf8_parse, string) unless block_given?
bytes = string.bytes
while true
byte = bytes.next
yield case byte
when 0x00..0x7F then byte
@DavidEGrayson
DavidEGrayson / workaround.c
Created July 10, 2012 23:12
Workaround for binutils 2.22 bug 13697 to ensure .data section is not empty.
static void __attribute__((used)) workaround(void)
{
static volatile unsigned char w = 1;
w++;
}
@DavidEGrayson
DavidEGrayson / gist:3195058
Created July 28, 2012 22:43
Junk I am getting Minecraft 1.3 server after Set Window Items (0x68)

\xFF\xFF\xFF\xFF
\xFF\xFF\x67
\xFF\xFF\xFF
\xFF\xFF\x67
\x00\x00\x09\x00\x03\x08\x00\x00
\xFF\xFF\x67
\x00\x00\x24\x01\x28\x1F\x00\x00
\xFF\xFF\x67
\x00\x00\x25\x01\x27\x2E\x00\x00\xFF\xFF\x08\x00\x01\x00\x00\x00\x00\x00
\x00\x2B\x00\x00\x00\x00\x00\x00\x00\x00\x38\x00\x05\x00\x00\x46\xAA\x78

@DavidEGrayson
DavidEGrayson / gist:3195139
Created July 28, 2012 23:05
Error when I tried to run mc3p on Windows: ImportError: cannot import name PKCS1_v1_5
C:\Users\David\Documents\minecraft\mc3p>python -m mc3p.proxy 192.168.11.84
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\David\Documents\minecraft\mc3p\mc3p\proxy.py", line 35, in <mod
ule>
from authentication import Authenticator, minecraft_credentials
File "mc3p\authentication.py", line 16, in <module>
@DavidEGrayson
DavidEGrayson / jlinkcdc_verify.txt
Created September 5, 2012 23:10
Trying to sign pololu_usb_to_serial.inf
C:\Users\david.POLOLU\Desktop\jlinkcdc>"C:\Program Files (x86)\Windows Kits\8.0\
bin\x64\signtool.exe" verify /v /pa jlinkcdc.cat
Verifying: JLinkCDC.cat
Signature Index: 0 (Primary Signature)
Hash of file (sha1): C8BF42F901C4A3E0855C5D1450A43FB057E036AB
Signing Certificate Chain:
Issued to: VeriSign Class 3 Public Primary Certification Authority - G5
Issued by: VeriSign Class 3 Public Primary Certification Authority - G5
@DavidEGrayson
DavidEGrayson / .overview.txt
Created October 25, 2012 17:42
`rvm rvmrc load` fails first time but succeeds subsequently
Reported on IRC and at: https://github.com/wayneeseguin/rvm/issues/1268
I think I have found a bug with RVM. Here is what happens:
david@rails-worker1:~$ sudo su - website
[sudo] password for david:
website@rails-worker1:~$ cd /u/apps/website/current
website@rails-worker1:/u/apps/website/current$ env > ~/env0.txt
website@rails-worker1:/u/apps/website/current$ rvm rvmrc load
Usage: rvm rvmrc {trust,untrust,trusted,load,reset,is_trusted,try_to_read_ruby,create}