Skip to content

Instantly share code, notes, and snippets.

View mxstbr's full-sized avatar
💅
writing JavaScript

Max Stoiber mxstbr

💅
writing JavaScript
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 / Readme.md
Last active December 20, 2023 12:01
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
@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 / Field.js
Last active February 23, 2022 07:39 — forked from hungrysquirrel/Field.js
Style Storybook with Styled Components
import React, { PropTypes } from 'react';
import styled from 'styled-components'
const Wrapper = styled.div`
// styles here that used to be for .test
`
const Label = styled.label`
// label styles here
`
@mxstbr
mxstbr / Component.js
Last active August 24, 2021 20:26
styled-components ❤ tachyons
// There's two ways to use Tachyons together with styled-components
// Both are valid, which one you use depends if you want to always apply a tachyons class when a certain component
// is rendered or if you want to apply it for specific instances.
// 1. Use .attrs to define classNames that should always be applied to a styled component
// Whenever you use <Component /> now it'll have both the styled-components as well as the Tachyons class
// See the docs for more info: https://www.styled-components.com/docs/basics#attaching-additional-props
const Component = styled.div.attrs({
className: 'bw0-l',
})`
@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 / idea.md
Last active February 16, 2021 18:33
Code splitting react-router routes with webpack 2

NOTE: Sokra confirmed I had a misunderstanding, Webpack is still a static build tool and the below won't work. It's still a nice concept though...

With webpack 1, code splitting react-router routes is quite tedious. It requires us to repeat the getComponent function over and over again. (See here for an explanation how it works with webpack 1)

Example:

<Router history={history}>
  <Route
    path="/"
@mxstbr
mxstbr / webpack-for-node-modules.js
Last active February 13, 2021 20:28
How to use webpack to compile node modules
/* eslint-disable no-var */
var path = require('path');
var autoprefixer = require('autoprefixer');
const MATCH_ALL_NON_RELATIVE_IMPORTS = /^\w.*$/i;
module.exports = [{
output: {
filename: '[name].js',
library: 'atrium-react-plugin-beta',
@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")
}
@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`,