Skip to content

Instantly share code, notes, and snippets.

View simonsmith's full-sized avatar

Simon Smith simonsmith

View GitHub Profile
@belgattitude
belgattitude / ci-yarn-install.md
Last active May 1, 2024 09:31
Composite github action to improve CI time with yarn 3+ / node-modules linker.
@EllyLoel
EllyLoel / reset.css
Last active April 13, 2024 18:14
CSS Reset
/*
Made by Elly Loel - https://ellyloel.com/
With inspiration from:
- Josh W Comeau - https://courses.joshwcomeau.com/css-for-js/treasure-trove/010-global-styles/
- Andy Bell - https://piccalil.li/blog/a-modern-css-reset/
- Adam Argyle - https://unpkg.com/open-props@1.3.16/normalize.min.css / https://codepen.io/argyleink/pen/KKvRORE
Notes:
- `:where()` is used to lower specificity for easy overriding.
*/
@davidmh
davidmh / quickfix-fzf.vim
Last active July 15, 2022 20:00
Filter the quickfix list with fzf
function! s:format_qf_line(line)
let parts = split(a:line, ':')
return { 'filename': parts[0]
\,'lnum': parts[1]
\,'col': parts[2]
\,'text': join(parts[3:], ':')
\ }
endfunction
function! s:qf_to_fzf(key, line) abort
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@drwpow
drwpow / smooth-scrolling.js
Last active October 15, 2023 12:51
Performant, 60FPS smooth scrolling in Vanilla JavaScript using requestAnimationFrame
/**
* @param {number} yPos Pixels from the top of the screen to scroll to
* @param {number} duration Time of animation in milliseconds
*/
const scrollTo = (yPos, duration = 600) => {
const startY = window.scrollY;
const difference = yPos - startY;
const startTime = performance.now();
const step = () => {
@jonnyparris
jonnyparris / prepare-commit-msg.sh
Last active April 10, 2024 20:16 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with the Jira ticket reference from a branch name
#!/bin/bash
# For instance with feature/add_new_feature_HEYT-653
# $ git commit -m"Fixed bug"
# will result with commit "[HEYT-653] Fixed bug"
# Customize which branches should be skipped when prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
@beaucharman
beaucharman / throttle.js
Last active November 12, 2022 15:39
An ES6 implementation of the throttle function. "Throttling enforces a maximum number of times a function can be called over time. As in 'execute this function at most once every 100 milliseconds.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debouncing/)
function throttle(callback, wait, immediate = false) {
let timeout = null
let initialCall = true
return function() {
const callNow = immediate && initialCall
const next = () => {
callback.apply(this, arguments)
timeout = null
}
@jesstelford
jesstelford / event-loop.md
Last active May 10, 2024 01:23
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

// note: I'm using redux-actions in here, so the actions might look a bit different than you are used too
// note: This is not complete but the concepts are
// excerpt from app.js
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import fetch from 'isomorphic-fetch'
// note: you could totally leave out the fetch argument here if you set a default (as I do in my actions)
// I'm right now not absolutely sure how I will handle this in the future (the way it is now it is a bit redundant)
@paulirish
paulirish / what-forces-layout.md
Last active May 9, 2024 07: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