Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / multiple-select-for-ios.js
Created February 17, 2014 06:08
fix multiple select bug for mobile safari
(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'));
@dongyuwei
dongyuwei / rename.rb
Created February 20, 2014 05:14
rename all css to less
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
<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 />
#cat ~/.bundler/config
#gem install bundler --pre
number_of_cores=`sysctl -n hw.ncpu`
bundle config --global jobs `expr $number_of_cores - 1`
@dongyuwei
dongyuwei / rbenv-bundle.md
Last active August 29, 2015 13:56
common workflow(steps) to use rbenv and bundle.
  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
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@dongyuwei
dongyuwei / .slate
Last active August 29, 2015 13:59 — forked from hulufei/.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
@dongyuwei
dongyuwei / carousel.html
Last active August 29, 2015 14:00
carousel like gmail's (attached)images preview
# 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)
@dongyuwei
dongyuwei / leveldb-keys-prefix-search.js
Last active August 29, 2015 14:01
test leveldb keys prefix search with a large dict.
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