Skip to content

Instantly share code, notes, and snippets.

View felixfbecker's full-sized avatar

Felix Becker felixfbecker

View GitHub Profile
@felixfbecker
felixfbecker / threads_debug.txt
Last active January 4, 2016 19:04
Threads debug log
Debugger listening on port 14905
waiting for debug protocol on port 4711
>> accepted connection from client
-> initializeRequest
{ type: 'request',
seq: 1,
command: 'initialize',
arguments: { adapterID: 'php', linesStartAt1: true, pathFormat: 'path' } }
@felixfbecker
felixfbecker / profile.ps1
Created September 16, 2016 10:57
My customized PowerShell prompt
# 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) {
@felixfbecker
felixfbecker / observable-array.ts
Created November 30, 2017 04:55
Observable Array
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 / protomap.ts
Last active April 19, 2018 07:05
Immutable __proto__ backed Map
// 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) {
@felixfbecker
felixfbecker / worker_threads_test.ts
Created October 12, 2018 16:30
Goroutines in Node with Worker Threads
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 / comlink.ts
Created February 17, 2019 15:49
Comlink types
#!/usr/bin/env pwsh
$ErrorActionPreference = 'Stop'
$repositoryRoot = $PWD
# Builds the PCRE extension to sqlite3.
function Build-Libsqlite3Pcre {
[OutputType([string])]
param()
#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 {
@felixfbecker
felixfbecker / interviews.psm1
Last active January 31, 2020 09:47
Automation for sending out coding exercises
#Requires -Modules PSGitHub, PSGSuite
function New-CodingExercise {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $CandidateUsername,
[Parameter(Mandatory)]
[string] $CandidateName,
@felixfbecker
felixfbecker / morph.ts
Last active April 27, 2020 16:11
TypeScript codemod to add history prop drilling where it was missing
/* eslint-disable no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-includes */
import {
Project,
Diagnostic,
SyntaxKind,
Node,
StructureKind,
QuoteKind,