Skip to content

Instantly share code, notes, and snippets.

View i1u5's full-sized avatar
🎯
Focusing

Ilµs i1u5

🎯
Focusing
View GitHub Profile
@i1u5
i1u5 / subsystem.ts
Created August 22, 2022 10:08
A Deno script to change a specified Deno compiled executable's subsystem mode
// Made by Oliver Lenehan, @sunsetkookaburra
// --allow-read --allow-write subsystem.ts [target]
if(!Deno.args[0]) Deno.exit(1);
async function readN(r: Deno.Reader, n: number): Promise<Uint8Array | null> {
const buf = new Uint8Array(n);
let nRead = 0;
// a null value of r.read() will nullish coalesce into NaN and
// polute nRead, causing (nRead < n) to be false and the loop to exit

Keybase proof

I hereby claim:

  • I am doomlerd on github.
  • I am doomlord (https://keybase.io/doomlord) on keybase.
  • I have a public key ASBUvJgqwDRvq5C0a5GCFpZ7yFLC2gwE21kU0AmSB57JLQo

To claim this, I am signing this object:

@i1u5
i1u5 / proportional-image-scaling.js
Last active March 26, 2020 17:14
Vanilla JS function to scale images proportionally using canvas and return a Base64 encoded image
function scaleImage(url, width = 1024, quality = 1.0) {
let img = new Image();
img.onload = function () {
let canvas = document.createElement("canvas"),
context = canvas.getContext("2d");
canvas.width = width;
canvas.height = width * (img.height / img.width);
context.drawImage(img, 0, 0, canvas.width, canvas.height);
return canvas.toDataURL('image/jpeg', quality);
};