Skip to content

Instantly share code, notes, and snippets.

View vinaysshenoy's full-sized avatar

Vinay Shenoy vinaysshenoy

View GitHub Profile
-nosplash
--launcher.defaultAction
openFile
-vm
C:/JDK7/jre/bin/server/jvm.dll #Windows
#/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java #OS X
-vmargs
-Xincgc
-Xss1m
-Duser.name=FirstName LastName
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@vinaysshenoy
vinaysshenoy / android-map-utility
Created June 8, 2014 10:12
Some Utility methods for Google's Android Map SDK
/**
* Returns the center of a map
*
* @param map The map to fetch the center location of
* @return The center of the map
*/
public static Location getCenterLocationOfMap(final GoogleMap map) {
final LatLng latLng = map.getCameraPosition().target;
final Location location = new Location(LocationManager.PASSIVE_PROVIDER);
location.setLatitude(latLng.latitude);
@vinaysshenoy
vinaysshenoy / gist:7d6ed97010c9ee48add6
Last active August 29, 2015 14:16
Checkout file from older commit
git checkout sha1 -- path/to/file.txt
git checkout 'master@{7 days ago}' -- path/to/file.txt
@vinaysshenoy
vinaysshenoy / gist:f54a208ad93b10e94a3a
Created March 1, 2015 06:58
Android check if color is dark
public boolean isColorDark(int color){
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255;
if(darkness<0.5){
return false; // It's a light color
}else{
return true; // It's a dark color
}
}
@vinaysshenoy
vinaysshenoy / gist:d8ed1e51ac0f6abb53ce
Created March 1, 2015 19:29
Remote branches deleted from remote repo
git remote prune <remote>
@vinaysshenoy
vinaysshenoy / gist:4dc5df8240a77383713e
Created March 1, 2015 19:33
Git delete branch both locally and remotely
git branch -d <branch>
git push <remote> :<branch>
@vinaysshenoy
vinaysshenoy / gist:fa8eb8b2447f5e7451af
Last active August 29, 2015 14:18
DP/PX Conversion
/**
* Converts a raw pixel value to a dp value, based on the device density
*/
private static float pxToDp(float px) {
return px / Resources.getSystem().getDisplayMetrics().density;
}
/**
* Converts a raw dp value to a pixel value, based on the device density
*/
@vinaysshenoy
vinaysshenoy / styled popup menu.java
Created August 18, 2015 07:54
Create a popup menu with a style
Context wrapper = new ContextThemeWrapper(getContext(), R.style.PopupMenu);
PopupMenu popupMenu = new PopupMenu(wrapper, v);
@vinaysshenoy
vinaysshenoy / colottohex.java
Created August 26, 2015 17:56
Android Color to hexString
String hexColor = String.format("#%06X", (0xFFFFFF & intColor)); //Without alpha
String hexColor = String.format("#%08X", (0xFFFFFFFF & intColor)); //With alpha(Not tested)