Sentry Commit Tracking - 2019-05-17 00:00:00

https://docs.sentry.io/workflow/integrations/global-integrations/#commit-tracking-4 关于 Releases https://docs.sentry.io/workflow/releases/?platform=php#create-deploy 如果配置了releases版本, 会有额外的功能 配置发布版本 在项目sdk配置 在sentry上创建 releases 版本, 关联 commits 部署是通知 sentry ruby sdk release 配置 Create Release and Associate Commits 这一步告诉sentry 这个release 有哪些commit 有两步 Organization Settings > Integrations. 配置 gitab 集成 部署的时候告诉sentry 部署了啥, 有哪些commit, 可以用 sentry-cli工具 在gitlab ci 的配置示例 官方 sentry-cli 文档 https://docs.sentry.io/workflow/releases/?platform=php#associate-commits-with-a-release sentry_commmit_tracking: stage: after_deploy image: getsentry/sentry-cli dependencies: - staging_deploy - prod_deploy script: - echo "Sentry Commit Tracking" - export SENTRY_URL=https://sentry.

Gitlab Ci MySQL 8 mysql_native_password - 2019-05-16 13:56:07

错误 ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory mysql 5.7 到 mysql 8 不在默认使用 mysql_native_password 添加参数--default-authentication-plugin=mysql_native_password test: stage: test services: - name: mysql:8 command: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password"]

[笔记] A Beginner’s Guide to GraphQL - 2019-05-07 00:00:00

links 原文: https://medium.freecodecamp.org/a-beginners-guide-to-graphql-86f849ce1bec A minimalistic zero-config GraphQL server. https://github.com/glennreyes/graphpack GraphQL Playground 调试工具介绍 https://www.prisma.io/blog/introducing-graphql-playground-f1e0a018f05d https://github.com/prisma/graphql-playground 知识点 schema types Queries Mutations Subscriptions schema Schema Definition Language (SDL) type Query { hello: String } Types 比如 Posts, Users, Likes, Groups 类型有 fields,比如 User 类型有 username email age type User { id: ID! name: String! email: String! age: Int } ! 表示这个field是 non-nullable 表示不可以为空 User类型可以为空的只有age queries mutations subscriptions Queries GraphQL如何知道从哪获取数据呢?

卸载 rvm! - 2019-05-06 00:00:00

实在搞不懂 为啥 rvm 把我 shell 搞的这么慢 remove: $ rvm implode 换成chruby + ruby-install 的方案 chruby: https://github.com/postmodern/chruby ruby-install: https://github.com/postmodern/ruby-install chruby-fish: https://github.com/JeanMertz/chruby-fish#readme fish shell 配置 RUBIES ~/.config/fish/config.fish set -x RUBIES $RUBIES ~/.rubies/*

Ruby 继承父类有参数如何实现? - 2019-05-05 20:36:49

英文原文 Implementing inheritance with params: CreateProducts < ActiveRecord::Migration[5.0] - Ruby Blog Rails 5 中可以看到migration定义中会有版本参数 ActiveRecord::Migration[5.0] 原理是只要< 后边返回的是类对象就可以 基本继承 class Human; end class Man < Human end 也可以这样,foo 为 Human 类 class Human; end foo = Human class Man < foo end 类似的 class Human; end def parent_class Human end class Man < parent_class end 实现带参数版本 class Human def self.[](version) puts version self end end class Man < Human[:basic] end 会打印 basic,Human[:basic] 表示调用类方法Human.

生成指定版本的Rails项目 - 2019-05-05 17:32:23

本地 Rails 默认5.0.2 版本 $ gem list --local rails (5.0.2, 5.0.0.1, 5.0.0, 4.2.8) 使用 _version_ 生成指定version的项目 rails _version_ new application_name 例如生成 4.2.8 版本 rails _4.2.8_ new todolists

doom emacs 使用 org & hugo - 2019-05-05 00:00:00

使用 Org to Markdown for Hugo https://ox-hugo.scripter.co/ doom emacs 配置 packages.el (package! ox-hugo) config.el ;; os-hugo (with-eval-after-load 'ox (require 'ox-hugo)) 自动导出 目录下 .dir-locals.el 文件 (("content-org/" . ((org-mode . ((eval . (org-hugo-auto-export-mode))))))) 命令导出

ActiveRecord’s Queries tricks 小记 - 2019-05-04 16:32:44

原文 https://medium.com/rubyinside/active-records-queries-tricks-2546181a98dd 关联表join时使用条件 # User model scope :activated, ->{ joins(:profile).where(profiles: { activated: true }) } 更好的做法 # Profile model scope :activated, ->{ where(activated: true) } # User model scope :activated, ->{ joins(:profile).merge(Profile.activated) } 关于 merge https://apidock.com/rails/ActiveRecord/SpawnMethods/merge https://api.rubyonrails.org/classes/ActiveRecord/SpawnMethods.html 嵌套join的差异 User has_one Profile Profile has_many Skills User.joins(:profiles).merge(Profile.joins(:skills)) => SELECT users.* FROM users INNER JOIN profiles ON profiles.user_id = users.id LEFT OUTER JOIN skills ON skills.profile_id = profiles.id # So you'd rather use: User.

How to run gitlab ci only when dir changed? - 2019-05-04 16:32:44

参考: https://gitlab.com/gitlab-org/gitlab-ce/issues/19813 当`db/migrate` 目录有变化的时候执行prod的测试脚本 test_prod_schema: stage: test script: - > if git diff HEAD~ --name-only|grep db/migrate; then cp config/database.prod-schema-mysql.yml config/database.yml bundle exec rails db:create mysql -h mysql -uroot -proot <<< "use shiji_prod; source db/tables_dump_April_28_2019.sql;" bundle exec rails db:migrate fi;

Phoenix 部署记 - 2019-05-03 16:32:44

安装elixir https://elixir-lang.org/install.html#unix-and-unix-like 使用ubuntu安装 Erlang Solutions repo: wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb Run: sudo apt-get update Install the Erlang/OTP platform and all of its applications: sudo apt-get install esl-erlang Install Elixir: sudo apt-get install elixir phoenix 部署流程 官方文档 https://hexdocs.pm/phoenix/deployment.html 处理配置文件,应用secret token, config.exs, prod.exs 编译静态文件, node & brunch 生产模式下启动,distillery & mix 配置 https 配置 使用 certbot 管理 Let’s Encrypt 证书 phoenix prod.exs https 配置示例 config :books, BooksWeb.