Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!env php | |
<?php | |
//script is intended to run from site directory | |
//tested on Joomla 2.5 | |
$currentDir = getcwd(); | |
echo "Running from \"${currentDir}\"\n"; | |
$configPath = $currentDir.'/configuration.php'; | |
$backupFolderPath = $currentDir.'/.backupdb'; | |
$backupPath = $backupFolderPath.'/backup.sql'; |
scramble = lambda word: [''.join(x) for c in range(len(word)) for x in itertools.combinations(word,c)] | |
# example: | |
# >>> scramble('sample') | |
# ['', 's', 'a', 'm', 'p', 'l', 'e', 'sa', 'sm', 'sp', 'sl', 'se', 'am', 'ap', 'al', 'ae', 'mp', 'ml', 'me', 'pl', 'pe', 'le', 'sam', 'sap', 'sal', 'sae', 'smp', 'sml', 'sme', 'spl', 'spe', 'sle', 'amp', 'aml', 'ame', 'apl', 'ape', 'ale', 'mpl', 'mpe', 'mle', 'ple', 'samp', 'saml', 'same', 'sapl', 'sape', 'sale', 'smpl', 'smpe', 'smle', 'sple', 'ampl', 'ampe', 'amle', 'aple', 'mple', 'sampl', 'sampe', 'samle', 'saple', 'smple', 'ample'] | |
# inspired by http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
hg log -G -l 10 --template "{rev} [{phase}] {date|isodate}, {author|person}, {node}\n {desc}\n\n" | |
#210 [public] 2016-04-23 02:41 +0300, d9k, 117988d537c4bfc178e44ef562a41944c1bdb942 | |
# one click buy form: payment system field |
//see https://github.com/mfunkie/react-overlay | |
import { Overlay } from 'react-overlay'; | |
// or | |
const { Overlay } = require('react-overlay'); | |
// or | |
var Overlay = require('react-overlay').Overlay; |
#/bin/bash | |
find tracks -size 0c -delete |
# run "bc -l" and then... | |
define fpow(a, b) { return e(b * l(a)); } | |
# example (calculate monthly percent by year percent): pow(1.08, 1/12) | |
# 1.00643403011000345482 |
function pyv() { | |
. ./venv/bin/activate | |
which python | |
python --version | |
} |
# schema | |
class LoginSchema(Schema): | |
login = SchemaNode( | |
String(), | |
title='Login', | |
widget=TextInputWidget(), | |
) | |
password = SchemaNode( |
## original is on https://gist.github.com/reedobrien/701444 | |
## it's newer version (works on python 3) | |
## code may contain bugs, check carefully | |
import deform | |
import deform.widget | |
from deform.widget import CheckedInputWidget | |
from colander import null, Invalid | |
from pyramid.threadlocal import get_current_request |