This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EventBus { | |
private final Subject<Boolean, Boolean> eventBus = new SerializedSubject<>(PublishSubject.<Boolean>create()); | |
private EventBus() { | |
} | |
private static class SingleTonHelper { | |
private static final EventBus INSTANCE = new EventBus(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rather than going one by one and unchecking each and every one, run this JS query from | |
//the console on chrome or firefox that shows up after "inspecting the code" and then just | |
// check the ones that you want after wards. | |
switches = document.getElementsByClassName("M0PRCSC-Rc-g M0PRCSC-Rc-h"); | |
for(i = 0; i < switches.length; i++) { | |
if (switches[i].getAttribute("aria-checked") == "false") { | |
switches[i].click() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The calculation (value * scale + 0.5f) is a widely used to convert from dps to pixel units | |
* based on density scale | |
* see developer.android.com (Supporting Multiple Screen Sizes) | |
*/ | |
public static int convertDpToPixels(int dp, DisplayMetrics displayMetrics) { | |
return Math.round(dp * ((displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT))); | |
} | |
Note: to get the display metrics do: getContext().getResources().getDisplayMetrics(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for file in *; do mv "$file” "`echo $file | tr "[:upper:]" "[:lower:]"`"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Xms512m | |
-Xmx3g | |
-XX:MaxPermSize=2g | |
-XX:ReservedCodeCacheSize=1g | |
-XX:+UseCompressedOops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// without reflection | |
ClassName className = new ClassName(); | |
className.unsubscribe(); | |
// with reflection | |
Object className = ClassName.class.newInstance(); | |
Method m = className.getClass().getDeclaredMethod("unsubscribe", new Class[0]); | |
m.invoke(className); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/libexec/java_home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generate KeyHash for Facebook SDK | |
1. First open a terminal (open a command prompt in windows). | |
2. Navigate in the terminal to the directory where your Android debug.keystore is stored. | |
3. Mostly it will located under “/Users/user_name/.android/” (In Windows will be C:\Documents and Settings\.android). | |
4. Once you are in the “.android” directory, run the following command.keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 | |
Note: “androiddebugkey” can be the username for the keystone file and “debug.keystore” can be the name of the keynote file | |
1. When it prompts you for a password, type android and hit Enter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getStringFromAssetFile(final Context context, final String filename) { | |
final int MAX_BUFF = 1024 * 100; | |
final InputStream is; | |
final InputStreamReader isr; | |
final BufferedReader br; | |
String resultData = ""; | |
try { | |
final AssetManager am = context.getAssets(); |
OlderNewer