Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
def extract_form_fields(self, soup): | |
"Turn a BeautifulSoup form in to a dict of fields and default values" | |
fields = {} | |
for input in soup.findAll('input'): | |
# ignore submit/image with no name attribute | |
if input['type'] in ('submit', 'image') and not input.has_key('name'): | |
continue | |
# single element nome/value fields | |
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'): |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
from datetime import datetime | |
######################################### | |
# Set up the django environment | |
######################################### | |
from django.core.management import setup_environ |
# saved from: http://pastie.org/private/bclbdgxzbkb1gs2jfqzehg | |
import sublime | |
import sublime_plugin | |
import subprocess | |
class RunExternalCommand(sublime_plugin.TextCommand): | |
""" | |
Runs an external command with the selected text, |
/* Flatten das boostrap */ | |
.well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid { | |
-moz-box-shadow: none !important; | |
-webkit-box-shadow: none !important; | |
box-shadow: none !important; | |
-webkit-border-radius: 0px !important; | |
-moz-border-radius: 0px !important; | |
border-radius: 0px !important; | |
border-collapse: collapse !important; | |
background-image: none !important; |
license: gpl-3.0 |
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate server.xml with the following command: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost:4443 | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl |
var d = document.createElement('div'); | |
d.innerHTML = '\ | |
<style>\ | |
*:not(.icon):not(i), *:not(.icon):not(i):after, *:not(.icon):not(i):before {\ | |
box-shadow: none !important;\ | |
text-shadow: none !important;\ | |
background-image: none !important;\ | |
}\ | |
*:not(.icon):not(i) {\ | |
border-color: transparent !important;\ |
// SVG2PNG | |
// By Cees Timmerman, 2024-04-05. | |
// Paste into console and adjust indices as needed. | |
let im = document.getElementsByTagName('img') | |
let fname = location.href | |
if (im.length < 1) { | |
let svg = document.getElementsByTagName('svg')[0] | |
let bb = svg.getBBox() | |
im = new Image(bb.width, bb.height) | |
im.src = 'data:image/svg+xml;charset=utf-8;base64,' + btoa(document.getElementsByTagName('svg')[0].outerHTML) |