Skip to content

Instantly share code, notes, and snippets.

View oussamahamdaoui's full-sized avatar
🎯
Focusing

Hamdaoui Oussama oussamahamdaoui

🎯
Focusing
View GitHub Profile
@oussamahamdaoui
oussamahamdaoui / whiteSpace.js
Created June 25, 2023 11:39
Short interpreter for the whitespace language in node js
//@ts-check
const { readFileSync } = require('fs');
const { join } = require('path');
const readline = require('readline');
/** @typedef {Exclude<typeof instructions[number]["name"], "NEW_LABEL">} INSTRUCTION_NAME */
/** @typedef {{name:INSTRUCTION_NAME}} INSTRUCTION */
/** @typedef {{value:bigint, type:"NUMBER"}|{type:"LABEL", value:string}} VALUE */
/** @typedef {VALUE|INSTRUCTION} VALUE_OR_INSTRUCTION */
@oussamahamdaoui
oussamahamdaoui / lib.js
Created March 13, 2023 00:59
Parser combinators for data validation Part 1 and 2
/**
* Context
* @typedef {object} Context
* @property {boolean} isError
* @property {string} errorMessage
* @property {number} index
* @property {any} result
* @property {any} srcObj
* @property {string} path
*
@oussamahamdaoui
oussamahamdaoui / initValidator.md
Last active April 5, 2022 17:42
Become validator for cryptozone

Set up a node

1 Get go

sudo apt-get update && sudo apt upgrade -y
sudo snap install --classic go
nano $HOME/.profile

2 Add this to the end of the file

const bech = require('bech32');
const { Tendermint34Client } = require('@cosmjs/tendermint-rpc');
const { setupBankExtension } = require('@cosmjs/stargate');
// create a rpc client to fetch data from a blockchain
const tendermintClient = QueryClient.withExtensions(
(await Tendermint34Client.connect("rpc-url")),
setupBankExtension );
// use this to get the balances
@oussamahamdaoui
oussamahamdaoui / devtools-detect.js
Last active January 29, 2024 10:04
Detect devtools open and close events tested on Chrome and Safari
(function() {
'use strict';
const el = new Image();
let consoleIsOpen = false;
let consoleOpened = false;
Object.defineProperty(el, 'id', {
get: () => {
consoleIsOpen = true;
}
{
"list":[
"localhost:400",
]
}