Skip to content

Instantly share code, notes, and snippets.

View prmichaelsen's full-sized avatar
🌚

Patrick Michaelsen prmichaelsen

🌚
  • Phoenix
  • 06:33 (UTC -06:00)
View GitHub Profile
@prmichaelsen
prmichaelsen / _app.tsx
Created October 5, 2023 04:38
Minimal example of passing hotkey strokes between VSCode and an internal webview
// Within SPA webapp
import { useEffect } from 'react';
export default function() {
useEffect(() => {
window.addEventListener('keydown', (event) => {
if ((event.ctrlKey || event.metaKey) && event.code === "KeyC") {
document.execCommand("copy");
} else if ((event.ctrlKey || event.metaKey) && event.code === "KeyX") {
document.execCommand("cut");
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/[email protected] /Users/patrick/workplace/parm-v1.0.0
├─┬ @angular/[email protected]
│ ├─┬ @angular/[email protected]
│ │ ├── @angular/[email protected] deduped
│ │ ├── [email protected] deduped
│ │ └── [email protected] deduped
│ ├─┬ @angular/[email protected]
│ │ ├── [email protected] deduped
│ │ ├── [email protected] deduped
│ │ └─┬ [email protected]
@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"