Skip to content

Instantly share code, notes, and snippets.

View austo's full-sized avatar

Austin Moran austo

  • Connecticut, USA
View GitHub Profile
@austo
austo / base64.c
Last active December 2, 2017 17:19
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
char const syms[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '+', '/'};
#include <cstdio>
#include <string>
enum { FIELD_SIZE = 8 };
void parse(int* out, int n, char const* s) {
if (!s || n <= 0) {
return;
}
int k = n * FIELD_SIZE;
'use strict';
function main() {
const args = process.argv.slice(2);
return asBits(args, (err, s) => {
if (err) {
console.error(err);
return process.exit(1);
}
return console.log(s);
@austo
austo / handler_wrap.cpp
Last active July 29, 2017 17:01
call based on type
#include <functional>
#include <iostream>
#include <string>
#include <vector>
// clang++ -std=c++11 -stdlib=libc++ -Wall handler_wrap.cpp -o handler_wrap
// g++ -std=c++11 -Wall handler_wrap.cpp -o handler_wrap
// Message Type #1
class Foo {
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
// clang++ -std=c++11 -stdlib=libc++ -Wall ptr_fun.m.cpp -o ptr_fun
// g++ -std=c++11 -Wall ptr_fun.m.cpp -o ptr_fun
class Foo {
public:
@austo
austo / graph-search.js
Created September 28, 2016 03:24
graph traversal strategies
'use strict';
const assert = require('assert'),
fs = require('fs'),
readGraph = require('./readGraph');
let stream = process.argv[2] ?
fs.createReadStream(process.argv[2]) : process.stdin;
readGraph(stream, (err, g) => {
@austo
austo / pullflat.sh
Last active August 29, 2015 14:03
flatten dk submodules
#!/bin/bash
set -o nounset
set -o errexit
# Needed for sed (Mac OS X sed does not understand \t)
TAB="$(printf '\t')"
TEMP='temp'
SUB='sub'
GIT='/usr/local/bin/git' # set to git executable
@austo
austo / curlXargs.sh
Created December 6, 2013 05:29
curl-xargs
$ curl --user 'officialApiClient:C0FFEE' http://localhost:8181/token -d 'grant_type=client_credentials' | \
json access_token | xargs -I tok curl -H "Authorization: Bearer tok" http://localhost:8181/secret | json
@austo
austo / serial.js
Created November 27, 2013 04:47
execute array of functions serially
function first(cb) {
console.log('hello from first...');
cb();
}
function second(cb) {
console.log('hello from second...');
cb();
}
var path = require('path'),
fs = require('fs'),
http = require('http');
http.createServer(function(req, res) {
var file = path.normalize('.' + req.url);
console.log('Trying to serve ', file);
function reportError(err) {
console.log(err);