Skip to content

Instantly share code, notes, and snippets.


Amit Upadhyay amitu

View GitHub Profile
amitu /
Last active Apr 10, 2018
Acko's api framework
# -*- coding: utf-8 -*-
# License: BSD
import json
import os
import re
import time
from django import forms
from django.conf import settings
amitu / gist:4633274
Created Jan 25, 2013
zsh preexec hook example
View gist:4633274
# less -F: Causes less to automatically exit if the entire file can be displayed on the first screen.
# .zshrc
function printc () {
print "printc" $1
autoload -Uz add-zsh-hook
amitu /
Created Nov 4, 2013
Python dictionary that maps rails specific timezones to standard timezones. Twitter returns timezones in this format.
"Abu Dhabi": "Asia/Muscat",
"Adelaide": "Australia/Adelaide",
"Alaska": "America/Juneau",
"Almaty": "Asia/Almaty",
"American Samoa": "Pacific/Pago_Pago",
"Amsterdam": "Europe/Amsterdam",
"Arizona": "America/Phoenix",
"Astana": "Asia/Dhaka",
"Athens": "Europe/Athens",
amitu / or.elm
Last active Jun 20, 2017
Elm Enhancement Proposal: Or (More of a thought experiment)
View or.elm
-- What if we have had an or keyword for creating types.
-- Motivation: I often have something that is of few other things.
-- Example 1 from my code:
-- this is my Main Msg. Main does not have any UI, it is an SPA, it delegates different
-- pages / Modules for UI and updated etc.
type Msg
View gist:fe548a624136a8be1031c0417062114e
### Keybase proof
I hereby claim:
* I am amitu on github.
* I am amitu ( on keybase.
* I have a public key whose fingerprint is 0AE6 B0E1 9D24 7DD8 4DD0 2BB2 1514 4294 2930 5B79
To claim this, I am signing this object:
amitu / com.amitu.waitforit.plist
Created Jun 10, 2016
waitforit launch agent plist for mac
View com.amitu.waitforit.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
amitu / hindic-top1000.txt
Last active May 21, 2016 generated transliteration for 1000 most frequently used words in english
View hindic-top1000.txt
you: Y UW1 => यू
I: AY1 => आय
to: T UW1 => टू
the: DH AH0 => दै
a: AH0 => ऐ
and: AH0 N D => ऐन्ड
that: DH AE1 T => दैट
it: IH1 T => इट
of: AH1 V => आव
me: M IY1 => मी
amitu /
Last active Apr 29, 2016
Django Model base class for encoded key. Useful for when you want to pass id in URL or JSON, but do not leak data to world (about how many objects you have of that kind).
from Crypto.Cipher import AES
from Crypto import Random
import base64
import binascii
import struct
from django.db import models
from django.conf import settings
amitu / Makefile
Created Apr 12, 2016
Self documenting makefile
View Makefile
node_modules: ## Install dependencies.
node_modules: package.json
npm install
help: ## Show this help.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
for help_line in $${help_lines[@]}; do \
amitu / .zshrc
Last active Mar 17, 2016
ZSH: Print time to execute each command as it is executed.
View .zshrc
preexec () {
START="$(python -c 'import time; print time.time()')"
precmd () {
if [ -z ${START} ];