Skip to content

Instantly share code, notes, and snippets.

@larryli
larryli / jquery.eviltransform.js
Last active October 14, 2020 04:42
Transform coordinate between earth(WGS-84) and mars in china(GCJ-02).
;(function($) {
function outOfChina(lat, lng) {
if ((lng < 72.004) || (lng > 137.8347)) {
return true;
}
if ((lat < 0.8293) || (lat > 55.8271)) {
return true;
}
return false;
}
@larryli
larryli / jquery.geolocation.js
Last active August 29, 2015 13:57
jQuery GeoLocation
;(function($) {
var settings = {
options: {
timeout: 5000,
maximumAge: 100
}
};
var busy = false;
var lat, lng, doneFunc;
@larryli
larryli / jquery.geolocationpicker.css
Last active August 29, 2015 13:57
jQuery GeoLocation Picker (By Google Map)
div.geolocationpicker {
width: 100%;
height: 400px;
border-radius: 7px;
box-shadow: 0pt 2px 4px rgba(0, 0, 0, 0.4);
margin: 0.5em 0 1em;
clear: both;
}
div.geolocationpicker div.geo-bar {
@larryli
larryli / after.sh
Last active April 20, 2016 13:29
laravel homestead install phalcon and remove postgresql/memcached/beanstalkd/redis
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
# install phalcon
phalcon_so="`php-config --extension-dir`/phalcon.so"
if [ ! -f $phalcon_so ]; then
# apt-get install -y php5-dev php5-mysql gcc libpcre3-dev
@larryli
larryli / install-shadowsocks-local-service.sh
Last active September 7, 2020 05:57
Debian/Ubuntu systemd shadowsocks-local service
#!/bin/sh
# sudo ./install-shadowsocks-local-service.sh
cp shadowsocks-local.default /etc/default/shadowsocks-local
cp shadowsocks-local.init /etc/init.d/shadowsocks-local
chmod +x /etc/init.d/shadowsocks-local
ln -s ../init.d/shadowsocks-local /etc/rc0.d/K01shadowsocks-local
ln -s ../init.d/shadowsocks-local /etc/rc1.d/K01shadowsocks-local
ln -s ../init.d/shadowsocks-local /etc/rc2.d/K01shadowsocks-local
ln -s ../init.d/shadowsocks-local /etc/rc3.d/K01shadowsocks-local
@larryli
larryli / 17monipdb2qqwry.php
Created September 19, 2015 12:56
自动下载 ipip.net 的 17monipdb.dat 然后转换为 qqwry.dat
<?php
// composer require "larryli/ipv4=~1.0"
include 'vendor/autoload.php';
$monipdb = new \larryli\ipv4\MonipdbQuery('17monipdb.dat');
if (!$monipdb->exists()) {
$monipdb->init();
}
@larryli
larryli / dnsmasq-gfwlist.py
Created April 23, 2016 08:23
自动更新 dnsmasq gfwlist 规则
#!/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
@larryli
larryli / GIT_SSH_COMMAND.sh
Last active January 21, 2021 20:35
Git ssh socks proxy
#!/bin/sh
export GIT_SSH_COMMAND='ssh -o ProxyCommand="connect -S 127.0.0.1:1080 %h %p"'
git config --global core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:1080 %h %p"'
git clone -c=core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:1080 %h %p"' git@github.com:larryli/ipv4.git
git config core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:1080 %h %p"'
@larryli
larryli / trans_china_districts.php
Last active December 8, 2016 10:48
转换 http://www.mca.gov.cn/article/sj/tjbz/a/ 的文本数据为 PHP 数据和 SQL
<?php
$directly = ['11', '12', '31', '50', '81', '82'];
$names = [
'拉祜族佤族布朗族傣族自治县', '保安族东乡族撒拉族自治县', '彝族哈尼族拉祜族自治县', '傣族拉祜族佤族自治县',
'哈尼族彝族傣族自治县', '彝族回族苗族自治县', '布依族苗族自治县', '布依族苗族自治州', '白族普米族自治县',
'苗族瑶族傣族自治县', '傣族景颇族自治州', '独龙族怒族自治县', '哈尼族彝族自治县', '哈尼族彝族自治县', '哈尼族彝族自治州',
'满族蒙古族自治县', '蒙古族藏族自治州', '苗族布依族自治县', '苗族土家族自治县', '土家族苗族自治县', '壮族苗族自治州',
'土家族苗族自治州', '仡佬族苗族自治县', '藏族羌族自治州', '傣族佤族自治县', '傣族彝族自治县', '哈萨克族自治县',
'回族土族自治县', '回族彝族自治县', '柯尔克孜自治州', '黎族苗族自治县', '苗族侗族自治县', '苗族侗族自治州',
@larryli
larryli / buttons.go
Last active August 16, 2017 08:53
Orange Pi Zero TTP224
package main
import (
"fmt"
"github.com/davecheney/gpio"
"os"
"os/signal"
"time"
)