Skip to content

Instantly share code, notes, and snippets.

Philippe O. Wagner philippeowagner

Block or report user

Report or block philippeowagner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am philippeowagner on github.
  • I am philippeowagner ( on keybase.
  • I have a public key ASCRLZctXidnKKuOdsm8_MzAeoxkKPYBx-HqPpoQ522Qdgo

To claim this, I am signing this object:

View gist:9263b6460a61e8c47cedce9e1d3ba3d3
from itertools import chain
from operator import attrgetter
def join_list(*args, sort_key=None):
if sort_key:
return sorted(chain(args), key=attrgetter(sort_key))
return list(chain(args))
philippeowagner / gist:7f52ebdd555bc26e0643e550c2eece1b
Created May 31, 2017 — forked from renyi/gist:7300109
Replaces {% url something %} with {% url "something" %}
View gist:7f52ebdd555bc26e0643e550c2eece1b
find . -name "*.html" -print0 | xargs -0 sed -i "" 's/ url \([^" >][^ >]*\)/ url "\1"/g'
philippeowagner / GiveMeMarkdown.js
Last active Mar 16, 2017
A bookmarklet that takes an HTML selection and converts it to Markdown
View GiveMeMarkdown.js
// GiveMeMarkdown is a bookmarklet that takes an HTML selection and converts it to Markdown
// javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";"loadingp";"20px";"#fff";"20px";;"fixed";"9999999";".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src=""+(Math.random());})();
(function () {
function callback() {
(function ($) {
var raw, userSelection;
if (window.getSelection) {
// W3C Ranges
userSelection = window.getSelection ();
// Get the range:
# taken from
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
philippeowagner / server.badbots
Last active Jan 12, 2019 — forked from hans2103/server.badbots
NGINX to block bad bots. (add Twenga|TwengaBot if you want to exclude them too)
View server.badbots
if ($http_user_agent ~* (360Spider||Abonti|AcoonBot|Acunetix|adbeat_bot||adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzz
philippeowagner /
Created Jul 14, 2016 — forked from yprez/
Django rest framework - Base64 image field
import base64
from django.core.files.base import ContentFile
from rest_framework import serializers
class Base64ImageField(serializers.ImageField):
def from_native(self, data):
if isinstance(data, basestring) and data.startswith('data:image'):
# base64 encoded image - decode
philippeowagner /
Created Jul 5, 2016 — forked from zacharyvoase/
A li’l class for data URI manipulation in Python.

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.


philippeowagner /
Created Jun 16, 2016
Terminal Colors for Python
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
View get a request
from django.test.client import RequestFactory
rf = RequestFactory()
get_request = rf.get('/hello/')
post_request ='/submit/', {'foo': 'bar'})
You can’t perform that action at this time.