Skip to content

Instantly share code, notes, and snippets.

@wasprobot
wasprobot / gist:d2c5cf3ce15595cfa69cc272b95d6d20
Created November 30, 2020 14:59
day of week 1901 - 2099 (js)
(((y-1901) + ((y-1901)/4 >> 0)) + (y%4 ? [0,3,3,6,1,4,6,2,5,0,3,5] : [0,3,4,0,2,5,0,3,6,1,4,6]) [m-1] + d + 1) % 7
@wasprobot
wasprobot / map_switch_case.py
Created May 24, 2018 19:50
An easy substitute for 'switch-case..' in python
def mock_get_bins(self, key):
return {
BinHelper.ROUNDED_STAR: 'rounded-bin',
BinHelper.UNROUNDED_STAR: 'unrounded-bin',
BinHelper.TOTAL_REVENUE: 'revenue-bin',
BinHelper.QUALITY_BONUS: 'quality-bin',
}[key]
@wasprobot
wasprobot / gist:53a90b4be30cabb53b9e
Created February 18, 2016 19:00
Find the 1st character in every *.html file in the current directory
for file in *.html; do echo -ne "$file" && head -1 "$file" | cut -c1 ; done