Skip to content

Instantly share code, notes, and snippets.

View jantimon's full-sized avatar
🧨

Jan Nicklas jantimon

🧨
View GitHub Profile
@jantimon
jantimon / css-om-tests.js
Created May 31, 2024 07:01
test cases for browser performance tests
// tested on: https://www.youtube.com/results?search_query=chrome+performance
const styleElement = document.createElement("style");
styleElement.innerHTML = `
@property --unused-property-no-inherit { inherits: false }
*, *:before, *:after { box-sizing: inherit }
.opacity-30 {
opacity: 0.3;
}
@jantimon
jantimon / css-om-test.js
Created May 25, 2024 09:00
different test cases to compare recalculate style timings
const styleElement = document.createElement("style");
styleElement.innerHTML = `@property --unused-property-no-inherit { inherits: false }`
document.head.appendChild(styleElement);
const styleSheet = styleElement.sheet;
setTimeout(() => {
performance.mark("inject html opacity 0.5");
console.log("add to <html> opacity: 0.5");
styleSheet.insertRule("html { opacity: 0.5 }", styleSheet.cssRules.length);
}, 1000);
@jantimon
jantimon / gist:f764e179baeee7c98b8bb6035fb2964a
Last active April 26, 2024 14:30
install stable diffusion v1 on Apple M1
brew update
brew install Cmake protobuf rust python
git clone https://github.com/bfirsh/stable-diffusion.git
git checkout apple-silicon-mps-support
mkdir -p models/ldm/stable-diffusion-v1/
# accept license and download the model
# sd-v1-4.ckpt from:
# https://huggingface.co/CompVis/stable-diffusion-v-1-4-original
@jantimon
jantimon / gist:2c464e8589b258a9516b3d7e99c580e4
Created August 4, 2022 20:03
Git Checkout Main / Cleanup / Yarn
#!/usr/bin/env bash
git fetch &
MAIN_BRANCH="main"
# detect master / main branch
if [ "$(git rev-parse --quiet --verify $MAIN_BRANCH)" ]; then
echo "main branch: ${MAIN_BRANCH}"
else
MAIN_BRANCH="master"
@jantimon
jantimon / reducerTypings.tsx
Created September 21, 2020 12:30
use reducer typings
export const actionCreator = <TState>() => <TOptions extends {}>(
actionHandler: ActionHandler<TOptions, TState>
) => actionHandler;
type ActionHandler<TOptions extends {}, TState extends {}> = (
state: TState,
options: TOptions
) => TState;
type ActionOptions<T> = T extends ActionHandler<infer TOptions, infer State>
? TOptions
: never;
@jantimon
jantimon / responsiveTests.js
Last active November 21, 2018 09:49
Codepen for Responsive Tests
//https://codepen.io/anon/pen/XyVQyp
setUpTestEnvironment();
console.log('Test', 500)
setViewportSize(500);
assert.equal(meassureElementWidth('.content'), 500)
@jantimon
jantimon / index.js
Created August 13, 2018 15:35
DynamicRequire
export default function() {
return import('react-dom');
}
const viewportClassPrefix = (viewport: 'xs' | 'sm' | 'md' | 'lg') => viewport === 'xs' ? '' : ('-' + viewport);
const flexAlignment = {
col: {
direction: {
outer: (viewport: 'xs' | 'sm' | 'md' | 'lg') => `flex${viewportClassPrefix(viewport)}-column`,
inner: (viewport: 'xs' | 'sm' | 'md' | 'lg') => `flex${viewportClassPrefix(viewport)}-row`,
},
@jantimon
jantimon / switch-case.ts
Created July 20, 2018 10:09
Typescript Prevent Default Case
interface Box {
height: number;
width: number;
color: 'RED' | 'BLUE'
}
function logColor(box: Box) {
switch (box.color) {
case 'RED':
console.log(box, 'is red');
@jantimon
jantimon / switch-case.ts
Created July 20, 2018 10:09
Typescript Prevent Default Case
interface Box {
height: number;
width: number;
color: 'RED' | 'BLUE'
}
function logColor(box: Box) {
switch (box.color) {
case 'RED':
console.log(box, 'is red');