Skip to content

Instantly share code, notes, and snippets.

View benbenbenbenbenben's full-sized avatar
🐶

Benjamin Babik benbenbenbenbenben

🐶
View GitHub Profile
@benbenbenbenbenben
benbenbenbenbenben / README.md
Created December 7, 2024 22:38 — forked from leonjza/README.md
Forward a remote iOS device, locally.

fwd_ios.sh

Forwards a remote iOS device, exposed via usbmuxd on Linux to a local macOS client.
The inverse (aka ssh -R) is left as an excercise to the reader, but shouldn't be too hard :)

This is basically a simple usbfluxd that only depends on socat.

install

Copy the bash script to a local file, say fwd_ios.sh and make it executable with chmod +x fwd_ios.sh.

static func convertDERtoRAW(_ signature: Data) throws -> Data {
// Check minimum length and sequence tag
guard signature.count >= 2, signature[0] == 0x30 else {
throw JWTSigningError.signatureConversionFailed
}
// Verify sequence length
let sequenceLength = Int(signature[1])
guard signature.count >= sequenceLength + 2 else {
throw JWTSigningError.signatureConversionFailed
type TupleBuilderEx<Constraint = any, Tail extends [...any] = []> = {
items: Tail,
add: TupleBuilderAdd<Constraint, Tail>
}
type TupleBuilderAdd<Constraint, Tail extends [...any] = []> = <Head extends Constraint>(head: Head) => TupleBuilderEx<Constraint, [...Tail, Head]>
const tupleBuilderEx = <Constraint = any, Head extends Constraint = Constraint, Tail extends [...any] = []>(head: Head, tail?: Tail): TupleBuilderEx<Constraint, [...Tail, Head]> => {
return {
@benbenbenbenbenben
benbenbenbenbenben / api.ts
Created March 8, 2024 16:35
mutating vs cloning fluent API
type Value = {
value: number
}
type ValueWithUse = Value & {
use: (x: number) => ValueWithUse
}
// patch a fluent API to a Value object with side effects
const withMutatingUse = (thing: Value): ValueWithUse => {
// exploring vitest behaviour with --pool=forks vs --pool=threads
// spoiler alert: same module, same behaviour - server is only created *once*
import { describe, expect, it } from "vitest";
const server = {
a: 0
}
describe("some module", () => {
type Contract<V, A extends any[]> = (value: V) => (...args: A) => V;
const argsStack: any[] = [];
const Barrier = Symbol();
export const contract = <V, A extends any[]>(
f: Contract<V, A>
): ((...args: A) => V) => {
const handler = (...contractArgs: A) => {
@benbenbenbenbenben
benbenbenbenbenben / linetrim.ts
Last active October 1, 2021 10:05
trim whitespace from start and end of lines in multiline strings in js/ts
// This little function joins strings[0] with the l-r-... zip of strings.slice(1) and expr
// TypeScript
export const linetrim = (strings: TemplateStringsArray, ...expr: string[]): string => {
return strings.slice(1).reduce((str, fragment, i) => str + expr[i] + fragment, strings[0]).replace(/^.*$/gm, line => line.trim() + `\n`)
}
// JavaScript
export const linetrim = (strings, ...expr) => {
return strings.slice(1).reduce((str, fragment, i) => str + expr[i] + fragment, strings[0]).replace(/^.*$/gm, line => line.trim() + `\n`)
@benbenbenbenbenben
benbenbenbenbenben / Dockerfile
Created February 24, 2020 18:42
Dockefile for taiko
FROM node:lts
#USER node
RUN apt-get update && \
apt-get install -y git-all gconf-service libasound2 libatk1.0-0 \
libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \
libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 \
libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \
@benbenbenbenbenben
benbenbenbenbenben / object-keys-lowercase.js
Created September 19, 2019 11:57
javascript object keys lowercaser
// lower case process.env variables:
const env = Object.keys(process.env).reduce((k,v) => Object.assign(k, {[v.toLowerCase()]:process.env[v]}), {})
package de.tsenger.u2f;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
public class AcosJPatch {
public static short getOffsetCdata(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short offset = apdu.getOffsetCdata();