Skip to content

Instantly share code, notes, and snippets.

@easternHong
easternHong / .pac
Created November 14, 2017 07:50
OmegaProfile_Auto_Switch
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@easternHong
easternHong / .pac
Created November 14, 2017 07:50
OmegaProfile_Auto_Switch
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@Message
public static class MsgHeader {
public MsgHeader() {
msgId = -1;
}
@Index(0)
public int msgId;
public byte[] toBytes() {
@easternHong
easternHong / ClassUtils.java
Created February 22, 2016 06:34
无需反射,获取一个类的实例...
/**
* <p>Operates on classes without using reflection.</p>
* <p/>
* <p>This class handles invalid {@code null} inputs as best it can.
* Each method documents its behaviour in more detail.</p>
* <p/>
* <p>The notion of a {@code canonical name} includes the human
* readable name for the type, for example {@code int[]}. The
* non-canonical method variants work with the JVM names, such as
* {@code [I}. </p>
@easternHong
easternHong / onLayout.java
Created December 8, 2015 14:29
android view layout children
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int row, col, left, top;
for (int i=0; i < getChildCount(); i++) {
row = i / mColumnCount;
col = i % mColumnCount;
View child = getChildAt(i);
left = col * child.getMeasuredWidth();
top = row * child.getMeasuredHeight();
@easternHong
easternHong / measure.java
Last active December 8, 2015 13:52
Android View Measure
//https://github.com/devunwired/custom-view-examples/tree/master/app/src/main/java/com/example/customview/widget
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(measure(widthMeasureSpec, true), measure(heightMeasureSpec, false));
}
private int measure(int measureSpec, boolean isWidth) {
int result;
int mode = MeasureSpec.getMode(measureSpec);
int size = MeasureSpec.getSize(measureSpec);
@easternHong
easternHong / gradle.properties
Created July 28, 2015 03:55
speed up android studio . and put this file into the ~/.gradle/
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# The Gradle daemon aims to improve the startup and execution time of Gradle.
@easternHong
easternHong / build.gradle
Last active August 29, 2020 07:59
android studio gradle checkstyle findbugs pmd lint
//go to https://github.com/easternHong/vb-android-app-quality
//get the config file and put them into app/config/..
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
task findbugs(type: FindBugs) {
description 'Run findbugs'
group 'verification'
classes = fileTree('build/intermediates/classes/debug/')
@easternHong
easternHong / xdman
Created July 8, 2015 12:41
install xdman
$ sudo add-apt-repository ppa:noobslab/apps
$ sudo apt-get update
$ sudo apt-get install xdman
Optional, to remove xdman, do:
$ sudo apt-get remove xdman
@easternHong
easternHong / install
Created June 25, 2015 14:43
ubuntu install flashPlayer plugin
目前这个安装器已经收录于 Ubuntu 14.04 官方源(从 Debian源中导入)。
Ubuntu 14.04 用户可以通过以下命令安装 Pepper Flash Player For Chromium :
sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --install
如果你想使用 Beta 版的 Google Chrome 中的 Pepper Flash Player ,那么可以把第二个命令改为:
sudo update-pepperflashplugin-nonfree --install --beta --unverified