Skip to content

Instantly share code, notes, and snippets.

@rhybroy
rhybroy / dnsmasq-gfwlist.py
Created August 31, 2018 16:54 — forked from lanceliao/dnsmasq-gfwlist.py
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
@rhybroy
rhybroy / dns-setter.sh
Last active August 29, 2015 14:22 — forked from finscn/dns-setter.sh
#!/bin/bash
# Please run this shell with "sudo ..."
SERVICE=Wi-Fi
# You could change the service. List all network services via:
# networksetup -listallnetworkservices
echo ""
echo "Current DNS on ${SERVICE}:"
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@rhybroy
rhybroy / pptp_autocon.applescript
Last active April 5, 2017 12:17
auto connect/disconnect pptp-vpn from the command line for mac
set msg to ""
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN (PPTP)"
if exists VPNservice then
set isConnected to connected of current configuration of VPNservice
if isConnected then
disconnect VPNservice
set msg to "Disconnected"
else
@rhybroy
rhybroy / bashrc
Created April 23, 2013 10:05
linux server rc
alias fp='ps aux|grep'
alias vi='mvim'
alias df="df -h"
alias mv="mv -i"
alias slink="link -s"
alias l="ls -lh"
alias la="ls -lhAF"
alias ll="ls -lhF"
alias lt="ls -lhtrF"
alias l.="ls -lhtrdF .*"
@rhybroy
rhybroy / tmux-iterm2.rb
Last active December 16, 2015 11:48
tmux-iterm2 brew install
require 'formula'
class TmuxIterm2 < Formula
url 'https://iterm2.googlecode.com/files/tmux-for-iTerm2-20130319.tar.gz'
sha1 'f14a0bad6991b9e3380d5c3a6057e09f62597d1f'
head 'git://tmux.git.sourceforge.net/gitroot/tmux/tmux'
depends_on 'pkg-config' => :build
depends_on 'libevent'
@rhybroy
rhybroy / default-ips
Last active December 10, 2015 05:38
generate vpn routes from ip txt
#
#Google
#
216.73.93.70/31
216.73.93.72/31
216.239.32.0/19
64.233.160.0/19
66.249.80.0/20
72.14.192.0/18
209.85.128.0/17
@rhybroy
rhybroy / pptp.sh
Created December 25, 2012 02:09
pptp install for ubuntu
#!/bin/bash
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this tool!\n"
exit 1
fi
clear
printf "
####################################################
# #
@rhybroy
rhybroy / arithmetic.py
Created November 28, 2012 03:53
计算字符串相似度(编辑距离算法)
#!/user/bin/env python
# -*- coding: utf-8 -*-
class arithmetic():
def __init__(self):
pass
''' 【编辑距离算法】 【levenshtein distance】 【字符串相似度算法】 '''
def levenshtein(self,first,second):
if len(first) > len(second):