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
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
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
# config/environment.rb => require 'xmlrpc/client' | |
#XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) | |
XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, true) unless XMLRPC::Config.const_defined?(:ENABLE_NIL_PARSER) | |
module XmlRpc | |
class Api | |
class << self | |
def method_missing(method, *args) |
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
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace Ladybear | |
{ | |
/// <summary> | |
/// Dispatches to an Action based on the first generic type parameter. |
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
public static class BubbleBabble | |
{ | |
private static readonly string vowels = "aeiouy"; | |
private static readonly string consonants = "bcdfghklmnprstvzx"; | |
public static string Convert(byte[] bytes) | |
{ | |
int seed = 1; | |
int rounds = 1 + bytes.Length / 2; | |
StringBuilder result = new StringBuilder(); |
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 xml.dom.minidom as xml | |
class Document(object): | |
""" | |
XML Document Builder | |
@author Simon Engledew | |
example: | |
dom = Document.catalog(version="1.0") |
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 __builtin__ | |
import operator | |
def merge(a, b): | |
a = a.copy() | |
a.update(b) | |
return a | |
class curry(object): | |
def __init__(self, fn, *args, **kwargs): |
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 python | |
import json | |
import requests | |
import json | |
import commands | |
import pipes | |
import sys | |
import glob | |
import os |
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
String.format = function format() | |
{ | |
var replacements = arguments; | |
return arguments[0].replace(/\{(\d+)\}/gm, function replace(string, match) { | |
return replacements[parseInt(match) + 1]; | |
}); | |
}; |