Skip to content

Instantly share code, notes, and snippets.

View marconi's full-sized avatar

Marconi Moreto Jr marconi

View GitHub Profile
@marconi
marconi / model_api.py
Created August 25, 2011 00:00
Cleaner model API
import copy
class Field(object):
def __init__(self, value=None):
self.name = None
self.value = value
def set_field_name(self, name):
"""
@marconi
marconi / post-receive
Created August 27, 2011 05:13
Found this nice script for adding git commits to trac.
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2010 Grzegorz Sobański
#
# Git post receive script developed for mlabs
# - adds the commits to trac
# based on post-receive-email from git-contrib
#
@marconi
marconi / cloudcli.py
Created March 16, 2012 11:25
A basic Dropbox client.
# -*- coding: utf-8 -*-
#####################################################
## Cloud CLI is a basic Dropbox client that lets you:
## upload, download, move and list files.
##
## Requirements: cmd2, Dropbox Python SDK
######################################################
@marconi
marconi / redis_rpush_test.py
Created June 12, 2012 07:16
Redis index by RPUSH test
import redis
import gevent
import itertools
from gevent import monkey
monkey.patch_socket()
QUEUE_NAME = 'queue'
@marconi
marconi / watchless.py
Created October 5, 2012 10:26
A less file compiler.
# -*- coding: utf-8 -*-
"""
Watchless will compile your less files whenever it detects changes.
Accepts one argument, the path where your less files are stored.
Say your less files are store in /static/less and it contains the file
layout.less, watchless will compile it and store the compiled css file
in /static/css/layout.css.
@marconi
marconi / watchless.py
Created October 6, 2012 03:46
A more intelligent less file compiler.
# -*- coding: utf-8 -*-
"""
Watchless will compile your less files whenever it detects changes.
Accepts one argument, the path where your less files are stored.
Say your less files are store in /static/less and it contains the file
layout.less, watchless will compile it and store the compiled css file
in /static/css/layout.css.
@marconi
marconi / gist:3968102
Created October 28, 2012 09:02
Cake file that watches coffee files and compiles them.
###
Compiles coffee scripts from coffee/ to js/.
###
fs = require 'fs'
{exec} = require 'child_process'
util = require 'util'
path = require 'path'
appFiles = []
@marconi
marconi / gist:4134148
Created November 23, 2012 05:37
A bare wsgi app.
def app(environ, start_response):
"""Simplest possible application object"""
data = 'Hello, World!\n'
status = '200 OK'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len(data)))
]
start_response(status, response_headers)
return iter([data])
@marconi
marconi / gist:4156372
Created November 27, 2012 19:17
Automount vendor apps in pecan
# <app>.controllers.root.py
class BaseController(object):
"""
Base controller which main app should extend to auto mount vendor apps.
"""
def __init__(self):
for app, pkg in conf.vendor_apps:
root_controller = importlib.import_module("%s.controllers.root" % pkg)
setattr(self, app, root_controller.RootController())
import hmac
import hashlib
import time
import uuid
SYSTEM_WIDE_SECRET = 'supersecret'
GENERATED_TOKENS = {}