Skip to content

Instantly share code, notes, and snippets.

View t-mart's full-sized avatar

Tim Martin t-mart

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 8, 2024 10:22
Pure ESM package

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.
@robin-a-meade
robin-a-meade / unofficial-bash-strict-mode.md
Last active March 24, 2024 17:21
Unofficial bash strict mode

Unofficial Bash Strict Mode

Sometimes a programming language has a "strict mode" to restrict unsafe constructs. E.g., Perl has use strict, Javascript has "use strict", and Visual Basic has Option Strict. But what about bash? Well, bash doesn't have a strict mode as such, but it does have an unofficial strict mode:

set -euo pipefail

set -e

@joshtynjala
joshtynjala / profiles.json
Created August 8, 2019 15:46
Ayu color schemes for Windows Terminal
{
"schemes" :
[
{
"background" : "#fafafa",
"black" : "#000000",
"blue" : "#3199e1",
"brightBlack" : "#686868",
"brightBlue" : "#399ee6",
"brightCyan" : "#4cbf99",
@js-choi
js-choi / compact-unicode-character-names.md
Last active October 12, 2023 10:56
Compact Unicode character names

Concise Unicode character names in JavaScript

J. S. Choi, 2022

⚠️ Warning: This article is not finished. The code will not yet run without errors.

All programmers must manipulate text; JavaScript programmers are no exception. Text manipulation often refers to specific characters, usually by their code points in hexadecimal – or by embedding the characters directly in source code.

@appeltel
appeltel / pubsub.py
Last active May 5, 2024 09:40
asyncio pubsub example
import asyncio
import random
class Hub():
def __init__(self):
self.subscriptions = set()
def publish(self, message):

Get/set ID3 meta tags using ffmpeg

A quick guide on how to read/write/modify ID3 metadata tags for audio / media files using ffmpeg.

FFmpeg has a free-form command line option that allows the user to specify key-value-pairs for encoding metadata. Let's take a look.

1. Read ID3 metadata

To list all global metadata tags for a media file, just set an input but no output file.

@rezich
rezich / nbajam.json
Created August 22, 2015 20:38
NBA Jam (arcade, v4.0) player stats in JSON form
[
{
"team": "Boston Celtics",
"name": "Xavier McDaniel",
"speed": 5,
"threePoint": 5,
"dunk": 5,
"pass": 1,
"power": 8,
"steal": 3,
@oliver
oliver / dct-demo.py
Created April 14, 2014 20:28
create an animation showing Discrete Cosine Transform and what its frequency levels look like
#!/usr/bin/python
import sys, os
from PIL import Image
import numpy
import scipy.fftpack
sourceImage = sys.argv[1]
image = Image.open(sourceImage)
@ndarville
ndarville / webm.md
Last active September 30, 2023 18:56
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@jacobvosmaer
jacobvosmaer / gist:3187346
Created July 27, 2012 10:35
Open all files with git merge conflicts in Vim

Open all files with git merge conflicts in MacVim

git diff --name-only | uniq | xargs mvim

When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.

Once you're in Vim, you can then switch between the files with :n and :prev, or another favourite: :w | n (save current file and open the next command line-supplied file).

UPDATE: see below for a version that works with real terminal commands.