Skip to content

Instantly share code, notes, and snippets.

View laat's full-sized avatar
💤

Sigurd Fosseng laat

💤
View GitHub Profile
@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', () => {
@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 / tizen.sh
Last active May 16, 2025 14:05
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
open System
let ( ..|..<++>..|.. ) x y = x + " " + y
let ( >.< ) x z = x ..|..<++>..|.. "." ..|..<++>..|.. "Thanks Obama." |> z
"custom operators" ..|..<++>..|.. "makes everything worse" >.< Console.WriteLine
import { DotenvConfigOptions } from 'dotenv';
const __DEV__ = process.env.NODE_ENV !== 'production';
export type ConfigValue = {
value?: (v: string) => any;
} & (
| {
required: true;
}
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) {
@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
@laat
laat / Nullable.ts
Last active February 8, 2020 15:40
rxjs nullable modad-ish
import { Observable, of } from "rxjs";
import { map, switchMap } from "rxjs/operators";
export class Nullable {
static isNotNull<T>(v: T): v is NonNullable<T> {
return v != null;
}
static bind = <T, R>(
project: (value: NonNullable<T>, index: number) => R
@laat
laat / aoc.org
Created December 1, 2020 23:03
org-mode and elisp

Advent Of Code 2020

Using org-mode and Emacs Lisp to solve Advent of Code.

(org-babel-lob-ingest "./library-of-babel.org")

Day 1

Part 1

The times macro

(defmacro laat/times (n fn arg) 
  (cons 'thread-last (cons arg (cl-loop for i below n collect fn))))
(laat/times 3 sqrt 256)