Skip to content

Instantly share code, notes, and snippets.

View achenglike's full-sized avatar

like achenglike

View GitHub Profile
@achenglike
achenglike / schemeapp_.gitignore
Created May 18, 2015 10:42
web页调起本地app
/build
@achenglike
achenglike / node-and-npm-in-30-seconds.sh
Created October 14, 2016 10:34 — 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.
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
@achenglike
achenglike / InterceptRequest.java
Created November 21, 2017 10:45 — forked from silvestrpredko/InterceptRequest.java
Append parameters to POST in Intercept(OkHttp)
/**
* @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 / ContextUtil
Created April 25, 2018 06:59
get activity from context
/**
* 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 / 修改TabLayout Indicator的宽度
Created June 7, 2018 11:32 — forked from Runly/修改TabLayout Indicator的宽度
change TabLayout Indicator width 修改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) {