Skip to content

Instantly share code, notes, and snippets.

// ---------------------------------------------------------
// Bun.serve
const server = Bun.serve({
port: 0,
fetch: async (req) => {
const url = new URL(req.url);
switch (url.pathname) {
case "/json":
const jsonResponse = {
message: "Hello, World!",
// Timer helper
class Timer {
constructor() {
this.t = process.hrtime.bigint();
}
end() {
return Number((process.hrtime.bigint() - this.t)/BigInt(1000))/1000;
}
};
Characteristics
Node
- Public Key
- Private Key
- Current public address (TCP Address, own if public node, closest public node if restricted node)
- UUID (UUID, constant)
If public port available, same as Private Address, else closest available public node
- Public Address Slots [10]
Slots used for opening tunnels to the closest private nodes
Characteristics
Node
- Public Key
- Private Key
- Current public address (TCP Address, own if public node, closest public node if restricted node)
- UUID (UUID, constant)
If public port available, same as Private Address, else closest available public node
- Public Address Slots [10]
Slots used for opening tunnels to the closest private nodes
Characteristics
Node
- Public Key
- Private Key
- Current public address (TCP Address, own if public node, closest public node if restricted node)
- UUID (UUID, constant)
If public port available, same as Private Address, else closest available public node
- Public Address Slots [10]
Slots used for opening tunnels to the closest private nodes
// Stat the file using uv
uv_fs_t stat_req;
stat_req.data = this;
// Run stat, store result and call ready callback
uv_fs_stat(uv_default_loop(), &stat_req, (const char *)composite.c_str(), [](uv_fs_t* req) {
File* self = static_cast<File*>(req->data);
function relativeToAbsoluteHumidity(celsius,rh) {
var ah = 4.7815706
+0.34597292*celsius
+0.0099365776*Math.pow(celsius,2)
+0.00015612096*Math.pow(celsius,3)
+0.0000019830825*Math.pow(celsius,4)
+0.000000015773396*Math.pow(celsius,5);
return ah * rh / 100;
}
var
deepExtend = require('deep-extend'),
deepmerge = require('deepmerge'),
klon = require('klon'),
jonas = (function () {
const toString = Object.prototype.toString;
function isMergeable (value) {
return value && typeof value === 'object' && toString.call(value) !== '[object Date]' && toString.call(value) !== '[object RegExp]';
}
func TetrominoFactory() Tetromino {
var tt rune = implementedTetrominos[rand.Intn(len(implementedTetrominos))]
switch tt {
case 'I':
return Tetromino{tt, []Sprite{
Sprite{[]Vector{{0, 1}, {1, 1}, {2, 1}, {3, 1}}},
Sprite{[]Vector{{2, 0}, {2, 1}, {2, 2}, {2, 3}}},
Sprite{[]Vector{{0, 2}, {1, 2}, {2, 2}, {3, 2}}},
Sprite{[]Vector{{1, 0}, {1, 1}, {1, 2}, {1, 3}}},
var telnet = require('telnet-client');
var connection = new telnet();
var params = {
host: 'horizons.jpl.nasa.gov',
port: 6775,
shellPrompt: 'Horizons> ',
timeout: 5000
};