How to dynamically create page in Gatsby.js from GraphQL source

1 - Install `gatsby-source-graphql` 2 - Add `gatsby-source-graphql` setting into `gatsby-config.js` ```js { resolve: `gatsby-source-g...

Wayne

How to replace moment.js

Found this repo: https://github.com/you-dont-need/You-Dont-Need-Momentjs Replacement: - [date-fns](https://github.com/date-fns/date-fns...

Wayne

How to add self-hosted fonts in Gatsby

This note is copied from https://dev.to/iangloude/4-steps-to-self-hosted-fonts-in-gatsby-aj2 1 - place your font files in `src/static/fo...

Wayne

Weird warning with Ruby 2.7

I kept having this `The called method '…' is defined here` warning from my rails console. Ex: ``` /Users/wayne/.rvm/gems/ruby-2.7.0/gems...

Wayne

ActiveStorage#attach has different return value between v5 and v6

In activestorage v5 ```rb current_user.images.attach( io: file, filename: file.original_filename, content_type: file.content_type ...

Wayne

We can change ActiveStorage route_prefix in Rails 6

Usage: ```rb # config/application.rb config.active_storage.routes_prefix = '/files' ``` So instead of having route like `www.example.c...

Wayne

Finally we can disable generated scope from ActiveRecord#enum in Rails 6

Usage: ```rb class Post < ApplicationRecord enum state: { draft: 0, published: 1, personal: 2 }, _scopes: false end ``` PR: https://g...

Wayne

幫衝浪板快速除蠟的神奇技巧

先公布解答:熱水 + 抹布。 以前除蠟都是把衝浪板拿到大台陽底下曬,然後再辛苦的用刮蠟東西把蠟一層一層刮下來,有時候刮到一半蠟又變硬或是底下的蠟還沒被曬溶,就會變得很難除。雖然說可以買除蠟用的 Wax Remover 來讓蠟融掉,但為了除蠟還買化學液體總覺得有點太超過了...

Wayne

如何 DIY 修理壞掉的衝浪板 Fin Box

## 需要的工具 - 美工刀 - 尖嘴鉗 - 砂紙 (80 grit) - 膠帶 - Q cell - Polyster Resin - MEKP Catalyst - 玻璃纖維布 (fiberglass cloth) - 新的 Fin Box P.S.// 我的板是...

Wayne

Ruby 2.7 pattern matching official docs has released

早前一篇文章 [New features in Ruby 2.7](/posts/361-new-features-in-ruby-2-7) 提到了 Ruby 2.7 將要有 pattern matching,現在 [official docs](https://docs....

Wayne

Validate JSON schema in Rails

This is an archive of my post from 2017 (revised by [@morhekil](https://twitter.com/morhekil)), original posted in [medium](https://mediu...

Wayne

How to communicate with iframes inside WebView

This is an archive of my post from 2017 (revised by [@morhekil](https://twitter.com/morhekil)), original posted in [medium](https://mediu...

Wayne

Flutter vs ReactNaive

最大的差異應該就在於 ReactNative 依賴於 JavaScript bridge running on run time,且對原生 components 的支援度較低 Flutter 的優勢則在於對原生的支援度高,因為不需要 bridge 就可以 communic...

Wayne

Using RabbitMQ and Hutch with RPC call for queue in Rails

This is an example how the author implement the RPC call using Hutch and communicate with RabbitMQ https://karolgalanciak.com/blog/2020/...

Wayne

寫 Ruby gem 的 best practice

寫 Ruby gem 的 best practice,滿受用的但太長了有空再來看,先記一下,please check the referecne ### Referecne - https://piotrmurach.com/articles/writing-a-rub...

Wayne

How to pass arguments to rake task

1. rake way ```rb task :add, [:num1, :num] do |t, args| puts args[:num1].to_i + args[:num].to_i end # rake add\[1,2\] ``` 2. ENV ``...

Wayne

Ruby under a microscope - Chapter 1 - Tokenization and Parsing

This is my reading note about the book `Ruby under a microscope` Chapter 1 - Tokenization and Parsing 第一章在講我們寫的 ruby code 是怎麼經過一系列的轉換最後...

Wayne

Install SElinux

```shell # install sudo apt install policycoreutils selinux-utils selinux-basics # activeate sudo selinux-activate # change to enforci...

Wayne

How to add a new user in kali linux

```shell ec2-user@kali:~$ su root@kali:/home/ec2-user# root@kali:/home/ec2-user# useradd -m wayne root@kali:/home/ec2-user# passwd wayne...

Wayne

Ruby HTTP client options

- The built-in net/http client - Faraday - http.rb (HTTP The Gem) - rest-client - httparty - excon - Typhoeus - Curb For some pros and c...

Wayne

Different between TCP and UDP

> 差別在於 TCP是雙向傳輸 UDP是單向.TCP傳送東西.會有封包數據.他可靠性高UDP可靠性低.傳送東西速度快。 在 TCP/ IP 協定家族中﹐傳送層主要有兩個協定﹕TCP 與 UDP。 TCP 提供的是一個連線導向(Connection Oriented)的可...

Wayne

Python use for loop to generate nested list to avoid weird behavior

如果使用 `[[0] *3] *2` 這樣的方式建立 nested array ` [[0, 0, 0], [0, 0, 0]]`,那第一個 array 跟第二個 array 都是指向同一個記憶體位置,所以當改變 element 的值時,例如: `list[0][0] =...

Wayne

一篇在講 Ruby on Rails 的 ActiveRecord 和 Elixir Phoenix Ecto 差別的文章

一篇在講 Rails 的 ActiveRecord 和 Phoenix Ecto 差別的文章,其實主要就是表達 Model 跟 Schema 脫鉤這樣而已,另外也提到了 Model 沒有 State 所以可以更好 passing around, ex: ```elixir...

Wayne

Python class method, instance method, and static method

* instance method => 傳 instance 進去的 function,以 self 作為第一個 argument * class method => 傳 class 進去的 function,以 cls (就是 class 的縮寫) 作為第一個 argu...

Wayne

FactoryBot build_stubbed, build, and create

- Speed `build_stubbed` > `build` > `ceate` - `build` is not persistent object, `build_stubbed` make object looks like persistent - `buil...

Wayne