Skip to content

Instantly share code, notes, and snippets.

View 0ex-d's full-sized avatar
💭
Engr. management

Precious 0ex-d

💭
Engr. management
  • Irgendwo, Irgendwohin (100% remote)
View GitHub Profile
@0ex-d
0ex-d / example-route.express.js
Created March 25, 2022 18:48
Quick verbose middleware in Node.js frameworks (Koa & Express)
app.get("/check", middleWare, (_, res) => {
res.send("Hello boi");
});

Keybase proof

I hereby claim:

  • I am mrbaguvix on github.
  • I am mrbaguvix (https://keybase.io/mrbaguvix) on keybase.
  • I have a public key ASCxHA1onX2VamExp7BF2QHF6Aq1vgb9kp96x0PHa2asRgo

To claim this, I am signing this object:

@0ex-d
0ex-d / baguvix.js
Created February 24, 2022 22:01
WIP 🚧 A single daemon in Node.js (using spawn)
const { spawn } = require('child_process');
const fs = require('fs');
const cmdProcesses = {
processDaemon: function(file) {
return new Promise((resolve, reject) => {
const args = [file, 'cron', '-', 'output', '-'];
const childProcess = spawn('baguvix', args);
@0ex-d
0ex-d / vim-commands.md
Created January 31, 2022 04:05
Vim easy command mappings

(Vi)m Commands

By David Akin

Create and open a new file

vim file.txt

Vim Modes:

@0ex-d
0ex-d / format_cryptoAmount.ts
Created December 27, 2021 11:13
Properly handle crypto currency and stable coins value in large decimals
import BigNumber = require('bignumber.js');
/** Format a value in crypto or stablecoin equivalent */
function cryptoFormat(numeric: string | number): number {
try {
const num = typeof numeric === 'string' ? Number(numeric) : numeric;
if (!Number.isNaN(num)) {
throw new TypeError('Amount should be a number');
}
return new BigNumber(num).toNumber();
@0ex-d
0ex-d / beginner_snippets_javascript.js
Last active December 27, 2021 11:20
Simple snippets for beginners in Javascript
// the below are snippets in JavaScript
// they are independent and have been broken
// into smaller functions
// it is likely you'll use them in your code
//
// Remember: no matter how small or big a project maybe
// it still comprises of one or more pieces coming together
// it is just how you use it (LOGIC) to solve a problem.
//
// Arrays & Objects powers the world
describe("Referential Equality", () => {
function foo() {
return 'bar';
}
const otherFoo = function() {
return `bar`;
};
/**
* Quick hack to generate migration template into a file
* @author David
* @param {*} files
* @returns {string} SQL template
*/
const SqlTempGenerator = files => {
if (!Array.isArray(files)) throw "Must be an array of SQL files";
let sqlStr = "INSERT INTO migrations (filename) VALUES";
return sqlStr.concat(" ", files.map(file => `('${file}')`).join(","), ";");
@0ex-d
0ex-d / style.css
Created June 3, 2021 21:02
Add shake effect to material-ui modal
@-webkit-keyframes shake {
0%,
to {
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
10%,
30%,
50%,
70%,
@0ex-d
0ex-d / price-alert-util.ts
Last active January 6, 2021 23:41
Price alert snippet for monitoring market cap on assets exchanges.
/**
* Price alert snippet
* For monitoring market cap on assets exchanges
* Precious Akin
*/
// Available exchange assets
enum ASSET {
'NGN' = '\u20A6', // ₦
'USD' = '$'