Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / .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 / gist:2434542
Created April 21, 2012 05:58
get ip address of specific Host
#include <netinet/in.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Boolean result;
CFHostRef hostRef;
CFArrayRef addresses;
NSString *hostname = @"m2.qiushibaike.com";
hostRef = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef)hostname);
@xhan
xhan / NSDropContainer.h
Created May 7, 2011 14:39
NSDropContainer
//
// NSDropContainer.h
#import <Cocoa/Cocoa.h>
@protocol NSDropContainerDelegate;
@interface NSDropContainer : NSBox {
id<NSDropContainerDelegate> _delegate;
@xhan
xhan / gist:730001
Created December 6, 2010 08:01
Update Adium status
tell application "Adium"
go available with message "test again" -- or away or invisible
end tell
@xhan
xhan / README.mdown
Created September 19, 2010 08:06
a script to automatic do follow action to sepcify users for baidu's microblog service "百度说吧" , check the readme file before use!

#README

#description ** do something evil as you want to **

steps not one by one

  • login with your account via any web brower
  • use some tools to get your cookies
  • pastie the cookies string into scripts
@xhan
xhan / 2 triggers' relationship.cs
Created May 6, 2010 17:06
2 triggers' relationship -> unity3d
public enum TriggerState
{
Init,
Running,
Finished
}
public class MixerTriggerScript : MonoBehaviour {
public PieJuiceTriggerScript anotherTrigger;
public TriggerState state = TriggerState.Init;