Skip to content

Instantly share code, notes, and snippets.

@k1000
k1000 / mp4tomp3.sh
Created August 18, 2014 13:29
mp4 to mp3
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 256k "${f%.m4a}.mp3"; done
"""
Celery base task aimed at longish-running jobs that return a result.
``AwesomeResultTask`` adds thundering herd avoidance, result caching, progress
reporting, error fallback and JSON encoding of results.
"""
from __future__ import division
import logging
import simplejson
@k1000
k1000 / upstart.conf
Last active August 29, 2015 14:16
Server instrumentation with Upstart, Gunicorn, Django
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
script
NAME=app_name
PORT=8002
NUM_WORKERS=3
TIMEOUT=120
@k1000
k1000 / lighttpd_rev_proxy.conf
Created March 14, 2015 09:51
Lighttpd configuration for reverse proxy and static media
$HTTP["host"] =~ "www.domain.org" {
server.name = "www.domain.org"
server.document-root = "/path/to/media/"
$HTTP["url"] !~ "^/(static|media)" {
proxy.server = ( "" =>
(( "host" => "127.0.0.1", "port" => 8008 ))
)
}
}
@k1000
k1000 / fabfile.py
Created November 21, 2009 11:55
deploy django fabfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
@k1000
k1000 / django snippets 4 kate
Created April 4, 2010 09:43
kate django model snippet
<snippets license="BSD" filetypes="Python" authors="Kamil Selwa" name="Django1.2 snippets based on Texmate http://svn.textmate.org/trunk/Bundles/Python%20Django.tmbundle/Snippets/">
<item>
<displayprefix></displayprefix>
<match>m2m</match>
<displaypostfix></displaypostfix>
<displayarguments>FIELDNAME</displayarguments>
<fillin>${1:FIELDNAME} = models.ManyToManyField(${RELATED_MODEL}, related_name=${RELATED_NAME}, ${limit_choices_to={'pub_date__lte': datetime.now}} )</fillin>
</item>
<item>
<displayprefix></displayprefix>
@k1000
k1000 / CSS prepare 4 IE
Created April 11, 2010 21:44
build CSS 4 IE
# -*- coding: utf-8 -*-
import sys, re, time
#based on http://stackoverflow.com/questions/222581/python-script-for-minifying-css
#css = open( sys.argv[1] , 'r' ).read()
myfile = "style.css"
css = open( "style.css" , 'r' ).read()
css = re.sub( r'\s+', ' ', css )
print "/* ---------------------------------------------------------------------*/"
print "/* -------------- GENERATED FROM %s AT %s ------------*/" % (myfile, time.strftime( "%d %b %Y %H:%M", time.gmtime()) )
@k1000
k1000 / gist:653175
Created October 29, 2010 08:57
requirements.txt
#requirements
PIL>=1.1.6
MySQL-python>=1.2.2
python-memcached>=1.44
simplejson>=2.0.9
html5lib>=0.10
#fundamental apps
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
-e hg+https://sorl-thumbnail.googlecode.com/hg/#egg=sorl
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._