Skip to content

Instantly share code, notes, and snippets.

View iczero's full-sized avatar
🪲
i made bugs

iczero iczero

🪲
i made bugs
View GitHub Profile
@iczero
iczero / mediasite-fetch.js
Last active January 15, 2021 02:28
Script to get information and download mediasite videos
#!/usr/bin/env node
// @ts-check
// $ npm install got path-to-regexp yargs cli-progress
// put value of MediasiteAuth cookie in a file named mediasite-auth-cookie.txt
// in the same directory as this script
const fs = require('fs');
const fsP = fs.promises;
const path = require('path');
const childProcess = require('child_process');
const got = require('got');
@iczero
iczero / dots3.js
Last active April 21, 2021 07:53
stupid unicode things
// @ts-check
const { Transform } = require('stream');
const zlib = require('zlib');
// abuse varwidth fonts by encoding bytes to very thin unicode characters
// for best results run calculateWidths() with different fonts and devices
/* run this on about:blank
let root = document.createElement('div');
document.body.appendChild(root);
@iczero
iczero / oneify.ts
Last active July 5, 2021 09:48
stupid api service
import express from 'express';
import createDebug from 'debug';
import childProcess from 'child_process';
// RANDOM BULLSHIT AS A SERVICE (RBaaS), brought to you by iczero
// IMAGINE BEING THE PERSON THAT WROTE THIS
// i have literally spent more time writing this than thinking about the problem
// Find the shortest path from n to 1 using the operations n = n/2, n = n + 1, n = n - 1.
// n can only be divided by 2 when it is even, and it is always an integer.
@iczero
iczero / sun.rb
Created December 14, 2021 01:40
awefwef
require 'matrix.rb'
def vector_rotation_to_quaternion(v1, v2)
b = v1.dot(v2)
c = v1.cross(v2)
angle = Math.atan2(c.norm(), b)
m = Math.sin(angle / 2)
if c.zero? then
a = c
else
import { formatWithOptions } from 'util';
import winston, { Logform, format, transports } from 'winston';
import chalk, { ChalkInstance } from 'chalk';
import moment from 'moment';
const FORMAT_OPTIONS = {
depth: null,
maxArrayLength: null,
breakLength: 120,
colors: process.stdout.isTTY
// fix encoding (utf-8 misinterpreted as latin1)
derp=(s,...n)=>n.map(v=>v.wholeText?v.data=s(v.data):derp(s,...v.childNodes));derp(s => (new TextDecoder).decode(new Uint8Array(s.split('').map(c => c.charCodeAt(0)))), document.body)
// rewrite entire page to derp
derp=(s,...n)=>n.map(v=>v.wholeText?v.data=s(v.data):derp(s,...v.childNodes));derp(s=>s.replace(/\w+/g,'derp'),document.body)
const formatUSD = n => '$' + n.toFixed(2).replace(/(?<=\b\d+)(?=(?:\d{3})+\b)/g, ',');
@iczero
iczero / api.ts
Last active January 16, 2024 07:34
an approximately terrible idea involving the invocation of git plumbing commands from typescript
import path from 'node:path';
import stream from 'node:stream';
import { git } from './spawn.js';
import { Repository } from './repository.ts';
import { FastifyPluginCallback } from 'fastify';
export const api: FastifyPluginCallback = (fastify, _opts, done) => {
const gitSmartSchema = {
type: 'object',
properties: {
@iczero
iczero / war_crimes.rs
Last active September 10, 2023 07:06
crimes against Rust
#![feature(macro_metavar_expr)]
macro_rules! repeat_2 {
($($what:tt)*) => {
$($what)*
$($what)*
}
}
macro_rules! make_repeat_from {
@iczero
iczero / fizzbuzz.ipynb
Last active September 25, 2023 02:56
fizzbuzz in jax
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.