Skip to content

Instantly share code, notes, and snippets.

View lovelock's full-sized avatar
🏠
Working from home

Frost Wong lovelock

🏠
Working from home
  • http://www.weibo.com
  • Beijing, China
View GitHub Profile
@lovelock
lovelock / Topology.java
Last active August 28, 2016 10:15
general storm topology main method
public static void main(String[] args) throw Exception {
TopologyBuilder builder = new TopologyBuilder();
String spout_id = "spout";
String bolt1_id = "bolt1";
String bolt2_id = "bolt2";
MySpout spout = new MySpout();
MyBolt1 bolt1 = new MyBolt1();
MyBolt2 bolt2 = new MyBolt2();
@lovelock
lovelock / updategfwlist.sh
Created August 28, 2016 10:27
感谢原作者
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
#
# Example usage
#
# ./whatever-you-name-this.sh
#
# Task Scheduling (Optional)
@lovelock
lovelock / vbox.sh
Created October 14, 2016 11:03
VBoxManage 操作
#!/usr/bin/env bash
OPTIND=1
ADDRESS="0.0.0.0"
PORT=5000
MEMORY=1024
VM_NAME=""
ISO_FILE=""
function show_help {
@lovelock
lovelock / storm-nimbus.conf
Created November 4, 2016 10:10
使用supervisord维持一个需要自动重启的进程的模板
[program:storm-nimbus]
command=/opt/apache/storm/bin/storm nimbus
directory=/opt/apache/storm
autostart=true
autorestart=true
user=hadoop
@lovelock
lovelock / example.com.conf
Created November 29, 2016 08:07
A simple PHP nginx vhost
server {
listen 80;
server_name example.com;
error_log /data/log/php/htdocs/error.log;
access_log /data/log/php/htdocs/access.log;
root /data/web/htdocs/public;
location / {
try_files $uri /index.php$is_args$args;
@lovelock
lovelock / nginx_log_rotation.sh
Created August 31, 2017 09:43
script to rotate nginx access/error log depending on current date, it should be run at 00:00
#!/usr/bin/env bash
YESTERDAY=$(date -d'1 days ago' +%Y%m%d)
for log in /data/log/nginx/*.log; do
mv ${log} ${log}.${YESTERDAY}
done
kill -USR1 `cat /run/nginx.pid`
sleep 1
@lovelock
lovelock / nginx.service
Created August 31, 2017 09:44
systemd nginx service
# Stop dance for nginx
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
@lovelock
lovelock / gt.sh
Created August 31, 2017 09:45
rename it to gt and put it at /usr/local/bin and you can use gt to create a git tag with current minute
#!/usr/bin/env bash
if [ $# == 0 ]; then
echo "tag must be set\n"
exit 1
fi
NOW=$(date +%Y%m%d%H%M)
git tag ${NOW}_${1}
@lovelock
lovelock / Liberal Regex Pattern for Web URLs
Created September 1, 2017 06:44 — forked from gruber/Liberal Regex Pattern for Web URLs
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@lovelock
lovelock / Liberal Regex Pattern for All URLs
Created September 1, 2017 06:44 — forked from gruber/Liberal Regex Pattern for All URLs
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))