Skip to content

Instantly share code, notes, and snippets.

View piboistudios's full-sized avatar
💭
Bothering the kind folks of web.libera.chat/#ircv3

Gabriel Hayes piboistudios

💭
Bothering the kind folks of web.libera.chat/#ircv3
View GitHub Profile
{
"privateKey": "[PRIVATE_KEY]",
"publicKey": "[PUBLIC_KEY]",
"encryptionKey": "[ENCRYPTION_KEY]"
}
@piboistudios
piboistudios / Indicator.js
Created December 17, 2023 18:55
Live Indicator Wrapper for `trading-signals` (requires `deepclone`)
import clone from 'deepclone';
import * as signals from 'trading-signals';
export class Indicator {
constructor(indicator) {
this.values = [];
this.indicator = indicator;
}
update(v) {
this.last = clone(this.indicator);
@piboistudios
piboistudios / merge.js
Last active February 4, 2023 00:22
An object merge algorithm. Doesn't boast performance at all, but will properly merge nested objects and arrays (by concatenation). This only works if the property is the same type on both objects, otherwise the second object's property will be taken and used to overwrite the target property in the merged object.
module.exports = function merge(a, b) {
return (Object.entries(a).map(e => ({
entries: e,
src: a,
other: b
})).concat(Object.entries(b).map(e => ({
entries: e,
src: b,
other: a
}))
@piboistudios
piboistudios / Lesson.MD
Last active March 14, 2022 16:45
ES6 Promises

ES6 Promises in a nutshell

Whenever you see someFunction(...).then(...)

(And may be followed with .catch(...) To handle errors)

That means:

  • someFunction returns a Promise
  • then(...) handles the promise once it is fulfilled (or resolved)
  • catch(...) handles the error (if one occurs during the promise) (e.g. when it is rejected)
@piboistudios
piboistudios / GunChain.MD
Last active January 14, 2022 00:29
GunChain

GunChain

This is a working draft of a proposal for a Block Chain based on the principles of Freeism.

Overview

The network is effectively a "public Cloud" where users own all of the data and services.

Basically, there must be an autonomously run cluster of services (like a Kubernetes one).

@piboistudios
piboistudios / copy-directory-to.js
Created July 25, 2019 17:09
Recursively Copy a Directory to another location
/**
* Moves files from one location to another, recursively traverses subdirectories.
* example usage: move-dir ./a ./b
*/
const fs = require('fs');
const fromDir = process.argv[2];
const bluebird = require('bluebird');
const chalk = require('chalk');
const toDir = process.argv[3];
console.log({ fromDir, toDir });
@piboistudios
piboistudios / App.hx
Last active May 2, 2019 21:39
Attempted CsContainer (sort of builds, c# compilation fails)
package;
import tink.http.containers.*;
import tink.http.Response;
import tink.web.routing.*;
class App {
static function main() {
var container = new tink.http.CsContainer(8080);
var router = new Router<Root>(new Root());
container.run(function(req) {
@piboistudios
piboistudios / BuildURL.js
Last active December 11, 2018 22:04
[ES6] This snippet of code prevents Axios from spamming a failing API endpoint
'use strict';
var utils = require('axios/lib/utils');
function encode(val) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
@piboistudios
piboistudios / ViewDataMixin.js
Last active December 9, 2018 09:40
ViewData Mixin for Vue.js; requires axios
const axios = require('axios').default;
const AxiosTransformer = (data, headers) => data
const consume = value => {
if (value instanceof Function) {
return value();
}
else return value
}
const propOrOther = (vm, value) => {
const otherName = `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
@piboistudios
piboistudios / shared-objects.rs
Last active July 16, 2018 21:35 — forked from rust-play/playground.rs
Code shared from the Rust Playground
// Author: Gabriel Hayes
use std::cell::RefCell;
use std::rc::{Rc, Weak};
#[derive(Debug)]
struct Node {
val: i64,
children: Vec<Rc<RefCell<Node>>>,
parent: RefCell<Weak<Node>>
}