Skip to content

Instantly share code, notes, and snippets.

View hdon's full-sized avatar

Donny Viszneki hdon

View GitHub Profile
@hdon
hdon / bug-20170416
Created April 16, 2017 23:11
bug-20170416
hdon@behemoth:~/src/git/bug-20170416$ cat foobarbaz.c
#include <stdlib.h>
#include <string.h>
typedef struct foo {
size_t *bar;
} foo;
int main(int argc, char **argv) {
foo baz;
hdon@behemoth:~/src/git$ git init trailstest
Initialized empty Git repository in /home/hdon/src/git/trailstest/.git/
hdon@behemoth:~/src/git$ cd trailtest
bash: cd: trailtest: No such file or directory
(reverse-i-search)`': ^C
hdon@behemoth:~/src/git$ cd trailstest
hdon@behemoth:~/src/git/trailstest$ yo
? 'Allo Don! What would you like to do? Trails
Make sure you are in the directory you want to scaffold into.
@hdon
hdon / database.json
Created March 6, 2017 20:33
Connecting to MySQL with Knex
{
"host": "xxxxxxxxxx"
, "user": "xxxxxxxxxx"
, "password": "xxxxxxxxxxxxxxxxxxxx"
, "database": "xxxxxxxxxxxxxxxxx"
}
@hdon
hdon / natstrings
Created August 20, 2016 22:03
IPv4 NAT string substitution
#!/usr/bin/env python
import sys, re
def s2ip(s):
a, b, c, d = map(int, s.split('.'))
return (a << 24) | (b << 16) | (c << 8) | d
def ip2s(n):
return '%d.%d.%d.%d' % (
(n >> 24)
,(n >> 16)& 255
@hdon
hdon / Gruntfile.js
Last active September 15, 2015 16:16
grunt-browserify-sourcemap-line-offset-2-bug
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
, browserifyOptions: {
debug: true /* generate source maps */
}
}
@hdon
hdon / willie-chess.py
Created June 18, 2015 03:15
Chess for IRC I guess...
# coding=utf8
"""
willie-chess.py - chess, duh
"""
# whipped this up at lunch.
# clone https://github.com/embolalia/willie
# put this in ./willie/modules
# create mysql database and table "chessgame"
# all moves are validated but en passant and castling aren't implemented
@hdon
hdon / genusers.py
Last active August 29, 2015 14:16
Generate non-colliding, intuitive usernames from domain names of 8- and 16-character lengths
import re
words = filter(lambda s:all([ord(c)<128 for c in s]), map(str.strip, open('/usr/share/dict/words')))
domainExp = re.compile('^[a-z0-9_]+$')
numbersExp = re.compile('[0-9]+')
englishWords = \
filter(
lambda s: domainExp.match(s),
map(str.lower,
map(str.strip,
open('/usr/share/dict/words')
T Clone(T)(T object) {
auto size = object.classinfo.init.length;
T ret = cast(T)((cast(void*)object)[0..size].dup.ptr);
return ret;
}
module com.codebad.shader;
import derelict.opengl3.gl3;
import file = std.file;
import std.exception : enforce;
import std.stdio : writeln, writefln;
import std.string : format, toStringz;
import std.traits : isPointer, PointerTarget;
import std.conv : to;
import std.path : baseName;
import std.traits : isSigned;
@hdon
hdon / test11.cpp
Created December 18, 2014 04:56
Compile-time linked list and key-value store
#include <iostream>
#include <type_traits>
using namespace std;
struct Nil {
typedef Nil Head;
typedef Nil Tail;
};
template <typename H, typename T = Nil> struct Lst {