Skip to content

Instantly share code, notes, and snippets.

View zachwalton's full-sized avatar

Zach Walton zachwalton

  • San Francisco, CA
View GitHub Profile
@zachwalton
zachwalton / gist:3ce41e064f177635d05f
Created September 5, 2014 18:34
Discover FDs on lazily umounted filesystems in Linux
There's no "right" way to do this, so...
When you lazily umount a filesystem in Linux, procfs changes /proc/pid/fd/* from absolute to relative paths. E.g. if you have a tail open on the FS:
[uid] 31624 0.0 0.0 100924 616 pts/86 Ss+ 10:12 0:00 tail -f /mnt/test
$ readlink /proc/31624/fd/3
/mnt/test
Then lazily umount the FS:
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind);
my $VERSION = '1.00';
my %IRSSI =
(
authors => 'Zach Walton',
contact => 'zacwalt@gmail.com',
name => 'birdsummoner',
description => 'Summon jonEbird back to #linux',
@zachwalton
zachwalton / gist:4436809
Last active December 10, 2015 12:49
Python Decorators in Perl
Modified from http://lemonnier.se/erwan/blog/item/45/
#
# connTest is our decorator subroutine.
#
sub connTest {
my $f = @_;
return sub {
&$f();
}
@zachwalton
zachwalton / bintree.py
Last active December 12, 2015 00:19
binary tree that serializes [a-zA-Z] into a string with n chars, where n is the number of nodes in the tree
import pprint
import string
import sys
HAS_LEFT_CHILD = 1 << 7
HAS_RIGHT_CHILD = 3 << 6
HAS_BOTH_CHILDREN = 1 << 6
HAS_NO_CHILDREN = ~(3 << 6)
@zachwalton
zachwalton / gist:5287198
Created April 1, 2013 19:46
a method and a class for interacting over a socket
class Listener(object):
"""
This accepts a list of `commands` and associated `responses` and opens a
socket on `port`. It then listens for any of the commands and dumps
the associated response.
Example:
Listener.listen(port=57359,
commands = [ "give_me_your_name",
@zachwalton
zachwalton / gist:5490478
Created April 30, 2013 17:49
theoretically a way to interact with the asmlib ABI. written with a lot of help from this awesome article: http://www.scaleabilities.co.uk/2013/02/07/diagnosing-asmlib/ i'm uploading this as a gist because it is a proof of concept and not syntactically correct. i need a testing environment, which i don't have right now. usage: ./asm_release ASMX…
//
// asm_release.c
//
// Releases disks from ASM after removing them from a disk group by utilizing the
// oracleasm ABI.
//
// Usage: ./asm_release ASMXXXXXX
// - where ASMXXXXXX is the ASM disk name.
//
// Constructed with help from the following article:
@zachwalton
zachwalton / gist:6226970
Created August 14, 2013 00:21
reads the stage-1 MBR bootloader to discover the location of the stage-2 bootloader. dumps the first 512 bytes of the secondary bootloader to the screen (filtered through hexdump -C)
dd if=/dev/sda \
of=/dev/stdout \
bs=512 \
skip=$( \
dc -e " 16i $( \
dd if=/dev/sda \
of=/dev/stdout \
bs=512 \
count=1 2> /dev/null \
| hexdump -C \
@zachwalton
zachwalton / gist:699391cd1cdc5bac76bc
Created February 4, 2016 21:22
convert dropbox urls to raw
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '0.0.1';
%IRSSI = (
authors => '',
contact => '',
name => 'fix_dropbox',
description => 'unfuck dropbox urls',
license => '',
@zachwalton
zachwalton / GOOOOOOOOAL
Last active February 19, 2016 20:26
GOOOOOOOOAL
zach (python):
import inspect
def g(v=None):
f=str(inspect.currentframe().f_back)
if not v:
g.__dict__[f] = g.__dict__[f] + 'O' if g.__dict__.get(f) else 'GO'
return g
print g.__dict__.pop(f, 'G') + 'AL'
@zachwalton
zachwalton / git-prompt.sh
Created July 17, 2016 22:40
git-prompt.sh, emoji version
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).