A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
For Mac users, I highly recommend iTerm 2 + Solarized Dark
| """ | |
| Forms to create payments with Systempay. | |
| Most code comes from https://github.com/dulaccc/django-oscar-systempay . | |
| With the following licence : | |
| Copyright (c) 2012 Pierre Dulac | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAG |
| import re | |
| from django import forms | |
| from django.contrib.sites.models import Site | |
| from django.utils.safestring import mark_safe | |
| class UrlWidget(forms.TextInput): | |
| def render(self, name, value, attrs=None): | |
| html = super(UrlWidget, self).render(name, value, attrs) |
| def get_error_message(form, field, message='required'): | |
| """Return an error message for a specific field on a form.""" | |
| return unicode(form.base_fields.get(field).error_messages[message]) |
| [ | |
| { | |
| "department": { | |
| "name": "Aisne", | |
| "number": "02" | |
| }, | |
| "postal_code": "02160", | |
| "name": "Œuilly" | |
| }, |
| #! /bin/bash | |
| export PATH="$PATH:/usr/local/bin:/" | |
| logger "test launched" | |
| casperjs test "$1" > "$2" & | |
| wait $! | |
| fail=$(grep -c "passed, 0 failed." $2) | |
| if [ $fail -eq 1 ]; then | |
| growlnotify "PASS" -m "casperjs" | |
| logger "test passed" | |
| else |
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
| # Alias ST2's command line tool for a shorter (easier-to-remember) name | |
| alias st="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" | |
| # Search for an open Sublime Text to a function definition | |
| function fx() { | |
| ack "function &?$1\(" | awk {'print $1'} | xargs st | |
| } | |
| # Example usage from the root of a WordPress repository |
| require 'digest/md5' | |
| def gfm(text) | |
| # Extract pre blocks | |
| extractions = {} | |
| text.gsub!(%r{<pre>.*?</pre>}m) do |match| | |
| md5 = Digest::MD5.hexdigest(match) | |
| extractions[md5] = match | |
| "{gfm-extraction-#{md5}}" | |
| end |