Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / c_array_dump.c
Created January 4, 2012 01:23
Raw data to unsigned char C array
/* Dump raw data to a unsigned char array. */
void c_array_dump(FILE *stream, const char *label, unsigned char *data, size_t size)
{
int pos;
fprintf(stream, "const unsigned char %s[] = {\n\t", label);
for (pos = 0; pos < size ; ++pos) {
fprintf(stream, "0x%02X", (unsigned char) data[pos]);
if (pos+1 != size)
fprintf(stream, ", ");
@gcmurphy
gcmurphy / .vimrc
Created January 16, 2012 05:28
vimrc
set et
set ts=4
set sw=4
set ai
set smarttab
set incsearch
set hlsearch
set wildmenu
set wildmode=list:longest,full
set backspace=2
@gcmurphy
gcmurphy / jt.c
Created April 24, 2012 04:36
Java classpath maker. I don't think this is needed in Java > 6 or if you have proper manifest.
#include <stdio.h>
#include <stdlib.h>
#include <talloc.h>
#include <dirent.h>
#include <regex.h>
int main(int argc, char *argv[])
{
int arg;
regex_t pattern;
@gcmurphy
gcmurphy / weekly.sh
Created May 9, 2012 05:44
Weekly Status Report - Status report using taskwarrior
#!/bin/bash
Recipient="user@example.com"
Subject="Status: $(date --date="7 days ago" +'%y-%m-%d')"
LastWeek=`task export status:completed end.after:$(date --date="7 days ago" "+%m/%d/%Y") |json_reformat | grep description | sed -e "s/\"description\"\: \"/\* /" -e "s/\",$//"`
ThisWeek=`task export status:pending |json_reformat | grep description | sed -e "s/\"description\"\: \"/\* /" -e "s/\",$//"`
Body=`echo -e "Last Week:\n\n${LastWeek}\n\nThis Week:\n\n${ThisWeek}\n\nGrant."`
thunderbird -compose "to='$Recipient',subject='$Subject',body='$Body'"
@gcmurphy
gcmurphy / align.c
Created June 4, 2012 01:49
alignment
#include <stdio.h>
int main()
{
void *p;
if (((unsigned long)p) & 15 == 0)
puts("16 bit aligned");
if (((unsigned long)p) & 23 == 0)
puts("24 bit aligned");
if (((unsigned long)p) & 31 == 0)
puts("32 bit aligned");
@gcmurphy
gcmurphy / exmample.js
Created July 13, 2012 00:48
Using custom middleware with a express-resource
var resource = require('express-resource')
, stuff = require('./resources/stuff') // the resource being wrapped..
, _ = require('underscore')
var inject = (function(){
if (arguments.length < 2){
console.log(arguments.length)
throw "Invalid arguments"
}
@gcmurphy
gcmurphy / vimf.sh
Created July 26, 2012 05:08
Find and open a file in vim
#!/bin/bash
vim $(ack -g $@)
@gcmurphy
gcmurphy / eg.c
Created August 16, 2012 01:30
Basic TAP test
int main()
{
const char *answer;
plan_tests(2);
answer = read_answer(stdin);
if (!answer){
fail("Malformed JSON data provided");
} else {
pass("Valid JSON data recieved");
}
@gcmurphy
gcmurphy / espeak.py
Created September 4, 2012 05:22
Sublime Text 2 plugin to read out lout the selected text
import sublime, sublime_plugin
import subprocess, threading
def _run(cmd, args):
subprocess.call([cmd, args])
class SpeakCommand(sublime_plugin.TextCommand):
def run(self, edit):
@gcmurphy
gcmurphy / autosave.js
Created September 6, 2012 05:43
Very simple autosave functionality using local storage
var AutoSave = (function(){
var timer = null;
function getEditor(){
var elems = document.getElementsByTagName("textarea")
if (elems.length <= 0)
return null;