Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@liuyu121
liuyu121 / git-branches-by-commit-date.sh
Last active August 28, 2015 10:14 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@liuyu121
liuyu121 / install-lnmp-env@ubuntu.sh
Created July 23, 2015 03:48
install latest LNMP + redis + etc.
sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
# install nginx
# add the repository ppa
sudo add-apt-repository ppa:nginx/stable
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo add-apt-repository ppa:ondrej/php5
#!/bin/bash
BUILDDIR=/tmp/phpimapmountainlion
# Original Script found at:
# http://blog.vucica.net/2012/10/installing-imap-extension-for-php-on-mountain-lion.html
mkdir "$BUILDDIR"
echo " "
echo "= FETCHING AND INSTALLING IMAP"
@liuyu121
liuyu121 / UUID.php
Last active August 29, 2015 14:10 — forked from dahnielson/UUID.php
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@liuyu121
liuyu121 / pdf2jpg.sh
Last active August 29, 2015 14:09 — forked from yura/pdf2jpg.sh
#!/bin/bash
# Script to convert PDF file to JPG images
#
# Dependencies:
# * pdftk
# * imagemagick
PDF=$1
@liuyu121
liuyu121 / linux_create_user
Last active August 29, 2015 14:08
linux create user
#!/bin/bash
# @see http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
@liuyu121
liuyu121 / replay_163_yum_repo.sh
Last active August 29, 2015 14:08
Use the 163 yum repo on cetnos 6.5
#!/bin/bash
wget http://mirrors.163.com/.help/CentOS6-Base-163.rep
cd /etc/yum.repos.d/
## !important backup the system yum repo
mv CentOS-Base.repo CentOS-Base.repo.bak
mv /path/to/CentOS6-Base-163.repo CentOS-Base.repo
The reason I wanted to share this post is configuring static IP on CentOS seems to trouble many centos users. Probably, when you configure static IP, network may not work as you expected, sometimes no internet access, sometimes no IP address on eth0 etc..
First, "watch-out whether it is a CentOS Desktop version or Server version".? because they are runs at different run-levels, where;
- Desktop ver runs on run-level 5
- Server ver runs on run-level 3
Second, watch-out the configuration on
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e