Skip to content

Instantly share code, notes, and snippets.

@mgk
mgk / rm
Created March 17, 2011 18:42
commmand line rm replacement in ruby that uses OS X Trash
#!/usr/bin/env ruby
# 'rm' replacement that integrates with OS X Trash
# To install: save as ~/bin/rm, make executable, and put ~/bin/rm 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.
require 'fileutils'
now = Time.now
@mgk
mgk / favorite_gems.md
Created April 11, 2012 19:33 — forked from ryanb/favorite_gems.md
A list of my favorite gems for various tasks.
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Run the tests:
python setup.py test
tox
  • Commit the changes:
@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.
@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
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 / 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>
@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
global
#debug
#daemon
log 127.0.0.1 local0
defaults
log global
option httplog
frontend unsecured *:80