Skip to content

Instantly share code, notes, and snippets.

View jay16's full-sized avatar

俊杰.li jay16

View GitHub Profile
@jay16
jay16 / gist:b4738498b7e98e7c90cd
Created May 18, 2014 06:40
android 自带的 base64 编码
android 自带的 base64 编码
首先导入包
import android.util.Base64;
String 变量 =android.util.Base64.encodeToString(字符串.getBytes(),Base64.DEFAULT);
也可简写为
String 变量 =Base64.encodeToString(字符串.getBytes(),Base64.DEFAULT);
至于解码
byte b[]=android.util.Base64.decode( 字符串,Base64.DEFAULT);
String 变量 =new String(b);
#!/usr/bin/env ruby
require "optparse"
#store options in hash
options = {}
opt_parse = OptionParser.new do |opts|
opts.banner = 'kp: kill multi process with keywords.'
opts.separator ""
opts.separator "Options"

最近在看Sinatra 1.3.5的源码。在Sinatra::Helpers模块中看到一个名为uri的方法,用来将一个相对路径转换为绝对路径。在该函数的代码中看到分别针对request.script_name和request.path_info进行了处理。但是并不清楚这两个参数的区别,于是做了一些reseach。

二者在RFC3875中有如下定义:

4.1.13. SCRIPT_NAME

The SCRIPT_NAME variable MUST be set to a URI path (not URL-encoded) which could identify the CGI script (rather than the script's output). The syntax is the same as for PATH_INFO (section 4.1.5) >

#!/usr/bin/env ruby
# Libraries:::::::::::::::::::::::::::::::::::::::::::::::::::::::
require 'rubygems'
require 'sinatra/base'
require 'slim'
require 'sass'
require 'coffee-script'
# Application:::::::::::::::::::::::::::::::::::::::::::::::::::
#帮助说明
help() {
echo "usage:kp keyword username"
echo " eg:kp resque webmail"
exit 0
}
#第一个参数为空,提示帮助说明
[ -z $1 ] && help
#encoding
task :default => [:base]
#eg: rake lookup[400]
desc "lookup http status explian info with status_code"
task :lookup, [:status_code] => :base do |t, args|
args.with_defaults(:status_code => "200")
status_code = args[:status_code].to_s
Rake::Task["usage"].invoke and exit unless status_code.length != 3 or (1..5).to_a.include?(status_code[0].to_i)
备份:
备份整个数据库
exp 用户名/密码@连接的远程计算机 IP/ 要备份的远程数据库名称 file= 文件路径
exp hom/[email protected]/qa file=d:\aa1.dmp
备份指定数据库表
exp Intfocus/[email protected]/orcl file=d:\DOG_TOTAL_BI.DMP tables=(dog_totle_bi)
导入指定数据库表(若表结构已经存在只导入数据)
assert(boolean, message="") # 若boolean为真则pass
assert_equal(expected, actual, message=nil)#若expected == actual则pass
assert_not_equal(expected, actual, message="")#若expected != actual则pass
assert_instance_of(klass, object, message="")#若klass == object.class为真则pass
assert_nil(object, message="")#若object.nil?则pass
assert_not_nil(object, message="")#若!object.nil?则pass
assert_kind_of(klass, object, message="")#若object.kind_of?(klass)为真则pass
assert_respond_to(object, method, message="")#若object.respond_to?(method)为真则pass
assert_match(pattern, string, message="")#若string =~ pattern为真则pass
assert_no_match(regexp, string, message="")#若regexp !~ string为真则pass
[root@solife tools]# ruby method_missing.rb
method missing stack called..
define_method: title
"title"
"title"
no mater what you do, i say: hello
[root@solife tools]# cat method_missing.rb
class A
def method_missing(method_id, *args)
puts "method missing stack called.."
source/_includes/custom/head.html中添加js代码:
<script>
function addBlankTargetForLinks () {
$('a[href^="http"]').each(function(){
$(this).attr('target', '_blank');
});
}
$(document).bind('DOMNodeInserted', function(event) {