Skip to content

Instantly share code, notes, and snippets.

View harryWonder's full-sized avatar
🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>

Ilori stephen harryWonder

🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>
View GitHub Profile
const PhotoEntity = require('../entity/photo.entity')
class PhotoDao {
/**
*
* @module Photo
* @description This method creates a new Photo instance and persists it to the database.
*
* @typedef {Object} Photo
const { omit } = require('lodash');
const DataSource = require('./data-source');
const { DataTypes } = require('sequelize');
const photo_log = require('../dao/photo_log.dao');
class PhotoEntity {
/** @type {import('sequelize').Model} */
photoModel = {}
const DbConfig = require('../config');
const Sequelize = require('sequelize');
class DatabaseConfig {
/**
* @type {import('sequelize').Sequelize}
*/
databaseClient = {};
@harryWonder
harryWonder / nigeria-states.js
Created August 19, 2022 22:35
Nigerian States
export default [
"Abia",
"Adamawa",
"Akwa Ibom",
"Anambra",
"Bauchi",
"Bayelsa",
"Benue",
"Borno",
"Cross River",
@harryWonder
harryWonder / partition_labels.js
Created July 22, 2022 02:26
This code snippet helps us to partition a string into several partitions. The total sum of the groups should equal the total length of the string and each of the alphabets in each group should be unique
/**
* Given a string, break the string down in such a way that the total group of the strings equals the total length of the string.
* Each alphabets should be unique in the group as well.
*/
const Alphabets = "abcdefghijklmnopqrstuvwxyz";
/**
* Use recursion to solve
* @param {string} input
@harryWonder
harryWonder / left_rotation.js
Created July 21, 2022 21:51
Left Rotations
function leftRotations(a = [], d = 5) {
const input = a;
const arrayLength = input.length;
const rotation = d;
for (let index = 0; index < arrayLength; index++) {
if ((index + 1) <= rotation) {
let arrayIndex = input.shift();
input.push(arrayIndex);
} else {
@harryWonder
harryWonder / staircase.js
Created June 14, 2022 20:51
The staircase algorithm with javascript.
/**
* Determine the number of stairs to print
* The default stair has to have at least 1 space from the left
* Other stairs should inherit the same syntax except the last one
*
* First thing I had to do was initalize an empty stairs.
* Create a loop based on the stairCaseLength Param.
* Initialize two indexes. (One to handle the loop from 0 - stairCaseLength)(i) and the other to (decrement the stairCaseLength)(j)
* For each case to be printed to the console, I had to use the .repeat method with (j - 1) to print the number of spaces the stairs(#)(i) should have. This would in turn make sure that the last stair to be printed has no spacing.
* The stairs denoted by (#) are also printed out using the repeat method and it takes the (i + 1) as a param.
@harryWonder
harryWonder / trim_strings.js
Created June 14, 2022 20:50
This function takes a string and limits it from the bottom based on the output length.
/**
* This function takes a string and limits it from the bottom based on the output length.
*
* The following strings are invalid as answers "Codility we test code": This is because we need to return coders instead.
* The string output should not be less than the output length as well.
* The string can return an empty string as an answer too,
*
* @param {string} message
* @param {number} outputLength
* @returns {string}
@harryWonder
harryWonder / 2d_diagonal_difference.js
Last active June 12, 2022 19:08
This File Shows My Solution To The 2D Diagonal Difference Algorithm Question (Difficulty: Easy)
function DiagonalDifference(InputArray) {
const Input = InputArray
/**
* Determine the matrix type [3,3] || [4,4]
* Validate the matrix is in the desired order.
* Confirm that all the sub-array has the required length.
* Pick the most common length from the array and remove the sub-arrays that don't match.
*/
@harryWonder
harryWonder / test.js
Created February 7, 2022 14:07
MetaCare Algorithm Test
/**
*
1. Build a function to accept the string as an arguement.
2. Capture the length of the string.
3. Determine that the string length is an even number. This would provide certainty that the brackets are even.
4. Write a loop based on the length of the string but divided.
5. Inside the loop, take the current index of the string and the inverse index of the string based on the loop index.
6. Concat the string and look for a match.
7. Push the results into an array and filter out negative values.
**/