Skip to content

Instantly share code, notes, and snippets.

🙃
localhost:3000

Haikel Fazzani haikelfazzani

🙃
localhost:3000
Block or report user

Report or block haikelfazzani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View animations.css
/* fadeIn */
@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0);
}
to {
opacity: 1;
transform: scale(1);
View regexp.js
function getItemName(filename) {
return filename.match(/[^\\.]+(?=\.)/gi)[0]
}
console.log(getItemName('\hello\world.zip')) // world
View useFetch.js
// version : async await
import React from 'react';
const useFetch = (url, options) => {
const [response, setResponse] = React.useState(null);
const [error, setError] = React.useState(null);
const [isLoading, setIsLoading] = React.useState(true);
React.useEffect(() => {
View groupby.js
var months = [
"jan", "fév", "mars", "avril", "mai", "juin", "juil", "août", "sep", "oct", "nov", "déc"
]
var data = [
{ user: 'kim', createdAt: '2019-10-01' },
{ user: 'haikel', createdAt: '2019-11-01' },
{ user: 'james', createdAt: '2019-11-01' },
{ user: 'mike', createdAt: '2019-10-01' },
{ user: 'joe', createdAt: '2019-09-01' },
@haikelfazzani
haikelfazzani / integerToRoman.js
Last active Sep 12, 2019
Convert a number into a Roman Numeral
View integerToRoman.js
function integerToRoman(num) {
let o = {
M: 1000, CM: 900, D: 500, CD: 400,
C: 100, XC: 90, L: 50, XL: 40,
X: 10, IX: 9, V: 5, IV: 4, I: 1
}
let result = ''
Object.keys(o).map(i => {
while (num >= o[i]) {
result += i;
@haikelfazzani
haikelfazzani / commands
Last active Dec 23, 2019
some windows commands (terminal) - rm, get get wifi password
View commands
-- your-WiFi-name
Netsh WLAN show interfaces
-- wifi password
netsh wlan show profile your-WiFi-name key=clear
-- remove folder
if exist folderName ( rmdir /s/q folderName )
or
rd /S nonemptydir
@haikelfazzani
haikelfazzani / array-map.js
Last active Apr 21, 2020
javascript array map method for old browser
View array-map.js
function map(a, cb) {
var res = [];
for (var i = 0, l = a.length; i < l; i++) {
res.push(cb(a[i], i, a));
}
return res;
};
// Example :
@haikelfazzani
haikelfazzani / uniq.js
Created Aug 30, 2019
remove duplicates
View uniq.js
let c = ['1','2','1','3', 4, 5, 1];
function uniq(a) {
return a.filter((v, i) => a.indexOf(v) === i);
}
uniq(c);
// [ '1', '2', '3', 4, 5, 1 ]
View flat-array.js
// flat single level array
arr1.reduce((acc, val) => acc.concat(val), []);
// deep level flatten
function flatDeep(arr1) {
return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(flatDeep(val)) : acc.concat(val), []);
};
//recursive flatten deep
function flatten(array) {
View code-challenges.js
/*
reverse the string but without the index of the numbers.
Example: "he2llo" - "ol2leh"
Example: "De5ary4ou" - "uo5yra4eD"
Example: "D23amn5Boy" - "y23oBn5maD"
*/
reverseNoNumbers = (a) => (
v = a.match(/\D/g),
You can’t perform that action at this time.