Skip to content

Instantly share code, notes, and snippets.

View quwubin's full-sized avatar

Wubin Qu quwubin

View GitHub Profile
@quwubin
quwubin / cat_all
Created March 22, 2015 14:58
List all the files with suffix .csv (e.g.) in directory "./" (e.g.)
#!/usr/bin/env ruby
require "find"
def get_opts
require 'trollop'
opts = Trollop::options do
version "#{File.basename($PROGRAM_NAME)} 1.0.0 (c) 2014 Wubin Qu"
banner <<-EOS
@quwubin
quwubin / fastaParser.go
Created September 18, 2014 02:28
A fasta parser in go lang
package main
import (
"bytes"
"fmt"
"log"
"os"
"strings"
"bufio"
"io"
@quwubin
quwubin / .vimrc
Created May 16, 2014 06:55
.vimrc
" ~./vimrc
" Kompatibilitätsmodus abschalten
set nocompatible
" Im GUI-Modus Consolas Zeichensatz setzen und fruity Farbschema benutzen.
if has("gui_running")
colorscheme fruity
set guifont=Consolas\ 12
else
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
import sys
import numpy
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance
import nltk.corpus
from nltk import decorators
import nltk.stem
stemmer_func = nltk.stem.EnglishStemmer().stem
stopwords = set(nltk.corpus.stopwords.words('english'))
@quwubin
quwubin / get_cpu_usage
Created March 25, 2014 08:17
Get CPU usage
#!/usr/bin/bash
# Give all CPUs usage percent
ps fuxw | awk '{ if ($3 ~ /^[0-9]/) {SUM +=$3}} END {print SUM"%"}'
@quwubin
quwubin / delete_empty_dir
Created March 25, 2014 01:17
Delete the empty directory
#!/usr/bin/env ruby
Dir.foreach('./') do |dir|
next unless File.directory?(dir)
next if ['.', '..'].include?(dir)
if Dir.entries(dir) == ['.', '..']
Dir.delete(dir)
end
end
@quwubin
quwubin / CairoNumberWidth.py
Created March 21, 2014 02:09
Virtual electrophotogram
#!/home/zhangcg/local/python/bin/python
# -*- coding:utf-8 -*-
#-----------------------------------------------------
# File: CairoNumberWidth.py
# Date: 2008-07-04
# Description:
#-----------------------------------------------------
__version__ = '1.0'
@quwubin
quwubin / get_free_memory
Created January 28, 2014 15:18
Get machine free memory both on Mac OS and Linux.
#!/usr/bin/python
# Author: Wubin Qu <quwubin@gmail.com>
# Tue Jan 28 23:17:08 2014
import platform
import subprocess
import re
def get_free_memory():
@quwubin
quwubin / parse_and_stats_medline.rb
Created February 24, 2013 13:39
Parse and statistics Medline (PubMed) abstract files
require 'bio'
# Input is abstract file in Medline format.
year_count = Hash.new(0)
File.read(ARGV[0]).split("\n\n").each do |article_block|
article = Bio::MEDLINE.new(article_block)
year_count[article.year] += 1
end
year_count.each do |year, count|
puts "#{year}, #{count}"