Skip to content

Instantly share code, notes, and snippets.

View vitovalov's full-sized avatar

Vito Valov vitovalov

View GitHub Profile
@vitovalov
vitovalov / Divider.java
Created June 5, 2018 08:46
Android Divider custom view 1dp x fullwidth
public class Divider extends View {
private Paint paint;
private int width;
private float density;
public Divider(Context context) {
super(context);
init(context);
}
@vitovalov
vitovalov / http_pw_send_push_firebase.sh
Created November 9, 2017 13:29
Send push notifications server firebase scripts
# http -v https://fcm.googleapis.com/fcm/send\
# Content-Type:application/json\
# Authorization:key=AIzaSyBHrVwAoCWYUKj85r4eZap56mJH2Rc6IkL\
# to=c3bKqL80zZA:APA91bENswXWWp9Lokh9hnESqnLqRAWNT5KZmoE_bPSEyjENJgq4J0D6KKOJRyEFbWxP5oayOvYf3UjBnXaxWocO8p1OeFOJkOEFqe922f7BZdBzZKCAfWAy72tJKv5osK08Hm1MEHGh\
# notification:=@push_firebase_notification.json
# http -v https://fcm.googleapis.com/fcm/send\
# Content-Type:application/json\
# Authorization:key=AIzaSyBHrVwAoCWYUKj85r4eZap56mJH2Rc6IkL\
# to=c3bKqL80zZA:APA91bENswXWWp9Lokh9hnESqnLqRAWNT5KZmoE_bPSEyjENJgq4J0D6KKOJRyEFbWxP5oayOvYf3UjBnXaxWocO8p1OeFOJkOEFqe922f7BZdBzZKCAfWAy72tJKv5osK08Hm1MEHGh\
@vitovalov
vitovalov / launch_location_history.java
Created June 26, 2017 15:13
Launch Google Location History Settings screen
Intent settings = new Intent("com.google.android.gms.location.settings.LOCATION_HISTORY");
startActivity(settings);
@vitovalov
vitovalov / replicate_tree.sh
Created December 21, 2015 22:08
Replicate only the folder structure (tree) without copying files.
rsync -av -f"+ */" -f"- *" ~/Android/android-sdk-macosx .
@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
@vitovalov
vitovalov / dagger2-problems-investigation-links.md
Last active September 27, 2015 23:59
Dagger2 problems investigation
@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 / 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 / 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 / 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