Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@dgrammatiko
dgrammatiko / analytics.js
Last active May 15, 2022 00:15 — forked from janispritzkau/analytics.js
Minimal Google Analytics script in modern javascript (677 bytes minified)
((document, location, navigator) => {
const domain = location.hostname.split(".")
const match = document.cookie.match(/(^|; ?)_ga=GA1\.\d\.(\d+\.\d+)(;|$)/)
// use existing client id or generate one
const cid = match ? match[2] : ~~(2147483648 * Math.random()) + "." + ~~(Date.now() / 1000)
// set cookie at highest possible domain level
for (let i = domain.length; i--;) {
const cookie = `_ga=GA1.${domain.length - i}.${cid}`
module.exports = function(eleventyConfig) {
eleventyConfig.addFilter('debug', function(...args) {
debugger;
});
}
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays
e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):(
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props

Cheat sheet: classes in JavaScript

Basic members of classes

class OtherClass {}

class MyClass1 extends OtherClass {

  publicInstanceField = 1;
@IanColdwater
IanColdwater / twittermute.txt
Last active April 14, 2025 16:31
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@Baldinof
Baldinof / .dockerignore
Last active February 13, 2024 22:52
Single PHP FPM container with Caddy
/vendor
/docker
/Dockerfile
// Run this on a loaded web page in the browser to log a CSS stylesheet to the console that contains all of the CSS rules that presently apply to the elements visible on the screen. This can be used for 'Critical CSS' generation
// You can use an import statement like this if it's in a <script type=module>
//import {process} from 'https://unpkg.com/cssomtools'
// Or a dynamic import() for copy/pasting into the JS console
import('https://unpkg.com/cssomtools').then(({process, all}) => {
// Log the final output to the console
console.log(
@mortenson
mortenson / index.js
Last active September 11, 2020 09:26
A quick CSS audit script for finding overly long/specific selectors in CSS files
#!/usr/bin/env node
// This is a quick CSS audit script I wrote for finding overly long/specific selectors in CSS files.
// Usage: Download this file, then run:
// $ npx https://gist.github.com/mortenson/628fd527a25efe4fd1a4940e14c31066 <space separated list of CSS files to audit>
const listSelectors = require('list-selectors');
const { calculate, compare } = require('specificity');
// This is useful if you want to anonymize the results to avoid blaming.
@matthewp
matthewp / example-minified.html
Last active January 16, 2020 18:00
SSR web components
<!doctype html>
<html lang="en">
<title>Web component SSR</title>
<script>
customElements.define("shadow-root",class extends HTMLElement{connectedCallback(){let a=this.parentNode,b=a.firstElementChild;this.remove(),a.attachShadow({mode:"open"}).append(b.content.cloneNode(!0))}});
</script>
<a-component>
<template>
<header>