Skip to content

Instantly share code, notes, and snippets.

View gautamk's full-sized avatar

Gautam gautamk

View GitHub Profile
@gautamk
gautamk / lowecase.py
Created December 27, 2015 05:04
Convert the first line of all csv files in the current directory to lowercase
import glob
for filename in glob.iglob("*.csv"):
firstline = None
rest = None
with open(filename, 'r') as f:
firstline = f.readline().lower()
rest = f.read()
with open(filename,'w') as f:
f.writelines([firstline])
f.write(rest)

Keybase proof

I hereby claim:

  • I am gautamk on github.
  • I am gautamk (https://keybase.io/gautamk) on keybase.
  • I have a public key whose fingerprint is D4D5 FA08 BA6B 2E25 502C 7B4A E080 51F8 245D D05F

To claim this, I am signing this object:

@gautamk
gautamk / oneTouch2Monas.py
Created January 30, 2015 01:48
Convert One Touch Expenser export csv to Monas import csv
import csv
from datetime import datetime
with open('expenses.csv','r') as input_csv_file:
csv_reader =csv.DictReader(input_csv_file,fieldnames=['Date','Amount','Note','Tag'], delimiter=';')
csv_reader.next()
with open('monas.csv','w') as output_csv_file:
output_csv_file.write('"Date (MM/DD/YYYY)","Category","Amount","Note"\n')
writer = csv.DictWriter(output_csv_file,
fieldnames=["Date (MM/DD/YYYY)","Category","Amount","Note"],quotechar='"')
@gautamk
gautamk / hs.js
Created September 13, 2013 13:47
[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[
//http://blog.kevburnsjr.com/javascript-asynchronous-rsa-key-generation
//http://kjur.github.io/jsrsasign/api/symbols/RSAKey.html
function xeroTest() {
var oauth_nonce = createGuid();
var oauth_timestamp = (new Date().valueOf()/1000).toFixed(0);
var signatureBase = "GET" + "&"
+ encodeURIComponent("https://api.xero.com/api.xro/2.0/Organisation") + "&"
+ encodeURIComponent("oauth_consumer_key=" + UserProperties.getProperty("consumerKey") + "&oauth_nonce="+oauth_nonce+"&oauth_signature_method=RSA-SHA1&oauth_timestamp="+oauth_timestamp+"&oauth_token=" + UserProperties.getProperty("consumerKey") + "&oauth_version=1.0");
@gautamk
gautamk / gist:5794766
Last active December 18, 2015 14:08
assertEquals of Json strings by parsing into hashmaps using Jackson
private static void assertEqualsJson(String expectedJson,String actualJson){
final ObjectMapper objectMapper = new ObjectMapper();
Map<String,Object> expected = null,actual = null;
try {
expected = objectMapper.readValue(expectedJson, new TypeReference<Map<String, Object>>() {});
actual = objectMapper.readValue(actualJson, new TypeReference<Map<String, Object>>() {});
} catch (IOException e) {
e.printStackTrace();
@gautamk
gautamk / monitorchanges.sh
Created February 18, 2013 07:10
monitor for file changes and loop
#!/bin/bash
while true
do
inotifywait . -e modify -r
wait
now=$(date +"%T")
wait
@gautamk
gautamk / infinite-loop.sh
Last active December 13, 2015 21:09
infinite loop a command
#!/bin/bash
while true
do
now=$(date +"%T")
wait
notify-send "Pre-execute $now";
wait
@gautamk
gautamk / gist:4617487
Created January 24, 2013 03:48
MTC Scraper Description
Ever wanted an api to access the various information about transportation options in chennai ? Well this is it.
This project does the heavy lifting so you don't have to . It also makes me look cool because its written clojure.
The project is available at https://github.com/gautamk/mtc-scraper
@gautamk
gautamk / download.gitignore.py
Created October 10, 2012 10:54
Download .gitignore files from github
#!/usr/bin/env python
import sys,urllib2,json
data={}
raw_data = "raw_data"
parsed_data = "parsed_data"
file_names = "file_names"
def exit():
sys.exit("----")