Skip to content

Instantly share code, notes, and snippets.

@tawfiknasser
tawfiknasser / list.js
Last active October 16, 2022 16:16
kata solution
function list(names){
const arrayLen = names.length
return names.reduce((previousValue, currentValue, currentIndex)=>{
if(currentIndex === arrayLen-1)
return previousValue+currentValue.name
if(currentIndex === arrayLen-2)
@tawfiknasser
tawfiknasser / HttpMethods.js
Last active August 23, 2022 10:43
http methods
module.exports = {
ACL: 'ACL',
BIND: 'BIND',
CHECKOUT: 'CHECKOUT',
CONNECT: 'CONNECT',
COPY: 'COPY',
DELETE: 'DELETE',
GET: 'GET',
HEAD: 'HEAD',
LINK: 'LINK',
@tawfiknasser
tawfiknasser / statusCodeSelector.js
Last active August 23, 2022 08:54
REST api responses status selector
module.exports = {
Continue: 100,
SwitchingProtocols: 101,
Processing: 102,
EarlyHints: 103,
OK: 200,
Created: 201,
Accepted: 202,
NonAuthoritativeInformation: 203,
NoContent: 204,
@tawfiknasser
tawfiknasser / solution_1.go
Last active August 26, 2022 08:30
Concurrent Merge Sort (Go)
/************
Concurrent Merge Sort
using goroutine and channel only
**************/
package main
import "fmt"
func Merge(left, right [] int) [] int{
merged := make([] int, 0, len(left) + len(right))
@tawfiknasser
tawfiknasser / package.json
Created November 9, 2021 15:38
lint or prettier staged only files
{
"lint" : "eslint ./",
"lint:staged": "eslint $(git diff --cached --name-only | grep -E '\\.(js)$')",
"lint:fix": "eslint . --fix",
"prettier": "prettier --write '**/*.{js,json,md}'",
"prettier:check": "prettier --check '**/*.{js,json,md}'",
"prettier-check:staged": "prettier --check $(git diff --cached --name-only | grep -E '\\.(js|json|md)$')"
}
@tawfiknasser
tawfiknasser / log.js
Last active August 26, 2022 13:10
simple custom log with stack tracer
module.exports = (...args) => {
const stack = Error().stack
let lines = stack.split('\n').slice(2, 3).join('').trim()
const d = new Date();
console.log(formatDate(d), '::App::', ...args, '::', lines)