Skip to content

Instantly share code, notes, and snippets.

View 0xR's full-sized avatar

Ruben Oostinga 0xR

View GitHub Profile
@0xR
0xR / pbpaste-md
Last active June 16, 2026 14:27
pbpaste-md — paste clipboard as clean Markdown on macOS. Converts RTF/HTML (Word, Pages, Confluence, Teams, browsers) via pandoc, stripping non-semantic spans, div wrappers, and Confluence prosemirror artifacts. Falls back to plain text.
#!/usr/bin/env bash
# pbpaste-md — paste the clipboard as Markdown, preserving formatting.
#
# Strategy:
# 1. If the clipboard has RTF (Word, Pages, TextEdit, Apple Mail, …) and
# `textutil` is available, convert RTF → HTML via textutil and then to
# Markdown via pandoc. RTF preserves list semantics that Word's HTML
# flavor mangles (it fakes bullets with <span style="font-family:Symbol">).
# 2. Else if the clipboard has HTML (Teams, Confluence, browsers, …),
# convert directly with pandoc.
@0xR
0xR / VertXAndReactor.kt
Last active November 13, 2019 14:50
Vert.X streams with Reactor
fun <Input, Output> processWithReactor(
vertx: Vertx,
inputStream: ReadStream<Input>,
outputStream: WriteStream<Output>,
processor: (Flux<Input>) -> Flux<Output>
) {
val publisher = ReactiveWriteStream.writeStream<Input>(vertx)
inputStream.pipeTo(publisher)
val writeStreamFlux = Flux.from(publisher)
// Chai
expect({ a: 1 }).to.deep.equal({ a: 1 });
expect({ a: 1 }).not.to.deep.equal({ a: 2 });
// Jest / jasmine
expect({ a: 1 }).toEqual({ a: 1 });
expect({ a: 1 }).not.toEqual({ a: 2 });
expect(json).toMatchSnapshot();
// Make sure chai and jasmine ".not" play nice together
const originalNot = Object.getOwnPropertyDescriptor(chai.Assertion.prototype, 'not').get;
Object.defineProperty(chai.Assertion.prototype, 'not', {
get() {
Object.assign(this, this.assignedNot);
return originalNot.apply(this);
},
set(newNot) {
this.assignedNot = newNot;
return newNot;
global.jestExpect = global.expect;
global.expect = chai.expect;
@0xR
0xR / App.spec.jsx
Last active November 2, 2016 16:43
expect({ a: 1 }).to.deep.equal({ a: 1 });
jestExpect({ a: 1 }).toEqual({ a: 1 });
// Usage: import makeTypeDef from './graphql-schema-creator.js';
// makeTypeDef('mynewtype', myTypeValue);
import {
GraphQLObjectType,
GraphQLNonNull,
GraphQLSchema,
GraphQLString,
GraphQLList,
GraphQLInt,