Skip to content

Instantly share code, notes, and snippets.

@wyozi
wyozi / .eslintrc.js
Last active August 8, 2024 07:19
Next.js ESLint rule to enforce prefetch={false} for links
const rulesDirPlugin = require("eslint-plugin-rulesdir");
rulesDirPlugin.RULES_DIR = "eslint-rules";
module.exports = {
rules: {
"rulesdir/no-link-prefetch": "error",
}
}
@wyozi
wyozi / inngestEncrypted.ts
Created August 17, 2023 08:39
inngest encrypted step.run return value
import crypto from "crypto";
import { StepOpts } from "inngest/types";
const CRYPTO_KEY = process.env.BACKGROUND_VAR_CRYPTO_KEY;
export type Encrypted<T> = {
iv: string;
ciphertext: string;
};
@wyozi
wyozi / deploy_functions.yml
Created March 21, 2023 08:49
Github action to deploy all serverless functions in a folder
name: Deploy serverless functions
on:
push:
paths:
- "functions/**"
branches:
- "main"
jobs:
list-functions:
runs-on: ubuntu-latest
@wyozi
wyozi / jsonnet.js
Created January 13, 2023 09:52
JSONNet language for codemirror v6
// src https://github.com/google/codemirror-mode-jsonnet
const jsonnet: any = {
token: function (stream, state) {
// Handle special states:
// In a C-style comment
if (state.cComment) {
if (stream.match(/\*\//)) {
state.cComment = false;
return "comment";
@wyozi
wyozi / cloudsqlProxy.ts
Created April 10, 2021 13:46
Setup Google Cloud SQL Proxy sidecar in Pulumi/Kubernetes with tombstone support
import * as pulumi from '@pulumi/pulumi'
import * as gcp from '@pulumi/gcp'
import * as k8s from '@pulumi/kubernetes'
export class CloudSQLAccount {
readonly serviceAccount: gcp.serviceaccount.Account
readonly serviceAccountKey: gcp.serviceaccount.Key
readonly credentialsSecret: k8s.core.v1.Secret
@wyozi
wyozi / TabCountSync.js
Created June 19, 2020 15:28
Same-origin tab count tracker with BroadcastChannel
class TabCountSync {
constructor() {
this.bc = new BroadcastChannel("tabcount-sync");
this.bc.postMessage("opened");
this.bc.onmessage = (ev) => this.onMessage(ev);
this.count = 1;
this.subscriptions = new Set();
}
@wyozi
wyozi / cofetch.lua
Last active June 7, 2020 15:01
Tiny GarrysMod coroutine functions
function cofetch(url, headers)
local co = coroutine.running()
assert(co)
-- ensure we wait at least one tick
timer.Simple(0, function()
http.Fetch(url, function(body, size, headers, code)
coroutine.resume(co, body, size, headers, code)
end, function(err)
coroutine.resume(false, err)
@wyozi
wyozi / bin_repl
Created June 2, 2020 13:27
Phoenix Framework must-haves
# Run REPL
iex -S mix
@wyozi
wyozi / conversion.sh
Created May 5, 2020 03:04
Imagemagick convert: *.png to gif
# Delay of 200ms per frame; remove transparent background and fill with white; loop
convert -delay 20 -alpha remove -background white *.png -loop 0 navmesh_weights.gif
@wyozi
wyozi / a.md
Created October 10, 2016 00:52
Notes on hashcat