Skip to content

Instantly share code, notes, and snippets.


Robert Moggach robmoggach

Block or report user

Report or block robmoggach

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
robmoggach /
Created Aug 17, 2011
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);
robmoggach /
Created Oct 25, 2012
bash command line script interface for zencoder-py
import os, sys
from optparse import OptionParser
from zencoder import Zencoder
if os.environ.get('ZENCODER_API_KEY'):
elif DEBUG:
robmoggach / sort
Created Dec 4, 2012
CLI sort a list by number of unique occurences
View sort
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
robmoggach /
Last active Dec 15, 2015
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):
robmoggach /
Created May 8, 2013
Python script to convert a hierarchy of fonts to OTF format This is useful if you have a huge collection of mac fonts that use resource forks and want cross platform fonts. Use at your own risk. It's not fully tested. Backup your originals before you run the script to be safe. It requires the fontforge python library.
import os, sys, string, re, MacOS
from string import capwords
import fontforge as ff
from optparse import OptionParser
TEST = False
SKIP_FILES = ['.DS_Store', '.AppleDB', 'convert_font.log', 'Icon?']
robmoggach /
Created May 8, 2013
Python script to change the font family of individual font files. It's useful if you have multiple fonts that should be the same family but are not grouped together in GUI software.
import os, sys, string, re, MacOS
from string import capwords
import fontforge as ff
from optparse import OptionParser
SKIP_FILES = ['.DS_Store', '.AppleDB', 'convert_font.log', 'Icon?']
class DirectoryWalker:
robmoggach / responsive-margins.less
Last active Aug 30, 2017
Responsive Margin & Padding Shortcuts for Twitter Bootstrap Using LESS CSS
View responsive-margins.less
// Responsive Margin & Padding Shortcuts for Twitter Bootstrap 3.0
// ---------------------------------------------------------------
// This is an addition to Twitter Bootstrap that allows additional margin and padding shortcuts
// for enhanced layout control purposes. It should be included after the bootstrap.less
// import statement or precompiled as you see fit. It differs from bootstrap standards in
// that for any given screen size it predetermines the margin/padding size. All you have to
// do is specify the size you want xs,sm,md,lg, or xl. The exception is for items that you
// want to be centered using auto left/right margins. This can be device responsive by
// specifying mc-xs, mc-sm, mc-md, or mc-lg depending on when you want that behavior.
robmoggach / PersonController.js
Created Jan 31, 2014
waterline issue with null foreign keys
View PersonController.js
index: function(req, res) {
.exec(function peopleFound(err, people) {
if (err) return res.json(err, 400);
if (!people) return res.json({ error: 'No people exist.' }, 404);
View macosx-ipnat
$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo natd -interface en1
$ sudo ipfw add divert natd ip from any to any via en1
robmoggach / importSVGFilesAsLayers.js
Created May 30, 2014
Illustrator script to import a folder of SVG files into separate offset layers
View importSVGFilesAsLayers.js
// Import SVG Files as Layers - Illustrator CS3 script
// Description: Imports a folder of SVG files as named layers into a new document
// Author: Robert Moggach (
// Version: 0.0.1 on 2014-05-29
function getFolder() {
return Folder.selectDialog('Please select the folder to be imported:', Folder('~'));
You can’t perform that action at this time.