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 / 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"
},
{
cbnCode bankName
044 Access Bank Nigeria Plc
063 Diamond Bank Plc
050 Ecobank Nigeria
084 Enterprise Bank Plc
070 Fidelity Bank Plc
011 First Bank of Nigeria Plc
214 First City Monument Bank
058 Guaranty Trust Bank Plc
030 Heritaage Banking Company Ltd
@ezesundayeze
ezesundayeze / auto-migrate-sequelize-from-models.md
Created September 23, 2020 14:51 — forked from glennposadas/auto-migrate-sequelize-from-models.md
How to auto generate migrations with Sequelize CLI from Sequelize models?

Reference: https://stackoverflow.com/a/59021807/3231194

It's 2020 and many of these answers no longer apply to the Sequelize v4/v5 ecosystem.

The one good answer says to use sequelize-auto-migrations, but probably is not prescriptive enough to use in your project. So here's a bit more color...

Setup

My team uses a [fork of sequelize-auto-migrations][1] because the original repo is has not been merged a few critical PRs. [#56][2] [#57][3] [#58][4] [#59][5]