Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active November 30, 2023 14:41
Pure ESM package
View esm-package.md

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@muffinista
muffinista / loveletters.rb
Created April 4, 2017 17:41
ruby version of LOVELETTERS
View loveletters.rb
#!/usr/bin/env ruby
#
# this code is modified from
#
# https://github.com/gingerbeardman/loveletter
#
# any mistakes are certainly added from me
#
@NeuroWinter
NeuroWinter / ffmpeg cheatsheet for glitching
Last active November 7, 2023 21:42
ffmpeg cheatsheet for glitching
View ffmpeg cheatsheet for glitching
FFMPEG '-i', file, '-c:v', 'libopenjpeg', "jpeg2000\\" + name + ".jp2"\
Convert image to jpeg2000
ffmpeg -i in.png -c:v libopenjpeg out.jp2
Hex Edit out.jp2
ffmpeg -i in.jp2 -c:v png out.png
General Edit
ffmpeg -i input.avi -c:v mpeg2video -g 999 -q:v 1 output.avi
*edit in avidemux/whatever*
@SuperPaintman
SuperPaintman / npm-f3-install.sh
Last active September 5, 2022 18:01
NPM install for low RAM machins. And "npm install ... killed" problem
View npm-f3-install.sh
#!/bin/bash
#
# Author: SuperPaintman <SuperPaintmanDeveloper@gmail.com>
#
###
# Constants
###
RETVAL=0
@mathiasbynens
mathiasbynens / web-platform-status-links.md
Last active June 3, 2023 08:05
Web platform status links
View web-platform-status-links.md
@jackcarter
jackcarter / slack_delete.py
Last active November 29, 2023 07:03
Delete Slack files older than 30 days. Rewrite of https://gist.github.com/jamescmartinez/909401b19c0f779fc9c1
View slack_delete.py
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 30 * 24 * 60 * 60
def list_files():
@paulirish
paulirish / what-forces-layout.md
Last active November 27, 2023 23:54
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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
@tvlooy
tvlooy / unit.sh
Last active October 6, 2023 21:24
Bash test: get the directory of a script
View unit.sh
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@chantastic
chantastic / on-jsx.markdown
Last active November 29, 2023 15:58
JSX, a year in
View on-jsx.markdown

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active November 27, 2023 17:32
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
View ultimate-ut-cheat-sheet.md