Skip to content

Instantly share code, notes, and snippets.

@mgk
mgk / rqretryworker.py
Last active August 29, 2015 14:25 — forked from spjwebster/rqretryworker.py
A basic rq worker that will retry failed jobs before dumping it in the failed queue.
#!/usr/bin/env python
import os, sys
sys.path.append(os.getcwd())
import logging
import rq
MAX_FAILURES = 3
@mgk
mgk / README.md
Last active August 29, 2015 14:10 — forked from rkirsling/LICENSE

Click in the open space to add a node, drag from one node to another to add an edge.
Ctrl-drag a node to move the graph layout.
Click a node or an edge to select it.

When a node is selected: R toggles reflexivity, Delete removes the node.
When an edge is selected: L(eft), R(ight), B(oth) change direction, Delete removes the edge.

To see this example as part of a larger project, check out Modal Logic Playground!

@mgk
mgk / gist:cb8cf7ea932dfbe7ac6f
Last active August 29, 2015 14:02 — forked from lucasfais/gist:1207002
Sublime Text Mac Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt

For ETS's SKLL project, we found out the hard way that Travis-CI's support for numpy and scipy is pretty abysmal. There are pre-installed versions of numpy for some versions of Python, but those are seriously out of date, and scipy is not there are at all. The two most popular approaches for working around this are to (1) build everything from scratch, or (2) use apt-get to install more recent (but still out of date) versions of numpy and scipy. Both of these approaches lead to longer build times, and with the second approach, you still don't have the most recent versions of anything. To circumvent these issues, we've switched to using Miniconda (Anaconda's lightweight cousin) to install everything.

A template for installing a simple Python package that relies on numpy and scipy using Miniconda is provided below. Since it's a common s

global
#debug
#daemon
log 127.0.0.1 local0
defaults
log global
option httplog
frontend unsecured *:80
@mgk
mgk / rm
Created April 12, 2014 15:41
OS X rm Trash wrapper
#!/usr/bin/env ruby
# 'rm' replacement that integrates with OS X Trash
#
# To install: save as ~/bin/rm, make executable, and put ~/bin first in your PATH
#
# Copyright (c) Michael Keirnan
# Disclaimer: Provided as-is, no warranty, may work, may not, be careful, don't run with scissors, etc.
#
# A lot of things like build tools shell out to rm. This has not caused me problems after several years of use
@mgk
mgk / ipython-debug.sublime-snippet
Created April 12, 2014 15:28
SublimeText ipython debug snippet
<snippet>
<content><![CDATA[
from IPython.core.debugger import Tracer; debug_here = Tracer()
debug_here()
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dbg</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
from pyparsing import *
# By default, PyParsing treats \n as whitespace and ignores it
# In our grammer, \n is significant, so tell PyParsing not to ignore it
ParserElement.setDefaultWhitespaceChars(" \t")
def parse(input_string):
def convert_prop_to_dict(tokens):
"""Convert a list of field property tokens to a dict"""
prop_dict = {}
@mgk
mgk / lol.py
Created March 31, 2014 22:46 — forked from faruken/lol.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from twisted.application import service
from twisted.web import server, static
from twisted.web.resource import Resource
from twisted.web.wsgi import WSGIResource
from twisted.internet import reactor
from flask.views import MethodView
@mgk
mgk / bash_prompt.sh
Last active August 29, 2015 13:56 — forked from insin/bash_prompt.sh
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.