Skip to content

Instantly share code, notes, and snippets.

@xhan
xhan / .profile
Created May 24, 2012 06:43
cd to current Xcode's project folder in Terminal
function cdxcode()
{
path="`osascript ~/Codes/scripts/cdxcode.scpt 2>/dev/null`"
if [ -n "$path" ]; then
echo "cd to $path"
cd "$path"
else
echo "no Xcode Project finded"
fi
}
@xhan
xhan / yaml-json.rb
Created April 5, 2013 10:30
simple script to convert between JSON and YAML
#! /usr/bin/env ruby
def usage
puts "USAGE: binary file.json/yaml [json/yaml] "
true
end
require 'yaml'
require 'json'
@xhan
xhan / update_yum_source.sh
Created September 16, 2013 02:57
update yum sources to 163.com ( moved from aliyun.com)
#!/bin/bash
#########################################
#Function: update yum source
#Usage: bash update_yum_source.sh
#Author: Customer service department
#Company: Alibaba Cloud Computing
#Version: 2.1
#########################################
check_os_release()
{
@xhan
xhan / .vimrc
Last active December 23, 2015 17:19
我的vim配置
"四个空格
set tabstop=4
"使用space代替tab
set expandtab
" #自动缩进的宽度
set shiftwidth=4
" 根据文件中其他地方的缩进空格个数来确定一个 tab 是多少个空格
set smarttab
" :retab 将所有 tab 扩展成空格,这样就完美了
@xhan
xhan / crontab_list.sh
Created September 30, 2013 04:21
get all user's crontab list
for user in $(cut -f1 -d: /etc/passwd);
do
crontab -u $user -l 2>/dev/null
if [ $? -eq 0 ]; then
echo $user
echo "-------------------------------"
fi
done