Skip to content

Instantly share code, notes, and snippets.

@sgsheg
sgsheg / gist:73da7ab8cdc2595f7b2c
Last active August 29, 2015 14:04
vim Bundle plugin

Mac软件


homebrew-cask

cask是基于homebrew的扩展命令,直接通过命令行去安装Mac的各种软件。免去之前通过下载链接下载DMG文件,然后拖动到Applitions目录,这种手动的安装方法。如果配置一部新的Mac机器,主要安装了cask,通过一个脚本就安装把用到软件一一安装上去,可以节约很多时间。

安装homebrew-cask之前要先安装一下几个软件:
  • Command Line Tools
  • homebrew
#!/bin/sh
# CRON
## delete encrypted backups older than 5 days
#55 3 * * * find /path/to/backups-enc -mtime +5 -exec rm {} \;
## delete un-encrypted backups older than 1 days
#55 3 * * * find /path/to/backups -mtime +0 -exec rm {} \;
## database dump at 4am UTC = 8pm PST (9pm PDT)
#0 4 * * * /path/to/this/script
@sgsheg
sgsheg / gist:c4b318c2fc726b44753c
Created August 23, 2014 08:16
listen php-fpm stop

Listen php-fpm stop and restart it again


#!/bin/bash
# author: Teddy

CheckURL="http://fueux.com"

STATUS_CODE=`curl -o /dev/null -m 10 --connect-timeout 10 -s -w %{http_code} $CheckURL`

#echo "$CheckURL Status Code:\t$STATUS_CODE"

@sgsheg
sgsheg / gist:5de4f842420567b98832
Last active August 29, 2015 14:05
修改linux默认的sh

Try linux command chsh.

The detailed commands is chsh -s /bin/bash. It will prompt you to enter your password. Your default login shell is /bin/bash now.

The following is quoted from man page:

The cash command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change the login shell for any account.

This command will change the default login shell permanently.

@sgsheg
sgsheg / gist:7972abcec7e6d625b408
Last active August 29, 2015 14:05
Update redis to the the lastest version

Update redis to the lastest version


You can use the following PPA: https://launchpad.net/~rwky/+archive/redis.

You can install this repo running the command:

sudo add-apt-repository ppa:rwky/redis

sudo apt-get update

@sgsheg
sgsheg / gist:e3fe6e287b50be949623
Created August 30, 2014 09:32
理解php中的一些符号
@sgsheg
sgsheg / gist:e22af809e19bff474abe
Created September 4, 2014 10:05
Vim 补全代码
命令 | 补全类型
--------------------------------------------------------------
<C -n> 普通关键字
<C -x> <C -n> 当前缓冲区关键字
<C -x> <C -i> 包含文件关键字
<C -x> <C -]> 标签文件关键字
<C -x> <C -k> 字典查找
<C -x> <C -l> 整行补全
<C -x> <C -f> 文件名补全
<C -x> <C -o> 全能补全
#############################################################################
# current prompt
#############################################################################
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
@sgsheg
sgsheg / Liberal Regex Pattern for Web URLs
Created October 12, 2015 10:51 — 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