Skip to content

Instantly share code, notes, and snippets.

View flyfire's full-sized avatar
🎯
Focusing

flyfire flyfire

🎯
Focusing
View GitHub Profile
package com.xinghui.notificationlistenerservicedemo;
import android.app.ActivityManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.Process;
@evrins
evrins / layout.xml
Created August 26, 2016 14:54 — forked from kamikat/layout.xml
NestedScrollView + SwipeRefreshLayout + RecyclerView
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
@littlecodersh
littlecodersh / main.py
Last active February 25, 2025 02:20
Main script behind itchat robot
#coding=utf8
import itchat
# tuling plugin can be get here:
# https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
from tuling import get_response
@itchat.msg_register('Text')
def text_reply(msg):
if u'作者' in msg['Text'] or u'主人' in msg['Text']:
return u'你可以在这里了解他:https://github.com/littlecodersh'
@markcerqueira
markcerqueira / WebViewMeasuringActivity.java
Last active November 28, 2018 21:21
Android WebView Content Measuring
public class WebViewMeasuringActivity extends RelativeLayout {
public void loadHtml(String html)
WebView webView = (WebView) findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new WebViewResizer(), "WebViewResizer");
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView webView, String url) {
webView.loadUrl("javascript:window.WebViewResizer.processHeight(document.querySelector('body').offsetHeight);");
@nesquena
nesquena / SnappyRecyclerView.java
Last active June 21, 2023 23:04
Snap-to-Center RecyclerView Extension
// From: http://stackoverflow.com/a/37816976
public class SnappyRecyclerView extends RecyclerView {
// Use it with a horizontal LinearLayoutManager
// Based on http://stackoverflow.com/a/29171652/4034572
public SnappyRecyclerView(Context context) {
super(context);
}
@tyomo4ka
tyomo4ka / git-aliases.md
Last active September 30, 2024 10:21 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup on OS X (brew)

The Ultimate Git Alias Setup on OS X (brew)

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bash_profile
@lbalmaceda
lbalmaceda / android_osx_setup.md
Last active February 26, 2021 08:14
Mac OS X Environment Setup with Android

Mac OS X Environment Setup with Android

Every time I format the drive and perform a clean install of the SO, I end up searching for my favorite stuff. This file tries to sum up my setup.

Browser

Download Chrome.

Also install the latest JDK (Java Development Kit).

Text Editor

@52cik
52cik / npm.taobao.sh
Last active November 23, 2024 11:42
npm 淘宝镜像配置
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
@swankjesse
swankjesse / HostSelectionInterceptor.java
Last active May 17, 2024 19:11
This OkHttp application interceptor will replace the destination hostname in the request URL.
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;
@109021017
109021017 / current_activity.sh
Created February 3, 2016 09:32
A shell script log the current android top activity
oldActvity=""
displayName=""
currentActivity=`adb shell dumpsys window windows | grep -E 'mCurrentFocus'`
while true
do
if [[ $oldActvity != $currentActivity && $currentActivity != *"=null"* ]]; then
displayName=${currentActivity##* }
displayName=${displayName%%\}*}
echo $displayName
oldActvity=$currentActivity