Skip to content

Instantly share code, notes, and snippets.

View ezesundayeze's full-sized avatar
🏠
Working from home

Eze Sunday ezesundayeze

🏠
Working from home
View GitHub Profile
@ezesundayeze
ezesundayeze / MerkleTreeImplementation.js
Created October 17, 2024 13:39
Merkle Tree Implementation.js
const CryptoJS = require('crypto-js');
/**
* Hashes a given input using the SHA-256 algorithm.
*
* @param {string} data - The input data to be hashed.
* @returns {string} - The resulting SHA-256 hash in hexadecimal format.
*/
function hash(data) {
return CryptoJS.SHA256(data).toString(CryptoJS.enc.Hex);
@ezesundayeze
ezesundayeze / mappingstorage.sol
Created October 9, 2024 18:11
Mapping Storage underhood experimnent
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
contract MappingStorageTest {
uint256 a;
uint256 b;
mapping(string => address) private addresses;
constructor() {
a = 20;
@ezesundayeze
ezesundayeze / contracts...noReturnValue.sol
Last active July 24, 2024 10:25
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2 <0.9.0;
import "hardhat/console.sol";
interface IFoo {
// Interface is returning data but the try/catch isn’t looking for it
function f() external view returns (uint256);
}
contract Foo {
@ezesundayeze
ezesundayeze / contracts...theRightKindOfCatch.sol
Created July 16, 2024 03:19
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "hardhat/console.sol";
contract ContractB {
function triggerPanic() external pure returns (uint256 c) {
uint256 a = 1;
uint256 b = 0;
c = a / b; // This will trigger a Panic error (division by zero)
@ezesundayeze
ezesundayeze / contracts...uncatchableTryCatch.sol
Created July 16, 2024 03:05
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract ContractB {
function exampleFunction() external view {
// here
}
}
@ezesundayeze
ezesundayeze / contracts...uncatchableTryCatch.sol
Created July 16, 2024 02:37
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract ContractB {
function outOfBounds(uint256 index) external view {
//
}
}
@ezesundayeze
ezesundayeze / auth_controller.rs
Created May 28, 2024 12:20 — forked from anowell/auth_controller.rs
Axum Auth: jwt token, accepts either Authz bearer or session cookie
use argon2::{Argon2, PasswordHash};
use axum_extra::extract::cookie::{Cookie, SameSite};
use axum_extra::extract::CookieJar;
async fn login_user(
ctx: State<ApiContext>,
Json(data): Json<LoginUser>,
) -> Result<(CookieJar, Json<LoginResponse>)> {
let user = models::user::get_user_pass_hash(&ctx.db, &data.email)
.await?
import schedule from 'node-schedule';
const publishPost = (postId: string, isScheduled: boolean, dateTime: string) => {
if (isScheduled) {
let date = extractDateParam(new Date(dateTime));
const { year, month, hours, minutes, seconds } = date;
@ezesundayeze
ezesundayeze / rustserver.rs
Created September 1, 2023 07:58
A simple Rust based server with no framework
use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
/// Handles an incoming client TCP stream.
///
/// # Arguments
///
/// * `stream` - The TCP stream for the connected client.
///
/// # Panics
[
{
"code": "044",
"bankName": "Access Bank Nigeria Plc"
},
{
"code": "063",
"bankName": "Diamond Bank Plc"
},
{