Skip to content

Instantly share code, notes, and snippets.

/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
// You can delete this file if you're not using it
const axios = require(`axios`)
exports.createPages = async({ actions: { createPage }, graphql }) => {
function resizeElementHeight(element) {
var height = 0;
var body = window.document.body;
if (window.innerHeight) {
height = window.innerHeight;
} else if (body.parentElement.clientHeight) {
height = body.parentElement.clientHeight;
} else if (body && body.clientHeight) {
height = body.clientHeight;
}
@jeff-free
jeff-free / csv_importable.rb
Last active June 13, 2022 00:54
Rspec CSV import feature testing with CSV foreach stubbing
# Implementation
module CSVImportable
extend ActiveSupport::Concern
included do
def self.import(file)
CSV.foreach(file.path, headers: true, encoding:'utf-8') do |row|
self.create! row.to_hash
end
# 確定目前到這個號碼,是否有需要提醒的使用者。
class QueueCallSetReminderService
attr_reader :reminders_to_push, :current_queue_records, :queue_rule, :shop, :shop_reminders
def self.call(*args)
QueueCallSetReminderService.new(*args).call
end
def initialize(shop, current_queue_records)
@shop = shop
1. 將以下資料 POST 到 /device_auth/authorize
- identifier_token,格式為 UUID
- os,請傳 iphone || ipad
會拿到 access_token
2. 將以下資料 post 到 /mobile/notification_services
- access_token
- apnl_token
server 會在 aws - sns 服務上註冊裝置資料
以上為準備工作,如果流程都順利,便可進行收訊息測試:
@jeff-free
jeff-free / gist:c4c214970e144db0412f
Created August 28, 2015 03:43
Rails sorting module code backend
module Modules::Manageable
extend ActiveSupport::Concern
included do
default_scope -> {order(position: :asc)}
after_create :add_position
before_destroy :decrease_position_when_delete_one
end
def add_position