Skip to content

Instantly share code, notes, and snippets.

like achenglike

Block or report user

Report or block achenglike

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@achenglike
achenglike / 修改TabLayout Indicator的宽度
Created Jun 7, 2018 — forked from Runly/修改TabLayout Indicator的宽度
change TabLayout Indicator width 修改TabLayout Indicator的宽度
View 修改TabLayout Indicator的宽度
/**
* 通过反射修改TabLayout Indicator的宽度(仅在Android 4.2及以上生效)
*/
private void setUpIndicatorWidth(TabLayout tabLayout) {
Class<?> tabLayoutClass = tabLayout.getClass();
Field tabStrip = null;
try {
tabStrip = tabLayoutClass.getDeclaredField("mTabStrip");
tabStrip.setAccessible(true);
} catch (NoSuchFieldException e) {
@achenglike
achenglike / ContextUtil
Created Apr 25, 2018
get activity from context
View ContextUtil
/**
* get Activity from context
* @param context
* @return
*/
public static Activity getActivity(Context context) {
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity)context;
}
@achenglike
achenglike / InterceptRequest.java
Created Nov 21, 2017 — forked from silvestrpredko/InterceptRequest.java
Append parameters to POST in Intercept(OkHttp)
View InterceptRequest.java
/**
* @param parameter - this is string that contains parameters for Http POST
* @param request - old Request
* @return - new {@link Request} with additional parameters
* */
public static Request interceptRequest(@NotNull Request request, @NotNull String parameter)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@achenglike
achenglike / node-and-npm-in-30-seconds.sh
Created Oct 14, 2016 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
View node-and-npm-in-30-seconds.sh
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
You can’t perform that action at this time.