Skip to content

Instantly share code, notes, and snippets.

@rcarmo
rcarmo / hosetests.hy
Created December 7, 2013 19:19
First stab at a plugin for running tests in hylang
(import os sys logging nose)
(import [nose.plugins [Plugin]])
(setv log (.getLogger logging "nose.plugins.hylang"))
(.setLevel log logging.DEBUG)
(defclass HoseTests [Plugin]
[[name "HoseTests"]
[options
@rcarmo
rcarmo / setup.hy
Last active December 28, 2015 05:59
Setuptools in hylang
(import [os [walk]]
[os.path [join splitext]]
[distutils.core [setup]]
[distutils.command.build [build]]
[fnmatch [fnmatch]]
[subprocess [Popen PIPE]])
(defn glob [path pattern]
"find all files matching a given pattern"
(for (step (walk path))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
# YOU NEED TO INSERT YOUR APP KEY AND SECRET BELOW!
# Go to dropbox.com/developers/apps to create an app.
app_key = 'YOUR_APP_KEY'
app_secret = 'YOUR_APP_SECRET'
# access_type can be 'app_folder' or 'dropbox', depending on
# how you registered your app.
access_type = 'app_folder'
import os
import sys
import pickle
import console
# I moved 'dropboxlogin' into a sub folder so it doesn't clutter my main folder
sys.path += [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')]
import dropboxlogin # this code can be found here https://gist.github.com/4034526
STATE_FILE = '.dropbox_state'
@rcarmo
rcarmo / gist:5857681
Created June 25, 2013 11:06
Bottle layout
<root>
+-- dev.py # Stub to run Bottle while coding
+-- app.py # WSGI glue
+-- tasks.py # Celery glue
+-- fabfile.py # Fabric deployment/build script
+-- Vagrantfile # never leave home without it
+-- etc
| +-- config.json # my main configuration file
+-- api
@rcarmo
rcarmo / ansi.py
Created May 19, 2013 21:48
A Python logging handler with ANSI coloring support
from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.formatters import TerminalFormatter, Terminal256Formatter, NullFormatter
class PygmentsHandler(logging.StreamHandler):
"""Console logging handler with syntax highlighting"""
def __init__(self, stream=None, syntax="guess", encoding='utf-8'):
# run the regular Handler __init__
logging.StreamHandler.__init__(self,stream)
@rcarmo
rcarmo / benchmark.py
Last active December 16, 2015 06:49
Go benchmark
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main application script
Created by: Rui Carmo
License: MIT (see LICENSE for details)
"""
import os, sys
#!/usr/bin/python
# vim:set fileencoding=utf-8 sw=2 ai:
import sqlite3
import datetime
import re
SQL = '''
select
name, version, time, author, text
@rcarmo
rcarmo / gist:5151527
Last active December 14, 2015 21:29
Build a dashboard using XMLRPC calls to Trac. Relies on jQuery Masonry (http://masonry.desandro.com). And uses jQuery because that's what Trac comes bundled with.
<script src="/main/chrome/shared/js/jquery.masonry.min.js"></script>
<script>
function dashboard(container, tracs, pattern) {
var boxes = {};
// set up the container with the appropriate classes
container.empty();
container.addClass('fluid');
container.addClass('clearfix');