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
@ryogrid
ryogrid / config.js
Last active September 5, 2024 13:56
current bostr config
// Bostr config
module.exports = {
// Server listener [Required]
address: "127.0.0.1",
port: "8080",
// Clusters.
// 0 will make bostr run clusters with available parallelism / CPU cores.
clusters: 1,
@bumi
bumi / nwc-openai.mjs
Created July 14, 2023 12:55
NWC, L402, OpenAI example
import { fetchWithL402 } from "alby-tools";
import { webln } from "alby-js-sdk";
import 'websocket-polyfill';
import * as crypto from 'crypto'; // or 'node:crypto'
globalThis.crypto = crypto;
const nwcURL = process.env.NWC_URL;
async function main() {
const nwc = new webln.NWC({ nostrWalletConnectUrl: nwcURL });
@Memory-of-Snow
Memory-of-Snow / 2_3_alt.js
Last active September 5, 2024 14:53
演習コードの改造案
/**
* テキスト投稿イベント(リプライ)を組み立てる
* @param {string} content 投稿内容
* @param {import("nostr-tools").Event} targetEvent リプライ対象のイベント
*/
const composeReplyPost = (content, targetEvent) => {
/* Q-1: これまで学んだことを思い出しながら、
リプライを表現するイベントを組み立てよう */
const {WebSocket} = require('websocket-polyfill');
const {relayInit,
getEventHash,
getPublicKey,
verifySignature,
signEvent,
generatePrivateKey} = require('nostr-tools');
const https = require('https');
//********* Constants **********************************************************************
@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');
@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));
@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()
@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',
@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 = {