Skip to content

Instantly share code, notes, and snippets.

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@geon
geon / async-iterator-server.ts
Created November 30, 2018 08:47
How to build a socket server with async and for-await.
import { createServer, Socket } from "net";
// Promisified socket.write().
const write = (socket: Socket, data: Buffer | string) =>
new Promise((resolve, reject) =>
socket.write(data as Buffer, (error: Error | undefined) => {
if (error) {
reject();
} else {
resolve();
@omardelarosa
omardelarosa / markov-piano.rb
Last active December 29, 2020 08:19
Markov-chain based generative Piano Music for SonicPi
set :root, 60
T = 4.0
# This hash simulates a markov chain.
# Each key is the state and the array
# value represents the next state.
H = {
60 => [58, 58, 58, 55, 60, 60, 60],
58 => [60, 56, 56, 58, 60, 60],
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 26, 2024 01:29
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@jareware
jareware / SCSS.md
Last active April 23, 2024 22:13
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso