Skip to content

Instantly share code, notes, and snippets.

@daniel42
daniel42 / bit_vector.h
Created November 9, 2010 07:48
Corresponding header file for my bit vector implementation
#ifndef _BIT_VECTOR_H
#define _BIT_VECTOR_H
typedef struct bit_vector {
// Bits for the bit vector
unsigned char* bits;
// Number of bits in the vector
unsigned int size;
} bit_vector_t;
@daniel42
daniel42 / bit_vector.c
Created November 9, 2010 07:47
Little bit vector implementation by me
/**
* On my mac, compile single file like this:
* clang -DUSEMAIN bit_vector.c
* gcc -DUSEMAIN bit_vector.c
*
* TODO: Run this through valgrind. I don't think I'm leaking memory
* TODO: This implementation could probably do more error checking. It
* does'nt validate the values being passed in.
*/
#include <stdio.h>
@daniel42
daniel42 / simplesuave.fs
Created November 8, 2010 06:48
Trying out the F# Suave web development library
// To compile: fsc -r ~/workplace/repos/suave/Suave/Suave.dll simplesuave.fs
// To run: MONO_PATH=$MONO_PATH:/Users/dc/workplace/repos/suave/Suave mono simplesuave.exe
open Suave.Web
open Suave.Combinator
choose [ url "/hello" >>= ok ("Hello World" |> cnst); ]
|> web_server [|HTTP, "127.0.0.1",8080|]
|> Async.RunSynchronously
|> ignore ;;
my $acc = sum(map { calc($_, $settings, $self) } @desc);
" Setup Pathogen
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
{- One solution to fizzbuzz. I think it's correct
- Took longer than 10 minutes but I'm still pretty
- new to haskell .
-}
fizzbuzz n
| mod3 n && mod5 n = "FizzBuzz"
| mod3 n = "Fizz"
| mod5 n = "Buzz"
| otherwise = show n
where mod5 x = x `mod` 5 == 0
@daniel42
daniel42 / MyApp.pm
Created August 28, 2010 23:33
Playing with gist in vim. Me working through Catalyst tutorial
package MyApp;
use Moose;
use namespace::autoclean;
use Catalyst::Runtime 5.80;
# Set flags and add plugins for the application
#
# -Debug: activates the debug mode for very useful log messages
# ConfigLoader: will load the configuration from a Config::General file in the
#!/usr/bin/env perl
use 5.12.0;
use warnings;
use Math::Random;
use Data::Dumper;
=pod
A little perl script for determining the draft order for a fantasy football (or any sport)
league.
#!/usr/bin/env perl
use Modern::Perl;
use MooseX::Declare;
use TryCatch;
use 5.12.0;
class BankAccount {
has 'balance' => ( isa => 'Num', is => 'rw', default => 0 );
method deposit(Num $amount) {
#!/opt/personal/pkg/perl5.10/bin/perl
# A script to combine some files or files in a directory together in a path
use Modern::Perl;
use Cwd 'abs_path';
use File::Find;
use Getopt::Long;
sub main {
my $regex;
GetOptions('regex=s' => \$regex);