Skip to content

Instantly share code, notes, and snippets.

#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@zen4ever
zen4ever / gist:961544
Created May 8, 2011 18:06
Cleanup ActionScript lineendings Mac
for i in $(find . -name '*.as' -exec file '{}' \; |
grep 'with CR line terminators' |
sed 's/:.*//g'); do
echo $i;
perl -pi -e 's/\r/\n/g;' "$i";
done
@zen4ever
zen4ever / urlrewrite.js
Created August 14, 2011 09:51
URLRewrite
(function(){
var url = new String(window.location);
window.location = url.replace(".marpasoft", "").replace("imported-", "");
})();
@zen4ever
zen4ever / settings.py
Created September 24, 2011 04:44
Static files config
import os.path
PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'site_media', 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
@zen4ever
zen4ever / widgets.py
Created September 25, 2011 21:43
Hour widget django
from django import forms
TIME_CHOICES = [('', '--------')]
for i in range(0, 24):
for m in ["00", "30"]:
hour = i % 12
if i == 12:
hour = 12
TIME_CHOICES.append(
("%02d:%s" % (i, m),
@zen4ever
zen4ever / install.sh
Created February 4, 2012 12:23
Install puppet via Gems/RVM on Debian (run as root)
sudo bash < <(curl https://raw.github.com/gist/1737523/puppet-install.sh )
@zen4ever
zen4ever / gist:2327666
Created April 7, 2012 11:13
Print available video capture formats on iOS
AVCaptureVideoDataOutput *videoOutput = [[AVCaptureVideoDataOutput alloc] init];
NSDictionary *formats = [NSDictionary dictionaryWithObjectsAndKeys:
@"kCVPixelFormatType_1Monochrome", [NSNumber numberWithInt:kCVPixelFormatType_1Monochrome],
@"kCVPixelFormatType_2Indexed", [NSNumber numberWithInt:kCVPixelFormatType_2Indexed],
@"kCVPixelFormatType_4Indexed", [NSNumber numberWithInt:kCVPixelFormatType_4Indexed],
@"kCVPixelFormatType_8Indexed", [NSNumber numberWithInt:kCVPixelFormatType_8Indexed],
@"kCVPixelFormatType_1IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_1IndexedGray_WhiteIsZero],
@"kCVPixelFormatType_2IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_2IndexedGray_WhiteIsZero],
@"kCVPixelFormatType_4IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_4IndexedGray_WhiteIsZero],
@zen4ever
zen4ever / gist:2494169
Created April 25, 2012 22:55
Decorator for using form with django-piston and JSON-encoded POST body
from django.utils import simplejson as json
from piston.decorator import decorator
def validate_json(form_class, class_method=True):
@decorator
def wrap(f, *args, **kwargs):
if class_method:
request = args[1]
@zen4ever
zen4ever / widgets.py
Created June 19, 2012 08:56
SpanWidget
class SpanWidget(forms.Widget):
"""
Renders a value wrapped in a <span> tag.
Based on Killarny, http://www.djangosnippets.org/snippets/1340/
Modified to place the value in a hidden control, so that it
returns a value in the GET/POST response.
"""
def __init__(self, attrs=None, choices=(), url=False):
super(SpanWidget, self).__init__(attrs=attrs)
self.url = url

Keybase proof

I hereby claim:

  • I am zen4ever on github.
  • I am zen4ever (https://keybase.io/zen4ever) on keybase.
  • I have a public key whose fingerprint is A2E7 B69E AA58 755C A525 B9C7 9963 9DEC 4A73 E6CD

To claim this, I am signing this object: