Skip to content

Instantly share code, notes, and snippets.

View thejeshgn's full-sized avatar

Thejesh GN thejeshgn

View GitHub Profile
// 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();
};
});
@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);
});
});
@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
@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/
@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);
#!/usr/bin/env python
"""
Usage:
./rtail.py user@host:path/foo.log bar.log host2:/path/baz.log
"""
import optparse
import os
# 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 - [email protected]
#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"})