Skip to content

Instantly share code, notes, and snippets.

Avatar

Donny Viszneki hdon

View GitHub Profile
View 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;
View gist:4d92d32127df8c10927572f1043297df
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 Mar 6, 2017
Connecting to MySQL with Knex
View database.json
{
"host": "xxxxxxxxxx"
, "user": "xxxxxxxxxx"
, "password": "xxxxxxxxxxxxxxxxxxxx"
, "database": "xxxxxxxxxxxxxxxxx"
}
@hdon
hdon / natstrings
Created Aug 20, 2016
IPv4 NAT string substitution
View natstrings
#!/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 Sep 15, 2015
grunt-browserify-sourcemap-line-offset-2-bug
View Gruntfile.js
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 Jun 18, 2015
Chess for IRC I guess...
View willie-chess.py
# 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 Aug 29, 2015
Generate non-colliding, intuitive usernames from domain names of 8- and 16-character lengths
View genusers.py
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')
View gist:37c10166344548a90088
T Clone(T)(T object) {
auto size = object.classinfo.init.length;
T ret = cast(T)((cast(void*)object)[0..size].dup.ptr);
return ret;
}
View shader.d
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 Dec 18, 2014
Compile-time linked list and key-value store
View test11.cpp
#include <iostream>
#include <type_traits>
using namespace std;
struct Nil {
typedef Nil Head;
typedef Nil Tail;
};
template <typename H, typename T = Nil> struct Lst {