Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Deepankar Bhardwaj deepankarb

🏠
Working from home
View GitHub Profile
@deepankarb
deepankarb / Android Studio .gitignore
Created Sep 18, 2017 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
View Android Studio .gitignore
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
View Util.java
public static String md5(String in) {
byte[] bytes;
StringBuilder hashtext;
try {
bytes = in.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(bytes);
BigInteger bigInt = new BigInteger(1, digest);
hashtext = new StringBuilder(bigInt.toString(16));
@deepankarb
deepankarb / TreeView.java
Created Sep 7, 2017
Donald Knuth's binary tree drawing algorithm.
View TreeView.java
package org.zg.koch;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
@deepankarb
deepankarb / remove-jdk.sh
Created Aug 31, 2017
Removes *all* JDK altgernatives.
View remove-jdk.sh
if [ -z "$1" ]
then
echo "Please specify JDK path"
exit 1
fi
JDK_PATH="$1"
JDK_APPS=( $() )
@deepankarb
deepankarb / add-jdk.sh
Created Aug 31, 2017
Add an alternative JDK
View add-jdk.sh
if [ -z "$1" ]
then
echo "Please specify JDK path"
exit 1
fi
if [ -z "$2" ]
then
PRIORITY=100
else
View 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
#
View .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
View .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set hlsearch
set tabstop=4
set ai
set nu
" Disable Arrow keys in Escape mode
map <up> <nop>
@deepankarb
deepankarb / loop
Created Jun 28, 2016
Execute runnables on the ui thread in a loop
View 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 / GallerLock.java
Created May 15, 2016
A simulation of a livelock between two persons passing each other in a narrow gallery.
View GallerLock.java
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;