Skip to content

Instantly share code, notes, and snippets.

require 'i18n'
require 'dry-validation'
require 'dry/validation/version'
puts "dry-validation version: #{Dry::Validation::VERSION}"
puts "\n\n#{'#' * 20} \n\n"
I18n.backend.store_translations(:'zh-CN', {errors: {str?: '必须是字符串'}})
schema = Dry::Validation.Schema do
@niedhui
niedhui / recruit-zn.md
Last active September 21, 2015 06:47
筹道股权招聘信息

[上海]筹道股权招 Ruby, Android, iOS 工程师

公司介绍

筹道股权 是专注于精品项目的股权融资平台。注册于上海自贸区,是中国证券业协会首批认证会员之一,也是上海唯一入围该名单的股权融资平台,荣获2015年福布斯“互联网金融50强”称号。成立至今,平台已帮助创新创业企业融资近80亿元,认证投资人近3万,位居全国第一梯队。

软件工程师

  • Ruby 职位要求
    • 熟悉 Ruby on Rails 或其它 Web 框架
    • 熟悉面向对象编程, 理解常用设计模式
  • 熟悉 CoffeeScript, Sass, Bootstrap, 能写前端页面
deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
@niedhui
niedhui / cdf.fish
Last active August 29, 2015 14:04
~/.config/fish/functions/cdf.fish
function cdf
cd (finder_path )
end
function finder_path
echo '
tell application "Finder"
if (1 <= (count Finder windows)) then
get POSIX path of (target of window 1 as alias)
else
@niedhui
niedhui / fish_prompt
Last active August 29, 2015 14:04
fish_prompt
# ~/.config/fish/functions/fish_prompt.fish
function _git_branch_name
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _git_status_symbol
set -l git_status (git status --porcelain ^/dev/null)
if test -n "$git_status"
# Is there anyway to preserve newlines so we can reuse $git_status?
if git status --porcelain ^/dev/null | grep '^.[^ ]' >/dev/null
@niedhui
niedhui / gist:10381216
Last active August 29, 2015 13:58
new openssl
sudo ./config --prefix=/usr/local shared
cd /usr/local/ssl
sudo curl -O http://curl.haxx.se/ca/cacert.pem
sudo mv cacert.pem cert.pem
sudo make
sudo make install
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local rbenv install 2.1.1 -k -f
queue = Sidekiq::Queue.new('default')
jobs = queue.find {|job| job.klass == 'Sidekiq::Extensions::DelayedMailer'}
jobs.map &:args
jobs.map &:delete
@niedhui
niedhui / ac_raw_sql.rb
Last active August 29, 2015 13:56
execute raw sql in rails app
class MyMigration < ActiveRecord::Migration
def up
create_table :users do
t.string :name
t.integer :age
end
end
end
MyMigration.migrate(:up)
2013-10-29T03:51:52Z 20467 TID-ot6k1pj7o DEBUG: Got TTIN signal
2013-10-29T03:51:52Z 20467 TID-ot6k1pj7o INFO: Thread TID-ot6k1pj7o
2013-10-29T03:51:52Z 20467 TID-ot6k1pj7o INFO: /home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/lib/sidekiq/cli.rb:118:in `backtrace'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/lib/sidekiq/cli.rb:118:in `block in handle_signal'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/lib/sidekiq/cli.rb:115:in `each'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/lib/sidekiq/cli.rb:115:in `handle_signal'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/lib/sidekiq/cli.rb:76:in `run'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bundler/gems/sidekiq-abed0c94ebae/bin/sidekiq:8:in `<top (required)>'
/home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bin/sidekiq:23:in `load'
/home/deployer/apps/myapp/sh
@niedhui
niedhui / sidekiq_crashed_log
Created October 29, 2013 05:32
sidekid crashed log
{"retry"=>true, "queue"=>"default", "class"=>"AlertWorker", "args"=>["xxxxxxxx"], "jid"=>"9f5aa5d17445402938b76d8d", "enqueued_at"=>1382677895.6413631, "error_message"=>"SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A", "error_class"=>"Faraday::Error::ConnectionFailed", "failed_at"=>2013-10-25 05:12:36 UTC, "retry_count"=>0}
2013-10-25T05:12:36Z 20467 TID-ot6khstos WARN: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
2013-10-25T05:12:36Z 20467 TID-ot6khstos WARN: /usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect'
/usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
/usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
/usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect'
/usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
/usr/local/rbenv/versions/ruby-2.0.0-p247/lib/ruby/2.