Skip to content

Instantly share code, notes, and snippets.

View davestevens's full-sized avatar

Dave Stevens davestevens

View GitHub Profile
@davestevens
davestevens / linkedList.c
Created January 27, 2012 17:05
Simple linked list implementation in C.
#include <stdio.h>
#include <stdlib.h>
typedef struct elementT {
unsigned value;
struct elementT *next;
} elementT;
elementT *removeElement(elementT *, unsigned);
elementT *addElement(elementT *, unsigned);
@davestevens
davestevens / gist:2118282
Created March 19, 2012 16:31
Set stack pointers for each cpu in leon3mp
!! Instructions for adding assembly code for leon3mp to setup stack pointers for each available CPU.
!! Running sparc-elf-gcc includes some system files in the final elf file, but editing these it is possible to set the stack pointer for each CPU before main is entered.
!! Edit the file sparc-elf-*.*.*/src/libgloss/sparc_leon/crt0.s
!! Add in the following assembly beneath the _start: label
! added code for setting stack pointer for each cpu
rd %asr17, %g5 ! load in configuration reg into g5
srl %g5, 28, %g5 ! shift so only cpuid is seen
@davestevens
davestevens / publications.bib
Created March 21, 2012 13:30
BibTeX bibliography of publications
%% This BibTeX bibliography file was created using BibDesk.
%% http://bibdesk.sourceforge.net/
%% Created for dave stevens at 2012-03-21 13:28:29 +0000
%% Saved with string encoding Unicode (UTF-8)
@davestevens
davestevens / combinations.pl
Created June 24, 2012 14:07
Attempt to display all combinations of data set
#!/usr/bin/perl
use strict;
use Data::Dumper;
my @b = (['a','b'],['c','d'],['e','f']);
my @all;
my @single;
&rec(0, \@all, \@single, @b);
@davestevens
davestevens / libxml2_error.c
Created July 3, 2012 10:05
Error produced by libxml2 when unlinking and linking xmlNodes from different xmlDocs and attempting to free the xmlDocs.
#include <stdio.h>
#include <libxml/parser.h>
/* compile:
gcc -m32 libxml_error.c `xml2-config --libs` `xml2-config --cflags` -Wall -Wextra -pedantic
*/
/* example xml input file
<?xml version="1.0"?>
<A>
@davestevens
davestevens / crop.php
Created November 5, 2012 11:41
Remove whitespace from around image.
<?php
/* Crop images */
/* Find whitespace around image and remove */
$border = 5;
/* Get image */
$orig = getImage($argv[1]);
@davestevens
davestevens / dec_to_str.pl
Created December 6, 2012 20:26
Convert decimal numbers to string and vice versa
#!/usr/bin/perl
use strict;
# Kind of useless script to convert numbers to their word equivalent and back
# Call dec_to_str() with a decimal value, returns a string containing the word equivalent
# eg. dec_to_str(123456) := one hundred and twenty three thousand four hundred and fifty six
# Call str_to_dec() with a number in words, returns decimal value
@davestevens
davestevens / gist:5029577
Created February 25, 2013 12:42
Setup jshint in emacs
This seems to run quicker than the jshint-mode example (https://github.com/daleharvey/jshint-mode) as it doesn't set up a node server each time.
1. Install node and get jshint
$ brew install node
$ npm install -g jshint
2. Update PATH to point to Node Packagem Manager bin directory
describe clCreateContext do
let(:params) { nil }
subject { clCreateContext(params) }
context "when calling with nil mooses" do
let(:params) { mooses: nil }
its(:errcode_ret) { should == CL_INVALID_MOOSE }
end
end
@davestevens
davestevens / gist:8596770
Created January 24, 2014 13:00
Turtle Roy
penup
lt 180
fd 50
lt 180
lt 90
fd 50
rt 90
pendown
repeat 360(sequence[lt 1, fd 1])
fd 150