Skip to content

Instantly share code, notes, and snippets.

@m0wfo
m0wfo / gist:1152960
Created August 17, 2011 23:57
My RVM alternative
#!/Users/chris/.ruby/current/bin/ruby
RUBY_HOME = ENV['RUBY_HOME']
RUBIES = {:jruby => 'jruby-1.6.0', :rubinius => 'rubinius/1.2', :mri => 'mri19'}
GEM_EXECUTABLES = {:rubinius => 'gems/bin', :mri => ''}
if ARGV.empty?
p 'Available interpreters:'
RUBIES.each { |key,value| p key }
@jarus
jarus / test.py
Created August 21, 2011 14:52
Testing Flask application with basic authentication
import base64
from myapplication import app
class MyTestCase(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def tearDown(self):
pass
@blahutka
blahutka / sprinkle.rb
Created August 23, 2011 19:10
Vagrant - Sprinkle provisioner
module Vagrant
module Provisioners
class Sprinkle < Base
register :sprinkle
class Config < Vagrant::Config::Base
attr_accessor :cookbooks_path
end
def prepare
@miku
miku / worldclock.sh
Created October 18, 2011 08:22
Worldclock for bash.
worldclock() {
ADDIS_ABABA=`TZ=Africa/Addis_Ababa date +"%c (%z %Z)"`
BERLIN=`TZ=Europe/Berlin date +"%c (%z %Z)"`
CHICAGO=`TZ=America/Chicago date +"%c (%z %Z)"`
HONK_KONG=`TZ=Asia/Hong_Kong date +"%c (%z %Z)"`
LONDON=`TZ=Europe/London date +"%c (%z %Z)"`
LOS_ANGELES=`TZ=America/Los_Angeles date +"%c (%z %Z)"`
MOSCOW=`TZ=Europe/Moscow date +"%c (%z %Z)"`
NEW_YORK=`TZ=America/New_York date +"%c (%z %Z)"`
SOFIA=`TZ=Europe/Sofia date +"%c (%z %Z)"`
@fmoralesc
fmoralesc / pipelines.py
Created October 20, 2011 03:23
Shell Pipelines for Python
from subprocess import Popen, PIPE
import re
import glob
import shlex
class Pipeline(object):
def __init__(self, descriptor=None):
self.steps = []
if descriptor:
for step in descriptor.split("|"):
@maximebf
maximebf / webtail.py
Created October 21, 2011 13:25
Web tail / tail -f as a webpage using websocket
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@textarcana
textarcana / git-log2json.sh
Last active January 24, 2025 22:12
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
anonymous
anonymous / gist:1406238
Created November 29, 2011 20:09
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@jamescasbon
jamescasbon / template.py
Created December 11, 2011 16:37
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()
@hrldcpr
hrldcpr / tree.md
Last active January 6, 2025 22:43
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!