Skip to content

Instantly share code, notes, and snippets.

View marconi's full-sized avatar

Marconi Moreto Jr marconi

View GitHub Profile
@marconi
marconi / faster_zipfsong.py
Last active December 19, 2015 08:58
A slightly faster zipfsong implementation.
from heapq import heappush, heappop
def run():
album_songs_count, songs_count = raw_input().split()
album_songs_count = int(album_songs_count) + 1
songs_count = int(songs_count)
songs = []
for i in xrange(1, album_songs_count):
@marconi
marconi / hound.py
Created May 26, 2013 01:09
Caffeinated coffee watchdog.
"""
Hound: Caffeinated coffee watchdog
Watches root directory of coffee script files,
detects changes and new files then compiles them into
js files preserving directory structure.
"""
import os
import sys
import hmac
import hashlib
import time
import uuid
SYSTEM_WIDE_SECRET = 'supersecret'
GENERATED_TOKENS = {}
@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())
@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: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 / 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 / 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 / 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 / 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
######################################################