Skip to content

Instantly share code, notes, and snippets.

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

Ezeokafor GoodnessEzeokafor

🏠
Working from home
View GitHub Profile
@GoodnessEzeokafor
GoodnessEzeokafor / encrypt.ts
Last active December 8, 2021 10:38
Obj Encryption
const osbEncryption = (str: string | Record<string, any>) => {
console.log("STRING",str)
const reverseString = str.split("").reverse().join("")
console.log("REVERSE STRING", reverseString)
let hmac = crypto.createHash("sha512");
hmac.update(typeof reverseString === 'string' ? reverseString : JSON.stringify(reverseString));
return Buffer.from(hmac.digest()).toString('hex')
}
@GoodnessEzeokafor
GoodnessEzeokafor / transactions.js
Created November 29, 2021 12:20
Mongo-Db-Transactions
/**
* Rules for MONGODB Multi Document Transactions
* All data modeling rules still applies
* Transactions should be the most common operation
* Pass in the session to all statements
* Implement retry logic , transactions can always abort
* Plan for DDL operations
*/
import db, { ClientSession } from 'mongoose';
/**
import math
from functools import reduce
class Calculator:
def __init__(self):
pass
def __str__(self):
return "Basic calculator"
pragma solidity >=0.4.22 <0.9.0;
import './BCShopSeller.sol';
import './BCShopCourier.sol';
contract BCShopBuyer {
address payable sellerAddress;
SellerInterface SellerContract;
CourierInterface CourierContract;
constructor(address payable _sellerAddress, address courierAddress) {
const BCShopCourier = artifacts.require("BCShopCourier");
const BCShopSeller = artifacts.require("BCShopSeller");
const BCShopBuyer = artifacts.require("BCShopSeller");
module.exports = async(deployer) => {
let deployBCShopCourier = await deployer.deploy(BCShopCourier)
.then(async(courier) => {
// console.log(data)
let deployBCShopSeller = await deployer.deploy(BCShopSeller, courier.address)
.then(async(seller) => {
pragma solidity >=0.4.22 <0.9.0;
import './BCShopCourier.sol';
interface SellerInterface{
function addSale(uint256 productID) external;
function buyerReceiveProduct(uint256 saleID)external;
function getProductPrice(uint256 productID) external view returns(uint256 price);
function getSaleStatus(uint256 saleID) external view returns(string memory status);
}
const BCShopCourier = artifacts.require('./BCShopCourier.sol')
require('chai')
.use(require('chai-as-promised'))
.should()
contract('BCShopCourier', ([deployer,account1,account2,account3]) => {
let contract
before(async ()=>{
contract = await BCShopCourier.deployed()
// pragma solidity ^0.5.16;
pragma solidity >=0.4.22 <0.9.0;
/**
NOTE VERSION SPECIFIED SHOULD BE THE SAME SPECIFIED IN truffle-config.js
*/
interface CourierInterface{
function startItemTranpost(string calldata _sku) external;
function getItemStatus(uint256 itemD) external view returns(string memory status);
function getItemLocation(uint256 itemID) external view returns(string memory location);
}

SSH SETUP

  • copy and paste ssh-keygen on your local machine

initial server setup/user setup

  • ssh root@your_server_ip
  • adduser sammy
  • usermod -aG sudo sammy - setup root privileges for the user
  • ufw app list - setup a basic filewall
  • ufw allow OpenSSH - setup a basic filewall
  • ufw enable - setup a basic filewall

SSH SETUP

  • copy and paste ssh-keygen on your local machine

initial server setup/user setup

  • ssh root@your_server_ip
  • adduser sammy
  • usermod -aG sudo sammy - setup root privileges for the user
  • ufw app list - setup a basic filewall
  • ufw allow OpenSSH - setup a basic filewall
  • ufw enable - setup a basic filewall