Skip to content

Instantly share code, notes, and snippets.

View yiweig's full-sized avatar

Yiwei Gao yiweig

View GitHub Profile
Hello world! This is just a sample file that can be accessed via a GET over the public internet. :)
@yiweig
yiweig / closure-table-operations.sql
Created April 25, 2019 17:19 — forked from kentoj/closure-table-operations.sql
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors
@yiweig
yiweig / getWeekNumber.js
Last active August 29, 2015 14:22 — forked from dblock/getWeek.js
// `date` must be a Date object, otherwise you may
// need to change lines 6 and 10 to account
// for a different data type.
function(date) {
// Create a copy of this date object
var target = new Date(date.valueOf());
// ISO week date weeks start on Monday
// so correct the day number
var dayNumber = (date.getDay() + 6) % 7;