Skip to content

Instantly share code, notes, and snippets.

View laat's full-sized avatar
💤

Sigurd Fosseng laat

💤
View GitHub Profile
@laat
laat / elementClosest.d.ts
Created November 19, 2019 11:43
simple ponyfills
/**
* Element.closest ponyfill
*/
export function elementClosest(element: Element, selector: string): Element | null
import { RequestHandler } from 'express';
/**
* Combine multiple middleware together.
* @param mids
*/
export const combineHandlers = (...mids: RequestHandler[]): RequestHandler =>
mids.reduce((a, b) => (req, res, next) => {
a(req, res, err => {
if (err) {
import { DotenvConfigOptions } from 'dotenv';
const __DEV__ = process.env.NODE_ENV !== 'production';
export type ConfigValue = {
value?: (v: string) => any;
} & (
| {
required: true;
}
open System
let ( ..|..<++>..|.. ) x y = x + " " + y
let ( >.< ) x z = x ..|..<++>..|.. "." ..|..<++>..|.. "Thanks Obama." |> z
"custom operators" ..|..<++>..|.. "makes everything worse" >.< Console.WriteLine
@laat
laat / tizen.sh
Last active May 8, 2025 06:30
Notes on Tizen commands that might work
sdb connect <ip>:<port> # connect to TV
sdb -s <deviceName> capability # get <installationPath>
# build
tizen cli-config "default.profiles.path=<profile_path>"
tizen build-web -out .buildResult -- <source-dir>
tizen package --type wgt --sign profileName -- <source-dir>/.buildResult # extract <package-file>
mv <package-file> .
rm -rf <source-dir>/.buildResult
@laat
laat / .browserlistrc
Last active February 13, 2019 23:15
tv dev browsers
# https://developer.samsung.com/tv/develop/specifications/web-engine-specifications
chrome 47 # Tizen 3.0 2017
chrome 56 # Tizen 4.0 2018
chrome 63 # Tizen 5.0 2019
# http://webostv.developer.lge.com/discover/webos-tv-platform/web-engine/
chrome 38 # webOS TV 3.x 2016-2017
chrome 53 # webOS TV 4.x 2018
@laat
laat / CaseInsensitiveMap.test.ts
Last active April 25, 2018 21:26
CaseInsensitiveMap
import CaseInsensitiveMap from './CaseInsensitiveMap';
describe('CaseInsensitiveMap', () => {
it('should be able to construct', () => {
const map: Map<string, string> = new CaseInsensitiveMap<string>();
});
it('should be able to construct with values', () => {
const map: Map<string, string> = new CaseInsensitiveMap<string>([['key', 'value'], ['key2', 'value2']]);
});
it('has case insensitive keys', () => {
import { Middleware, Action } from 'redux';
// Grabbed from:
// https://github.com/reactjs/redux/blob/master/src/utils/isPlainObject.js
function isPlainObject(obj: any) {
if (typeof obj !== 'object' || obj === null) return false
let proto = obj
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto)
function equals(a1, a2) {
return (a1.length == a2.length) && a1.every(function(element, index) {
return element === a2[index];
});
const combineResults = async () => {
const [a, b, c] = await Promise.all([requestSlowly('a'), requestSlowly('b'), requestSlowly('c')]);
return a + b + c;
}