Skip to content

Instantly share code, notes, and snippets.

@grodtron
grodtron / quicksort.cpp
Created July 19, 2012 02:43
An implementation of quicksort (Not completely working)
#include <iostream>
using std::cout;
using std::endl;
//#define DEBUG 1
#include <stdlib.h>
#include <time.h>
void _qsort(int *, int);
@grodtron
grodtron / Readme.txt
Created July 11, 2012 22:22
Second assignment - implementing a linked list
This was getting too big... Moved to here: https://github.com/grodtron/LinkedList
@grodtron
grodtron / .gitignore
Created July 10, 2012 17:17
Little assignment for a programming class
Debug/*
*.vcxproj*
*.o
*.swp
test
@grodtron
grodtron / reverse.cpp
Created June 8, 2012 03:40
A small program to reverse the order of words in a string
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
/*
*
* Small program to reverse the order of words in a sentence
*
@grodtron
grodtron / quiny-count.clj
Created May 25, 2012 22:53
A quiny clojure script that sums the values of the bytes of its own source (without any file i/o)
(let [s "(let [s %s] (apply + (map int (format s (pr-str s)))))"] (apply + (map int (format s (pr-str s)))))
@grodtron
grodtron / DFT_Matrix.m
Created May 18, 2012 14:43
A Matlab script to calculate the discrete Fourier Transform of a signal using matrix multiplication.
clear;
clc;
% This is a test
% This x[n] is a simple square pulse centered at the origin
% it can be replaced with any finite-duration signal, as long as
% n is updated to match
x = [ zeros(1,8) ones(1,5) zeros(1,8) ];
n = -10:10;
@grodtron
grodtron / recolor.bash
Created May 13, 2012 22:11
A bash/ImageMagick script to recolor transparent .png files
#!/bin/bash
# A small script to change the color of mono-colored transparent .pngs
#
# Uses ImageMagick to read the most common 100% alpha color and then computes
# scale factors to multiply the whole image by.
#
# Improvements to be made:
# -deal with images containing pure black.
# -make portable between new and old ImageMagick versions
@grodtron
grodtron / quine.clj
Created May 7, 2012 01:53
A Clojure Quine
(fn [] (let [s "(fn [] (let [s %s] (format s (pr-str s))))"] (format s (pr-str s))))
@grodtron
grodtron / hash.c
Created February 29, 2012 04:19
A test program that computes and displays the 64 bit NFW hash of an arbitrary c-string
/*
* This file contains an implementation of the
* 64-bit Fowler-Noll-Vo (FNV) hash function.
*
* More information can be found here;
* http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
*
* Gordon Bailey - Feb 28, 2012
*
*/
@grodtron
grodtron / dissassembler.py
Created February 8, 2012 03:27
Dissasembler for simplified version of motorolla 68000
#!/usr/bin/python
import optparse
def add(opcode,memory=None):
dest = ((opcode >> 9) & int( "111",2))
src = ((opcode >> 0) & int( "111",2))
mode = ((opcode >> 3) & int("111111",2))
destType = 'd' if mode == int("001000",2) else 'a'