Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import smtplib | |
from flask import Flask | |
from flask import request, redirect | |
app = Flask(__name__) | |
SMTP_SERVER = 'smtp.gmail.com' | |
SMTP_PORT = 587 | |
#!/bin/bash | |
set -xi | |
sudo ip addr add 172.16.4.99/22 dev eth0 | |
GATEWAY=$(ip route show | grep default | awk '{ print $3}') | |
echo "Current default gateway: $GATEWAY" | |
if [ -z $GATEWAY ] | |
then | |
sudo ip route del default $GATEWAY |
ls *.gz -1 | xargs -I {} sh -c "gzip -d {} || true" 2>&1 | awk '{ print $2}' | sed 's/:$//' | xargs -t -I {} mv {} ../{}_bcorrupted |
[Unit] | |
Description=Automatically start CoW climb over the wall(Great Firewall) | |
After=network.target | |
[Service] | |
Type=simple | |
ExecStart=/usr/sbin/cow | |
User=samos | |
[Install] |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# This code is under the MIT license. | |
# Inspired by this StackOverflow question: | |
http://stackoverflow.com/questions/3295405/creating-django-objects-with-a-random-primary-key | |
import struct | |
from Crypto.Cipher import DES | |
from django.db import models | |
def base36encode(number): |
from functools import wraps | |
from django.http import HttpResponse | |
def json_response(dict_to_convert_to_json): | |
return HttpResponse(json.dumps(dict_to_convert_to_json), mimetype="application/json") | |
def required_parameters(parameters=('email', 'api_key'), http_method='POST'): | |
""" | |
Check if the required parameters are present in the request | |
@param parameters: The names of the parameters that should be supplied |