View multiple-select-for-ios.js
(function(){
//fix a special bug in mobile safari, see https://discussions.apple.com/message/23745665#23745665
var multiSelect = $('select[multiple]');
multiSelect.on('blur',function(){
var me = $(this);
me.data('value',me.val());
setTimeout(function(){
me.val(me.data('value'));
View rename.rb
count = 0;
Dir["./src/main/webapp/assets/**/*.css"].each {|f|
# File.rename(f, f.downcase)
count = count + 1
system("git mv #{f} #{f.sub(/.css$/,'.less')}")
}
puts count
# find src/main/webapp/assets -name *.css|wc -l
View dropzone-upload-file.erb
<form action="http://up.qiniu.com/" enctype="multipart/form-data" class="dropzone dz-clickable" id="upload-form">
<div class="dz-default dz-message">
<span>Drop files here to upload</span>
</div>
<input name="token" type="hidden" value="<%= @token %>">
<input name="x:uid" type="hidden" value="<%= current_user.id %>">
<div class="fallback">
<input name="file" type="file" multiple />
View bundler_config.sh
#cat ~/.bundler/config
#gem install bundler --pre
number_of_cores=`sysctl -n hw.ncpu`
bundle config --global jobs `expr $number_of_cores - 1`
View rbenv-bundle.md
  1. install rbenv and ruby-build plugin via git clone.
  2. rbenv install --list
  3. rbenv install target-ruby-version(such as rbenv install 2.1.0)
  4. echo $PATH # ~.rbenv/shims should be the head of path. Ensure gem is ~/.rbenv/shims/gem, not the old system gem.
  5. rbenv local target-ruby-version
  6. gem install bundle -V keep eyes on the gem cmd path, which should be ~/.rbenv/shims/gem.
  7. rbenv rehash
  8. bundle install --path=vendor/bundle bundle path should be ~/.rbenv/shims/bundle
  9. bundle exec some-shell-cmd
View _flash_messages.html.erb
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
View .slate
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout qwerty
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
View carousel.html
View redis-keys-prefix-search.rb
# compl1.rb - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
require 'rubygems'
require 'redis'
r = Redis.new
# Create the completion sorted set
if !r.exists(:compl)
View leveldb-keys-prefix-search.js
var levelup = require('levelup')
// open a data store
var db = levelup('/tmp/foo.leveldb')
var list = [];
var start = new Date().getTime();
var prefix = "ha";
//cat /usr/share/dict/words | grep "^ha" | wc
db.createReadStream({
start: prefix, // jump to first key with the prefix