- Functional
- Imperative
- Object-oriented
- Procedural
- Stack-based
- "Multi-paradigm"
- Lazy
- Eager
This file contains 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 {find, fromEvent, scan} from 'rxjs'; | |
const up = "ArrowUp", down = "ArrowDown", left = "ArrowLeft", right = "ArrowRight"; | |
const sequence = [up, up, down, down, left, right, left, right, "b", "a"]; | |
fromEvent<KeyboardEvent>(document, 'keyup').pipe( | |
scan((i, {key}) => (sequence[i] == key) ? i+1 : 0, 0), | |
find(i => i == sequence.length) | |
).subscribe(() => console.log("unlocked")) |
This file contains 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 AnyFunction = (...args: any[]) => any; | |
type ImmutablePrimitive = undefined | null | boolean | string | number | AnyFunction; | |
type Immutable<T> = | |
T extends ImmutablePrimitive ? T : | |
T extends Map<infer K, infer V> ? ReadonlyMap<Immutable<K>, Immutable<V>> : | |
T extends Set<infer E> ? ReadonlySet<Immutable<E>> : | |
{ readonly [P in keyof T]: Immutable<T[P]> } | |
This file contains 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
/** returns a promise that resolves when element becomes available */ | |
function waitForElement(selector, timeout=1000) { | |
return new Promise((resolve, reject) => { | |
let start, element; | |
requestAnimationFrame(function wait(timestamp) { | |
if (start == null) start = timestamp; | |
element = document.querySelector(selector); | |
if (element) { | |
resolve(element); | |
} else { |
This file contains 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 coerceBooleanProperty(prop: unknown): boolean { | |
return !!prop; | |
} | |
const CoerceBoolean: PropertyDecorator = (proto, prop) => { | |
const values = new WeakMap(); | |
Object.defineProperty(proto, prop, { | |
get() { | |
return values.get(this) | |
}, |
This file contains 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
#!/bin/bash | |
# Let's Encrypt Certificate reload on Synology NAS | |
# Services configured through DSM to use a given certificate create their own copies of the certificate files. | |
# This script will update those copies after the original certificate is renewed. | |
# | |
# Install and configure acme.sh on the Synology NAS by following the tutorial: | |
# https://github.com/Neilpang/acme.sh/wiki/Synology-NAS-Guide | |
CERT_DIR=/usr/syno/etc/certificate |
This file contains 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
interface Inner<T> { | |
value: T; | |
} | |
interface Numeric { | |
content: Inner<number>; | |
} | |
interface Text { | |
content: Inner<string>; |
This file contains 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
''' | |
Created on Feb 24, 2011 | |
The purpose of this script is to create the SDE connection file needed to connect to your SDE | |
@author: rrubalcava | |
''' | |
import os, arcpy | |
class CreateSDEConnection: |
This file contains 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
/// <reference path='../leaflet/leaflet.d.ts' /> | |
namespace L { | |
type LatLngExpression = L.LatLng | number[] | ({ lat: number; lng: number }); | |
export var JSMarker = L.Marker.extend({ | |
options: { title: 'MyMarker' }, | |
initialize: function(latLng: LatLngExpression, options?: L.MarkerOptions) { |
This file contains 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
#include <stdio.h> | |
/* Scheduler includes. */ | |
#include "FreeRTOS.h" | |
#include "task.h" | |
#include "queue.h" | |
#include "semphr.h" | |
/* Library includes. */ | |
#include "stm32f10x.h" |
NewerOlder