Skip to content

Instantly share code, notes, and snippets.

View fuzzy's full-sized avatar

Mike 'Fuzzy' Partin fuzzy

  • A Place For Mom
  • Seattle, WA
View GitHub Profile
#include <Python.h>
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
#include <sys/endian.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@fuzzy
fuzzy / staticobj.py
Created October 12, 2011 03:34
static object with type checking, and some slight example usage.
class StaticObject(object):
'''
Class: StaticObject(object)
Author: Mike "Fuzzy" Partin
TODO:
'''
def __setattr__(self, key, val):
'''
Method: StaticObject.__setattr__(key, val)
Author: Mike "Fuzzy" Partin
@fuzzy
fuzzy / dtop.py
Created October 31, 2011 18:12
This is a quick recipe for a simple 'top' for watching DistCC. I know there's distccmon-text, but I prefer a 'top'-like display.
#!/usr/bin/env python
import os, sys, time
import curses,struct
states = ['STARTUP', 'BLOCKED', 'CONNECT', 'PREPROCESS', 'SEND', 'COMPILE', 'RECEIVE', 'DONE']
DISTCC_DIR = os.getenv('DISTCC_DIR') or '%s/.distcc' % os.getenv('HOME')
def getStats(scr):
curses.init_pair(10, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(11, curses.COLOR_RED, curses.COLOR_BLACK)
@fuzzy
fuzzy / .cpkg.sh
Created March 6, 2012 20:58
start of the cpkg system for managing multiple versions of whatever on a session by session basis
OS=$(uname -s)
LNDIR=$(which lndir)
# Setup for our OS, Linux maybe someday.
case "${OS}" in
Linux)
PKG_DIR="${HOME}/.custom/pkgdir/${OS}"
GO_DIR="${HOME}/.custom/go/${OS}"
PLATFORM="${OS}"
SHA1=$(which sha1sum)
@fuzzy
fuzzy / deps.rb
Created March 29, 2012 22:39
Simple but functional dependancy resolution
#!/usr/bin/env ruby
class Graph
attr_accessor :items, :retv
def initialize(items=nil)
if items != nil
@items = items
@retv = []
end
end
@fuzzy
fuzzy / dmd2setup.sh
Created April 28, 2012 03:32
DMD (git) builds (supports multilib builds)
#!/bin/sh
run() {
${*} 1>>/tmp/log 2>>/tmp/log
}
case "$(uname -s)" in
Linux) NCPU=$(($(cat /proc/cpuinfo|grep MHz|wc -l)+1)) ;;
esac
@fuzzy
fuzzy / tags
Created April 28, 2012 20:24
tags file for vim, for the D runtime.
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
AA src/rt/aaA.d 95;" s file:
ADDPD src/core/simd.d 75;" e enum:XMM
ADDPS src/core/simd.d 74;" e enum:XMM
ADDSD src/core/simd.d 73;" e enum:XMM
ADDSS src/core/simd.d 72;" e enum:XMM
ADDSUBPD src/core/simd.d 271;" e enum:XMM
ADDSUBPS src/core/simd.d 272;" e enum:XMM
AES_BIT src/core/cpuid.d 291;" e enum:src/core/cpuid.d
AF_INET src/core/sys/posix/sys/socket.d 260;" e enum:src/core/sys/posix/sys/socket.d
@fuzzy
fuzzy / lndir.rb
Created May 14, 2012 04:26
lndir.rb (targeted to cpkg)
#!/usr/bin/env ruby
require 'find'
Find.find(ARGV[0]) do |f|
c = ARGV[0].split('/').size
d = f.split('/').size
e = "#{ENV['CPKG_SESSION_DIR']}/#{f.split('/')[c...d].join('/')}"
begin File.symlink(f, e);
rescue Errno::EEXIST
end
end
@fuzzy
fuzzy / bbldr.py
Created June 1, 2012 20:25
Handles making building world/kern a little more pleasant on the eyes, not done yet, only supports FreeBSD and doesn't log at the moment.
#!/usr/bin/env python
import os, re, sys, time
import subprocess as SP
class oList(list):
def join(self):
retv = ''
for i in self:
retv += i+' '
@fuzzy
fuzzy / pyrctl.c
Created June 3, 2012 20:33
Python rctl binding for FreeBSD 9.X+
/*-
* Copyright (c) 2010 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Edward Tomasz Napierala under sponsorship
* from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met: