Skip to content

Instantly share code, notes, and snippets.

View Anderson-Juhasc's full-sized avatar
:octocat:
Looking for work

Anderson Juhasc Anderson-Juhasc

:octocat:
Looking for work
View GitHub Profile
@cmdruid
cmdruid / filter.ts
Last active October 10, 2024 13:04
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
@fernandoporazzi
fernandoporazzi / recursos-nostr-em-portugues.md
Last active May 5, 2025 17:51
Recursos Nostr em Português

TL;DR: nostr1 é um protocolo que tem o poder de substituir ferramentas como Twitter, Telegram e etc.


O que é nostr?

Nostr é algo novo e confuso, mas ao mesmo tempo é algo muito legal. Nostr é o protocolo aberto mais simples que é capaz de criar uma rede social global que é resistente a censuras de uma vez por todas.

Footnotes

  1. nostr = Notes and Other Stuff Transmitted by Relays

@imksoo
imksoo / nostr_history.js
Last active September 5, 2024 14:52
Nostrのリレーから過去ログをあさってくるnode.js
const relay = 'wss://relay-jp.nostr.wirednet.jp'
const authors = ['634bd19e5c87db216555c814bf88e66ace175805291a6be90b15ac3b2247da9b']
function history (until = Math.floor(new Date() / 1000)) {
let socket
if (typeof (WebSocket) === 'undefined') {
const WebSocket = require('websocket').w3cwebsocket
socket = new WebSocket(relay)
} else {
socket = new WebSocket(relay)
@imksoo
imksoo / copyNostrNotes.js
Created February 27, 2023 06:03
Script to duplicate past events(kind1) between relay servers
const srcRelay = 'wss://relay.snort.social'
const dstRelay = 'wss://relay-jp.nostr.wirednet.jp'
const authors = ['634bd19e5c87db216555c814bf88e66ace175805291a6be90b15ac3b2247da9b']
let srcSocket
let dstSocket
if (typeof (WebSocket) === 'undefined') {
const WebSocket = require('websocket').w3cwebsocket
srcSocket = new WebSocket(srcRelay)
dstSocket = new WebSocket(dstRelay)
@braydonf
braydonf / nostr-amethyst-top-feed-sketch.js
Last active September 5, 2024 15:05
Nostr Amethyst Top Feed Sketch
'use strict';
const assert = require('assert');
const window_of_time_ms = 86400000 * 4; // 96 hours
class Note {
constructor(event) {
this.event = event;
this.weight = {
@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',
@melvincarvalho
melvincarvalho / phone.js
Last active September 5, 2024 14:54
phone.js
#!/usr/bin/env node
import fastify from 'fastify'
import fastifyWebsocket from '@fastify/websocket'
import { validateEvent, verifySignature } from 'nostr-tools'
const port = process.argv[2] || 3000
const events = []
const subscribers = new Map()
@tegila
tegila / nostr.noble.js
Last active September 5, 2024 15:06
Awesome work from @fiatjaf and @paulmillr resulting in total integration between #nostr and #bitcoin
const log = console.log;
import { hex } from '@scure/base';
import * as btc from '@scure/btc-signer';
import { secp256k1, schnorr as secp256k1_schnorr } from '@noble/curves/secp256k1';
import { bech32 } from '@scure/base';
const privKey = secp256k1.utils.randomPrivateKey();
//const privKey = hex.decode('');
log('privKey', hex.encode(privKey));
@starbackr-dev
starbackr-dev / nip59.js
Created May 29, 2023 19:20
This code demonstrates how clients can implement NIP-59 for secure DMs using a paid relay which requires AUTH (NIP-42)
const {WebSocket} = require('websocket-polyfill');
const {relayInit,nip04,
getEventHash,
getPublicKey,
verifySignature,
signEvent,
nip42,finishEvent,
generatePrivateKey} = require('nostr-tools');
const {WebSocket} = require('websocket-polyfill');
const {relayInit,
getEventHash,
getPublicKey,
verifySignature,
signEvent,
generatePrivateKey} = require('nostr-tools');
const https = require('https');
//********* Constants **********************************************************************