Skip to content

Instantly share code, notes, and snippets.

View aleclarson's full-sized avatar

Alec Larson aleclarson

View GitHub Profile
/**
* Taken from https://github.com/scrollback/juri
*
* Use of other URL-safe characters
*
* . Dot in strings
* _ Spaces in strings
*
* - Value: Start of negative number
* In numbers, negative exponent
@aleclarson
aleclarson / rollup-typescript.md
Last active May 6, 2024 19:37
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install

@OliverJAsh
OliverJAsh / foo.md
Last active May 10, 2019 16:18
TypeScript object types
@jakub-g
jakub-g / async-defer-module.md
Last active May 25, 2024 18:23
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@jaytaylor
jaytaylor / ._README.md
Last active March 4, 2024 23:39
URL Encoding in pure bash / sed.
@beginor
beginor / snowflake-id.sql
Last active May 11, 2024 18:48
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@aleclarson
aleclarson / README.md
Last active February 11, 2018 22:56
lula - Lua package manager

lula

Try it:

wget https://gist.githubusercontent.com/aleclarson/759b5600974c6a8073eff2e3eb81699f/raw/lula.sh -O ~/bin/lula
chmod +x ~/bin/lula

package.lua

@Aerijo
Aerijo / making_language_grammar.md
Last active March 18, 2024 05:03
Guide to writing an Atom language grammar

A guide to writing a language grammar (TextMate) in Atom

Tree sitter

  • Atom is transitioning to an entirely new way of defining grammars using tree-sitter. This will be enabled by default quite soon now. It is theoretically faster and more powerful than regex based grammars (the one described in this guide), but requires a steeper learning curve. My understanding is that regex based grammars will still be supported however (at least until version 2), so this guide can still be useful. To enable it yourself, go to Settings -> Core and check Use Tree Sitter Parsers

Links for tree-sitter help:

@ebeigarts
ebeigarts / README.md
Last active September 14, 2017 22:46
Dokku redeploy fix

Rebuild dokku nginx configuration with correct container IP addresses after system reboot until #2736 is released.

sudo curl -L -o /etc/systemd/system/dokku-redeploy-fix.service https://gist.github.com/ebeigarts/e3256021986f625acec62d9add04dfc3/raw/d85afd4e8beba843e273f4c8b7237c375a7eabea/dokku-redeploy-fix.service &&
sudo curl -L -o /usr/bin/dokku-redeploy-fix https://gist.github.com/ebeigarts/e3256021986f625acec62d9add04dfc3/raw/b4b3be7f3fdf51ba4e7716ac8cf04f40b97a762b/dokku-redeploy-fix.sh &&
sudo chmod +x /usr/bin/dokku-redeploy-fix &&
sudo systemctl enable dokku-redeploy-fix
@bsorrentino
bsorrentino / getDPI.js
Last active February 11, 2023 03:25
Get DPI from javascript (live at: https://jsfiddle.net/bsorrentino/s8c51jvt/)
//
// inspired by https://stackoverflow.com/a/838755/521197
//
function getDPI() {
var div = document.createElement( "div");
div.style.height = "1in";
div.style.width = "1in";
div.style.top = "-100%";
div.style.left = "-100%";
div.style.position = "absolute";