This file contains hidden or 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
import android.content.Context; | |
import android.support.annotation.Nullable; | |
import android.support.v4.view.PagerAdapter; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* {@link ViewPager} that wraps current page's height |
This file contains hidden or 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
package net.leolink.android.rxbus; | |
import android.support.annotation.IntDef; | |
import android.support.annotation.NonNull; | |
import android.util.SparseArray; | |
import java.lang.annotation.Retention; | |
import java.util.HashMap; | |
import java.util.Map; |
This file contains hidden or 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
#!/bin/bash | |
################################################################## | |
# Open Atlassian Stash pull request from command line. | |
# (opens the default browser at the proper URL with data prefilled) | |
# | |
# It infers current branch name, repo name, current user name, from git config. | |
############################### CONFIG ########################### | |
URL_PREFIX="https://YOU_GIT_DOMAIN.com/your/project/path/compare/commits?commits&" |
This file contains hidden or 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
import edu.princeton.cs.algs4.WeightedQuickUnionUF; | |
/** | |
* Created by leolink on 11/24/16. | |
*/ | |
public class Percolation { | |
private static final int UNOPENED = 0b000; | |
private static final int OPENED = 0b001; | |
private static final int CONNECTED_TOP = 0b010; | |
private static final int CONNECTED_BOTTOM = 0b100; |
This file contains hidden or 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
Find: ^(\W+public void .*?)_([A-Z]{1})([a-zA-Z]*)_([A-Z]{1})([a-zA-Z]*)\(\) \{$ | |
Replace: $1_\l$2$3_\l$4$5() { | |
This will cause all texts like this: | |
" public void method1_DoThisDoThat_ReturnThisReturnThat() {" | |
be relaced with: | |
" public void method1_doThisDoThat_returnThisReturnThat() {" |
This file contains hidden or 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
import android.os.Handler; | |
import android.os.Looper; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.TimeUnit; |
This file contains hidden or 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
# General | |
export LANG=en_US.UTF-8 | |
export LC_CTYPE=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
# Path to your oh-my-zsh installation. | |
export ZSH=~/Dropbox/MY/Preferences/Unix/\[dot\]oh-my-zsh | |
export MANPATH="/usr/local/man:$MANPATH" | |
export SSH_KEY_PATH="~/.ssh/dsa_id" | |
# zsh custom folder | |
ZSH_CUSTOM="$ZSH/custom" |
This file contains hidden or 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
int value = -229; | |
System.out.println(value); | |
System.out.println(value >> 5); | |
System.out.println(value >>> 5); | |
System.out.println(Integer.toBinaryString(value)); | |
System.out.println(Integer.toBinaryString(value >> 5)); // `>>` preserves integer's sign | |
System.out.println(Integer.toBinaryString(value >>> 5)); // `>>>` doesn't preserve integer's sign, just shift everything to the right then fill all the empty bit on the left with 0 | |
//======================= RESULT | |
-229 |
This file contains hidden or 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 toHexString(int decimal) { | |
String codes = "0123456789ABCDEF"; | |
StringBuilder builder = new StringBuilder(8); | |
builder.setLength(8); | |
for (int i = 7; i >= 0; i--) { | |
// E.g: let decimal = 229 -> its value when expressed in binary is 11100101 | |
// And binary form of 0xF is 1111 (equals to ..00000001111) |
This file contains hidden or 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 CustomEllipsizeTextView extends TextView { | |
private static final int MAX_LINE = 2; | |
private static final String ELLIPSIZE_STRING = "..."; | |
private String originalText; | |
private int maxLines = MAX_LINE; | |
private String postfix; | |
private boolean postfixAdded; |
NewerOlder