Skip to content

Instantly share code, notes, and snippets.

View wesscoby's full-sized avatar
😎
It does get easier...

Emmanuel Sekyere wesscoby

😎
It does get easier...
View GitHub Profile

// Question 1 const bills = [ {date: '2018-01-20', amount: '220', category: 'Electricity'}, {date: '2018-01-20', amount: '20', category: 'Gas'}, {date: '2018-02-20', amount: '120', category: 'Electricity'} ];

// Answer const getCategoryList = (inputObject) => { let categoryList = [];

@wesscoby
wesscoby / favorite_quotes.json
Created November 14, 2018 08:37
A JSON file of my Favorite Quotes, esepcially, Programming-related
{
"name" : "All time favorite quotes",
"collected_by" : "WessCoby",
"version" : 1.0,
"quotes_database" : [
{
"description": "Popular Quotes",
"type": "single",
"data": [
{
<?php
$people = '{
"data":[{
"first_name":"jake",
"last_name":"bennett",
"age":31,
"email":"[email protected]",
"secret":"VXNlIHRoaXMgc2VjcmV0IHBocmFzZSBzb21ld2hlcmUgaW4geW91ciBjb2RlJ3MgY29tbWVudHM="
},{
"first_name":"jordon",
@wesscoby
wesscoby / stats.js
Last active April 13, 2019 19:48
Codewares Kata
/*
* You are the "computer expert" of a local Athletic Association (C.A.A.). Many teams of runners come to compete.
* Each time, you get a string of all race results of every team who has run.
* For example, here is string showing the individual results of a team of 5 runners: "01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|17"
* Each part of the string is of the form: h|m|s where h,m,s (h for hour, m for minutes, s for seconds) are positive or null integers,
* (represented as strings) with one or two digits. There are no traps in this format.
* To compare the results of the teams you are asked for giving three statistics; range, average and median
*
* Range: difference between the lowest and highest values. In {4, 6, 9, 3, 7}, the lowest value is 3 and highest is 9 so the range is 9 - 3 = 6
*
@wesscoby
wesscoby / stats.php
Last active April 13, 2019 19:47
Codewars Kata
<?php
/*
* You are the "computer expert" of a local Athletic Association (C.A.A.). Many teams of runners come to compete.
* Each time, you get a string of all race results of every team who has run.
* For example, here is string showing the individual results of a team of 5 runners: "01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|17"
* Each part of the string is of the form: h|m|s where h,m,s (h for hour, m for minutes, s for seconds) are positive or null integers,
* (represented as strings) with one or two digits. There are no traps in this format.
* To compare the results of the teams you are asked for giving three statistics; range, average and median
*
* Range: difference between the lowest and highest values. In {4, 6, 9, 3, 7}, the lowest value is 3 and highest is 9 so the range is 9 - 3 = 6
/*
36 | mary | accra | trader
24 | judith | kumasi | banker
22 | kofi | accra | trader
* The string above is formatted as 'AGE | NAME | LOCATION | WORK and separated with the ENTER key
* Given the string above, write a snipet that can delete any of the options above and return the same format of the string
* So, should the snipet delete the location column =, then your output should be:
36 | mary | trader
@wesscoby
wesscoby / categorizeData.js
Created April 13, 2019 19:31
Categorize data(an array of objects) based on a specified category (a property in the data)
/*
* Categorize data based on a specified category (a property in the data)
* @data an array of objects
* @category the criteria for categorizing the @data. @category must be a property in @data
*/
module.exports = (data, category) => {
// Get the category list with which to categorize the data
// getCategoryList is assigned to an iife
let getCategoryList = (() => {
@wesscoby
wesscoby / rename.js
Created April 15, 2019 06:22 — forked from scriptex/rename.js
Rename all files in a folder with NodeJS
const fs = require('fs');
const path = require('path');
const args = process.argv.slice(2);
const dir = args[0];
const match = RegExp(args[1], 'g');
const replace = args[2];
const files = fs.readdirSync(dir);
files
.filter(file => file.match(match))
@wesscoby
wesscoby / csf
Last active May 24, 2019 11:53
Creates a new bash script file in the current working directory. This is meant for #WSL users as it kind of solves the CR [Carriage Return (\r)] and LF [Linefeed (\n)] issue in Windows, since the file will be created in the Linux environment, and not Windows.
#!/bin/bash
# Title : csf
# Date : 17.05.2019
# Author : WessCoby <[email protected]>
# Version : 1.0.0
# Description : Short for 'Create Script File' [A simple bash script creator]
# Creates a new bash script file in the current working directory.
# This kind of solves the CR [Carriage Return (\r)] and LF [Linefeed (\n)] issue in Windows,
# since the file will be created in a Unix environment, and not Windows.
@wesscoby
wesscoby / commit
Last active May 30, 2019 09:12
A simple bash script to aid in staging and committing files. Meant for #WSL and #Linux Users
#!/bin/bash
# Title : commit
# Date : 16.05.2019
# Author : WessCoby <[email protected]>
# Version : 1.0.2
# Description : A simple bash script to aid in staging and committing files to git
# Options : None
### Git Prefix specifying the current working directory