Skip to content

Instantly share code, notes, and snippets.

View lyhcode's full-sized avatar

Kyle Lin lyhcode

View GitHub Profile
@lyhcode
lyhcode / vpnconn.sh
Created January 25, 2013 17:21
Let VPN clients access to server LAN using iptables and route
# ubuntu vpn server
sudo iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d 192.168.0.0/24 -j MASQUERADE
# mac os x client
sudo route add 192.168.0.0/24 192.168.100.1
@lyhcode
lyhcode / client-ifconfig.txt
Created January 25, 2013 16:05
all relevant configuration files and the route tables
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=2b<RXCSUM,TXCSUM,VLAN_HWTAGGING,TSO4>
ether 10:9a:dd:46:41:8d
worker.list=loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=contpub1
worker.loadbalancer.sticky_session=1
worker.loadbalancer.error_escalation_time=0
worker.loadbalancer.max_reply_timeouts=10
worker.contpub1.reference=worker.template
worker.contpub1.host=localhost
@lyhcode
lyhcode / svn
Created January 5, 2013 13:39
sample configuration /etc/xinetd.d/svn
# default: off
# description: svnserve is the server part of Subversion.
# server_args = -i -r /var/lib/svn/repositories
service svn
{
disable = no
port = 3690
socket_type = stream
protocol = tcp
wait = no
@lyhcode
lyhcode / selenium_screenshot.groovy
Created December 30, 2012 14:35
Groovy + Selenium for Web ScreenShot Capturing
@Grapes([
@Grab('org.seleniumhq.selenium.client-drivers:selenium-java-client-driver:1.0.2'),
@Grab('org.seleniumhq.selenium:selenium-server:2.25.0'),
@GrabConfig(systemClassLoader=false, initContextClassLoader=true)
])
import com.thoughtworks.selenium.*
import org.openqa.selenium.server.*
seleniumServer = new SeleniumServer()
@lyhcode
lyhcode / jsoup_demo.groovy
Created December 30, 2012 13:34
Groovy + Jsoup
@Grab('org.jsoup:jsoup:1.7.1')
def doc = org.jsoup.Jsoup.connect("https://news.google.com/nwshp?hl=zh-TW&tab=wn").get()
doc.select("#s_POPULAR .titletext").each {
node->
println "title=${node.text()}"
}
n02.jpg 0.052
s10.jpg 0.037
n05.jpg 0.099
b02.jpg 0.110
b04.jpg 0.085
n04.jpg 0.088
n10.jpg 0.064
s04.jpg 0.028
n03.jpg 0.064
b03.jpg 0.066
@lyhcode
lyhcode / nekohtml.groovy
Created December 27, 2012 10:51
Groovy + NekoHTML simple demo
@Grab('net.sourceforge.nekohtml:nekohtml:1.9.16')
def parser = new org.cyberneko.html.parsers.SAXParser()
def page = new XmlParser(parser).parse('https://news.google.com/nwshp?hl=zh-TW&tab=wn')
page.depthFirst().DIV.grep{ it.'@class'=='title' }.each {
println it.A.SPAN.text()
}
@lyhcode
lyhcode / gist:3884579
Created October 13, 2012 13:06
solved: paypal Data does not match input character set or default encoding.
<!--
Solve the PayPal error:
paypal Data does not match input character set or default encoding.
-->
<input type="hidden" name="charset" value="UTF-8">
@lyhcode
lyhcode / hcsr04.ino
Created October 10, 2012 08:30
Arduino + HC-SR04 超音波測距控制 LED 燈閃爍
#define TRIGPIN 10
#define ECHOPIN 13
#define LED1 8
#define LED2 9
long ping() {
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);