Skip to content

Instantly share code, notes, and snippets.

View quwubin's full-sized avatar

Wubin Qu quwubin

View GitHub Profile
@quwubin
quwubin / st2_user_settings.txt
Last active December 14, 2015 03:48
Sublime text 2 Use Settings
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"default_line_ending": "unix",
"highlight_line": true,
"word_wrap": "true",
"font_size": 12
}
@quwubin
quwubin / 360buy.rb
Created November 5, 2012 00:52 — forked from mimosz/.gitignore
京东商品价格解析
# -*- encoding: utf-8 -*-
require 'mini_magick'
require 'rtesseract'
require 'nokogiri'
require 'nestful'
require 'csv'
require 'pp'
class Buy360
def initialize(url='')
@quwubin
quwubin / gist:3747136
Created September 19, 2012 01:39 — forked from Amitesh/gist:1160287
Word wrap in Ruby
# It works for pure text only. It will fail for html and url type of text.
# http://henrik.nyh.se/2007/03/ruby-wordwrap-method
def wrap_long_string(text,max_width = 20, separator = "\n")
(text.length < max_width) ?
text :
text.scan(/.{1,#{max_width}}/).join(separator)
end
@quwubin
quwubin / batch_run.rb
Created July 11, 2012 03:03
Ruby tips
#!/usr/bin/env ruby
ARGV[1..-1].each do |file|
puts file
`#{ARGV[0]} #{file}`
end
# Example
# ./batch_run.rb "tar zxvf" refseq_genomic.*.gz
@quwubin
quwubin / biodb.rb
Created June 12, 2012 07:34
Download database from NCBI
#!/usr/bin/env ruby
#
# Wubin Qu <[email protected]>
require 'fileutils'
module Biodb
module DbProcess
attr_reader :ftp_address, :dir
attr_accessor :available_dbs
@quwubin
quwubin / remove_blank_line.rb
Created June 8, 2012 01:31
Ruby: Remove blank lines and leading ^M characters
#!/usr/bin/env ruby
#
# Wubin Qu <[email protected]>
#
if ARGV.size != 1
$stderr.puts "
Remove blank lines and leading ^M characters
Usage: