Skip to content

Instantly share code, notes, and snippets.

View thejeshgn's full-sized avatar

Thejesh GN thejeshgn

View GitHub Profile
# Basic text search with relevancy for MongoDB.
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/
# Copythingie 2010 - Ward Bekker - ward@tty.nl
#create (or empty) a docs collection
doc_col = MongoMapper.connection.db('example_db').collection('docs')
doc_col.remove({})
#add some sample data
doc_col.insert({ "txt" => "it is what it is"})
#!/usr/bin/env python
"""
Usage:
./rtail.py user@host:path/foo.log bar.log host2:/path/baz.log
"""
import optparse
import os
@nathos
nathos / amznshortener.js
Created May 25, 2010 20:39
AmznShortener - Javascript bookmarket source for an Amazon.com short-link generator.
(function(){
var aff = 'nathos-20'; // replace 'nathos-20' with your Amazon affiliate ID, including the '-20'
if (!document.getElementById('ASIN')) {
alert('Can\'t find an Amazon product ID');
return;
}
var asin = document.getElementById('ASIN').value;
prompt(
'Here is the shortened affiliate link:',
'http://amzn.com/' + asin + '?tag=' + aff);
@thejeshgn
thejeshgn / batchEntoKn.php
Created February 4, 2011 16:20
Transliterating english to Kannada
<?php
/**
Trasliterate method takes 5 , seaparated english words and transliterates them into Kannada,
The result is an array of words in the same order. This uses Non public Google online transliteration API for this.
When you run this method give a 10ms seconds gap between each call to be on the safer side.
By : Thejesh GN http://thejeshgn.com
More: http://thejeshgn.com/2011/02/04/batch-transliterating-names-into-kannada-using-google-api/
@darktable
darktable / app.yaml
Created March 16, 2011 19:10
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@bradleybuda
bradleybuda / instrument_ajax.js
Created March 30, 2011 18:21
Instrument all jQuery AJAX events
_.each(['Start', 'Stop', 'Complete', 'Error', 'Success', 'Send'], function(s){
$(window)['ajax' + s](function(event, xhr, options) {
// your instrumentation goes here
console.log('ajax' + s);
});
});
// force certain pages to be refreshed every time. mark such pages with
// 'data-cache="never"'
//
jQuery('div').live('pagehide', function(event, ui){
var page = jQuery(event.target);
if(page.attr('data-cache') == 'never'){
page.remove();
};
});
@amix
amix / amazon_sender.py
Created May 17, 2011 13:39
Amazon SES helper script using boto
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
@erans
erans / get_lat_lon_exif_pil.py
Created May 20, 2011 21:16
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: