Skip to content

Instantly share code, notes, and snippets.

View pneff's full-sized avatar

Patrice Neff pneff

View GitHub Profile
75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 7
@pneff
pneff / Back Template
Created February 14, 2014 08:33
Anki Card Type for multiple-choice
<div class="check-container"><span id="check"></span></div>
{{#Question}}
<p>{{Question}}</p>
{{/Question}}
{{#Image}}
<p class="image">{{Image}}</p>
{{/Image}}
#!/bin/bash
# Merges a local branch
set -e
# Needs a branch name as argument.
test -n "$1" || exit 1
# Update master to origin.
git fetch --no-recurse-submodules
git checkout master && git merge origin/master
@pneff
pneff / README.md
Last active December 22, 2015 21:39
palias command

This is a little script I use to avoid having to edit any files when I define a new alias.

Example usage:

$ palias g=git

This file needs to be sources from the main bash config file.

@pneff
pneff / tumblr-gist.js
Created July 10, 2012 13:40 — forked from slezica/tumblr-gist.js
tumblr gist embedder
var real_docwrite = document.write,
body = $('body');
(function insertGists(tags) {
var $tag;
if (tags.length > 0) {
tag = tags.shift();
$tag = $(tag);
document.write = function(stylesheet) {
$('head').append(stylesheet);
@pneff
pneff / app-common.js
Created July 10, 2012 13:25
Response design with Backbone.js
require(
[
"views/page",
"Router"
],
function (pageView, Router) {
pageView.render();
$('body').prepend(pageView.el);
new Router();
Backbone.history.start();
@pneff
pneff / index.html
Created October 14, 2011 18:39
Dojo build system example
<html>
<body>
<div dojo-type="mycorp.mywidget">testing</div>
<script src="/dojo/dojo.js"
djConfig="parseOnLoad: true"></script>
<script>dojo.require("mycorp.mywidget");</script>
</body>
</html>
@pneff
pneff / validate.py
Created October 14, 2011 17:16
Example for WsgiService validation
def asbool(s):
"""Simple function to convert any string into a boolean."""
return str(s).lower() in ('true', '1')
@mount('/validate/{user_id}')
@validate('user_id', re='[0-9]*', convert=int, doc='An integer user id')
class ValidatingResource(Resource):
@validate('activate', convert=asbool, doc='Will aways be True or False (default False)')
@validate('email', re='.*@.*', doc='Must contain an @')
def GET(self, user_id, email, activate=False):
@pneff
pneff / echo.py
Created October 14, 2011 16:57
Echo REST service
#!/usr/bin/env python
"""
echo web service: this is a simple WsgiService example.
"""
import datetime
from wsgiservice import Resource, get_app, mount, validate, expires
@mount('/echo')
class EchoResource(Resource):
"""Returns whatever the user inputs."""