Skip to content

Instantly share code, notes, and snippets.

@looio
looio / auto-redir-mobile.js
Created April 28, 2016 05:23 — forked from cssmagic/auto-redir-mobile.js
让手机用户自动跳转到移动版网站。
var _ua = _ua || {};
_ua.str = navigator.userAgent.toLowerCase();
_ua.isAndroid = _ua.str.indexOf('android') > -1 && _ua.str.indexOf('mobile') > -1;
_ua.isIPhone = /\(i(?:phone|pod);/.test(_ua.str);
if (_ua.isAndroid || _ua.isIPhone) {
location.href = 'http://m.example.com/';
}
@looio
looio / ss-redir 透明代理.md
Created November 20, 2015 00:59 — forked from wen-long/ss-redir 透明代理.md
ss-redir 透明代理.md

##ss-redir 的 iptables 配置(透明代理)

透明代理指对客户端透明,客户端不需要进行任何设置就使用了网管设置的代理规则

创建 /etc/ss-redir.json 本地监听 7777 运行ss-redir -v -c /etc/ss-redir.json

iptables -t nat -N SHADOWSOCKS
# 在 nat 表中创建新链
iptables -t nat -A SHADOWSOCKS -p tcp --dport 23596 -j RETURN
# 23596 是 ss 代理服务器的端口,即远程 shadowsocks 服务器提供服务的端口,如果你有多个 ip 可用,但端口一致,就设置这个
@looio
looio / gist:80b036b4d111c6cdec79
Created May 13, 2015 12:23
Grails 3.0.x issue fix
More details about the problem in InfoQ article See http://www.infoq.com/news/2014/08/Java8-U11-Broke-Tools and http://www.takipiblog.com/2014/08/07/oracles-latest-java-8-update-broke-your-tools-how-did-it-happen/ . The articles mainly mention Java 8u11 breaking things, but the same problems are in Java 7u65/7u67 and 8u20 .
However in Java7 it's possible to use "-XX:-UseSplitVerifier" or "-Xverify:none" command line option to workaround the problems. In Java 8 the only work around is using the "-Xverify:none" jvm commandline option.
I recently ran into the same issue when Travis upgraded their JVM to 7u67 . They downgraded back to 7u60 . This was the issue: https://github.com/travis-ci/travis-ci/issues/2725
# https://android.googlesource.com/platform/frameworks/native/+/master/cmds/dumpsys/
# dumpsys command dumps system data (status of system services) to the screen
$ adb shell dumpsys
# to see all available system services
$ adb shell service list
Example of output:
> Found 72 services:
StringBuilder buf=new StringBuilder();
InputStream json=getAssets().open("book/contents.json");
BufferedReader in=
new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str=in.readLine()) != null) {
buf.append(str);
}
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@looio
looio / gist:86b9c1c5e88cf2946d01
Created October 23, 2014 05:07
remote logger - send logs to server
public final class Logger {
public static final String DISPATCHER_REPORT_URI = App.getDispatcherUri() + "/vidLog/report";
private static final int CAPACITY = 10;
private static final String APPLICATION_LOG_TAG = "YourApp";
private static List<String> logs = new Vector<String>(CAPACITY);
public synchronized static void r(String msg) {
public static String sha1(String s, String keyString) throws
UnsupportedEncodingException, NoSuchAlgorithmException,
InvalidKeyException {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(key);
byte[] bytes = mac.doFinal(s.getBytes("UTF-8"));
# https://android.googlesource.com/platform/frameworks/native/+/master/cmds/dumpsys/
# dumpsys command dumps system data (status of system services) to the screen
$ adb shell dumpsys
# to see all available system services
$ adb shell service list
Example of output:
> Found 72 services:
import java.util.ArrayList;
import java.util.List;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;