Skip to content

Instantly share code, notes, and snippets.

View vitovalov's full-sized avatar

Vito Valov vitovalov

View GitHub Profile
@vitovalov
vitovalov / generate_android_strings.sh
Created February 20, 2015 22:07
This script allows to generate android strings.xml in each defined language creating all needed directories
# Made by vitovalov@gmail.com
# Overwrites existing files and directories
# Creates missing directories
node generate strings.json 'android'
# no trailing slash
PROJECT_DIR=~/project/src/main/res
if [ ! -d "$PROJECT_DIR" ]; then
echo "Error: Please define PROJECT_DIR"
@vitovalov
vitovalov / delete_local_merged_branches.sh
Last active August 29, 2015 14:15
Delete locally already merged branches on develop
git checkout develop
git branch --merged | grep -v "*" | grep -v -e "[develop|master]" | xargs -n 1 git branch -d
@vitovalov
vitovalov / delete_local_refs_to_remote_branches.sh
Created February 20, 2015 22:17
Delete local references to remote branches
git remote prune origin
@vitovalov
vitovalov / rescale_for_android.sh
Created February 20, 2015 22:21
Resize to a given size maintaining proportions and automatically generate all android resource directories
# Author: @vitovalov
# Description: Resize to a given size and automatically generate all android resource directories
# Usage: sh rescale_for_android.sh <dp size (mdpi)> <source path to original images> <output path for results>(optional)
if [ "$#" -le 1 ]; then
echo "\nUsage: sh rescale_for_android.sh <dp size (mdpi)> <source path to original images> <output path for results>(optional)\n"
exit 1
fi
mdpisize=$1
hdpisize=$(echo "$mdpisize * 1.5" | bc -l)
@vitovalov
vitovalov / gifit.sh
Created February 20, 2015 22:23
mp4 to gif using ffmpeg and gifsicle(brew)
# Author: @vitovalov
# Description: pass it a mp4 and you will have a gif
# Dependencies: ffmpeg, gifsicle
if [ "$#" -le 1 ]; then
echo "\nUsage: sh gifit.sh <source path to original mp4> <delay between frames>"
echo "Warning! filenames shouldn't contain the extension\n"
exit 1
fi
ffmpeg -i $1.mp4 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=$2 > $1.gif
@vitovalov
vitovalov / genymotion_utils.md
Created February 20, 2015 22:28
Genymotion utils

Nombre emulador Genymotion

Lista VMs

Para sacar el listado de maquinas virtuales (imagenes) de los emuladores Genymotion creados:

VBoxManage list vms

Ejecutar

@vitovalov
vitovalov / secondsSinceLastLaunch.java
Created March 27, 2015 21:25
Get elapsed time from the first time user launched the app using SharedPreferences and Joda-Time
long lastLaunchedDateMillis = VITPreferencesUtils.getLongGeneric(PuzzleApp.getInstance(), "first_launch_date", -1);
DateTime current = new DateTime();
DateTime lastLaunchedDate = new DateTime(lastLaunchedDateMillis);
if (lastLaunchedDateMillis != -1) {
int secsElapsed = Seconds.secondsBetween(lastLaunchedDate, current).getSeconds();
Log.e("VI PRINT", "HomeActivity.onCreate " + "secsElapsed:" + secsElapsed);
} else {
VITPreferencesUtils.saveLongGeneric(PuzzleApp.getInstance(), "first_launch_date", current.getMillis());
}
@vitovalov
vitovalov / pull_db_from_device.sh
Last active August 29, 2015 14:22
Pull SQLite DB from Android 5 Nexus 5
# -d is used to target the connected device and not emulator(-e)
# by setting permission 777 you are allowing to everybody r/w access
adb -d shell "run-as com.vitaminlabs.visualization chmod -R 777 /data/data/com.vitaminlabs.visualization/databases/"
adb -d shell "cp /data/data/com.vitaminlabs.visualization/databases/visualization.db /sdcard/visualization.db"
adb -d pull "/sdcard/visualization.db"
@vitovalov
vitovalov / dagger2-problems-investigation-links.md
Last active September 27, 2015 23:59
Dagger2 problems investigation
@vitovalov
vitovalov / studio.vmoptions
Created November 12, 2015 00:05
Increment Android Studio RAM memory ~/Library/Preferences/AndroidStudio1.4
-Xms1280m
-Xmx6050m
-XX:MaxPermSize=3050m
-XX:ReservedCodeCacheSize=98m
-XX:+UserCompressedOoops