Skip to content

Instantly share code, notes, and snippets.

View TheoOkafor's full-sized avatar
🎯
Focusing

Theo Okafor TheoOkafor

🎯
Focusing
  • Lagos, Nigeria
View GitHub Profile
@TheoOkafor
TheoOkafor / permutateString.js
Created May 30, 2022 12:59
An algorithm that prints all permutations of a string
/**
* Returns an array of strings, with different positions of char in the string - str
*/
function swapAll(str, char) {
const result = [];
for (let i = 0; i <= str.length; i += 1) {
const newStr = `${str.slice(0, i)}${char}${str.slice(i, str.length)}`;
result.push(newStr);
}
return result;
@TheoOkafor
TheoOkafor / pollingUnitsScraper.js
Created May 6, 2022 10:27
Script for scraping polling units from INEC website
/* eslint-disable no-param-reassign */
/* eslint-disable no-await-in-loop */
/**
*
* @param {string} stateId
* @returns {object}
*/
const getLgas = async (stateId) => {
const formData = new FormData();
@TheoOkafor
TheoOkafor / test.js
Last active January 20, 2021 21:48
test the runtime with and without console.log statement
const testRuntimeWithConsole = () => {
console.time('====== WITH CONSOLE.LOG ====='); // the start time
let result = 0;
for (let i = 0; i < 100; i += 1) {
result += i;
console.log(result); // log the result to the console
}
console.timeEnd('====== WITH CONSOLE.LOG ====='); // the end time
return result;
};
@TheoOkafor
TheoOkafor / test.py
Created January 20, 2021 21:33
Test the runtime with and without print statement
import time
def test_runtime_with_print():
start_time = time.time()
result = 0
for i in range(100):
result = result + i
print(result)
print("======= WITH PRINT =======: {} milliseconds".format((time.time() - start_time) * 1000))
return result
@TheoOkafor
TheoOkafor / Categories.js
Last active July 25, 2020 16:00
Various business categories
[
"Agency and Consultancy",
"Agriculture",
"Aluminium and Metal",
"Artisans",
"Arts and Entertainment",
"Automobile",
"Baking Services",
"Beauty and Salon",
"Books and Stationery",
@TheoOkafor
TheoOkafor / business-categories.js
Created July 8, 2020 08:38
Ranges of Business Categories
const categories = [
"Abattoir and meat selling services",
"Accommodation",
"Accounting / auditing consultancy ",
"Accounting / auditing, taxation and financial management consultancy ",
"Accounting and auditing consultancy",
"Accounting and general goods delivery and merchandise movers",
"Activities auxiliary to financial services and insurance activities",
"Activities of extraterritorial organizations and bodies",
"Activities of head officies;management consultancy activities",
@TheoOkafor
TheoOkafor / mdi-icons.js
Created June 11, 2020 12:31
Material Design Icons Array (Name and Unicode values)
// This data is scraped from https://cdn.materialdesignicons.com/5.3.45/
const mdiIcons = [
{
"unicode": "F01C9",
"name": "mdi-ab-testing"
},
{
"unicode": "F1328",
"name": "mdi-abjad-arabic"
@TheoOkafor
TheoOkafor / mdi-icons.js
Created June 11, 2020 12:30
Material Design Icons Array (Name and Unicode values)
// This data is scraped from https://cdn.materialdesignicons.com/5.3.45/
const mdiIcons = [
{
"unicode": "F01C9",
"name": "mdi-ab-testing"
},
{
"unicode": "F1328",
"name": "mdi-abjad-arabic"
@TheoOkafor
TheoOkafor / fontawesome-icons.js
Created June 11, 2020 09:44 — forked from johnmurch/fontawesome-icons.js
Font Awesome icon Names [Array] - v4.3.0
[
"fa-adjust",
"fa-adn",
"fa-align-center",
"fa-align-justify",
"fa-align-left",
"fa-align-right",
"fa-ambulance",
"fa-anchor",
"fa-android",
@TheoOkafor
TheoOkafor / sitesData.sql
Created March 12, 2020 12:56
A complex SQL query written for codescreen challenge
-- Selects season name, group id and client id
WITH RECURSIVE getSeason(SeasonName, GroupID, SeasonID, ClientID) AS (
SELECT
DISTINCT Seasons.SeasonName,
SeasonClients.GroupID,
SeasonClients.SeasonID,
SeasonClients.ClientID
FROM SeasonClients
INNER JOIN Seasons ON SeasonClients.SeasonID = Seasons.SeasonID
WHERE