This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chroot_jail { | |
TEMP="/tmp/$$.$(date +%s)" | |
mkdir "$TEMP" | |
sudo unionfs "$1=RW:/=RO" "$TEMP" -o allow_other -o dev -o cow | |
trap "sudo fusermount -u \"$TEMP\" && rm -r \"$TEMP\"" INT TERM EXIT | |
sudo chroot "$TEMP" /bin/bash -c "$(cat)" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def from_pattern(pattern, type): | |
def coerce(value, *args): | |
value = str(value) | |
match = pattern.search(value) | |
if match is not None: | |
return type(match.group(1), *args) | |
raise ValueError("unable to coerce '%s' into a %s" % (value, type.__name__)) | |
return coerce |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
import snack, ipaddr, optparse, re, shlex | |
parser = optparse.OptionParser() | |
parser.add_option('--no-cancel', action='store_true', dest='no_cancel', help='Do not display a cancel button') | |
parser.add_option('--title', action='store', dest='title', default='Configure Networking', help='set the form title') | |
parser.add_option('--interface', action='store', dest='interface', default='eth0', help='interface to edit') | |
parser.add_option('--interfaces-file', action='store', dest='interfaces_file', default='/etc/network/interfaces', help='target interfaces file to edit') | |
parser.add_option('--dns-file', action='store', dest='dns_file', default='/etc/resolvconf/resolv.conf.d/base', help='target dns file to edit') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cache | |
class << self | |
def read(key, &block) | |
if (value = self[key]).nil? and block_given? | |
value = block.call | |
self[key] = value | |
end | |
return value | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
def self.before_filter_in_instance(&block) | |
before_filter do |controller| | |
controller.instance_eval(&block) | |
end | |
end | |
# fails! | |
# params is not available |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# post commit hook to play "Hallelujah" after a commit | |
FILENAME=~/.git/post-commit.mp3 | |
DIRECTORY=`dirname $FILENAME` | |
if [ ! -d "$DIRECTORY" ] | |
then | |
mkdir "$DIRECTORY" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SEThreadInvocation.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface SEThreadInvocation : NSObject | |
{ | |
NSThread * _thread; | |
NSInvocation * _invocation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if GC.respond_to?(:copy_on_write_friendly=); GC.copy_on_write_friendly = true; end | |
def pidfile | |
@pidfile ||= File.expand_path(File.join('..', '..', 'tmp', 'pids', 'consumer.pid'), __FILE__) | |
end | |
case ARGV.first | |
when 'start' then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl rand 9 -base64 |