This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bitly tech talk 4/22/2010 | |
On 4/22 we held a bit.ly tech talk on 'Command Line Fu', where we invited talented hackers to come share their best moves. Please correct my notes and add your fu here! | |
# @jehiah | |
# in place file regex replacement | |
perl -pi -e 's/this/that/g' filename_pattern | |
# print the last column of a file ($NF stands for 'Number of Fields' or more commonly Last Field). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import httplib | |
import tornado.web | |
class ErrorHandler(tornado.web.RequestHandler): | |
"""Generates an error response with status_code for all requests.""" | |
def __init__(self, application, request, status_code): | |
tornado.web.RequestHandler.__init__(self, application, request) | |
self.set_status(status_code) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MySQLdb | |
from DBUtils import PooledDB | |
from MySQLdb import cursors | |
import settings | |
import logging | |
class DB(object): | |
"""simple database wrapper""" | |
mysqldbpool = None | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This module encapsulates all knowledge about what environment your | |
code is running in (ie: development / production). | |
Note: make sure all calls to settings.get() are done at runtime, and not at import time. | |
usage: | |
import settings | |
def test(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylibmc | |
import Queue | |
import logging | |
import functools | |
""" | |
This is a transparent pool library that wraps a pylibmc client | |
from MemcachePool import mc | |
mc.get(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
twitter_archiver.py written by Jehiah Czebotar 2010 <[email protected]> http://jehiah.cz/ | |
this uses the great 'python twitter tools' library by Mike Verdone | |
http://mike.verdone.ca/twitter/ | |
usage: | |
$ pip install twitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
this script parses Adium XML log files into a csv | |
use -u to specify your usernames to look for | |
use -d to specify the path (with wildcards) to adium xml logs (be careful to check all installed adium versions) | |
you can then read data with | |
import csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## this is a quick and dirty script to automagically install the latest chromium build on OSX 10.5 | |
## you can set this up as a nightly cron job, or run manually from the command line | |
# USAGE: | |
# save script to your home directory aka /Users/$USER/ | |
# open up a command prompt (aka /Applications/Utilities/Terminal) | |
# run manually from the command line whenever you want the most recent chromium build | |
# $ sh get_latest_chromium.sh | |
# start it as a nightly task (runs at 1am or edit the plist below) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bit.ly API implementation - thanks to Richard Johansso http://gist.github.com/112191 | |
require 'httparty' | |
class Api::Bitly | |
include HTTParty | |
base_uri 'api.bit.ly' | |
format :json | |
# Usage: Bitly.shorten("http://example.com") | |
def self.shorten(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# a simple way to parse shell script arguments | |
# | |
# please edit and use to your hearts content | |
# | |
ENVIRONMENT="dev" |
OlderNewer