Skip to content

Instantly share code, notes, and snippets.

@felixfbecker
felixfbecker / morph.ts
Last active Apr 27, 2020
TypeScript codemod to add history prop drilling where it was missing
View morph.ts
/* eslint-disable no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-includes */
import {
Project,
Diagnostic,
SyntaxKind,
Node,
StructureKind,
QuoteKind,
@felixfbecker
felixfbecker / interviews.psm1
Last active Jan 31, 2020
Automation for sending out coding exercises
View interviews.psm1
#Requires -Modules PSGitHub, PSGSuite
function New-CodingExercise {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $CandidateUsername,
[Parameter(Mandatory)]
[string] $CandidateName,
View not-needed-packages.ps1
#Requires -Module PSGitHub
#Requires -Module PowerGit
[CmdletBinding()]
param()
$items = Get-Content not-needed-packages.txt | Select-String -Pattern 'Typings already defined for ([^ ]+)' -Context 0,5
$i = 0
$items | ForEach-Object {
View build.ps1
#!/usr/bin/env pwsh
$ErrorActionPreference = 'Stop'
$repositoryRoot = $PWD
# Builds the PCRE extension to sqlite3.
function Build-Libsqlite3Pcre {
[OutputType([string])]
param()
View comlink.ts
@felixfbecker
felixfbecker / worker_threads_test.ts
Created Oct 12, 2018
Goroutines in Node with Worker Threads
View worker_threads_test.ts
import { Worker } from 'worker_threads'
export function work<P extends any[], R>(script: (...args: P) => R | PromiseLike<R>, ...args: P): Promise<R> {
return new Promise((resolve, reject) => {
const workerSource = `
const { workerData, parentPort } = require('worker_threads');
Promise.resolve((${script})(...workerData))
.then(result => {
parentPort.postMessage({ type: 'success', result })
}, error => {
@felixfbecker
felixfbecker / protomap.ts
Last active Apr 19, 2018
Immutable __proto__ backed Map
View protomap.ts
// tslint:disable:forin
export class ProtoMap<V> {
private _values: any;
public [Symbol.toStringTag]: 'ProtoMap' = 'ProtoMap'
constructor(init?: Iterable<[string, V]> | { [key: string]: V }) {
this._values = { __proto__: null }
if (init) {
View observable-array.ts
import { Subject } from 'rxjs/Subject'
export interface Splice<T> {
/**
* The zero-based location in the array from which to start removing elements.
*/
start: number
/**
* The number of elements to remove.
*/
@felixfbecker
felixfbecker / profile.ps1
Created Sep 16, 2016
My customized PowerShell prompt
View profile.ps1
# Fix UTF8 Output
# [Console]::OutputEncoding = [Text.Encoding]::UTF8
$OutputEncoding = [Text.Encoding]::UTF8
$env:COMPOSER_DISABLE_XDEBUG_WARN = 1
$env:NPM_CONFIG_UNICOE = 'true'
# A helper function to switch between multiple versions of PHP, NodeJS, ...
function Use-Version($program, $version, $arch) {
View bundle.js.map
{
"version": 3,
"sources": [
"node_modules/browser-pack/_prelude.js",
"node_modules/angular-animate/angular-animate.js",
"node_modules/angular-animate/index.js",
...
"node_modules/angular/angular.js",
"node_modules/angular/index.js",
"node_modules/javascript-natural-sort/naturalSort.js",