Skip to content

Instantly share code, notes, and snippets.

View odeke-em's full-sized avatar

Emmanuel T Odeke odeke-em

View GitHub Profile
@odeke-em
odeke-em / Makefile
Last active August 29, 2015 14:02
Dictionary implementation using a Trie.
CC := gcc
radTest: radLoadWords.c radTrie.o element.o wordTransition.o
$(CC) -DTEST_LOAD_WORDS radTrie.o element.o wordTransition.o radLoadWords.c -o $@
%.o: %.c
$(CC) -c $< -o $@
clean:
rm -f *.o radTest
@odeke-em
odeke-em / gist:57350d2c525416d1a8f8
Created December 29, 2014 21:30
Bud erraneous index
diff --git a/src/master.c b/src/master.c
index cd846e1..0733d3b 100644
--- a/src/master.c
+++ b/src/master.c
@@ -354,7 +354,7 @@ bud_error_t bud_master_get_spawn_args(bud_config_t* config, char*** out) {
} else {
/* Goal is to skip piped_index, thus excluding --piped-config argument: */
for (i = 0, j = 0; i < config->piped_index; i++, j++)
- args[j++] = config->argv[i];
+ args[j] = config->argv[i];
@odeke-em
odeke-em / urlWalker.js
Last active August 29, 2015 14:14
URL Walker.
var _un = require('underscore');
var url = require('url');
var util = require('util');
var request = require('request');
function walkUrl(targetUrl, callback) {
var probes = {};
var errBucketIndex = 5;
// status codes are in the range 100 - 999
@odeke-em
odeke-em / lib_loader.c
Created February 11, 2015 20:31
lib loader
// Author: Emmanuel Odeke <odeke@ualberta.ca>
// Module to handle platform agnostic loading of dynamic libraries
#include <stdio.h>
#include <stdlib.h> // For exit(...)
#include <stdarg.h>
#include "lib_loader.h"
static errorReporter errReporter = NULL;
@odeke-em
odeke-em / commonPrefix.go
Last active August 29, 2015 14:15
commonPrefix.go
package main
import "fmt"
func commonPrefix(values ...string) string {
vLen := len(values)
if vLen < 1 {
return ""
}
minIndex := 0
@odeke-em
odeke-em / expected.c
Created February 25, 2015 22:49
const+spillover: A trivial reproduction of what tripped me out with using const within a for loop.
#include <stdio.h>
#include <string.h>
int main() {
char *lang = "c_language";
size_t len = strlen(lang);
size_t i;
for (i = 0; i < len; ++i) {
const char c = lang[i];
var bucket = new AWS.S3({params: {Bucket: 'foo'}});
var callback = function(err, data) { if (err) console.log(err); else console.log(data);}
// Objects since 2015-02-23
bucket.listObjects({Prefix: '2015-02', Marker: '2015-02-23-00:00:00'}, callback);
// Objects after 4:00 p.m on 2015-02-23
bucket.listObjects({Prefix: '2015-02-23', Marker: '2015-02-23-16:00:00'}, callback);
#!/bin/bash
target_name="foo" # Remember to set your name here
target_email="foo@example.com" # Set the new email here
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = $target_name ];
then export GIT_AUTHOR_EMAIL=$target_email;
fi; git commit-tree "$@"'
#include <stdio.h>
int main() {
FILE *ifp = fopen(__FILE__, "r");
if (ifp == NULL)
return -1;
char c;
while ((c = getc(ifp)) != EOF) putchar(c);
fclose(ifp);
return 0;
const crypto = require('crypto');
function hexSha256ify(password) {
var sha256sum = crypto.createHash('sha256');
sha256sum.update(password + '');
return sha256sum.digest('hex');
}
function createNewUser(data) {
data = data || {};