Skip to content

Instantly share code, notes, and snippets.

View KennethMurugu's full-sized avatar
🎯
Focusing

Kenneth Murugu KennethMurugu

🎯
Focusing
View GitHub Profile
@KennethMurugu
KennethMurugu / axios-error.ts
Last active May 5, 2021 07:41
Handling Axios Errors
export function getAxiosErrorMsg(error: any): string {
let msg = ''
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data)
// console.log(error.response.status)
// console.log(error.response.headers)
msg = error.response.data.msg ? error.response.data.msg : error.response.statusText
} else if (error.request) {
@KennethMurugu
KennethMurugu / input.scss
Created March 1, 2021 09:04
Generated by SassMeister.com.
$spacing-sizes: (
0: 0rem,
1: 0.25rem,
2: 0.5rem,
3: 0.75rem,
4: 1rem,
5: 1.25rem,
6: 1.5rem,
7: 1.75rem,
8: 2rem,
@KennethMurugu
KennethMurugu / monkey_banana.pl
Created January 18, 2018 12:23
Prolog solution to monkey-banana problem
%Facts
is_at(monkey, door).
is_at(box, window).
is_at(banana, middle).
hungry(monkey).
%Rules
grasp(monkey, banana):- hungry(monkey), climb(monkey, box), is_at(banana, middle).
climb(monkey, box) :- is_at(monkey, box, middle).
is_at(monkey, box, middle) :- push(monkey, box, middle).
@KennethMurugu
KennethMurugu / easing.js
Created July 25, 2017 10:20 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity