Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env deno run --allow-net --allow-env --allow-read --allow-write --unstable
import { getToken } from "npm:github-app-installation-token";
const privateKeyPath = prompt(
"Please enter filename of your private key, like `./your.app.private-key.pem`:"
);
console.log("privateKeyPath", privateKeyPath);
const privateKey = await Deno.readTextFile(privateKeyPath);
console.log(privateKey);
javascript:(function(){var a=document.createElement('style'),b;document.head.appendChild(a);b=a.sheet;b.insertRule('*{outline: green solid 1px !important;background: rgb(0 100 0 / 0.1) !important;}',0);})()
@JLarky
JLarky / README.md
Created August 10, 2022 06:08
Make git diff work on binary bun lock files, i.e. bun.lockb

Hi, I hope this finds you well

Here's what I promise you:

image

Here's how to get it:

Set gitattributes somewhere in your repo

@JLarky
JLarky / README.md
Created August 1, 2022 17:29
Ultimate example of solidjs context hook with nice type-safe (TypeScript) wrappers and reduced boilerplate by using `ReturnType`

So here we have an example:

// updating state in React
count === 0; // true

setCount(count + 1);

console.log(count, doubleCount, el.textContent); // 0, 0, 0
@JLarky
JLarky / script.ts
Created June 27, 2022 21:48
Emojis that start with asterisk
/*️⃣ this is a valid JS comment thanks to https://discord.com/channels/722131463138705510/730114401427783713/991082758749192262 */
// $ curl https://unpkg.com/emoji.json@13.1.0/emoji.json > emoji.json
// $ deno run -A --watch script.ts
const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile("emoji.json");
const emojis: any[] = JSON.parse(decoder.decode(data));
emojis.forEach((e) => {
if (e.char.split("")[0] === "*") {
@JLarky
JLarky / .prettierrc.js
Last active February 13, 2024 12:18
Use prettier formatting with Astro (pnpm)
/**
* @type {import('prettier').Options}
*/
module.exports = {
plugins: [require.resolve('prettier-plugin-astro')],
overrides: [
{
files: '**/*.astro',
options: { parser: 'astro' }
@JLarky
JLarky / index.html
Last active June 20, 2022 02:17
how to add error message in case if your CRA (create react app) failed to load the bundle https://twitter.com/JLarky/status/1538707165308801024
<script>
window.onload = function () {
setTimeout(function () {
const rootElement = document.getElementById("root2");
if (rootElement.childElementCount === 0) {
rootElement.innerHTML =
"<h1 class='m-4 fog:text-header2'>Failed to load page.</h1><p class='ml-4'>Please try one more time; if it still doesn't work, email <a class='fog:text-link' href='mailto:support@fogbender.com'>support@fogbender.com</a>.</p>";
console.error("Failed to load page.");
}
}, 3000);
@JLarky
JLarky / isEmail.ts
Created June 17, 2022 04:12
validate email using the same algoritm like browser does for input fields type=email
function isEmail(email: string) {
const el = document.createElement('input');
el.value = email;
el.type = 'email';
return el.validity.valid;
}
import { createNewFogbender } from "fogbender";
import {
FogbenderConfig,
FogbenderFloatingWidget,
FogbenderHeadlessWidget,
FogbenderIsConfigured,
FogbenderProvider,
FogbenderWidget,
} from "fogbender-react";