Skip to content

Instantly share code, notes, and snippets.

View prmichaelsen's full-sized avatar
🌚

Patrick Michaelsen prmichaelsen

🌚
  • 19:31 (UTC -06:00)
View GitHub Profile
import { useState, useEffect, useCallback } from 'react';
const getSize = () => {
return {
width: window.innerWidth,
height: window.innerHeight,
};
};
export function useResize() {
function hashString(s) {
let hashValue = 0;
for (let i = 0; i < s.length; i++) {
hashValue = (hashValue * 31 + s.charCodeAt(i)) % 4294967296;
}
let bucket = Math.floor((hashValue / 4294967296) * 8);
return bucket;
}
@font-face {
font-family:Slack-Lato;
font-style:normal;
font-weight:300;
src:local("☺"),url(https://a.slack-edge.com/bv1-10/lato-light-0b50f74.woff2) format("woff2"),url(https://a.slack-edge.com/bv1-10/lato-light-1475c14.woff) format("woff");
unicode-range:u+0000-f8fe,u+f900-ffff;
}
@font-face {
font-family:Slack-Lato;
font-style:normal;
@prmichaelsen/parm@2.0.0 /Users/patrick/workplace/parm-v1.0.0
├─┬ @angular/forms@14.1.2
│ ├─┬ @angular/common@14.1.2
│ │ ├── @angular/core@14.1.2 deduped
│ │ ├── rxjs@7.5.6 deduped
│ │ └── tslib@2.4.0 deduped
│ ├─┬ @angular/core@14.1.2
│ │ ├── rxjs@7.5.6 deduped
│ │ ├── tslib@2.4.0 deduped
│ │ └─┬ zone.js@0.11.8
@prmichaelsen
prmichaelsen / Img.tsx
Last active August 12, 2022 19:21
renders an image element that dynamically updates its bottom margin s.t. it always has a total height that is some multiple of 1.5em
import React, {
useEffect, useRef,
useState, useCallback,
} from 'react';
export function useResize() {
const getSize = () => {
return {
width: window.innerWidth,
height: window.innerHeight
#!/usr/bin/env ts-node
const grades: [number, string][] = [
[96, 'A+'],
[93, 'A' ],
[90, 'A-'],
[86, 'B+'],
[83, 'B '],
[80, 'B-'],
[76, 'C+'],
@prmichaelsen
prmichaelsen / formatLetterGrade.ts
Last active July 4, 2022 07:37
formats letter grades using [threshold, character] pairs
#!/usr/bin/env ts-node
const thresholds = [
90,
80,
70,
60,
0,
];
/**
resources referred when writing this script:
- https://gitlab.com/MPuschi/lotr-skip/-/blob/main/skip.js
- https://codepen.io/wellingguzman/pen/XqYqmG
- https://stackoverflow.com/questions/5235145/changing-source-on-html5-video-tag
*/
// Create Video and Canvas-Element
var canvas = document.createElement("canvas");
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "$id$",
"description": "WidgetGroupConfig_2-15",
"type": "object",
"additionalProperties": false,
"required": [
"widgetGroupId",
"cti",
"configurations"
F
E
Am
Dm

[verse 1]
ive got
F
two cats sleepin around in this