Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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.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 / consume.go
Created March 14, 2014 06:48
Golang beanstalk test
package main
import (
"fmt"
. "gist.github.com/9521299.git"
"github.com/kr/beanstalk"
"time"
)
func main() {
@larryli
larryli / die.go
Last active August 29, 2015 13:57
Die err message if err not nil by Golang
// Package offers a function that die err message if err not nil.
//
// import . "gist.github.com/9521299.git"
// Die(err, something...)
//
package gist9521299
import (
"fmt"
"os"
@larryli
larryli / mgo.go
Last active August 29, 2015 13:57
labix.org/v2/mgo test
package main
import (
"fmt"
. "gist.github.com/9521299.git"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
)
func main() {
@larryli
larryli / json-fmt.go
Last active January 2, 2016 20:29
json indent formatter
// echo {"a":"b"} | go run json-fmt.go [-prefix ""] [-indent " "]
// go run json-fmt.go [-prefix ""] [-indent " "] {\"a\":\"b\"}
// go run json-fmt.go [-prefix ""] [-indent " "] -file data.json
package main
import (
"encoding/json"
"flag"
. "gist.github.com/9521299.git"