Skip to content

Instantly share code, notes, and snippets.

@edwardoboh
edwardoboh / CodeSnippet.md
Last active April 28, 2022 16:15
ZR - BE

DRY

Below are two functions which are both syntactically and semantically correct. The first one violates the famous software development principle, DRY (Don't Repeat Yourself) and the second function fixes it. The programming language used here is Javascript.

function validateObject(exampleObject){ //Violates DRY
    const errorMessages = [];
    if(!exampleObject["color"]){
        errorMessages.push("Error! Please enter a value into the color field");
    }
@edwardoboh
edwardoboh / ZKU - Background Assignment Codes.md
Last active May 3, 2022 12:13
This Gist contains my code answers to HarmonyOne Zero-Knowledge University Background Assignment

Section B

Q1. Simple "Hello World" Smart Contract

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
@edwardoboh
edwardoboh / MySQL Setup.md
Created June 8, 2022 14:40
Gist for setting up MySQL for local development

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@edwardoboh
edwardoboh / laravel_skill_test_answer_by_edwardoboh.md
Last active June 16, 2023 11:43
My answer to the Full-Stack Laravel Developer Skills Test

1. Voting

Schema Image To quickly know the result of a given referendum question, we query the votes table, filtering by the referenda_questions id.

As we never expect to query a single voter's voting record, we convert the user's base data into a hashed value before storing in the database, thereby protecting the base information of the user. The user(voter) information is not normalized in this scenario. For the purpose of authenticity, we still need to preserve a table of voters to ensure that only registered voters can vote. An alternative would be storing the voter_hash directly in the votes table.

2. Rewriting history with git

Conventional Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@edwardoboh
edwardoboh / post-receive.md
Created July 18, 2022 09:10
cPanel Git Post Receive Hook
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
@edwardoboh
edwardoboh / paystackInt.js
Last active July 31, 2022 14:18
How to add Paystack Hooks to a ReactJs Page
import React, { useState } from "react";
import { Redirect } from "react-router-dom";
import { Row, Col, Form, Button, Table, Card } from "react-bootstrap";
import { LoopCircleLoading } from "react-loadingg";
import { usePaystackPayment } from "react-paystack";
import { referralSettlement, sendData } from "../services/httpService";
import { getTransactionDetails, configurePaymentGateway } from "../helpers";
import { getTransactionReferenceCode, isPortedMtnNumber } from "../utils";
@edwardoboh
edwardoboh / test_faker_api.md
Last active June 25, 2023 06:56
Test Faker API for browser and Nodejs

Faker API test

/**
 * 1. Using Fetch API with Browser
 */
function makeApiCalls(){
    return (async () => {
        try{
@edwardoboh
edwardoboh / GitHub Actions + AWS Code Deploy.md
Last active February 19, 2023 13:57
From GitHub Actions through Code Deploy to AWS EC2 - NodeJs Recipe

CI/CD Pipeline Set-up steps

Create IAM Role and Service Role for AWS CodeDeploy

Create a service role with the following access:

  • AmazonEC2RoleForAWSCodeDeploy - IAM Role, grants CodeDeploy access to S3 bucket
  • AWSCodeDeployRole - Service Role, Grants CodeDeploy access to EC2

Confirm Trust Relationships of the created Role matches below

{
@edwardoboh
edwardoboh / Nodejs Typescript Set-up.md
Last active June 23, 2023 14:39
Set-up instruction for using Typescript in a Nodejs project

Typescript Nodejs API Setup

It is recommended to make use of Yarn in place of NPN where possible.

Initialize the project

yarn init -y

Install Typescript globally if not already installed, or install on the project using the -D or --save-dev flag