Skip to content

Instantly share code, notes, and snippets.

View rjmoggach's full-sized avatar
🦄
React'ing.

Robert Moggach rjmoggach

🦄
React'ing.
View GitHub Profile
@rjmoggach
rjmoggach / cms_app.py
Last active December 15, 2015 06:19
I use this in a site-specific app called 'theme' to add django-wiki to django-cms painlessly. With this app activated there are two app integrations available in the pages Advanced menu ("Wiki Apphook" & "Notify Apphook") Add a new subpage, select the integration, mark the page as published and in menus and django-wiki is part of the site!
# django-wiki hook for django-cms
from django.conf.urls.defaults import patterns
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _
from wiki.urls import get_pattern as get_wiki_pattern
from django_notify.urls import get_pattern as get_notify_pattern
class WikiApphook(CMSApp):
@rjmoggach
rjmoggach / sort
Created December 4, 2012 18:52
CLI sort a list by number of unique occurences
echo 4 10 2 38 39 4 39 4 10 4 44 4 4 38 6 38 38 6 11 32 4 11 52 14 39 \
38 38 10 40 40 4 38 38 38 | fmt -1 | sort | uniq -c | sort -nr
@rjmoggach
rjmoggach / zencode.py
Created October 25, 2012 15:35
bash command line script interface for zencoder-py
#!/usr/bin/python
import os, sys
from optparse import OptionParser
from zencoder import Zencoder
DEBUG=False
if os.environ.get('ZENCODER_API_KEY'):
ZENCODER_API_KEY=os.environ.get('ZENCODER_API_KEY')
elif DEBUG:
@rjmoggach
rjmoggach / pixel2hex.java
Created August 17, 2011 04:51
Pixel 2 Hex Coordinate hack
// cellRadius is the distance from center to vertex or length of an edge
// longSpan is the long side of the triangle
// shortSpan is short side
float[][] XM = new float[][] { { 1 / (2*longSpan), -1 / cellRadius }, { 1 / longSpan, 0 } };
float[][] YM = new float[][] { { 1 / (2*longSpan), 1 / cellRadius }, { -1 / (2*longSpan), 1 / cellRadius } };
HVector pixel2hex(PVector pv) {
int n;
PVector mj = floorDot(pv, matrixXM);