Skip to content

Instantly share code, notes, and snippets.

@colinhacks
colinhacks / keybindings.json
Created August 12, 2024 20:25
`goToDefinition` and `navigateBack`
[
{
"key": "cmd+;",
"command": "editor.action.goToDeclaration"
},
{
"key": "shift+cmd+;",
"command": "workbench.action.navigateBack",
"when": "canNavigateBack"
}
@trvswgnr
trvswgnr / fetchJson.test.ts
Last active September 6, 2024 00:00
nice lil typescript fetch wrapper with errors as values
import { describe, it, expect, spyOn } from "bun:test";
import { fetchJson } from "./fetchJson";
class MockResponse {
static instanceCount = 0;
constructor(
public readonly ok: boolean,
private jsonSuccess: boolean | "bad parse",
) {
MockResponse.instanceCount++;
@alexanderson1993
alexanderson1993 / Debug.ts
Created July 17, 2024 23:58
TinyBase PartyKit Client
import { TinyBaseSynchronizedPartyKitServer } from "@/party/TinyBaseSynchronizedPartyKitServer.ts";
import type * as Party from "partykit/server";
export default class Server
extends TinyBaseSynchronizedPartyKitServer
implements Party.Server
{
constructor(readonly room: Party.Room) {
super(room);
}
# GitHub Action that will run prettier on the whole repo and commit the changes to the PR.
name: Prettier
on:
pull_request:
branches: [main]
jobs:
prettier:
runs-on: ubuntu-latest
export function detangle() {
let blocked = false
return callback => (...args) => {
if (blocked) return
blocked = true
callback(...args)
@MariaSolOs
MariaSolOs / builtin-compl.lua
Last active September 19, 2024 21:28
Built-in completion + snippet Neovim setup
---Utility for keymap creation.
---@param lhs string
---@param rhs string|function
---@param opts string|table
---@param mode? string|string[]
local function keymap(lhs, rhs, opts, mode)
opts = type(opts) == 'string' and { desc = opts }
or vim.tbl_extend('error', opts --[[@as table]], { buffer = bufnr })
mode = mode or 'n'
vim.keymap.set(mode, lhs, rhs, opts)
@0xngmi
0xngmi / detect-push0-support.js
Created April 29, 2024 12:09
Detect chains that dont support PUSH0
async function detectPush0Support(rpcs) {
return (await Promise.all(rpcs.map(async rpc => {
try {
const res = await fetch(rpc, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"method": "eth_call",
@fabiospampinato
fabiospampinato / inspect.zsh
Last active April 20, 2024 23:37
Node.js inspect function and plugin for zsh
# INSPECT
function inspect () {
eval NODE_OPTIONS="--inspect-brk" $@
}
# INSPECT PLUGIN
# Toggles the "inspect " prefix upon double ESC key
function plugin-inspect () {
@arshaw
arshaw / temporal-avoid-bigint.js
Created April 6, 2024 00:46
Ways to avoid BigInt while using Temporal
new Temporal.ZonedDateTime(nano, timeZone, calendar)
/* instead: */ Temporal.Instant.fromEpochMilliseconds(milli)
/* */ .toZonedDateTimeISO(timeZone)
/* OR */
/* instead: */ Temporal.Instant.fromEpochMilliseconds(milli)
/* */ .toZonedDateTime({ timeZone, calendar })
zonedDateTime.epochMicroseconds
/* instead: */ zonedDateTime.epochMilliseconds
@hf02
hf02 / DOM3D.user.js
Last active March 29, 2024 03:57 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// ==UserScript==
// @name 3D DOM viewer
// @namespace https://gist.github.com/hf02/2f2fb776ba233fd758af559b9de9e177
// @version 2024-03-27
// @description 3D DOM viewer
// @author OrionReed (forked by hf02)
// @match *://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_registerMenuCommand
// ==/UserScript==