refer to: https://github.com/bcrypt-ruby/bcrypt-ruby 特别有意思 加密之后,每次都是变化的,估计是跟timestamp 做了salt吧。 说人话: 就是每次生成 加密字符串的时候,都使用当前时间戳作为参数了。 所以给人感觉是不断变化的。(我猜的,具体看官方文档吧 )https://github.com/bcrypt-ruby/bcryp...
Rails Redirect_to:back不能用了,使用:redirect_torequest.referrer
refer to: https://stackoverflow.com/questions/8952487/how-do-i-redirect-back-to-a-page-im-currently-on redirect_to request.referrer, alert: "登录成功"
Ruby Bcrypt的使用
refer to: https://github.com/bcrypt-ruby/bcrypt-ruby 特别有意思 加密之后,每次都是变化的,估计是跟timestamp 做了salt吧。 说人话: 就是每次生成 加密字符串的时候,都使用当前时间戳作为参数了。 所以给人感觉是不断变化的。(我猜的,具体看官方文档吧 )https://github.com/bcrypt-ruby/bcryp...
Rails Find_each,find_by_batch
refer to: find_each 用法很简单,就是跟  Model.where.each do ... 一样的。 find_by_batch: 循环的时候,里面是  一个model array. Block.where('id < 30').find_in_batches(batch_size: 10) do |g| g.each {|b| puts...
Rails Find_each,find_by_batch
refer to: find_each 用法很简单,就是跟  Model.where.each do ... 一样的。 find_by_batch: 循环的时候,里面是  一个model array. Block.where('id < 30').find_in_batches(batch_size: 10) do |g| g.each {|b| puts...
Rails Sidekiq作为railsjob,优先级的问题
1. sidekiq 会把任务放在redis中 2. 如果有多个同样rails app 下的sidekiq 同时启动,那么会在terminal中看到3个对应的进程 不过每次任务被执行的话,只能被这多个sidekiq中的 随机一个执行。
Rails Sidekiq作为railsjob,优先级的问题
1. sidekiq 会把任务放在redis中 2. 如果有多个同样rails app 下的sidekiq 同时启动,那么会在terminal中看到3个对应的进程 不过每次任务被执行的话,只能被这多个sidekiq中的 随机一个执行。
Html Ruby Sinatra Headers的重要性:ipfs的headers会阻碍普通浏览器的显示ipfsheadersbrowserfirefoxshowcontent
特别神奇 我的sinatra应用,充当了 ipfsgateway的代理。 如果返回 ipfs的headers的话,就会让浏览器卡住30秒左右,然后无法显示 (尝试了一下,就算删掉 access-control,  x-ipfs 开头的header也无法正常显示。估计是其他的header起作用) HTTP/2 200 OK access-control-allow-headers:...
Ruby Webrickbuiltinhttpproxy代理服务器
refer to: https://stackoverflow.com/questions/12187509/how-do-i-write-a-simple-https-proxy-server-in-ruby https://ruby-doc.org/stdlib-2.5.0/libdoc/webrick/rdoc/WEBrick/HTTPProxyServer.html webric...
Ruby Sinatra 默认不要显示exception信息sinatradonotshowexceptionstack
refer to: https://stackoverflow.com/questions/26233926/sinatra-error-handling 在app.rb 中加上: configure :development do disable :show_exceptions end 然后运行: RACK_ENV=production ruby app.rb ...
Ruby Vcrgem的使用mockhttprequest
refer to:   https://relishapp.com/vcr/vcr/v/6-1-0/docs/getting-started VCR用来使用mock http request的。  使用方法很简单: 在  test/test_helper.rb 或者对应的rspec文件中: require 'vcr' VCR.configure d...
Google 如何搜索标点符号:加上引号即可。例如'&.'
例如: 我想搜索 a&.b 中的  &. 是啥意思,就需要: ruby '&.' 而不是 ruby &. 后者得不到精确结果
Ruby Webrickbuiltinhttpproxy代理服务器
refer to: https://stackoverflow.com/questions/12187509/how-do-i-write-a-simple-https-proxy-server-in-ruby https://ruby-doc.org/stdlib-2.5.0/libdoc/webrick/rdoc/WEBrick/HTTPProxyServer.html webric...
Ruby Safenavigationoperatorapple&.color
refer to: https://stackoverflow.com/questions/36812647/what-does-ampersand-dot-mean-in-ruby class Apple attr_accessor :color end apple = Apple.new color: 'red' apple&.color # => red b...
Ruby Inspectv.s.pretty_inspect还是使用后者吧
refer to https://stackoverflow.com/questions/6501506/ruby-inspect-readability 打印大对象的时候太爽了。 用法: puts your_object.pretty_inspect 一张图用来对比
Ruby Sinatra 默认不要显示exception信息sinatradonotshowexceptionstack
refer to: https://stackoverflow.com/questions/26233926/sinatra-error-handling 在app.rb 中加上: configure :development do disable :show_exceptions end 然后运行: RACK_ENV=production ruby app.rb ...
Ruby Linux 修改进程名称changelinuxprocessname
refer to https://www.honeybadger.io/blog/how-to-change-the-process-name-in-ruby-for-top-and-ps/ 找了几个。有2种方案 1. 在ruby进程中修改名称。 Process.setproctitle("sleeper") puts 'hi, now sleep' sleep 1000 然后就可以...
Ruby Safenavigationoperatorapple&.color
refer to: https://stackoverflow.com/questions/36812647/what-does-ampersand-dot-mean-in-ruby class Apple attr_accessor :color end apple = Apple.new color: 'red' apple&.color # => red b...
Postgres 使用hashindex之后,rails的upsert_all无法生效的问题:
refer to: https://stackoverflow.com/questions/44274080/postgres-hash-index-with-unique-constraint https://stackoverflow.com/questions/469471/how-do-i-alter-a-postgresql-table-and-make-a-column-uni...
Ruby Methodparametersinglestardoublestart方法参数中的单*与**的参数splatoperator
refer to: https://www.freecodecamp.org/news/rubys-splat-and-double-splat-operators-ceb753329a78/ *:  splat operator   不能作用于hash **:  double splat operator   ruby 2.0 ...