Skip to content

Instantly share code, notes, and snippets.

View ojii's full-sized avatar

Jonas Obrist ojii

View GitHub Profile
@ojii
ojii / example.html
Created August 4, 2011 18:48
django-cms 2.2 tutorial app files
{% load cms_tags sekizai_tags %}
<!doctype html>
<head>
<title>{{ request.current_page.get_title }}</title>
{% render_block "css" %}
</head>
<body>
{% cms_toolbar %}
{% placeholder "main" %}
@ojii
ojii / macbook air
Last active September 26, 2015 18:07
my public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFMCGT2Lz0LKndS26QHocSa7bJ/8kabu1JQbYJQ8sGd0Y1RbOLnJZiibM0uE0mvSTeXyxuNJyyPe7nvSR4aNfq5bn7dA8ek7Siy1449kA22nwI/GM62fYfIDwAt6GJSvacCKaZWokQ/kiZ9UG9anE+RXR1GSDgE42CPfcT0VFDu83TQ0/55qEfmMWimFqoZG/dCUGarTmNta+irEy4JL0VNQ2B59IDW/WskmgP6EuGBUoCiuOy95SiFS5t/SQrRebpDTtLiSvb+4lbL2BmAUQnuPoYPgLbj62w5n/E9qWbYCck/00TGSjvQfZeSXJYDYlEpbVMGx7p0C3S89+KB26/ jonas@Jonass-MacBook-Air.local
@ojii
ojii / chainable_manager.py
Created August 22, 2011 09:01
ChainableManager for Django
# -*- coding: utf-8 -*-
from django.db import models
from django.db.models.query import QuerySet
class ChainableManager(models.Manager):
"""
class MyChainableManager(ChainableManager):
def active(self):
@ojii
ojii / autobild.sh
Created September 14, 2011 04:19
autobild.sh
#!/bin/sh
#
# Copyright (c) 2011, 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
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 175, current 1920 x 1080, maximum 1920 x 1080
default connected 1920x1080+0+0 0mm x 0mm
1920x1080 50.0* 51.0
1680x1050 52.0
1600x1024 53.0
1440x900 54.0
1400x1050 55.0
1360x768 56.0 57.0
1280x1024 58.0 59.0
from multiprocessing import Process
from django.core import serializers
from django.core.management import call_command
from StringIO import StringIO
def dump_database():
sio = StringIO()
call_command('dumpdata', stdout=sio, natural=True)
return sio.getvalue()
@ojii
ojii / autoruntests.sh
Created October 6, 2011 17:34
local mini ci
#!/bin/sh
run_tests()
{
COMMAND TO RUN YOUR TESTS
if [ "$?" != "0" ]
then
notify-send "BUILD FAILED" -i "error"
else
notify-send "Build Successful"
fi
@ojii
ojii / messages_test_mixin.py
Created October 7, 2011 10:01
django messages framework testing utilities
from contextlib import contextmanager
from django.contrib.messages.storage.base import BaseStorage, Message
from django.test.client import RequestFactory
from django.utils.decorators import method_decorator
class TestMessagesBackend(BaseStorage):
def __init__(self, request, *args, **kwargs):
self._loaded_data = []
super(TestMessagesBackend, self).__init__(request, *args, **kwargs)
@ojii
ojii / cbv_decorator.py
Created October 7, 2011 10:09
Django view decorator to CBV decorator
from django.utils.decorators import method_decorator
def cbv_decorator(decorator):
"""
Turns a normal view decorator into a class-based-view decorator.
Usage:
@cbv_decorator(login_required)
class MyClassBasedView(View):
@ojii
ojii / multi_hex_color_code_re.py
Created October 18, 2011 13:06
multi_hex_color_code_re.py
import re
GOOD = {
"#abc": ['abc'],
"#abc,#123": ['abc', '123'],
"567": ['567'],
"abc,123": ['abc', '123'],
"abc,#611": ['abc', '611'],
"#aaff33": ['aaff33'],
"9923cc": ['9923cc'],