Skip to content

Instantly share code, notes, and snippets.

View ojii's full-sized avatar

Jonas Obrist ojii

View GitHub Profile
@ojii
ojii / deferred.js
Created July 18, 2012 12:01
Twisted style Deferred in Javascript
/*
* Copyright (c) 2012, Jonas Obrist
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@ojii
ojii / Info
Created July 11, 2012 14:03
DjangoCon Europe 2012 pictures
"Raw" picture material from Sunday-Wednesday at DjangoCon Europe 2012. By raw I mean I didn't filter out bad images, I just removed those that showed laptop screens with legible emails etc on them.
File Size: 5787908 Bytes
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
@ojii
ojii / info.txt
Created July 7, 2012 18:18
raw DjangoCon 2012 video material
Raw video material from DjangoCon Europe 2012.
File size: 29013548 Bytes
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
@ojii
ojii / Readme.rst
Created July 5, 2012 15:25
Minimial Flask app for frontend guys

How to run this

First time

  1. Make a virtualenv: virtualenv env
@ojii
ojii / chainable_manager.py
Created July 3, 2012 13:24
Django Model Managers
from django.db import models
class ChainableManager(models.Manager):
"""
A manager that allows chaining of all methods defined on it.
Example:
class MyManager(ChainableManager):
def active(self):
@ojii
ojii / make_as_tag.py
Created June 28, 2012 15:44
experimental function to turn classytags tags into as tags
from deepcopy import deepcopy
from classytags.core import TagMeta
from classytags.arguments import ARgument
from classytags.helpers import AsTag
def make_as_tag(original, new_name):
class NewTag(AsTag, original):
name = new_name
options = deepcopy(original.options)
@ojii
ojii / switch.py
Created March 28, 2012 10:01
Switch-Case in the Django Template Langauge
# -*- coding: utf-8 -*-
"""
In Django 1.4+ you should probably use if-elif-else-endif instead of this.
Usage:
{% switch somevar %}
{% case 1 %}
...
{% endcase %}
@ojii
ojii / paypalipn.py
Created February 26, 2012 16:01
paypalipn
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from raven.contrib.django.models import get_client
from registration.forms import IPNForm
import logging
import urllib2
URLS = {
@ojii
ojii / gist:1869970
Created February 20, 2012 16:20
Create free Clickmap account
URI, POST
/api/account/register
data = {
'username': '...',
'password': '...',
'email': '...', # optional
}
@ojii
ojii / py.js
Created February 3, 2012 17:48
Pythonify Javascript
// Array
Array.prototype.remove = function(ele){var index = this.indexOf(ele); if(index != -1){this.splice(index, 1);}};
Array.prototype.copy = function(){return this.slice(0);};
// String
String.prototype.endswith = function(suffix) {return this.indexOf(suffix, this.length - suffix.length) !== -1;};
String.prototype.startswith = function(prefix) {return this.indexOf(prefix) === 0;};
String.prototype.join = function(seq){return seq.join(this);};
String.prototype.isdigit = function(){return !isNaN(parseInt(this));};