Skip to content

Instantly share code, notes, and snippets.

[Unit]
After=network.target
[Service]
ExecStart=/usr/bin/node /home/ubuntu/project/app.js
ExecStop=/bin/kill -s INT $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/project
@LuKks
LuKks / db.json
Created December 9, 2022 22:33 — forked from mafintosh/db.json
{
"since": 7380137,
"addresses": [
"0x8c6b04da932d1151e0e1c65f3d8b12a971e02b17",
"0xd04a779f681014832013a5cc58bfafafa26cbaf5",
"0x439aa60d35338b01e7ce16b98469c26dd8a79b52",
"0x904224d70521a09aC117CD499F6B4A68aBc5B852"
],
"transactions": [
{
const net = require('net')
// Server side
const server = net.createServer({ allowHalfOpen: true }, function (socket) {
console.log('[server side] new connection')
socket.on('data', function (data) {
console.log('[server side] received:', data.toString())
socket.write('server says hey')
const Hypercore = require('hypercore')
const Hyperswarm = require('hyperswarm')
const ram = require('random-access-memory')
const core = new Hypercore(ram, process.argv[2], {
valueEncoding: 'json'
})
main()
@LuKks
LuKks / core-get.js
Last active July 20, 2022 02:56
Lost promise?
const Hypercore = require('hypercore')
const RAM = require('random-access-memory')
const core = new Hypercore(RAM)
// console.log(core)
main().then(() => {
console.log('main ended') // it doesn't reach this line
})
const DHT = require('@hyperswarm/dht')
const keyPairServer = DHT.keyPair()
main()
async function main () {
const node1 = new DHT()
const node2 = new DHT()
await node1.ready()