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 () {
@deepankarb
deepankarb / svg-to-android.sh
Last active July 14, 2018 13:13
A script to generate android assets from a SVG file. Requires inkscape to resize and convert.
#!/bin/bash
if [[ -z "$1" ]];
then
echo "No SVG file specified. Exiting."
exit -1
fi
ispng=$(file $1)
echo $ispng | grep -q SVG
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);
}
}
find -name "*.xml" -exec xmllint --format '{}' --output '{}' \;
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
adjectives=[
"adorable",
"adventurous",
"aggressive",
"alert",
"attractive",
"average",
"beautiful",
"blue-eyed ",
"bloody",
@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;
@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);
}