Skip to content

Instantly share code, notes, and snippets.

View gaurav's full-sized avatar

Gaurav Vaidya gaurav

View GitHub Profile
@gaurav
gaurav / get_fusion_table.py
Created August 24, 2011 06:19
Simple code to download a Fusion Table which is being shared publically
#!/usr/bin/python
import urllib
tableid = 1344517 # A dummy but public fusion table I created
sql = "SELECT * FROM %d" % tableid
file = urllib.urlopen("https://www.google.com/fusiontables/api/query?sql=" + urllib.quote_plus(sql))
print file.read()
# Expected output:
@gaurav
gaurav / bulkloader-log-20110829.143822
Created August 29, 2011 21:06
Error output while uploading LayerIndex
[INFO 2011-08-29 14:38:22,517 bulkloader.py] Logging to bulkloader-log-20110829.143822
[INFO 2011-08-29 14:38:22,518 bulkloader.py] Throttling transfers:
[INFO 2011-08-29 14:38:22,518 bulkloader.py] Bandwidth: 250000 bytes/second
[INFO 2011-08-29 14:38:22,518 bulkloader.py] HTTP connections: 8/second
[INFO 2011-08-29 14:38:22,518 bulkloader.py] Entities inserted/fetched/modified: 20/second
[INFO 2011-08-29 14:38:22,518 bulkloader.py] Batch Size: 10
[INFO 2011-08-29 14:38:23,649 bulkloader.py] Opening database: bulkloader-progress-20110829.143822.sql3
[DEBUG 2011-08-29 14:38:23,656 adaptive_thread_pool.py] [WorkerThread-0] WorkerThread: started
[DEBUG 2011-08-29 14:38:23,657 adaptive_thread_pool.py] [WorkerThread-1] WorkerThread: started
[DEBUG 2011-08-29 14:38:23,657 adaptive_thread_pool.py] [WorkerThread-2] WorkerThread: started
@gaurav
gaurav / gist:1208725
Created September 10, 2011 20:17
A script to find US places with the name of a state in them
#!/usr/bin/perl -w
use 5.0100;
use strict;
use warnings;
# Read in the list of US states attached to the end of this source file.
my %US_STATES = ();
while(<DATA>) {
@gaurav
gaurav / gist:1215190
Created September 13, 2011 21:10
Spotlight not functional
Machine:
PowerPC G5 Mac OS X 10.5.8
Symptoms:
1. Spotlight completely non-functional.
2. Running `sudo mdutil -i on /` results in error code -1.
3. No 'mds' or 'mdworker' running in Activity Manager.
Solution:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
@gaurav
gaurav / unicode.json
Created November 17, 2011 22:51
A GeoJSON file containing Unicode text.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Atom Zombie Smasher
Commander: Gaurav
Start date: November 19, 2011
Zeppelin: One Moon Zeppelin
Codename: OperationWakingHeron528
----------------------------------
JANUARY 1961: AURORA AUSTRALIS.
Shorter daytime.
@gaurav
gaurav / iucn.json
Created November 22, 2011 03:38
A bigger GeoJSON file
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gaurav
gaurav / gist:1475883
Created December 14, 2011 09:35
LaTeX to HTML on a Mac
1. Find your texbin directory. This is usually /usr/texbin, which is symlinked to wherever the actual directory is.
2. Add it to your PATH (i.e. `# export PATH=/usr/texbin:$PATH`)
3. Run the 'htlatex' command. This will convert your LaTeX file into an HTML document. Note that this really just a script around normal LaTeX, so you'll have to do the usual things (htlatex -> bibtex -> htlatex for citations, htlatex -> htlatex for references). I think: I had my LaTeX all PDF-LaTeXed and ready to go, so all the .bib/.toc/etc. files had already been created.
3.1. You might want to run 'htlatex file.tex "xhtml,fn-in"' if you have footnotes. Without that option, footnotes will be put into their own HTML file.
4. At this point, you have an HTML file. Check it and make sure it's good enough.
5. Open the HTML file in TextEdit. Oddly enough, Pages can't open HTML files, but TextEdit can. Go figure.
6. TextEdit can now save your file as an RTF or Doc file.
7. Success!
@gaurav
gaurav / flickr_species_badge.html
Created April 5, 2012 06:07
A species badge (for Panthera tigris) from Flickr
<script>
var species_name = "Panthera tigris"; // Tweak this
var number_of_images = 5; // Tweak this
</script>
<!-- Start of Flickr Badge -->
<style type="text/css">
#flickr_badge_source_txt {padding:0; font: 11px Arial, Helvetica, Sans serif; color:#666666;}
#flickr_badge_icon {display:block !important; margin:0 !important; border: 1px solid rgb(0, 0, 0) !important;}
#flickr_icon_td {padding:0 5px 0 0 !important;}
@gaurav
gaurav / delimit2rdf.pl
Created October 2, 2012 08:03
A file to split a DwC-A file into triples
#!/usr/bin/perl -w
use strict;
use warnings;
use v5.10.0;
=head1 NAME
delimit2rdf.pl -- Delimited file to RDF