refer to https://stackoverflow.com/questions/6501506/ruby-inspect-readability 打印大对象的时候太爽了。 用法: puts your_object.pretty_inspect 一张图用来对比
Ruby 单独运行某个unittest
refer to: https://stackoverflow.com/questions/1506780/how-to-run-a-single-test-from-a-rails-test-suite bundle exec ruby -I test test/models/cell_input_test.rb 单独运行某个test case: ruby -I test test/un...
Ruby Any_instance,stub,mocha
refer to https://stackoverflow.com/questions/3760691/what-is-the-use-of-any-instance-method-in-rails # 表示 所有的Product 的实例,在运行 save 方法后,都需要返回false Product.any_instance.stubs(:save).returns(false) ...
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 然后就可以...
Dokku 基本用法
refer to: https://dokku.com/docs/deployment/application-deployment/ 注册 默认是乞丐版,不需要注册。 PRO版可以注册,有UI界面 安装 需要 ubuntu 18, 20 以上。 1G 内存以上 过程略. 使用 可以认为,dokku 是通过git push 来自动触发的,这里用到的 git push <origin&...
Ruby Sinatracrosssitegem:
refer to: https://github.com/britg/sinatra-cross_origin Gemfile: gem "sinatra-cross_origin", "~> 0.3.1" app.rb 中增加下面几行即可: require 'sinatra' require 'sinatra/cross_origin' configure do enabl...
Rails Refinerycms修改wym编辑器,带有http的内容自动插入ahref
参考: http://siwei.me/blog/posts/ruby-paste-image-from-clipboard-to-blog 哈哈,想要这个功能  很久了,所以人啊,就是懒。今天早上自己动手,一小时搞定了。 1. 核心内容:(https://stackoverflow.com/questions/2176861/javascript-get-clipboard-...
Linux Rails Restart_very_quickly的例子
还是记录一下吧,实在太好用了 例如某个  rails 应用 path 中包含 admin , 跑在9701端口: kill -9 `ps -ef | grep admin | grep 9701 | awk {'print $2'}` setsid nohup bundle exec puma -C config/puma.rb &
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...
Blockchain Eip,contenthash,cidversion0,1,base58,base32的概念和相互转换
EIP:    refer to: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1577.md Ethereum Improvement Propalsal: 以太坊改进提案。 会提出以太坊的各种特性和新功能。 ENS; refer to: https://ens.domains/ Ethere...
Ruby Sinatra的用法,还是完整的记录一下吧
sinatra的特点就是快,因为代码少,加载的少。   sinatra <  grape < rails 所以sinatra 作为api 特别合适。 下面是一些笔记。 Gemfile source 'https://gems.ruby-china.com' gem 'sinatra-contrib' gem 'puma' 所有的内容都放在app...
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 ...
Windows Winrar的命令行的使用
refer to: https://www.shayanderson.com/application/winrar-command-line-password-backup-windows.htm "C:\Program Files (x86)\WinRAR\WinRAR.exe" a -pexpass -r C:\Users\user\backup\example.BAK.rar C:\U...
Ruby 单独运行某个unittest
refer to: https://stackoverflow.com/questions/1506780/how-to-run-a-single-test-from-a-rails-test-suite bundle exec ruby -I test test/models/cell_input_test.rb 单独运行某个test case: ruby -I test test/un...
Rails Rakeassets:precompile遇到错误:sassc::syntaxerror:error:invalidcssafter"}":
refer to: https://stackoverflow.com/questions/54267203/sasscsyntaxerror-error-invalid-css-after/73564234#73564234 问题很难排查。 不过不要紧, 直接修改gem file, 让问题暴露出来即可。 见上面的stack over flow I met the same proble...
Blockchain Ruby Eth.rbgem的使用(调用contractsetter,getter)亲测可用,直接用这个
refer to: https://github.com/q9f/eth.rb Gemfile: #source "https://rubygems.org" source "https://gems.ruby-china.com" gem "forwardable" gem "eth" 方法: require "forwardable" require "eth" # 先提供key...
Ruby Any_instance,stub,mocha
refer to https://stackoverflow.com/questions/3760691/what-is-the-use-of-any-instance-method-in-rails # 表示 所有的Product 的实例,在运行 save 方法后,都需要返回false Product.any_instance.stubs(:save).returns(false) ...
Rails 快速重启的脚本restartveryquickly
kill -9 `ps -ef | grep admin | grep 9701 | awk {'print $2'}`setsid nohup bundle exec puma -C config/puma.rb &
Rails Refinerycms修改wym编辑器,带有http的内容自动插入ahref
参考: http://siwei.me/blog/posts/ruby-paste-image-from-clipboard-to-blog 哈哈,想要这个功能  很久了,所以人啊,就是懒。今天早上自己动手,一小时搞定了。 1. 核心内容:(https://stackoverflow.com/questions/2176861/javascript-get-clipboard-...
Rails Homeland论坛的部署过程和注意事项
refer to: https://github.com/ruby-china/homeland 部署过程非常简单,安装好对应的依赖,环境,git clone code 即可。 修改 HomeController , 那里的404 要注释掉 3 class HomeController < ApplicationController 4 def uploads 5 ...