Skip to content

Instantly share code, notes, and snippets.

View terrytowne's full-sized avatar

Terry Towne terrytowne

View GitHub Profile
  1. 开启ipv4转发
vi /etc/sysctl.conf
# 将net.ipv4.ip_forward=0更改为net.ipv4.ip_forward=1
sysctl -p
  1. 安装dnsmasq 和pdnsd解决dns污染

DNS的解析方案为 resolve.conf ==> dnsmasq ==> pdnsd

@terrytowne
terrytowne / messages.vue
Created May 22, 2016 23:36 — forked from niallobrien/messages.vue
Vue componet using a Feathers backend over websockets
<template>
<div>
<input type="text" placeholder="Enter message" v-model="newMessage" @keyup.enter="addMessage">
<button type="submit" @click="addMessage">Add message</button>
<ul>
<li v-for="message in messages">
<span @dblclick="editMessage(message)" v-if="message != editedMessage">{{ message.text }}</span>
<input
type="text"
v-model="message.text"
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@terrytowne
terrytowne / gist:6f4530fdc95a2f5ebf80
Created August 17, 2014 01:32
Disable double tap
public class HelpWebView extends WebView {
private GestureDetector gestureDetector;
private AtomicBoolean mPreventAction = new AtomicBoolean(false);
private AtomicLong mPreventActionTime = new AtomicLong(0);
public HelpWebView(Context context) {
super(context);
gestureDetector = new GestureDetector(context, new GestureListener());
}
@terrytowne
terrytowne / gist:5ae2c27331ffe1b402b9
Created August 16, 2014 02:50
Android ScaleGestureDetector work with GestureDetector.
@Override
public boolean onTouchEvent(MotionEvent event)
{
boolean result = mScaleGestureDetector.onTouchEvent(event);
// result is always true here, so I need another way to check for a detected scaling gesture
boolean isScaling = result = mScaleGestureDetector.isInProgress();
if (!isScaling)
{
// if no scaling is performed check for other gestures (fling, long tab, etc.)
@terrytowne
terrytowne / gist:7a535791eb0d0819aacc
Created August 15, 2014 09:49
capture a view to bitmap
// cache enable flag
captureRelativeLayout.setDrawingCacheEnabled(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(Config.ARGB_8888, false);
captureRelativeLayout.destroyDrawingCache();
// build cache
captureRelativeLayout.buildDrawingCache(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(Config.ARGB_8888, false);
captureRelativeLayout.destroyDrawingCache();
@terrytowne
terrytowne / gist:0f32995915328c31a70c
Created August 14, 2014 09:12
Android save WebView rendered picture.
ImageView imageview;
WebView webview;
class Background extends AsyncTask<Void, Void, Bitmap>
{
@Override
protected Bitmap doInBackground(Void... params)
{
try
{
Thread.sleep(2000);