This file contains 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 | |
import collections | |
def get_current_mounts(): | |
""" Get the currently mounted filesystems. """ | |
# Reading from /proc/mounts is only consistent within a single read(3) | |
# call. Unfortunately, the maximum amount of data you can get from | |
# this file in a single call is hardcoded by the kernel to PAGE_SIZE | |
# (4096 bytes on x86). As a consequence, there is no way to read |
This file contains 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
@deferred | |
def deferred_check_missing(node, kw): | |
try: | |
json_request = kw.get("request").json_body | |
except ValueError: | |
raise Invalid(node, "Malformed JSON provided") | |
if "mail" not in json_request and "uuid" not in json_request: | |
raise Invalid(node, "Both mail and uuid are missing") |
This file contains 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
// Add Honeypot protection. | |
if (module_exists('honeypot')) { | |
honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction')); | |
} |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "precise64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" |
This file contains 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 fabric.api import local | |
import pip | |
def freeze (): | |
local("pip freeze > requirements.txt") | |
local("git add requirements.txt") | |
local("git commit -v") | |
def upgrade (): | |
for dist in pip.get_installed_distributions(): |
This file contains 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
<?php | |
// == is not transitive | |
if (0 == FALSE) { | |
echo "0 == FALSE\n"; | |
} | |
if ("string" == TRUE) { | |
echo "'string' is TRUE\n"; |
This file contains 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 collections import Mapping | |
from twisted.names import dns, server, client, cache | |
from twisted.application import service, internet | |
class MapResolver(client.Resolver): | |
def __init__(self, mapping, servers): | |
client.Resolver.__init__(self, servers=servers) |
This file contains 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 json | |
from flask import Flask, Response | |
app = Flask(__name__) | |
@app.route('/', defaults={'path': ''}) | |
@app.route('/<path:path>') | |
def catch_all(path): | |
ret = { | |
"something": 1, |
This file contains 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
def parse_commit(commit): | |
r = {} | |
info, diffstat = commit.split("ENDOFOUTPUTGITMESSAGEHERE") | |
info = info.strip() | |
lines = info.split('\n') | |
r["sha1"] = lines[0] | |
r["parent"] = lines[1] | |
r["author"] = lines[2] | |
r["commiter"] = lines[3] | |
r["timestamp"] = lines[4] |
This file contains 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/bash | |
USER=YOUR_USERNAME | |
HOST=YOUR_SERVER_HOSTNAME | |
WEBPATH=PATH_TO_WEBSERVER_ROOT | |
WEBURL=YOUR_URL | |
BACKUP_DIR=DIR_FOR_BACKUP | |
file=$(mktemp $BACKUP_DIR/XXXXXX) | |
mv $file $file.html |