Skip to content

Instantly share code, notes, and snippets.

View Buttonwood's full-sized avatar

Buttonwood Buttonwood

View GitHub Profile
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
if [ ! -f "/etc/fstab.bak" ]; then
# 备份分区表
echo "cp /etc/fstab /etc/fstab.bak"
fi
echo "echo Start finding disk drives ...... !"
@Buttonwood
Buttonwood / op.sh
Created October 11, 2014 02:32
expect 自动登录
# http://dongwm.blog.51cto.com/2621371/781099
#!/usr/bin/expect #设置解析器
set timeout 10 #设置超时时间
set password1089 *****
set passwordvps *****
set passwordkvm26 *****
set password4150 ***** #以上密码我隐藏了
set file1 [lindex $argv 0] #程序第一个参数
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@File: map-shuff-reduce.py
@Author: Hao Tan
@Date:
@Email: tanhao2013@foxmail.com
@Desc:
"""
@Buttonwood
Buttonwood / gcd.py
Created October 26, 2014 12:35
A short python script for gcd implement!
def gcd_bruteforce(m,n):
l = min(m,n)
gcd = 0
for x in xrange(1,l):
if m % x == 0 and n % x == 0:
gcd = x
return gcd
def gcd_euclidean(m,n):
l = n % m
@Buttonwood
Buttonwood / cobar.sh
Created November 26, 2014 07:23
A shell script for auto add sql to cobar
### corbar 添加查看表
#!/bin/bash
if [ $# != 3 ]; then
echo "Usage: sh $0 old.sql table_num table_name|sh"
echo "Example: sh job.sh old.sql 8 docdb"
echo " old.sh: 每张表要添加的sql语句"
echo " table_num: 每个ip有多少张表 [8]"
echo " table_name: 每张表的名字 [docdb]"
exit
fi
@Buttonwood
Buttonwood / cmd.py
Created December 8, 2014 04:05
A short script for stop and start cluster in patch.
#!/usr/bin/env python
# encoding: utf-8
"""
@File: cmd.py
@Author: Hao Tan
@Date: 2014-12-06
@Email: tanhao2013@foxmail.com
@Desc: A short script for stop and start cluster in patch.
"""
@Buttonwood
Buttonwood / refGene.sql
Created March 13, 2015 07:27
gff to store in mysql
CREATE TABLE `refGene` (
`bin` smallint(5) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`chrom` varchar(255) NOT NULL,
`strand` char(1) NOT NULL,
`txStart` int(10) unsigned NOT NULL,
`txEnd` int(10) unsigned NOT NULL,
`cdsStart` int(10) unsigned NOT NULL,
`cdsEnd` int(10) unsigned NOT NULL,
`exonCount` int(10) unsigned NOT NULL,
use Data::Dumper;
while (<>) {
my @tmp = split(/\s+/,$_);
my $head = join("\t",@tmp[0,1,2,3]);
my $end = &store_hash($tmp[9],$tmp[10]);
my @key = sort {$a <=> $b} keys (%$end);
foreach my $x (@key) {
my $last = $end->{$x};
print "$head\t$x\t$last\n";
@Buttonwood
Buttonwood / helper.py
Created July 15, 2015 01:47
Some useful functions as helpers for python programming
#!/usr/bin/env python
# encoding: utf-8
import socket, fcntl, struct
def get_hostname():
return socket.gethostname()
def get_local_ip(ifname = 'eth0'):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
inet = fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))
@Buttonwood
Buttonwood / Emoji.java
Created July 29, 2015 03:54
表情字符判断
/**
* 判断一个字符是否emoji表情字符
*
* @param ch
* 待检测的字符
*/
public static boolean isEmoji(char ch) {
return !((ch == 0x0) || (ch == 0x9) || (ch == 0xA) || (ch == 0xD)
|| ((ch >= 0x20) && (ch <= 0xD7FF))
|| ((ch >= 0xE000) && (ch <= 0xFFFD)) || ((ch >= 0x10000) && (ch <= 0x10FFFF)));