Skip to content

Instantly share code, notes, and snippets.

View fritz0705's full-sized avatar
๐ŸŽ‚

Fritz fritz0705

๐ŸŽ‚
View GitHub Profile
@fritz0705
fritz0705 / pixelflutc.go
Last active October 17, 2015 12:39
Evil Pixelflut Client
package main
import (
"flag"
"fmt"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"io"
# coding: utf-8
import netaddr
import lglass.bird
import lglass.route
import lglass.database.file
with open("routes.bird") as fh:
routes = lglass.route.RoutingTable(lglass.bird.parse_routes(fh))
@fritz0705
fritz0705 / graph.py
Created September 27, 2013 13:07
Simple gist to visualize a database
#!/usr/bin/env python3
# coding: utf-8
import hashlib
import argparse
import lglass.database.file
import lglass.rpsl
def spec_id(spec):
@fritz0705
fritz0705 / bench.h
Last active December 19, 2015 09:59
simple benchmarking tool, but not perfect
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 199309L
#error Expected _POSIX_C_SOURCE >= 199309L
#endif
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif
#include <time.h>
#include <stdio.h>
@fritz0705
fritz0705 / ssh_birdc.sh
Created May 8, 2013 12:49
Script to allow selection between bird and bird6 on SSH connect
#!/bin/bash
BIRD4="sudo /opt/bird/sbin/birdc"
BIRD6="sudo /opt/bird/sbin/birdc6"
BIRD=$BIRD4
case $SSH_ORIGINAL_COMMAND in
bird*4|ip*4)
BIRD=$BIRD4
// -fstrict-aliasing -Wall -Wextra -Werror -pedantic -std=c99
#include <string.h>
#include <stdio.h>
#define ARRAY_COPY(dst, src, len) {\
struct {\
struct {\
char __[len];\
} *__s, *__d;\
/* gcc -o intlen intlen.c */
#include <stdio.h>
#define TYPE_INFO(type) #type, (sizeof(type) * 8), sizeof(type)
#define TYPE_FORMAT "%s\t%u\t%u\n"
int main(void)
{
puts("type\tbits\tbytes");
<?php
function get_head_commit($dir = "./") {
$head = explode(": ", file_get_contents($dir . "/HEAD"));
assert($head[0] == "ref");
$head = $head[1];
$head = file_get_contents($dir . "/" . $head);
return $head;
}
?>
# This is O(scary)
def match_string(hay, nee):
if not nee:
return 0
index = {}
for offset, c in zip(range(0, len(hay)), hay):
if c not in index:
index[c] = []
index[c].append(offset)
indices = []
@fritz0705
fritz0705 / window.py
Created October 31, 2012 02:30
window.py
def window(iterable, size=2):
i = iter(iterable)
win = []
for e in range(0, size):
win.append(next(i))
yield win
for e in i:
win = win[1:] + [e]
yield win