Skip to content

Instantly share code, notes, and snippets.

View molszewski's full-sized avatar
🐱
Possibly at home with ~3 cats

Michal Olszewski molszewski

🐱
Possibly at home with ~3 cats
View GitHub Profile
@molszewski
molszewski / keybase.md
Created December 1, 2014 10:09
keybase proof

Keybase proof

I hereby claim:

  • I am molszewski on github.
  • I am molszewski (https://keybase.io/molszewski) on keybase.
  • I have a public key whose fingerprint is 6B76 B083 CD51 AC01 9598 2EE8 8EFF 3760 5990 CD02

To claim this, I am signing this object:

@molszewski
molszewski / .bash_profile.sh
Created September 19, 2014 13:11
bash profile
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
@molszewski
molszewski / mac_osx_settings.sh
Last active August 29, 2015 14:06
mac osx settings
defaults write -g ApplePressAndHoldEnabled -bool false
defaults write -g InitialKeyRepeat -int 18
defaults write -g KeyRepeat -int 0
defaults write com.apple.finder AppleShowAllFiles 1
@molszewski
molszewski / forms.twig
Last active August 29, 2015 14:05
Handful of macros that help integrating Silex/Symfony Form & Validator components with Bootstrap
{% macro errors_for(field) -%}
{% if not field.vars.valid %}
<div class="alert alert-danger form-error" role="alert">
<ul class="list-unstyled">
{% for error in field.vars.errors %}
<li>{{ error.message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
#!venv/bin/python
# Requirements:
# - virtualenv in venv dir (virtualenv venv)
# - Flask: venv/bin/pip install flask
# - formencode: venv/bin/pip install formencode
# - FormEncode-Jinja2: venv/bin/pip install FormEncode-Jinja2
from flask import render_template_string, flash, redirect, request
from formencode import Invalid, variabledecode, Schema, ForEach, NoDefault
@app.route("/claims/new-employment-end-date", methods=["POST"])
def new_employment_end_date():
def on_success(validated):
draft_id = session.get('draft_id')
day = validated['new_job_end']['day']
month = validated['new_job_end']['month']
year = validated['new_job_end']['year']
date = "{day}/{month}/{year}".format(**locals())
#!venv/bin/python
# Requirements:
# - virtualenv in venv dir (virtualenv venv)
# - Flask: venv/bin/pip install flask
# - formencode: venv/bin/pip install formencode
# - FormEncode-Jinja2: venv/bin/pip install FormEncode-Jinja2
from flask import render_template_string, flash, redirect, request
from formencode import Invalid, variabledecode, Schema, All
@molszewski
molszewski / weasyprint_spike.py
Created January 29, 2014 14:55
WeasyPrint spike
#!venv/bin/python
# Script requires:
# - virtualenv in venv dir (virtualenv venv)
# - XQuartz-2.7.5 (installed separately)
# - cairo pango gdk-pixbuf libxmllibxslt libffi (brew install cairo pango gdk-pixbuf libxmllibxslt libffi)
# - WeasyPrint (pip install WeasyPrint)
from weasyprint import HTML
@molszewski
molszewski / reportlab_spike.py
Last active August 29, 2015 13:55
ReportLab spike
#!venv/bin/python
# Script requires:
# - virtualenv in venv dir (virtualenv venv)
# - reportlab (pip install reportlab)
from reportlab.pdfgen import canvas
c = canvas.Canvas("report_lab_spike_output.pdf")
c.drawString(10,600,"Hello World")
@molszewski
molszewski / weasyprint_jinja2_spike.py
Last active August 29, 2015 13:55
WeasyPrint + Jinja2 spike
#!venv/bin/python
# Script requires:
# - virtualenv in venv dir (virtualenv venv)
# - XQuartz-2.7.5 (MacOSX only, installed separately from https://xquartz.macosforge.org/landing/)
# - cairo pango gdk-pixbuf libxmllibxslt libffi (brew install cairo pango gdk-pixbuf libxmllibxslt libffi)
# - WeasyPrint (pip install WeasyPrint)
# - Jinja2 (pip install Jinja2)
from weasyprint import HTML