Skip to content

Instantly share code, notes, and snippets.

View nkpremices's full-sized avatar
🎯
Focusing

Prémices Kamasuwa nkpremices

🎯
Focusing
View GitHub Profile
const isFalsy = value => !value;
const isWhitespaceString = value =>
typeof value === 'string' && /^\s*$/.test(value);
const isEmptyCollection = value =>
(Array.isArray(value) || value === Object(value)) &&
!Object.keys(value).length;
const isInvalidDate = value =>
value instanceof Date && Number.isNaN(value.getTime());
const isEmptySet = value => value instanceof Set && value.size === 0;
const isEmptyMap = value => value instanceof Map && value.size === 0;
@nkpremices
nkpremices / jwt.php
Created January 14, 2022 18:20
Generate you own jwt library with plain PHP. Prerequesites PHP 7.3.5 – 7.4.23
<?php
/*
To generate JWT you need mainly header, payload and secret.
Next you create a signature from the encoded header, the encoded payload, a secret,
the algorithm specified in the header.
The header is a JSON object with the following properties:
{
"alg": "HS256",
"typ": "JWT"
@nkpremices
nkpremices / switch.ts
Last active May 19, 2021 15:57
switch statement with regexp
const getAdminTitle = (locationPathname: string) => {
switch (locationPathname) {
case '/admin':
return 'admin';
case (
locationPathname.match(
'/admin/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/offers',
) || {}
).input:
import pandas as pd
# create dataframe
city_data = pd.read_csv('../../Documents/Udacity/city_data.csv')
global_data = pd.read_csv('../../Documents/Udacity/global_data.csv')
my_city_data = city_data.loc[city_data['city'] == 'Kigali']
paris_data = city_data.loc[city_data['city'] == 'Paris']
# render dataframe as xlsx
@nkpremices
nkpremices / test.js
Created May 28, 2019 13:33
A testing file for the presims micro session
const chai = require('chai');
const chaiHttp = require('chai-http');
const app = require('../index');
chai.use(chaiHttp);
describe('404 and forward to error handler', function () {
it('Should return an object', function(done) {
chai
.request(app)
var foo = function() => {
console.log('Hello world');
};
foo();
babel --plugins transform-es2015-arrow-functions file.js
@nkpremices
nkpremices / arrow.function.js
Last active April 17, 2019 17:43
arrow function example
const foo = () => {
console.log('Hello world');
}
foo();