Skip to content

Instantly share code, notes, and snippets.

@geekman
geekman / lspkgbom
Created October 19, 2011 06:28
runs lsbom from .pkg without leaving temp files lying around
#!/bin/sh
# runs lsbom from .pkg without leaving temp files lying around
PKG=$1
[ ! -f "$PKG" ] && echo "usage: $0 <pkg-file> [ <lsbom-args> ... ]" && exit 1
shift
BOM=$(pkgutil --bom "$PKG")
lsbom $@ "$BOM"
@geekman
geekman / killgit
Created November 4, 2011 01:45
removes .git directories from working copy
#!/bin/sh -x
#
# killgit - removes .git directories recursively
#
find . -type d -name .git -exec rm -rf {} \;
@geekman
geekman / gist:1360530
Created November 12, 2011 13:38
dmesg output of ASUS P8H67-M EVO
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-131.17.1.el6.x86_64 (mockbuild@c6b5.bsys.dev.centos.org) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #1 SMP Thu Oct 6 19:24:09 BST 2011
Command line: ro root=UUID=fce6e337-a49c-4328-87f0-d2a27013bb73 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet vga=773 usbcore.autosuspend=1
KERNEL supported cpus:
Intel GenuineIntel
AMD AuthenticAMD
Centaur CentaurHauls
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009d800 (usable)
@geekman
geekman / ppxml.py
Created November 17, 2011 07:47
pretty-prints XML
#!/usr/bin/python
#
# pretty print xml
# modified from http://stackoverflow.com/questions/749796
#
import xml.dom.minidom
import codecs
import sys
@geekman
geekman / gist:1403032
Created November 29, 2011 02:06
extract native methods from ctags file
awk 'BEGIN {FS="\t"} $4 == "m" && index($3, " native ")' < tags
@geekman
geekman / gist:1441933
Created December 7, 2011 08:00
unpack struct from stream-like object
#
# example:
# f = open('/path/some/file', 'r')
# age, year, c = unpack('>HHB', f)
#
import struct
def unpack(fmt, f, offset=None):
"""Unpacks data read from file stream at optionally specified offset"""
@geekman
geekman / exeshim.c
Created January 4, 2012 10:46
simple shim (not really) executable for logging arguments
/*
* simple replacement executable for logging arguments
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int i;
@geekman
geekman / ks.cfg
Created March 12, 2012 05:24
Kickstart file for a minimal CentOS VM
#
# Kickstart file for minimal CentOS VM
# http://fedoraproject.org/wiki/Anaconda/Kickstart
#
# to use, pass ks=http://server/ks.cfg to kernel
#
#version=RHEL6
install
text
@geekman
geekman / gist:2779738
Created May 24, 2012 06:03
list normal open windows (like Alt-Tab or Task Manager does)
import win32con
import win32gui
import ctypes
_user32 = ctypes.windll.user32
excludes = (_user32.GetShellWindow(), win32gui.FindWindow('Shell_TrayWnd', None))
winlist = []
win32gui.EnumWindows(lambda hwnd, l: l.append(hwnd) if \
schtasks /Change /TN \Microsoft\Windows\Maintenance\WinSAT /DISABLE