Note: /my/* routes requires cognito user token
GET /users # Return list of users, for admin purpose only
GET /users/:userId/profile # For viewing other's profile
| import keyBasedDebounce from '../keyBasedDebounce' | |
| jest.useFakeTimers().setSystemTime(new Date('2024-09-01')) | |
| describe('keyBasedDebounce', () => { | |
| beforeEach(() => { | |
| jest.clearAllMocks() | |
| }) | |
| it('should debounce the function call', () => { |
| // credit to: https://codepen.io/michellebarker/pen/RwMWYpb | |
| <div class="grid"> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> | |
| <div class="item"></div> |
| const DataLoader = require("dataloader"); | |
| const users = new Map([ | |
| [ | |
| 1, | |
| { | |
| id: 1, | |
| name: "Tom", | |
| }, | |
| ], |
| const DataLoader = require("dataloader"); | |
| const users = new Map([ | |
| [1, { id: 1, name: "Tom" }], | |
| [2, { id: 2, name: "John" }], | |
| [3, { id: 3, name: "Ann" }], | |
| [4, { id: 4, name: "Peter" }], | |
| [5, { id: 5, name: "May" }], | |
| ]); |
| const DataLoader = require("dataloader"); | |
| const stories = new Map([ | |
| [1, { id: 1, title: "story 1" }], | |
| [2, { id: 2, title: "story 2" }], | |
| [3, { id: 3, title: "story 3" }], | |
| [4, { id: 4, title: "story 4" }], | |
| [5, { id: 5, title: "story 5" }], | |
| ]); |
| SELECT * FROM singers LIMIT 5; | |
| SELECT * FROM songs WHERE singer_id = 1; | |
| SELECT * FROM songs WHERE singer_id = 2; | |
| SELECT * FROM songs WHERE singer_id = 3; | |
| SELECT * FROM songs WHERE singer_id = 4; | |
| SELECT * FROM songs WHERE singer_id = 5; |
| #!/bin/bash | |
| while read oldrev newrev ref | |
| do | |
| branch=`echo $ref | cut -d/ -f3` | |
| if [ "master" == "$branch" ]; then | |
| git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch | |
| echo 'Changes pushed live.' | |
| fi |
| // http://imweb.io/topic/59dc5a8b856028aa249e2a58 | |
| // https://segmentfault.com/a/1190000006930013 | |
| // 總之,IE真的是毒瘤... | |
| { | |
| "presets": [ | |
| ["es2015", | |
| { | |
| "loose": true | |
| }], | |
| "stage-0" |
| class Counting extends Array { | |
| constructor(...items) { | |
| if (items.length > 1) super(...items); | |
| else { | |
| super(); | |
| this.push(...items); | |
| } | |
| } | |
| swap(idx1, idx2) { | |
| const length = this.length; |