Skip to content

Instantly share code, notes, and snippets.

@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: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"

#!/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

Mac软件


homebrew-cask

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

安装homebrew-cask之前要先安装一下几个软件:
  • Command Line Tools
  • homebrew
@sgsheg
sgsheg / gist:73da7ab8cdc2595f7b2c
Last active August 29, 2015 14:04
vim Bundle plugin
@sgsheg
sgsheg / gist:9123320a4486cbb619e3
Created July 29, 2014 08:25
make div center the screen jquery plugin
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + 
                        $(window).scrollTop()) + "px");
    this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + 
                        $(window).scrollLeft()) + "px");
    return this;

}

@sgsheg
sgsheg / gist:218fa339c0ea53a56e24
Last active August 29, 2015 14:03
input only numberic
function validate(evt) {
	var theEvent = evt || window.event;
	var key = theEvent.keyCode || theEvent.which;
	key = String.fromCharCode( key );
	var regex = /[0-9]|\./;
	if( !regex.test(key) ) {
		// alert('hello')
	theEvent.returnValue = false;
	if(theEvent.preventDefault) theEvent.preventDefault();

}

#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
@sgsheg
sgsheg / gist:a888017d69a44b296195
Created June 8, 2014 03:13
MySQL必知必会

Mysql基本

========

  1. 检索数据
    • 检索单个列数据
    • 检索多个列数据
    • 检索所有列数据
    • 检索不同的值
      • 使用 DISTINCT关键字
      • 不能部分使用DISTINCT,关键字用于所有列,不仅仅是跟在其后的列。
  • 限制结果
@sgsheg
sgsheg / gist:7f625c6cd150e8f4dad5
Last active August 29, 2015 14:02
Make a DIV Into a Link

I am looking for an XHTML 1.1 valid way to make a DIV into a clickable link.

More better:

You can't make the div a link itself, but you can make an <a> tag act as a block, the same behaviour a <div> has.

a {
    display: block;

}