Skip to content

Instantly share code, notes, and snippets.

@roshanca
roshanca / Rakefile
Last active January 1, 2016 08:59
My workflow Rakefile
require 'rubygems'
require 'rake/minify'
## -- Misc Configs -- ##
public_dir = "public" # 生成的预览目录
source_dir = "source" # 源码目录
export_dir = "export" # 输出文件目录
themes_dir = "themes"
current_theme = "swsc"
@roshanca
roshanca / Rakefile
Created March 12, 2014 09:18
Compile and compress JavaScript
namespace :js do
desc 'Build JavaScript from CoffeeScript source code'
task :build do
command = [
'./node_modules/coffee-script/bin/coffee',
'--compile',
'--output ./lib',
'./src/*.coffee'
]
@roshanca
roshanca / checkall.js
Created March 26, 2014 01:54
全选功能
/**
* CheckSyncor
* @param {HTMLElement} trigger 全选触发器
* @param {HTMLCollection} checkbox checkox 的 DOM 集合
*/
function CheckSyncor(trigger, checkbox) {
this.trigger = trigger;
this.checkbox = checkbox;
this.length = checkbox.length;
@roshanca
roshanca / Guardfile
Created April 2, 2014 08:46
jekyll and compass watch Guardfile
guard 'jekyll-plus', serve: ENV['JEKYLL_SERVE'] do
watch /^source/
watch /^_config\.yml/
end
guard 'compass' do
watch %r{^sass/(.*)\.s[ac]ss$}
end
@roshanca
roshanca / example.js
Last active August 29, 2015 13:59
解析 URL 各部分的通用方法
var myURL = parseURL('http://abc.com:8080/dir/index.html?id=255&m=hello#top');
myURL.file; // = 'index.html'
myURL.hash; // = 'top'
myURL.host; // = 'abc.com'
myURL.query; // = '?id=255&m=hello'
myURL.params; // = Object = { id: 255, m: hello }
myURL.path; // = '/dir/index.html'
myURL.segments; // = Array = ['dir', 'index.html']
myURL.port; // = '8080'
@roshanca
roshanca / noiframe.js
Created April 15, 2014 03:37
禁止别人以 iframe 加载你的页面
if (window.location != window.parent.location) window.parent.location = window.location;
pre {
counter-reset: line-numbering;
border: solid 1px #d9d9d9;
border-radius: 0;
background: #fff;
padding: 0;
line-height: 23px;
margin-bottom: 30px;
white-space: pre;
overflow-x: auto;
@roshanca
roshanca / Solution.md
Last active August 29, 2015 14:04
How to show numeric soft keyboard for password field in Android

The password input tag is in a div like this

<div id="passwordCell" style="display:inline;">
    <input type="password" pattern="[0-9]*" name="Password" id="Password" placeholder="4 digit numeric only allowed" maxlength="4"/>
</div>
  1. add another input field in the #passwordCell div, and give it an id, for example, password_mask
  2. hide the #Password input field
require 'digest/md5'
hash = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
# puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
if hash.has_key? key
@roshanca
roshanca / business-name.md
Last active August 29, 2015 14:06
网上营业厅业务名称
业务名称 英文全称 简称
证券账户 security-account account
融资融券 securities-margin-trading margin
小贷通 light-loan-transaction loan
资管产品 asset-management-product product
三方存管 third-party-depository depository
开放式基金 open-ended-fund open-fund
风险测评 risk-evaluation evaluation
委托方式 ways-of-agency agency