Skip to content

Instantly share code, notes, and snippets.

View dotgc's full-sized avatar

Gaurav Chauhan dotgc

  • Bangalore, India
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dotgc on github.
  • I am dotgc (https://keybase.io/dotgc) on keybase.
  • I have a public key ASD0u7Z3cPcN62Kw8Anv-rIGzl3IVn94G24d4WS7mMc1vgo

To claim this, I am signing this object:

@dotgc
dotgc / functions.bash
Created March 4, 2016 19:18
useful bash functions
### Extract Archives ###
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.gz) tar xzvf $1 ;;
*.bz2) bzip2 -d $1 ;;
*.rar) unrar2dir $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
@dotgc
dotgc / BaseUploader.java
Last active November 25, 2019 11:22
S3 Async Post uploads for Android/Java using OkHttp which posts the callback to the calling thread if it has a looper. So if you start the async post on the Main Thread, the response callback is also executed on the main thread.
public abstract class BaseUploader {
protected String mBucketUrl;
protected S3Data mData;
protected ResponseCallback mCallback;
public BaseUploader(String bucketUrl, S3Data data, ResponseCallback cb) {
mBucketUrl = bucketUrl;
mData = data;
mCallback = cb;
}
@dotgc
dotgc / latency.txt
Created October 25, 2015 05:09 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms