Skip to content

Instantly share code, notes, and snippets.

View mxstbr's full-sized avatar
:shipit:
Shipping

Max Stoiber mxstbr

:shipit:
Shipping
View GitHub Profile
@mxstbr
mxstbr / sync-text-replacements.tsx
Created April 17, 2024 17:56
Raycast snippets > iOS/MacOS text replacements sync Raycast command
import { useEffect } from "react";
import { Detail, open } from "@raycast/api";
import { useExec } from "@raycast/utils";
import Papa from "papaparse";
type Row = {
// "On my way!"
ZPHRASE: string;
// omw
ZSHORTCUT: string;
@mxstbr
mxstbr / adr-template.md
Last active April 3, 2023 20:55
This is the ADR template that @mxstbr used successfully before. It is a shortened version of https://github.com/joelparkerhenderson/architecture-decision-record/blob/main/templates/decision-record-template-madr/index.md with slight renamings to make things clearer.

[short title of problem]

  • Status: [proposed | rejected | accepted | deprecated | … | superseded by ADR-0005]
  • Deciders: [list everyone involved in the decision]
  • Links: [list all the related links]

Context and Problem Statement

[Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]

@mxstbr
mxstbr / comparison.md
Created March 17, 2021 10:52
Bundle size comparison between GraphQL clients
  • Standard create-react-app
  • Sets up the GraphQL provider and client, nothing else
// src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
// Switch between them with comments
// import GraphQLProvider from "./Apollo"
@mxstbr
mxstbr / en.js
Created September 12, 2020 07:28
We need your help to translate the https://feedback.fish widget into more languages! If you know a language, please help by posting a translation for these strings in a comment below.
const en = {
titles: {
default: `What's on your mind?`,
idea: `Share an idea`,
issue: `Report an issue`,
other: `Tell us anything!`,
},
categories: {
idea: `Idea`,
issue: `Issue`,
@mxstbr
mxstbr / PaginationTypes.graphql
Created February 20, 2018 10:23
Code snippets for "Securing Your GraphQL API from Malicious Queries" blog post
type Participant {
# The complexity of getting one thread in a thread connection is 3, and multiply that by the amount of threads fetched
threadConnection(first: PaginationAmount, after: String): ThreadConnection @cost(complexity: 3, multiplier: "first")
}
type Thread {
participants(first: PaginationAmount,...): [Participant] @cost(complexity: 2, multiplier: "first")
}

First, start Chrome and open the page you want to profile:

./chrome --js-flags=”--prof” --no-sandbox http://localhost:8080/index.html

Note: This page should do things on-load, simply close Chrome once it's done

Then preprocess the biggest .log file you get: (since the biggest one should be from the main renderer):

@mxstbr
mxstbr / send-email.js
Created November 13, 2017 17:06
A send email util for Postmark
import postmark from 'postmark';
const debug = require('debug')('send-email');
const stringify = require('json-stringify-pretty-compact');
let client;
if (process.env.POSTMARK_SERVER_KEY) {
client = new postmark.Client(process.env.POSTMARK_SERVER_KEY);
} else {
console.log(
'\nℹ️ POSTMARK_SERVER_KEY not provided, debug mode enabled. Will log emails instead of actually sending them.'
import createLogger from 'graphql-log';
let list = [];
const logExecutions = createLogger({
logger: (name) => {
list.push(name);
fs.writeFileSync('resolvers.js', JSON.stringify(list, null, 2));
},
});
@mxstbr
mxstbr / asyncify.js
Last active March 13, 2018 09:14 — forked from ForbesLindesay/iter.js
A reusable utility to turn a callback-based listener into an async iterable
// @flow
// Turn a callback-based listener into many async iterators without buffering
import { $$asyncIterator } from 'iterall';
type Listener = ((arg: any) => void) => Promise<any>;
const defaultOnError = (err: Error) => {
throw new Error(err);
};

Keybase proof

I hereby claim:

  • I am mxstbr on github.
  • I am mxstbr (https://keybase.io/mxstbr) on keybase.
  • I have a public key whose fingerprint is 78D3 829B 9CE0 7924 2C15 4E38 673F 4304 C9E3 A511

To claim this, I am signing this object: