Skip to content

Instantly share code, notes, and snippets.

View amitu's full-sized avatar
😀
Building fastn.com

Amit Upadhyay amitu

😀
Building fastn.com
View GitHub Profile
@amitu
amitu / gist:4633274
Created January 25, 2013 10:13
zsh preexec hook example
# 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
amitu / debug.conf
Created September 10, 2013 22:21
Dummy plugin for logstash.
input {
stdin {
type => "foo"
}
}
filter {
if [type] == "foo" {
foo {
message => "Hello world!"
}
@amitu
amitu / jdk7.sls
Created September 11, 2013 20:10
installing jdk7 via salt
java7_ppa:
cmd.run:
- name: add-apt-repository ppa:webupd8team/java --yes && apt-get update
- user: root
accept-license:
cmd.run:
- name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
- unless: debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1
- user: root
@amitu
amitu / views.py
Created September 15, 2013 17:28
djangothis with labels
from importd import d
from path import path
from datetime import datetime
from djangothis.app import dotslash, read_yaml, watchfile
from django.shortcuts import render
posts = None
labels = {}
@amitu
amitu / load_keen.py
Last active December 24, 2015 07:49
Upload some test data to keen.io
# find the list of backup files
# for each file see the position till where we have read the file from "stack"
# for each file see if there is more in it.
# if there is more, start reading and writing to keen
# find total size of all files
# go thru in ls -t order so we always traverse them in same order
from progressbar import ProgressBar
import keen, pdb, json, time
@amitu
amitu / rails_tz.py
Created November 4, 2013 14:24
Python dictionary that maps rails specific timezones to standard timezones. http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html. 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
amitu / manage.py
Created November 6, 2013 05:30
Find out why is something getting imported, as import fails in django sometimes leads to unhelpful "ImproperlyConfigured" exception
#!/usr/bin/env python
import sys, traceback
class ImportBlocker(object):
def find_module(self, fullname, path=None):
if "mobil" in fullname and "mobile" not in fullname:
print fullname
print traceback.print_stack()
raise Exception()

Keybase proof

I hereby claim:

  • I am amitu on github.
  • I am amitu (https://keybase.io/amitu) on keybase.
  • I have a public key whose fingerprint is 0573 B4C1 B82D 985B C0A0 4799 CD50 23F8 FC63 BFB9

To claim this, I am signing this object:

@amitu
amitu / screenshot.go
Last active July 4, 2019 17:32
screenshot.go
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa -framework Foundation
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
NSData *data;
eventsource
go-eventsource
client/client