This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) { | |
if (argc <= 1) { | |
printf("Usage: %s [+/-shift]\n", argv[0]); | |
return 1; | |
} | |
char* shift_str = argv[1]; | |
int sign = 1; | |
if (shift_str[0] == '-') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://til.simonwillison.net/llms/python-react-pattern | |
import * as proc from "node:child_process"; | |
import * as https from "node:https"; | |
import * as readline from "node:readline"; | |
import * as url from "node:url"; | |
import { Configuration, OpenAIApi } from "openai"; | |
async function main() { | |
const bot = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vec | |
#define vec_free(a) ((a) ? free(vec__raw(a)),0 : 0) | |
#define vec_push(a,v) (vec__maybegrow(a,1), (a)[vec__n(a)++] = (v)) | |
#define vec_count(a) ((a) ? vec__n(a) : 0) | |
#define vec_add(a,n) (vec__maybegrow(a,n), vec__n(a)+=(n), &(a)[vec__n(a)-(n)]) | |
#define vec_last(a) ((a)[vec__n(a)-1]) | |
#include <stdlib.h> | |
#define vec__raw(a) ((int *) (a) - 2) | |
#define vec__m(a) vec__raw(a)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mod = require('module'); | |
const os = require('os'); | |
const colors = { | |
red: '\033[0;31m', | |
none: '\033[0m', | |
}; | |
const logErr = (msg) => process.stderr.write(`${colors.red}ERROR: ${msg}${os.EOL}${colors.none}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { default: HasteMap } = require("jest-haste-map"); | |
class NoCrawlHasteMap extends HasteMap { | |
// https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/index.ts#L754-L798 | |
// usually calls out to a fn that runs `find` in the current directory, which is *incredibly* | |
// slow if you have a lot of files | |
async _crawl() { | |
return { | |
hasteMap: this._createEmptyMap(), | |
removedFiles: [], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
rm -rf out | |
mkdir out | |
cat >"index.js" <<EOF | |
console.log("hello from nodejs!"); | |
EOF | |
zip -q out/archive.zip index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fd '**/package.json' | node count_versions_in_monorepo.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DirectedGraph<T> { | |
readonly edges: Map<T, Set<T>> = new Map(); | |
addAll(from: T, ...to: T[]) { | |
let dependencies = this.edges.get(from); | |
if (dependencies == null) { | |
dependencies = new Set(); | |
this.edges.set(from, dependencies); | |
} | |
Sets.addAll(dependencies, to); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -e | |
emoji=( | |
"+1" | |
"-1" | |
"100" | |
"1234" | |
"1st_place_medal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { atomizeCss } from "../"; | |
describe(`${atomizeCss.name}`, () => { | |
it("works with a simple rule", () => { | |
const { newCss, selectorMapping } = atomizeCss(`.class { color: red; }`); | |
expect(newCss).toBe(".a0 { color:red; }"); | |
expect(selectorMapping.get(".class")).toEqual([".a0"]); | |
}); | |
test("de-dupes between rules", () => { |
NewerOlder