Skip to content

Instantly share code, notes, and snippets.

View dlundquist's full-sized avatar

Dustin Lundquist dlundquist

  • Seattle, WA
  • 12:14 (UTC -07:00)
View GitHub Profile
#!/usr/bin/perl
use strict;
use warnings;
use LWP;
# $prerequisites->{course}->{requirement}
my $prerequisites = {};
my $ua = LWP::UserAgent->new();
@dlundquist
dlundquist / memory.c
Created October 22, 2012 18:23
Explaining different memory types
#include <string.h>
#include <stdio.h>
void print_maps();
char *foo = "This string is allocated in the string pool within the text segment which is read and execute only so it should be considered a const char *\n";
char bar[] = "This string is allocated in the initialized data section of the data segement\n";
char *baz;
int
@dlundquist
dlundquist / .gitignore
Created October 3, 2012 03:08
Makefile for Latex assignments
*.aux
*.log
*.dvi
*.ps
*.pdf
@dlundquist
dlundquist / .vimrc
Created September 21, 2012 14:56
vimrc
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
set et
set shiftwidth=4
set tabstop=4
set modeline
set spell
highlight constant ctermfg=lightblue
set background=dark
@dlundquist
dlundquist / gist:1448796
Created December 8, 2011 21:54
DNS round robin in perl LWP
#!/usr/bin/perl
use strict;
use warnings;
use LWP;
use LWP::Protocol::http; # So we can manipulate EXTRA_SOCK_OPTS
use HTTP::Request::Common;
# LWP DNS round Robin
#!/usr/bin/perl
# Generates a random IPv6 address in the same subnet as the machine is currently in
# Written by Dustin Lundquist <[email protected]>
use strict;
use warnings;
sub getglobaladdress {
@dlundquist
dlundquist / shuffle.rb
Created July 8, 2010 22:43
Faro Shuffle
#!/usr/bin/ruby
MAX_ROUNDS = 50
# Splits the deck of cards into two equal parts
# in the case of an odd deck size, the extra card goes in the first part
def cut(cards)
b_size = cards.length / 2
a_size = cards.length - b_size
# Returns a new hash applying the supplied transform to all values
class Hash
def copy_and_transform(&transform)
rv = self.class.new
self.each do |k,v|
case transform.arity
when 1
rv[k] = yield(v)
when 2
rv[k] = yield(k,v)