This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--blitz-color-content-primary: #000000; | |
} | |
$blitz-color-content-primary: var(--blitz-color-content-primary, #000000); | |
$blitz-color-content-secondary: #000000; | |
.test { | |
background-color: $blitz-color-content-primary; | |
background-color: $blitz-color-content-secondary; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Key = string | number | symbol | |
const PathSymbol = Symbol('path'); | |
function pathProxy(path: Key[] = []) { | |
return new Proxy({ | |
get [PathSymbol]() { | |
return path; | |
}, | |
}, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example: https://stackblitz.com/edit/react-ts-hesbky?file=use-reducer.ts | |
// inspired by https://github.com/zeit/swr/pull/186/files | |
import {useState, useRef} from "react"; | |
type StateDependencies<T> = { | |
[K in keyof T]?: boolean; | |
}; | |
function equals(compareA, compareB) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const INCOME = 100_000; | |
// ----- 2022 ----- // | |
// https://www.canada.ca/en/revenue-agency/services/forms-publications/payroll/t4032-payroll-deductions-tables/t4032on-jan/t4032on-january-general-information.html | |
const CPP_BRACKETS = [ | |
[ 3_500, 0 ], // exemption | |
[ 61_400, 0.0570], // cap | |
[Infinity, 0 ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum WebStatus { | |
Loading, | |
Error, | |
Success, | |
NotCalled, | |
} | |
interface SuccessState<S> { | |
status: WebStatus.Success; | |
payload: S; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { assocPath, flip, path, init, last, toPairs } from 'ramda'; | |
function isObject(value: any): boolean { | |
return Object.prototype.toString.call(value) === '[object Object]'; | |
} | |
function isFunction(value: any): boolean { | |
return Object.prototype.toString.call(value) === '[object Function]'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** ES 2015 naive implementation of https://github.com/tj/co */ | |
function coAsync(generator) { | |
var gen = generator(); | |
return new Promise(function(resolve, reject) { | |
(function async({value, done}) { | |
if (done) return resolve(value); | |
if (Array.isArray(value)) { | |
Promise.all(value).then(values => async(gen.next(values))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets value of object given a string path | |
// Example: objectPathGet({a: {b: {c: {d: "hello"}}}}, "a.b.c.d") // returns "hello" | |
function objectPathGet(obj, path, _default) { | |
try { | |
var keys = path.split("."); | |
return (function _get(obj) { | |
var child = obj[keys.shift()]; | |
return keys.length ? _get(child) : child; | |
})(obj); | |
} catch(err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function snakeToCamel(str) { | |
return str.replace(/(\_[a-z])/g, function(char){return char[1].toUpperCase();}); | |
} | |
function camelToSnake(str) { | |
return str.replace(/([A-Z])/g, function(char){return "_" + char.toLowerCase();}); | |
} | |
function upperCaseFirst(str) { | |
return str[0].toUpperCase() + str.slice(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unlimited depth nested dictionary | |
def nested_dict(): | |
return defaultdict(nested_dict) | |
# Specify max depth of nested dictionary | |
def nested_dict(instance_type, max_depth): | |
def _nested_dict(depth): | |
if depth < max_depth: | |
return defaultdict(partial(_nested_dict, depth + 1)) |
NewerOlder