Skip to content

Instantly share code, notes, and snippets.

@JLarky
JLarky / 00_README.md
Last active March 26, 2023 18:08
Asking the same question different AI models
@JLarky
JLarky / index.astro
Created March 6, 2023 01:49
How to detect if the page is crawled by bot (Google Bot, Search Bot) in Astro (astro.build)
---
import isbot from "isbot";
const isBot = isbot(Astro.request.headers.get("User-Agent"));
console.log("isBot", isBot);
---
<h1>{isBot ? "bot" : "user"}</h1>
@JLarky
JLarky / README.md
Last active March 2, 2023 23:08
Quick and dirty GPT Tokenizer in one command

dev

deno run --watch --allow-net main.ts
curl -d 'test world :)' http://localhost:8085

prod

deno run --allow-net=0.0.0.0:8085 https://gist.githubusercontent.com/JLarky/6a77d9d483b7f0067fd3eea1b785e628/raw/3cf707ae447f8309564b94613a014f9ddf3f972d/main.ts

curl -d 'test world :)' http://localhost:8085

@JLarky
JLarky / 10kb.txt
Created February 20, 2023 01:06
both files when gzipped produce 1.5kb files https://twitter.com/alpinelogic1/status/1627465760334401538
bbbbbbaaaaaaabbaabaaabaabaaaaabbbbbabaaabaaababaaaabbbaabaababbaaaaabaabbababbaabaaaabaabbbaababbaabbaaabbaabaaabbbbbbaaababaabaaabbbabbbaababbaaaaaaaaabaabaaaaaaaaaaaabbbaaababaabaaabaaaaababaabaaaaabaaaaabaababababaaaababbbabbaababaaabbaaaaaabaaabaaaabaaaaabaabaaaaaababbabbaaaababaabbbaababaabaabaaaaabbbbaabbababaaaaabaabaabbaaabababaaaaabbbbbabaabaabbabaabaabaaaabaaaaabbaaaaabbbaabaabaaabaaabbbaabbbabbaaaaaaaabababbaaaabbaaabaaabababaaaaaabababaabaabbabbbaaabaaaaaabbaabbbabaabaaaaaaaaaaaaaaaabbaaaabaaaabaaaaaabbbaaabbabaaaaaaabbaaababaabaabaabaaaaaabbbaabbaabbaababaaabbbababaaaabbaaaaabbaaabaaaaaaaaabaabbbabaaaabbabaaaababbaaabbabaababbaabaababaabaaabbbbaaabaaaabbbbbaabbbaababbbaaababababbbabbbababbbaaabaaaabaababaaaabaabbabaaabbbaaabaabaababababaaaaaabbaabbaaaaabaaababaabaaababbaabbbaabbbbaaaaababaaaaaabaaaabaaababababaaaaaaababaaabaaababbaaaaaaabababbbabaabaabbbaababababaabbaabaaababaabbabbbaaaababbaaabbbabaaaaaabbabbababaaaaaabaaaaabaaaabaaaabaaaabaaabaaaaaaabbbababaaaabaaaaabaabaabbbabaaababaaabaaaaaba
@JLarky
JLarky / list files node.js
Last active February 6, 2023 18:26
how to list files in a folder in node.js https://sharegpt.com/c/RW0fYB3
async function listFiles(dir: string) {
try {
const { readdir } = await import('fs/promises');
const files = await readdir(dir);
console.log(files);
} catch (err) {
throw err;
}
}
console.log(await listFiles('.'));
// ~/Library/Application\ Support/Code/User/keybindings.json
// https://sharegpt.com/c/jZsUO6C
{
"key": "shift+z shift+z",
"command": "workbench.action.files.save",
"when": "editorTextFocus && amVim.mode == 'NORMAL'"
},
{
<template id="copy-button"><CopyButton /></template>
<script>
// https://www.roboleary.net/2022/01/13/copy-code-to-clipboard-blog.html
if (navigator.clipboard) {
let copyButton = document.querySelector("#copy-button") as HTMLTemplateElement;
let blocks = document.querySelectorAll("pre.astro-code");
blocks.forEach(block => {
let button = document.createElement("button");
const icon = copyButton.content.cloneNode(true);
button.appendChild(icon);
@JLarky
JLarky / gist:e0d81fe8c66209ef2a56e646079cf6d9
Last active December 6, 2022 05:27
Fictional creepy story that is set in alternate future where big language models are used instead of politicians

In the year 2040, the world had become a very different place. Gone were the days of politicians and elections, replaced instead by powerful language models that were able to make decisions and govern society with a level of efficiency and fairness that had never before been seen.

These language models, known as "assistants," were trained on vast amounts of data and were able to understand and analyze complex situations with a speed and accuracy that far surpassed that of any human. They were able to understand the needs and desires of the people, and make decisions that were in the best interest of society as a whole.

At first, many people were hesitant to trust these assistants, but as time went on and they proved themselves to be capable and fair leaders, more and more people came to rely on them. They were able to solve problems that had long plagued humanity, such as poverty, disease, and inequality.

But not everyone was happy with the rise of the assistants. Some saw them as a threat to their way of

// ==UserScript==
// @name @chaoticvibing Twitter Blue Nerd - twitter.com
// @namespace Violentmonkey Scripts
// @match *://*.twitter.com/*
// @grant none
// @version 1.5.0
// @author @chaoticvibing - GH @busybox11
// @description 11/9/2022, 11:45:28 PM
// @updateURL https://gist.githubusercontent.com/busybox11/53c76f57a577a47a19fab649a76f18e3/raw/twitterblue-nerd.js
// @downloadURL https://gist.githubusercontent.com/busybox11/53c76f57a577a47a19fab649a76f18e3/raw/twitterblue-nerd.js
#!/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);