Skip to content

Instantly share code, notes, and snippets.

@strinkaus-gd
strinkaus-gd / Store.ts
Last active October 20, 2023 11:11 — forked from koenbok/store.ts
Framer createStore & useStore
import * as React from "react"
import { useState, useEffect } from "react"
/*
from Koen Bok
A hook to simply use state between components
Usage:
@asci
asci / fadeInWhenShown.tsx
Created September 6, 2019 12:48
Framer X Override for component to fade in when appear on screen
import * as React from "react"
import { useState, useEffect, useRef } from "react"
import { Override, motion } from "framer"
// Override
export function OnScreen(props): Override {
const ref = useRef()
const [wasShown, setWasShown] = useState(false)
const onScreen = useOnScreen(ref)
@steveruizok
steveruizok / Resizer.tsx
Created June 19, 2019 08:38
A Framer X Code Component that will resize to fit its text content.
import * as React from "react"
import {
Frame,
FrameProps,
useMotionValue,
addPropertyControls,
ControlType,
} from "framer"
type Props = FrameProps & {
@koenbok
koenbok / store.ts
Last active November 10, 2023 00:17
import * as React from "react";
/**
A hook to simply use state between components
Warning: this only works with function components (like any hook)
Usage:
// You can put this in an central file and import it too
const useStore = createStore({ count: 0 })
@bisubus
bisubus / ES5-ES6-ES2017-ES2019 omit & pick
Last active April 13, 2024 21:03
ES5/ES6/ES2017/ES2019 omit & pick
@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
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

Development Contract Killer

A fork of the popular open-source contract for web designers and developers by Stuff & Nonsense, reworded for developers


Between us [company name] and you [customer name]

@scribu
scribu / package-setup.sh
Created December 24, 2013 01:05
Set up the package index for WP-CLI
#!/usr/bin/env bash
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR=$HOME/.wp-cli
fi
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
if [ ! -x composer.phar ]; then
@davatron5000
davatron5000 / Sublime Text Setup.md
Last active April 15, 2023 15:39
A new user's guide to SublimeText 2. Estimated reading time: 2 mins. Estimated workthrough time: 12 minutes.

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public