Skip to content

Instantly share code, notes, and snippets.

View deepankarb's full-sized avatar
🏠
Working from home

Deepankar Bhardwaj deepankarb

🏠
Working from home
View GitHub Profile
@deepankarb
deepankarb / sync.sh
Last active August 29, 2015 14:04 — forked from wernerb/sync.sh
#!/bin/sh
#input sharelink here. Example: https://drive.google.com/folderview?id=0B1g-MbiD2F6vdtOT92b3MoerO&usp=sharing
SHARELINK="https://drive.google.com/folderview?id=idU&usp=sharing"
DESTINATION="/full/path/to/folder"
# Change following to false when you don't want to delete files when they are missing from google drive. This can
REMOVEFILES=true
# Begin code
download () {
public static void cancelAsyncTask(AsyncTask<?, ?, ?> task) {
if (task == null) {
return;
}
if (!task.getStatus().equals(AsyncTask.Status.FINISHED)) {
Logger.debug(TAG, "Cancelling AsyncTask " + task.toString() );
task.cancel(true);
}
}
Strg Alt Shift Key Function
x Einf Generate/Insert dialog
x x ENTER Statements completion like blocks and brackets
x x T Surrond codeblock with…
x W Select succesively increasing code blocks
x F11 bookmarks and mark the line with selected key
x F11 invokes a list of bookmarks. Pressing a key takes to associated bookmark.
x x Backspace go to most recent code edit. Hit again to go even further back.
x E recent opened files
x x E recent edited files
@deepankarb
deepankarb / dex.sh
Last active September 3, 2015 09:34 — forked from JakeWharton/dex.sh
`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH.
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
'alrm=$(adb shell dumpsys alarm | grep $app | grep when | cut -f11 -d" "); for a in $alrm; do date --date="@"${a:0:-3}; done'
@deepankarb
deepankarb / GallerLock.java
Created May 15, 2016 08:32
A simulation of a livelock between two persons passing each other in a narrow gallery.
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
/**
* A simulation of a livelock between two persons passing each other in a narrow gallery.
*/
public class GalleryLock {
final static boolean LOG_VERBOSE = false;
find -name "*.xml" -exec xmllint --format '{}' --output '{}' \;
@deepankarb
deepankarb / loop
Created June 28, 2016 04:21
Execute runnables on the ui thread in a loop
private void loop(Deque<Runnable> rs, int delay) {
final Runnable first = rs.removeFirst();
new Handler().post(first);
rs.addLast(first);
new Handler().postDelayed(() -> loop(rs, delay), delay);
}
@deepankarb
deepankarb / .bashrc
Created January 31, 2017 06:28
bashrc
#PS1
#export PS1="\[\e[01;32m\]\A\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;34m\]\w\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;34m\]\\$\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
export PS1="\[\e[00;34m\]\w\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[01;32m\]\A\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;34m\]\\$\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
# gitprompt configuration
# Set config variables first
GIT_PROMPT_ONLY_IN_REPO=1
# as last entry source the gitprompt script
source /home/"$(whoami)"/.bash-git-prompt/gitprompt.sh
@deepankarb
deepankarb / lzs.py
Created August 22, 2017 05:49 — forked from FiloSottile/lzs.py
#!/usr/bin/env python
#-*- coding:utf-8 -*-
##############################################################
# Lempel-Ziv-Stac decompression
# BitReader and RingList classes
#
# Copyright (C) 2011 Filippo Valsorda - FiloSottile
# filosottile.wiki gmail.com - www.pytux.it
#