Skip to content

Instantly share code, notes, and snippets.

View Kwpolska's full-sized avatar

Chris Warrick Kwpolska

View GitHub Profile
--- /tmp/final1 2015-07-11 13:44:21.131354076 +0200
+++ /tmp/final2 2015-07-11 13:44:42.664368756 +0200
@@ -233,92 +233,78 @@
2315,
'99cab11de316dba3ac8bd1dbb921d1a7'],
'checker:': 'MD5Checker',
- 'deps:': [ 'posts/2014/10/13/revamping-my-projects-page-with-nikola.rst',
- 'themes/kw/templates/index.tmpl',
- 'posts/2011/03/05/zsh-a-shell-for-the-power-users.rst',
- '/home/kwpolska/git/nikola/nikola/data/themes/base-jinja/templates/comments_helper_intensedebate.tmpl',
@Kwpolska
Kwpolska / markdown-doc-parser.py
Last active August 29, 2015 14:23
Markdown document parser (via #python@freenode)
#!/usr/bin/env python3
import re
data = """# Foo
Print a string.
```sh
echo "foo"
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kwpolska
Kwpolska / nikola-manpage.txt
Created June 23, 2015 15:40
Nikola manpage
NIKOLA(1) User Commands NIKOLA(1)
NAME
Nikola - A Static Site and Blog Generator
SYNOPSIS
Create an empty site (with a setup wizard):
nikola init mysite
#!/usr/bin/env python3
from passlib.hash import bcrypt_sha256
print('u/u', end='')
try:
v = bcrypt_sha256.verify('admin', '$bcrypt-sha256$2a,12$St3N7xoStL7Doxpvz78Jve$3vKfveUNhMNhvaFEfJllWEarb5oNgNu')
print(' +' if v else ' -')
except TypeError:
print(' F')
#!/usr/bin/env python3
from passlib.hash import bcrypt_sha256
print('u/u', end='')
try:
bcrypt_sha256.verify('admin', '$bcrypt-sha256$2a,12$St3N7xoStL7Doxpvz78Jve$3vKfveUNhMNhvaFEfJllWEarb5oNgNu')
print(' +')
except TypeError:
print(' F')
# Don’t use this, use itertools.zip_longest() instead!
def alternate_all(*args):
ls = [iter(i) for i in args]
stops = 0 # cheat and get 9 LOC by making this a keyword argument
while stops != len(ls):
stops = 0
for l in ls:
try:
yield next(l)
except StopIteration:
@Kwpolska
Kwpolska / if-elif.py
Created April 19, 2015 16:43
Python if/elif/else instructions
input = ['foo deinstall 1', 'foo install 2', 'bar install 3', 'bar deinstall 4', 'foo bar 5']
for i in input:
# If the lines start or end with (de)install, you could try startswith/endswith instead.
if 'deinstall' in i:
print("Will deinstall:", i)
elif 'install' in i:
print("Will install:", i)
else:
print("Unrecognized:", i)
if True:
if True:
for key, value in (("host", host,),
("port", port,),
("user", username,),
("password", password,),):
pass
for key, value in (
("host", host,),
("port", port,),
("user", username,),
("password", password,),
):