Skip to content

Instantly share code, notes, and snippets.

@heinrich-ulbricht
heinrich-ulbricht / CompressString.js
Created June 11, 2021 13:38
JavaScript: Compressing a string to send via query parameter
// pako finally worked (browser, Teams desktop client, Teams Android client); I tried/checked a lot of libraries but they either produced wrong results, did not compress good or were old or without good docs: shorter, shoco, lzma-js, lzutf8 (did not work in Teams Android client), lz-string
const pako = require('pako');
const {Base64} = require('js-base64');
let stringToCompress = 'test';
let compressedStringBytes = pako.deflate(stringToCompress);
let compressedStringBytesBase64 = Base64.fromUint8Array(compressedStringBytes, true);
// send via query parameter
// -----------------------------
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@tomchristie
tomchristie / proxy.py
Created January 15, 2020 13:06
An ASGI proxy service.
import httpx
from starlette.requests import Request
from starlette.responses import StreamingResponse
class Proxy:
def __init__(self, hostname):
self.hostname = hostname
self.client = httpx.AsyncClient()

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
" .vimrc
" Enable persistent undo
set undofile
" Use a temporary directory to store undo files
set undodir=~/.tmp
@vincentriemer
vincentriemer / iphone-frame-overlay-app.js
Created January 20, 2019 23:52
Video iPhone Frame Overlay Web App Prototype
import React, { Component, useCallback, useState, useRef } from "react";
import "./App.css";
const imgUrl = require("./assets/iPhone-XS-Portrait-Space-Gray.png");
const fullSize = {
width: 1325,
height: 2616
};
@Icelandjack
Icelandjack / Yoneda.markdown
Last active February 10, 2023 00:06
Yoneda
import Data.Functor.Yoneda
import Data.Char
import Data.Kind

infixr 5
  ·

type  List :: (Type -> Type) -> Constraint
class List f where
@yelouafi
yelouafi / algebraic-effects-series-1.md
Last active June 29, 2024 20:05
Operational Introduction to Algebraic Effects and Continuations

Algebraic Effects in JavaScript part 1 - continuations and control transfer

This is the first post of a series about Algebraic Effects and Handlers.

There are 2 ways to approach this topic:

  • Denotational: explain Algebraic Effects in terms of their meaning in mathematics/Category theory
  • Operational: explain the mechanic of Algebraic Effects by showing how they operate under a chosen runtime environment

Both approaches are valuables and give different insights on the topic. However, not everyone (including me), has the prerequisites to grasp the concepts of Category theory and Abstract Algebra. On the other hand, the operational approach is accessible to a much wider audience of programmers even if it doesn't provide the full picture.

@jkusachi
jkusachi / HMR Regex
Last active September 13, 2017 19:47
help filter out noise in chrome dev tools when using hot module reload n stuff
// hide HMR and GET
/^((?!HMR|GET).)*$/
// Hide Warnings
/^((?!warning).)*$/
// Hide all
/^((?!warning|HMR|GET).)*$/
// wrap regex in / / if using Canary
@retrography
retrography / scheme.applescript
Last active August 27, 2018 22:42
Apply a color preset to the current iTerm session from command prompt
#!/usr/bin/osascript
-- Copyright © 2016, Mahmood Shafeie Zargar all rights reserved
-- This program is released under the terms of MIT License
-- Sort routine from http://www.macosxautomation.com/applescript/sbrt/sbrt-05.html
on run argv
try
set argument to item 1 of argv
on error