Skip to content

Instantly share code, notes, and snippets.

View vishalxl's full-sized avatar
💭
I may be slow to respond.

Vishal vishalxl

💭
I may be slow to respond.
View GitHub Profile
@melvincarvalho
melvincarvalho / nostr-tx-broadcast.js
Created April 27, 2023 08:16
nostr-tx-broadcast.js
const WebSocket = require('ws');
const bitcoin = require('bitcoinjs-lib');
const fetch = require('node-fetch');
const base64 = require('base64-js');
const relays = [
'wss://nostr.wine',
'wss://nos.lol',
'wss://nostr.fmt.wiz.biz',
'wss://nostr.zebedee.cloud',
@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()
@eskema
eskema / nostr-rs-relay_no-docker.md
Last active July 18, 2023 08:42
How to install nostr-rs-relay on ubuntu without Docker

These are the steps I took to install and run a nostr relay on a new server.

First, you'll need the server, this tutorial is using the most basic server Hetzner provides (CX11 - €4.15/mo), you don't need much. If you don't know where to get your server from and decide to go with Hetzner, consider using my affiliate link: https://hetzner.cloud/?ref=4FZql6rUwaeQ

Once you have your server running, log into it via SSH. I'm on a MacOS, so I'll use Terminal as my command line tool. open a new Terminal window and paste the following commands:

@vishalxl
vishalxl / Nostr Through Command Line.md
Last active April 12, 2023 04:07
Nostr commands for Bash Terminal on Linux ( also available on Windows 10 as Ubuntu WSL)

Read Events On Command Line

Print all events:

This would print the latest 100 events:

echo '["REQ", "a", {"limit": 100} ]' | websocat wss://nostr-pub.wellorder.net

Pretty print all events

Blind Diffie-Hellman Key Exchange (blind ecash)

The goal of this protocol is for Bob to get Alice to perform a Diffie-Hellman key exchange blindly, such that when the unblinded value is returned, Alice recognizes it as her own, but can’t distinguish it from others (i.e. similar to a blind signature).

Alice:
A = a*G
return A

Bob:
Y = hash_to_curve(secret_message)
r = random blinding factor
[
"ed1d0e1f743a7d19aa2dfb0162df73bacdbc699f67cc55bb91a98c35f7deac69",
"fd3fdb0d0d8d6f9a7667b53211de8ae3c5246b79bdaf64ebac849d5148b5615f",
"e668a111aa647e63ef587c17fb0e2513d5c2859cd8d389563c7640ffea1fc216",
"1bbb8324577ac089607e45813bac499ebdab4621d029f8c02b2c82b4410fd3f4",
"51535ad9f0e13a810f73ea8829a79b3733bd1fffb767c4885990b02f59103a13",
"2508ed2c2ab3f6728a880fafbc0895a2afeacbb74eb69847255fb60564af0d85",
"3707f1efc7515524dce41d3bf50bfd9fdaed3494620b5f94fcf16d2766da4ec2",
"dbab9040bc1f0c436b0f92f517702498358edc1fde2c7884d0e1036c739d44f3",
"ad5aab5be883a571ea37b231cd996d37522e77d0f121cedfd6787b91d848268e",
@frencojobs
frencojobs / readline.dart
Created March 9, 2021 12:24
Dart read from console line by line asynchronously.
import 'dart:async';
import 'dart:convert';
import 'dart:io' as io;
/// Reads a single line from [stdin] asynchronously.
Future<String> readLine() async {
final c = Completer<String>(); // completer
final l = io.stdin // stdin
.transform(utf8.decoder) // decode
.transform(const LineSplitter()) // split line
@raghav4
raghav4 / Ansicolor.md
Created February 8, 2020 07:17
Color codes for console using Ansi
@proteye
proteye / aes_encryption_helper.dart
Created September 5, 2018 10:54
How to AES-256 (CBC/CFB mode) encrypt and decrypt in Dart/Flutter with Pointy Castle
import 'dart:convert';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "./convert_helper.dart";
// AES key size
const KEY_SIZE = 32; // 32 byte key for AES-256
const ITERATION_COUNT = 1000;
@dsample
dsample / README.md
Last active April 19, 2024 23:16
ASCII art diagrams

ASCI art characters for creating diagrams

Characters:

Single line

  • ASCII code 191 = ┐ ( Box drawing character single line upper right corner )
  • ASCII code 192 = └ ( Box drawing character single line lower left corner )
  • ASCII code 193 = ┴ ( Box drawing character single line horizontal and up )
  • ASCII code 194 = ┬ ( Box drawing character single line horizontal down )