Skip to content

Instantly share code, notes, and snippets.

View heynemann's full-sized avatar

Bernardo Heynemann heynemann

View GitHub Profile
@heynemann
heynemann / gist:1061888
Created July 3, 2011 02:14
installing provy
$ pip install provy
@heynemann
heynemann / gist:1061894
Created July 3, 2011 02:23
Provy install
# make sure fabric, jinja2 and m2crypto are installed
$ pip install fabric
$ pip install jinja2
$ pip install m2crypto
# now actually installing it
$ git clone [email protected]:heynemann/provy.git
$ python setup.py install
$ provy --version
@heynemann
heynemann / VagrantFile
Created July 3, 2011 02:57
provy sample code
Vagrant::Config.run do |config|
config.vm.define :frontend do |inner_config|
inner_config.vm.box = "base"
inner_config.vm.forward_port("http", 80, 8080)
inner_config.vm.network("33.33.33.33")
end
config.vm.define :backend do |inner_config|
inner_config.vm.box = "base"
@heynemann
heynemann / askfor.py
Created July 3, 2011 04:26
provy sample code 2
servers = {
'frontend': {
'address': '33.33.33.33',
'user': 'vagrant',
'roles': [
FrontEnd
],
'options': {
'mysql-db-password':
AskFor('mysql-db-password',
@heynemann
heynemann / running-provy
Created July 12, 2011 23:46
provy sample code 3
provy -s server -p password mysql-db-password=somepass
@heynemann
heynemann / reader.py
Created January 3, 2012 01:15
NAMED PIPE READING IMAGE
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
NAMED_PIPE = '/tmp/PIPE'
def main():
if not os.path.exists(NAMED_PIPE):
os.mkfifo(NAMED_PIPE)
@heynemann
heynemann / gist:1771563
Created February 8, 2012 17:42
Getting exif tags
from PIL.ExifTags import TAGS
import PIL
img = PIL.Image.open('sony-cybershot.jpg')
exif = img._getexif()
for k, v in exif.items():
print TAGS.get(k, k), v
def render(self, context):
content = self.nodelist.render(context)
if not settings.COMPRESS or not len(content.strip()):
return content
if self.kind == 'css':
compressor = CssCompressor(content)
if self.kind == 'js':
compressor = JsCompressor(content)
cachekey = "%s-%s" % (compressor.cachekey, self.mode)
output = self.cache_get(cachekey)
@heynemann
heynemann / gist:3341234
Created August 13, 2012 14:30
nginx conf for thumbor
upstream thumborbe {
server thumbor.myhost.com:8090 ;
server thumbor.myhost.com:8091 ;
server thumbor.myhost.com:8092 ;
server thumbor.myhost.com:8093 ;
server thumbor.myhost.com:8094 ;
server thumbor.myhost.com:8095 ;
}
location ~* "^/.{28}/.*(jpg|jpeg|gif|png)(#.*)?$" {
@heynemann
heynemann / mapper.py
Created August 13, 2012 14:33
r3 sample mapper
#!/usr/bin/python
# -*- coding: utf-8 -*-
from r3.worker.mapper import Mapper
class CountWordsMapper(Mapper):
job_type = 'count-words'
def map(self, lines):
#time.sleep(0.5)