Skip to content

Instantly share code, notes, and snippets.

View IanVS's full-sized avatar

Ian VanSchooten IanVS

View GitHub Profile
@jaens
jaens / storyBookRouter.tsx
Created February 18, 2024 00:01
Storybook fake Tanstack router
/* eslint-disable react-refresh/only-export-components */
import {
createMemoryHistory,
createRootRoute,
createRoute,
createRouter,
useRouterState,
type NotFoundRouteProps,
} from "@tanstack/react-router";
import { createContext, useContext, type ReactNode } from "react";
@adripo
adripo / change_filament_without_ams.gcode
Last active June 13, 2024 14:36
G-code to manually change filament without AMS. See https://github.com/bambulab/BambuStudio/issues/278
;===== Change filament G-code without AMS ===
;===== version: 1.2 =========================
;===== original version date: 20230719 ======
;===== description ==========================
; Everything between M620 and M621 is executed only if AMS is connected.
; All M620, M620.x and M621 commands are removed to enable manual filament change.
; first filament change is skipped
{if toolchange_count > 1}
@shilman
shilman / mdx-v2-sb-6.5.md
Last active March 20, 2023 15:05
Experimental MDXv2 Support in Storybook 6.5

Experimental MDXv2 Support in Storybook 6.5

The MDX team has just released the long-awaited MDXv2 with dramatically better syntax and performance. It's a huge win for the community! 🎉

Now I'm excited to announce experimental support in Storybook 6.5. This gist summarizes how to try it out, how to report bugs, and known gotchas that you might encounter along the way.

Installation

Since MDXv2 is a breaking change, it's an opt-in feature in Storybook 6.5.

@shilman
shilman / storybook-react-docgen-typescript.md
Last active January 23, 2024 03:43
Storybook React props handling for Typescript

NOTE: This was written in 2020 and has been superseded by docs at storybook.js.org

Storybook React props handling for Typescript

We've flip-flopped on prop table handling for React components written in Typescript. This document attempts to be a final reference for anybody who's been trying to follow along.

TLDR:

SB6 uses react-docgen-typescript by default. We hope to use react-docgen in SB7. The whole experience led to zero-config in SB6, so it's now a one-line change main.js to switch between the two.

@benjie
benjie / npm-wrong-tag.md
Created July 26, 2017 12:16
Resolve publishing npm package to wrong tag

If you accidentally publish a package to the wrong tag (e.g. @latest when you meant to tag it as @next) you can resolve as follows:

npm show PACKAGE_NAME versions # To view the versions you've published
npm dist-tags add PACKAGE_NAME@NEW_VERSION next # Tag the new package version as `@next`
npm dist-tags add PACKAGE_NAME@OLD_VERSION latest # Restore the correct `@latest` to be your previous release version
@thevangelist
thevangelist / my-component.spec.js
Created August 4, 2016 13:06
The only React.js component test you'll ever need (Enzyme + Chai)
import React from 'react';
import { shallow } from 'enzyme';
import MyComponent from '../src/my-component';
const wrapper = shallow(<MyComponent/>);
describe('(Component) MyComponent', () => {
it('renders without exploding', () => {
expect(wrapper).to.have.length(1);
});
@jmreidy
jmreidy / test_mocha.opts
Last active January 9, 2018 11:49
Unit test React Native with Mocha
--compilers js:./test/support/compiler
--require ./test/support/init
@mmrko
mmrko / mocha-react-css-modules.js
Last active January 1, 2024 00:15
Mocha & React & CSS Modules with Sass
// setup.js
import hook from 'css-modules-require-hook'
import sass from 'node-sass'
hook({
extensions: [ '.scss' ],
preprocessCss: data => sass.renderSync({ data }).css
})
@paulirish
paulirish / what-forces-layout.md
Last active November 3, 2024 22:00
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@jhliberty
jhliberty / ember-config-environment.js
Created June 12, 2015 03:21
Basic JWT Auth for Seeds.js/Sane Stack (aka Ember on Sails)
var ENV = {
modulePrefix: 'frontend',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}