Skip to content

Instantly share code, notes, and snippets.

View fuzzy's full-sized avatar

Mike 'Fuzzy' Partin fuzzy

View GitHub Profile
@fuzzy
fuzzy / bit.rb
Created June 21, 2013 15:28
an example of metaprogramming in ruby
class Logging
def initialize
@PROMPTS = {
:info => '>>'.bold.green,
:warn => '**'.bold.yellow,
:error => '!!'.red,
:fatal => '!!'.bold.red,
:debug => '**'.bold.cyan
}
@fuzzy
fuzzy / car.py
Last active December 17, 2015 18:09
#!/usr/bin/env python
################################################################################
# #
# Copyright (c) 2013, Mike 'Fuzzy' Partin <[email protected]> #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
@fuzzy
fuzzy / output.txt
Created May 26, 2013 02:58
car.py output
$ ls
./ ../ Python-2.7.4.tar.bz2 car.py* ruby-1.8.6-p420.tar.gz
$ ./car.py
Sat May 25 19:55:33 2013
objA = Libarchive(fname="/home/mpartin/.cpkg/tmp/ruby-1.8.6-p420.tar.gz", debug=True)
DEBUG: Loaded library <CDLL '/usr/lib/libarchive.so', handle 80079d000 at 801775f90>
objB = Libarchive(fname="/home/mpartin/.cpkg/tmp/Python-2.7.4.tar.bz2", debug=True)
DEBUG: Loaded library <CDLL '/usr/lib/libarchive.so', handle 80079d000 at 80177e0d0>
ret = objA.extractArchive()
#!/usr/bin/env python
################################################################################
# #
# Copyright (c) 2013, Mike 'Fuzzy' Partin <[email protected]> #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
#!/usr/bin/env ruby
require 'drb'
class PingCheck
attr_accessor :cfg
def initialize(count=3, wait=3)
@cfg = Hash.new
@cfg[:count] = count
@cfg[:wait] = wait
@fuzzy
fuzzy / slndir.sh
Created August 5, 2012 16:07
lndir in Sh
slndir() {
if [ -z "${1}" ] || [ -z "${2}" ]; then
echo 'Usage: slndir /dir1 /dir2/'
else
SRC=${1}
if [ "${2}" = "." ] || [ "${2}" = "./" ]; then
DST=${PWD}
else
DST=${2}
fi
@fuzzy
fuzzy / cpkg-usage
Created July 31, 2012 22:17
cpkg rewrite usage
$ cpkg
cpkg <command> <...>
Commands:
list [pkg] List packages or versions of [pkg]
use [global|(session)] <pkg>-<ver> Use <pkg>-<ver>
drop [global|(session)] <pkg>-<ver> Stop using <pkg>-<ver>
In progress:
@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:
@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 / 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