Skip to content

Instantly share code, notes, and snippets.

View rochacbruno's full-sized avatar
🛠️
Working on Galaxy_ng and Dynaconf

Bruno Rocha rochacbruno

🛠️
Working on Galaxy_ng and Dynaconf
View GitHub Profile
@coderanger
coderanger / admin.py
Created August 31, 2010 22:45
Pagination for admin inlines
class MyInline(admin.TabularInline):
model = MyModel
extra = 0
template = 'admin/edit_inline/list.html'
def get_formset(self, request, obj=None, **kwargs):
FormSet = super(ActivationKeyInline, self).get_formset(request, obj, **kwargs)
class NewFormSet(FormSet):
def _construct_forms(self, *args, **kwargs):
qs = self.get_queryset()
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@klipstein
klipstein / b64field.py
Created November 22, 2010 12:25
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
@dnouri
dnouri / gist:867230
Created March 12, 2011 13:25
guess_time: Parsing time from user input.
import time
def guess_time(s):
"""
>>> guess_time('20:00')
(20, 0)
>>> guess_time(' 23:59')
(23, 59)
>>> guess_time('20:00foo')
(20, 0)
@uhop
uhop / admin.py
Created March 14, 2011 00:31
Adding Dojo's rich editor to Django's Admin.
# Example how to add rich editor capabilities to your models in admin.
from django.contrib.admin import site, ModelAdmin
import models
# we define our resources to add to admin pages
class CommonMedia:
js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',
@mattgorecki
mattgorecki / gist:974920
Created May 16, 2011 17:32
web2py mobile browser detection
# Detect mobile device. Set to mobile view if available
from mobile.sniffer.detect import detect_mobile_browser
if detect_mobile_browser(request.env.http_user_agent):
mobile_view = '%s.mobile.%s' % (request.function, request.extension)
if os.path.exists(os.path.join(request.folder, 'views',request.controller, mobile_view)):
response.view = '%s/%s' % (request.controller, mobile_view)
@rochacbruno
rochacbruno / 1humano.py
Created May 29, 2011 11:55
Seres humanos comuns e a reprodução desenfreada orientada a objetos
#--*-- coding: UTF-8 --*--
class Humano(object):
"""Human Being"""
def __init__(self, nome, pai=None, mae=None):
print "alguém fez besteira e colocou mais um ser Humano no mundo \n"
self.nome = nome
self.pai = pai
self.mae = mae
self.filhos = 0
@rochacbruno
rochacbruno / 1humano.py
Created May 30, 2011 23:43 — forked from douglascamata/1humano.py
Seres humanos comuns e a reprodução desenfreada orientada a objetos
#encoding: utf-8
class Humano(object):
"""Human Being"""
def __init__(self, nome, pai=None, mae=None):
print "alguem fez besteira e colocou mais um ser Humano no mundo \n"
self.nome = nome
self.pai = pai
self.mae = mae
@scturtle
scturtle / ftpserver.py
Created June 20, 2011 16:03
simple ftp server by python
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')
#rec
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1600x900 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mkv
###convert
mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 aula3.mkv -o aula3_mencoder.avi
#MERGE
mkvmerge -o complete.mkv part1.mkv +part2.mkv +part3.mkv +part4.mkv
#conv ffmpeg