Skip to content

Instantly share code, notes, and snippets.

View cmcbride's full-sized avatar

Cameron McBride cmcbride

  • Boston, MA (USA)
View GitHub Profile
function process_types(fmt :: String, args...)
# Process types of arguments for libc's printf family.
# Grab everybody's type.
types = [typeof(arg) for arg in args]
# Perform the following conversions:
# string -> Ptr{Uint8} (for %s)
# arrays -> Ptr{Void} (for %p)
types = map(t -> (t == ASCIIString ? Ptr{Uint8} : t), types)
@ahoward
ahoward / a.rb
Created February 28, 2014 19:29
message passing to processes, threads, or any combination is über simple in ruby
# it's easy, in ruby, to setup a worker farm that utilizes processes, threads,
# or any combination. the following code sets up three processes, each with
# three worker threads, and a super simple, message passing api, to send
# messages to any process, which will use one of it's threads to do work
#
#
slaves = Array.new(3){ Slave.new{ Worker.new }}
workers = slaves.map(&:object)
a, b, c = workers
@ahoward
ahoward / a.rb
Created May 8, 2012 16:06
did i mention style is everything?
#
# perl got some things right. here-docs were one of them. YAML takes this
# further when we have to define large data structures.
#
# if you find yourself typing " ' ) ( [ ] too many times in a row, whack
# yourself on the wee-wee with a keyboard and whip out the YAML
#
this_fucking_licks_hairy_balls_to_edit =
@cmcbride
cmcbride / const.c
Created May 14, 2011 22:45
C const
// This is a slight modification of the original at:
// http://www.cap-lore.com/Languages/const.c
//
// Does "int const *" refer to a constant pointer, or a constant integer?
// The following shows what gcc thinks.
// gcc 4 rejects any of the lines below that are commented out.
typedef const int * cip;
typedef int const * icp;
typedef int * const ipc;
typedef int const * const icpc;