Skip to content

Instantly share code, notes, and snippets.

View cmdruid's full-sized avatar
💭
Looking to contribute

cmd cmdruid

💭
Looking to contribute
  • Freelance
  • Austin, TX
  • 02:27 (UTC -06:00)
View GitHub Profile
@cmdruid
cmdruid / filter.ts
Last active January 3, 2024 22:21
Nostr Event Filter Example
/** Basic implementation of NIP 01 filters in typescript. */
interface Event {
id : string
kind : number
created_at : number
pubkey : string
subject ?: string
content : string
sig : string
@cmdruid
cmdruid / transpile.md
Created October 17, 2023 04:35
A quick and simple transpiler for resolving path aliases in typescript.

Here is a nice trick that I would like to share if you are working with typescript and path aliases.

Suppose you have a typescript project, and you are in love with path aliases.

// tsconfig.json
{
  "baseUrl": "./src",
  "paths": {
    "@/*" : [ "./*" ]
  },
@cmdruid
cmdruid / proposal.md
Last active October 12, 2023 01:26
Draft documentation for the Proposal specification

The Proposal

A proposal is the precursor to creating a contract. It defines the terms of the contract and how it should be executed. It is written in a simple JSON format that is easy to read, for humans and machines alike.

Example of a proposal:

{
  title     : 'Basic two-party contract plus moderator.',
  details   : 'n/a',
@cmdruid
cmdruid / chatgpt-links.md
Last active July 29, 2023 20:45
Resources and links following the "Hacking ChatGPT" workshop on April 8th, 2023 at Pleb Lab.
@cmdruid
cmdruid / pedersen.js
Created July 28, 2023 19:24
Pedersen Commitment Example
import { Buff } from '@cmdcode/buff-utils'
import { Field, Point } from '@cmdcode/crypto-utils'
// Suppose a prover P wants to convince a verifier V
// that they know x and r such that: C = g^x * h^r
// First, generate our x and r values.
const x = 'deadbeef'.repeat(4)
const r = 'decafeed'.repeat(4)
@cmdruid
cmdruid / scriptless-tweak.ts
Created February 15, 2023 05:57
scriptless-tweak-example
import { Buff } from '@cmdcode/buff-utils'
import { Hash, Field, Point } from '@cmdcode/crypto-utils'
import HDWallet from '../src/index.js'
const ec = new TextEncoder()
const root = HDWallet.fromBase58('tpubDCMvBvR79bHQMYnYCZJzwD8SRvYf287A5soUXot1ESGSJERdXQ8PsEB4tcAqa3B5nzNHKST9VxaEdAv6MvVNtzKWRwsfMrbdPjtRD4p3maM')
const node = await root.getPath('1/0')
const pub = Buff.buff(node.publicKey.slice(1))
async function taproot_tweak_pubkey(
@cmdruid
cmdruid / script.sh
Last active February 10, 2023 05:34
Setup VNC on remote server
#!/usr/local/env bash
mkdir -p ~/.config/autostart
cat >> ~/.config/autostart/x11vnc.desktop << 'EOF'
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
@cmdruid
cmdruid / asyncPipe.ts
Last active December 30, 2022 00:17
ES6 Asynchronous Pipe Function, in Typescript
// Useful for type-checking your pipe middleware.
export type PipeMethod<T> = (input : T) => Promise<T>
// Return type for the pipe method.
type PipeReturn<T> = (input: T, catcher: Function) => Promise<PipeOutput<T>>
// Object returned by the pipe method.
interface PipeOutput<T> {
errors: unknown[];
output: T
@cmdruid
cmdruid / config.yml
Last active November 23, 2022 21:11
This is my Ruby DNS Updater script. If you are using an .htaccess file to forward a domain or subdomain to your server's dynamic IP address, this script will make sure that .htaccess file stays updated with your server's current address. This script is an alternative to using services like Dynamic DNS or No-IP. This script uses SFTP and the 'net…
# This is my Ruby DNS Updater script. If you are using an .htaccess
# file to forward a domain or subdomain to your server's dynamic IP
# address, this script will make sure that file stays updated with
# your server's current address. This script is an alternative to
# using services like Dynamic DNS.
# This script uses SFTP and the 'net-sftp' gem to connect to your
# hosting via a secure connection. You must add all your relevant
# information below in order for this script to work.
@cmdruid
cmdruid / cloudflare-worker.js
Last active November 13, 2022 14:30
Import a (modified) NostrEmitter into a Cloudlfare Worker
/* Cloudflare Worker Script */
import NostrEmitter from './emitter.js'
const delay = (ms = 1000) => new Promise((r, _) => setTimeout(r, ms))
export default {
async fetch(request) {
let cache
const emitter = new NostrEmitter()