Skip to content

Instantly share code, notes, and snippets.

View lindskogen's full-sized avatar
🏃‍♂️

Johan Lindskogen lindskogen

🏃‍♂️
View GitHub Profile
@lindskogen
lindskogen / BluetoothCentral.swift
Last active June 17, 2019 09:40
Sketch of a BindableObject for finding friends by local PTP
//
// BluetoothCentral.swift
//
// Created by Johan Lindskogen on 2019-06-16.
// Copyright © 2019 Johan Lindskogen. All rights reserved.
//
import SwiftUI
import CoreBluetooth
import Combine
@lindskogen
lindskogen / pickbyvaluetype.ts
Last active September 18, 2020 20:54
Typescript Pick by value type
type ExtractKeysByValueType<O, V> = {
[P in keyof O]: O[P] extends V ? P : never;
}[keyof O]
type PickByValueType<O, V> = Pick<O, ExtractKeysByValueType<O, V>>
type OmitByValueType<O, V> = Omit<O, ExtractKeysByValueType<O, V>>
// Usage:
@lindskogen
lindskogen / pollen.1h.py
Last active March 22, 2021 09:43
pollen.1h.py
#!/usr/bin/env LC_ALL=en_US.UTF-8 /usr/local/bin/python3
#
# <bitbar.title>Pollenkoll</bitbar.title>
# <bitbar.version>v0.2</bitbar.version>
# <bitbar.author>lindskogen</bitbar.author>
# <bitbar.author.github>lindskogen</bitbar.author.github>
# <bitbar.desc></bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies>python</bitbar.dependencies>
@lindskogen
lindskogen / cb.ts
Created May 12, 2021 15:22
Create branch from azure devops assigned tasks
#!/usr/bin/env deno run --quiet --no-check --allow-net=dev.azure.com --allow-run --allow-env=AZURE_DEVOPS_READ_WORK_ITEMS_TOKEN
import * as Colors from "https://deno.land/std@0.96.0/fmt/colors.ts";
import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
const prefix = Deno.args[0] ?? "feature";
const ids_query =
"SELECT [System.Id] FROM workitems WHERE [System.TeamProject] = @project AND [System.State] <> 'Ready for test' AND [System.State] <> 'Parked' AND [System.State] <> 'Removed' AND [System.State] <> 'Tested OK' AND [System.State] <> 'Done' AND [System.AssignedTo] = @me";
const organizationName = "x";
@lindskogen
lindskogen / bufferTime.ts
Created September 16, 2022 17:09
BufferTime higher order saga
import { ActionMatchingPattern } from '@redux-saga/types';
import { ActionPattern, delay, fork, race, take } from 'redux-saga/effects';
export const bufferTime = <P extends ActionPattern, A extends ActionMatchingPattern<P>>(
ms: number,
pattern: P,
worker: (action: A) => any,
mergeFn: (a1: A, a2: A) => A,
) =>
fork(function* () {