Skip to content

Instantly share code, notes, and snippets.

Avatar

Yiwei Gao yiweig

View GitHub Profile
View sample_text.txt
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 Apr 25, 2019 — forked from kentoj/closure-table-operations.sql
Closure Table operations SQL fragments
View closure-table-operations.sql
-- 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
View getWeekNumber.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;