Skip to content

Instantly share code, notes, and snippets.

View hiway's full-sized avatar

Harshad Sharma hiway

View GitHub Profile
@hiway
hiway / zen_of_python.py
Created February 6, 2013 09:15
Quoting Zen of Python randomly (started as a joke between friends, *had* to automate it)
#!/usr/bin/env python
import random
zen = """Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
@hiway
hiway / hello.asm
Last active December 18, 2015 19:19
Program that boots an emulator/computer from a floppy and prints 'Hello, world.'
[bits 16] ; Tell assembler to use 16 bit code.
[org 7c00h] ; BIOS will load us to this address.
;===================================================================
mov si, string_hello ; store string pointer into SI
call print_string
call sleep
;===================================================================
print_string:
@hiway
hiway / geocode.py
Last active December 18, 2015 19:39
Helper module to get latitude, longitude of addresses using Google Maps API.
import re
import requests
def _clean_degrees(value):
return re.sub('[^-\.0-9]', '', value)
def get_coordinates(address):
"""Expects a string of address and returns tuple
(latitude, longitude)
@hiway
hiway / traffline.py
Created June 21, 2013 22:54
Quickly query Traffline API to get estimated time to reach your destination in current traffic.
"""Traffline ETA
Usage:
traffline.py <source> <destination> <city>
"""
from docopt import docopt
import requests
import json
@hiway
hiway / itunes_lyrics_fetch.py
Created June 29, 2013 13:40
You'll need to install lyricwiki and appscript before you can use this script.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import sleep
import lyricwiki
import appscript
it = appscript.app('iTunes')
def fetch_and_add_lyrics():
@hiway
hiway / devanagari_math.py
Created October 9, 2013 12:44
A quick n' dirty hack for doing math and getting output in Devanagari script (Unicode) instead of ASCII.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def devanagari_math(statement):
trans = {
u'१':'1',
u'२':'2',
u'३':'3',
u'४':'4',
u'५':'5',
@hiway
hiway / imapfilter-config.lua
Created February 6, 2014 15:12
IMAPfilter configuration file
-- Created with much inspiration from:
-- https://gist.github.com/dylanwh/408810
-- http://gaillourdet.net/2011/05/server-side-imap-filtering-done-right/
-- Todo: include this: https://chris-lamb.co.uk/posts/rotating-email-your-inbox-using-imapfilter
options.timeout = 120
options.subscribe = true
options.expunge = true
@hiway
hiway / hdr_linux_gphoto2_dslr.py
Last active August 29, 2015 14:03
Timelapse Scripts Collection (written at different times, for different devices)
#!/usr/bin/env python
import os, re
from subprocess import call, Popen, PIPE
def run(command):
print 'Running:', command
p = Popen(command, shell=True, stdout=PIPE)
lines = p.stdout.readlines()
for line in lines:
@hiway
hiway / ideavimlockdown.py
Created August 20, 2014 09:22
Create VIM lockdown script where vimscript is not available => IdeaVIM (for PyCharm etc)
"""
Script to create an .ideavimrc comptabile VIM lockdown key-remapper as used by github.com/hiway/po
This will unmap EVERYTHING and render your VIM useless - the idea is to begin with your own keymapping instead of VIM's legacy keymaps. You may refer to github.com/hiway/po for more information.
To create a new .lockdown_ideavim: `python ideavimlockdown.py > ~/.lockdown_ideavim`
Then use it within your ~/.ideavimrc by adding "source ~/.lockdown_ideavim" within the file.
"""
excludes = [":", "\n", "!", chr(0x9), chr(0x16), " ", '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '(', ')', ',']
@hiway
hiway / google_links.py
Created October 31, 2014 11:25
Fetch top X URLs for keywords from Google