Using CSS tables to vertical align center content.
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
/* | |
Spec: https://wicg.github.io/shape-detection-api/#barcode-detection-api | |
*/ | |
interface BarcodeDetector { | |
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>; | |
} | |
type BarcodeFormat = | |
| "aztec" |
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 CamelCase<T> = T extends `-${infer A}-${infer B}` | |
? `${A}${Capitalize<CamelCase<B>>}` | |
: T extends `${infer A}-${infer B}` | |
? `${A}${Capitalize<CamelCase<B>>}` | |
: T |
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 Undefined<T> = { [P in keyof T]: P extends undefined ? T[P] : never } | |
type FilterFlags<Base, Condition> = { | |
[Key in keyof Base]: | |
Base[Key] extends Condition ? Key : never | |
}; | |
type AllowedNames<Base, Condition> = | |
FilterFlags<Base, Condition>[keyof Base]; |
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 isFormValid = form => { | |
const elements = form && form.elements | |
if (!elements) return false | |
return Array.from(elements).every(elem => elem.validity && elem.validity.valid) | |
} |
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
//Based on http://www.samliew.com/icval/ | |
function validateNRIC(str) { | |
if (str.length != 9) | |
return false; | |
str = str.toUpperCase(); | |
var i, | |
icArray = []; | |
for(i = 0; i < 9; i++) { |
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
$total-columns: 6; | |
$col-widths: (); | |
@for $i from 1 through $total-columns { | |
@for $j from 1 through $i { | |
$w: ($j/$i); | |
@if not index($col-widths, $w) { | |
.col-#{$j}-#{$i} { | |
width: $w * 100%; |