Skip to content

Instantly share code, notes, and snippets.

@mjumbewu
mjumbewu / renderers.py
Last active November 28, 2019 09:19
A Django REST Framework renderer which renders data from DRF serializers into CSV. The underlying functions will render any hierarchy of Python primitive containers to CSV.
import csv
from collections import defaultdict
from rest_framework.renderers import *
from StringIO import StringIO
class CSVRenderer(BaseRenderer):
"""
Renderer which serializes to CSV
"""
@mjumbewu
mjumbewu / gist:4667649
Last active February 5, 2024 17:59
Synaptic TouchPad properties on a Dell XPS 13
mjumbewu@mjumbewu-xps ~
$ uname -a
Linux mjumbewu-xps 3.5.0-22-generic #34+kamal11~DellXPS-Ubuntu SMP Fri Jan 11 09:12:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
mjumbewu@mjumbewu-xps ~
$ xinput list-props 12
Device 'CyPS/2 Cypress Trackpad':
Device Enabled (132): 1
Coordinate Transformation Matrix (134): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (255): 1
@mjumbewu
mjumbewu / find_legistar.py
Created February 27, 2013 18:39
A scraper to collect Legistar subdomain names from Google
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
from requests import get
import re
import time
pattern = re.compile(r'(\w+)\.legistar\.com')
@mjumbewu
mjumbewu / Complex.js
Last active December 15, 2015 21:48 — forked from dsamarin/Complex.js
var Complex = function(real, imag) {
if (!(this instanceof Complex)) {
return new Complex (real, imag);
}
if (typeof real === "string" && imag == null) {
return Complex.parse (real);
}
this.real = Number(real) || 0;
@mjumbewu
mjumbewu / gist:5923624
Last active December 19, 2015 08:09 — forked from fkh/gist:5923372
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from unittest import TestCase, main
from functools import wraps
from os import environ
# ============================================================
# Helper functions -- skip these and go to the tests...
# ============================================================
@mjumbewu
mjumbewu / handlebars-formatTextForHTML.coffee
Last active December 19, 2015 16:49 — forked from arbales/handlebars-formatTextForHTML.coffee
Now matches things like "I got this from http://github.com/, and it's great!" as well. The trailing comma would throw it off before.
LINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?).?(\s+|$)/gi
EMOJI_DIRECTORY = "/path/to/assets/emoji/20x20"
# Handlebars is presumed, but you could swap out
ESCAPE_EXPRESSION_FUNCTION = Handlebars.Utils.escapeExpression
MARKSAFE_FUNCTION = (str) -> new Handlebars.SafeString(str)
# Emoji unicode chars become images.
@mjumbewu
mjumbewu / browserstack_tunnel_setup.sh
Last active December 20, 2015 00:19
A small bash script to start a BrowserStack tunnel as part of a Travis Build.
#!/bin/bash
# Setup and start BrowserStack Tunnel for your TravisCI build
#
# This script was adopted from Santiago Suarez Ordoñez's Sauce Connect
# setup script: https://gist.github.com/santiycr/5139565/
#
# This script requires your .travis.yml to include the following private
# env variable:
#
@mjumbewu
mjumbewu / review2013.09.09.js
Last active December 23, 2015 01:59
JS Review
// We went over:
/*
* - What's JS used for
* - Modifying document structure (the HTML is not the webpage, like the
* blueprint is not the building)
* - Retrieving data from a server without a page reload
* - Widgets and usability
*/
@mjumbewu
mjumbewu / paginated_csv_renderer.py
Created September 20, 2013 15:27
Django REST Framework CSV renderer that works with Paginated data
from rest_framework_csv.renderers import CSVRenderer
class PaginatedCSVRenderer (CSVRenderer):
results_field = 'results'
def render(self, data, media_type=None, renderer_context=None):
if not isinstance(data, list):
data = data.get(self.results_field, [])
return super(PaginatedCSVRenderer, self).render(data, media_type, renderer_context)
rvm system
travis encrypt SAUCE_USERNAME=$SAUCE_USERNAME --repo openplans/hatch
travis encrypt SAUCE_ACCESS_KEY=$SAUCE_ACCESS_KEY --repo openplans/hatch
# Add the values to your .travis.yml file
#
# NOTE: If you specify "--add env.global" with the encrypt command this will
# be done automatically.
#
# env: