• 无头浏览器指没有图形界面,直接执行脚本代码。electron 不属于这类。

    electron 作用是利用本地系统通知和获得访问文件权限,这两个现在浏览器也有 API 了。剩下的就是习惯问题,像 https://vscode.dev/ 已经在浏览器内实现了完整功能,看能不能习惯完全在浏览器内写代码。

  • 去掉 do 就行了。

  • 从错误信息看从解包就出异常了,很可能是下载下来的包是坏文件。

  • 有可能网络问题。

  • 一台服务器部署多个项目 at 2021年11月02日

    http://nginx.org/en/docs/http/server_names.html

    通过 server_name 指定不同域名对应不同应用。

  • Migrations are pending at 2021年10月31日
    $ bin/rails -T | grep db
    rails db:create                          # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to creating the development and test databases, except when DATABASE_URL is present
    rails db:drop                            # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to dropping the development and test databases, except when DATABASE_URL is present
    rails db:environment:set                 # Set the environment value for the database
    rails db:fixtures:load                   # Loads fixtures into the current environment's database
    rails db:migrate                         # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
    rails db:migrate:down                    # Runs the "down" for a given migration VERSION
    rails db:migrate:redo                    # Rolls back the database one migration and re-migrates up (options: STEP=x, VERSION=x)
    rails db:migrate:status                  # Display status of migrations
    rails db:migrate:up                      # Runs the "up" for a given migration VERSION
    rails db:prepare                         # Runs setup if database does not exist, or runs migrations if it does
    rails db:reset                           # Drops and recreates the database from db/schema.rb for the current environment and loads the seeds
    rails db:rollback                        # Rolls the schema back to the previous version (specify steps w/ STEP=n)
    rails db:schema:cache:clear              # Clears a db/schema_cache.yml file
    rails db:schema:cache:dump               # Creates a db/schema_cache.yml file
    rails db:schema:dump                     # Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)
    rails db:schema:load                     # Loads a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`) into the database
    rails db:seed                            # Loads the seed data from db/seeds.rb
    rails db:seed:replant                    # Truncates tables of each database for current environment and loads the seeds
    rails db:setup                           # Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)
    rails db:structure:dump                  # Dumps the database structure to db/structure.sql
    rails db:structure:load                  # Recreates the databases from the structure.sql file
    rails db:version                         # Retrieves the current schema version number
    rails test:db                            # Run tests quickly, but also reset db
    
  • 如果是推广产品就好好做个介绍,不是留个链接让大家猜你想表达什么。

  • 资安工具 gem: rack-attack at 2021年10月24日

    跟随 Rails 版本升级,就不用太担心框架层面的漏洞。业务代码的漏洞强烈推荐 https://github.com/presidentbeef/brakeman 这个 gem,把它加到 CI 流程。

  • 资安工具 gem: rack-attack at 2021年10月23日

    rack-attack 可以防比较简单的脚本攻击,例如不停的发贴。真遇到 ddos 攻击需要云服务的防火墙服务。

  • 现在想学个语言能够自由去根据自己业务做定制开发

    按这个需求 Rails 好。跟着 Rails 全栈是最省心的。

  • docker

  • 卡池有没有 DHH 型的?

  • 超出预算。

  • Rust 微微框架 Vial at 2021年10月19日

    用框架没必要把源码都看懂吧,也就出 bug 的时候会看一下是框架问题还是自己问题。

    Web 应用相当一部分在调外部接口,例如支付接口、错误收集、日志系统,如果用小众语言发现没有相应的 client 就要自己写了,很麻烦。(Ruby 在 Web 领域不是小众)

  • Rust 微微框架 Vial at 2021年10月19日

    如果喜欢轻量级框架,应该试试 Sinatra,起码有 Stripe 在用,证明了生产环境可靠性。

    (主楼没必要把文档贴上来,太长影响回复)

  • RSA 公钥加密长度超出 at 2021年10月17日

    那实际超出了没?

  • 不用,我用 ubuntu 镜像然后装源里面的 ruby。如果需要特定 ruby 版本就用 ruby 的镜像。

  • 现在开发环境已经需要四个进程,Rails,sidekiq,scss,esbuild,另开终端已经显得麻烦了。

    Rails css/js-buundling 默认用 foreman 启动开发进程,因为 foreman 是 Ruby gem。

    对我来说 docker 是更好的选择,开发环境用 docker compose,生产环境用 docekr swarm。

  • foreman 是开发环境用的,作者曾经在 heroku 工作,所以 Profile 和 heroku 的格式一样。

    生产环境应该 export 到系统的管理配置,例如 upstart,stystemd http://ddollar.github.io/foreman/#EXPORT-FORMATS

    foreman 诞生的时候 systemd 还没成为主流。

  • 清华源也是 lets encrypt 的,就新了 20 天,是不是有什么不同?

  • Rails Webpack 遇到了问题 at 2021年10月10日

    信息不充足,把项目 push 到 GitHub 让看看源码。

    另外 webpacker 已经预定在下个版本移除,没必要现在学。如果要用 webpack 和 react 独立配置即可,不需要 webpakcer。 https://ruby-china.org/topics/41699

  • 我是用官方源的,而且 Ruby 和系统都是比较新的应该不会遇到这个问题。

  • let's encrypt 的旧根证书过期,需要更新客户端 https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

    尝试更新 rubygem,Ruby 版本或系统的 ca bundle。

  • param = 200 给 param 赋予了一个新的 object,所以没有改变 count 的值。

    Integer 类型不能改变自身,要用一些可以改变自身的类型,例如 Hash 或者自己创建一个类:

    data = { count: 500 }
    
    proc = Proc.new { |params|
      params[:count] = 200
    }
    
    proc.call(data)
    
    puts data[:count]
    #=> 200
    
  • 这是不正常的,先搞清楚目前在用什么机制,importmap 吗?

  • app server 的多线程是为了提高并发,不然前一个请求完成之前,后面来的请求都要阻塞。

  • 用 docker 就不用管 buildpack 支不支持了

  • 以前 unicorn 流行就是因为进程模型简单,但是占内存。在 puma 稳定,并且主流 gem 都实现了线程安全之后,现在流行的就是 puma 多进程 + 多线程模型。未来有希望跟随 Ruby 发展用上 ractor + fiber 的并发模型,但还需要时间。

    想说的是,如果你的框架不考虑线程安全问题,只能限定运行的 app server 用多进程模型。

  • Rack 只是接口,并发是交由 app server 实现,例如 puma 就是多线程模型。如果你要实现框架的话,要在框架层实现并发安全。

  • 回复顶楼问题,你想要的可能是:

    Base.newrequest env
    cb = Base.route[method][path]
    resp = Base.instance_eval(&cb) # cb 在 Base 的实例环境下执行
    

    但这个设计我觉得有问题,多线程环境下 Base 的实例变量会有并发冲突。