Skip to content

Instantly share code, notes, and snippets.

View adedayojs's full-sized avatar
📖
The word is life

Adedayojs adedayojs

📖
The word is life
View GitHub Profile
#!/bin/bash
# Logout current GitHub credentials and remove global user.name, user.email
echo -e "host=github.com\nprotocol=https\n" | git credential-osxkeychain erase
git config --unset-all --global user.name
git config --unset-all --global user.email
// Email address
^[\\w\\-]+(\\.[\\w\\-]+)*@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$
^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$
^([\w\.*\-*]+@([\w]\.*\-*)+[a-zA-Z]{2,9}(\s*;\s*[\w\.*\-*]+@([\w]\.*\-*)+[a-zA-Z]{2,9})*)$ //List of semi-colon seperated email addresses
^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$
// IP Address
function titleCase(str){
str = str.toLowerCase().split(' ');
let final = [ ];
for(let word of str){
final.push(word.charAt(0).toUpperCase()+ word.slice(1));
}
text.replace(/[^a-zA-Z0-9]+/gi, " ");
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
// This function allows you to loop through a certain number of times
// It is similar to the range function in python (if you are familiar with python)
function loopNumbers(number){
for(let i of [].constructor(number)){
// Do your thing
}
// Other function related things
}
Math.min(...array)
// This function allows you to fetch the maximum number in a given array of numbers only
Math.max(...array)
/******--------EXAMPLE-----*******/
// Create your array
const arrayOfNumbers = [1,2,3,4,5,6,7,8,9]
Math.max(...arrayOfNumbers) // Expected Outcome 9
counterReducer = (state, action) => {
switch (action.type) {
case 'INCREASE':
return { ...state, count: state.count + 1 };
case 'DECREASE':
return { ...state, count: state.count - 1 };
default:
return state;
}
};
function addAction(type, payload){
action = {
type:'ADD',
payload
}
return action
}
function removeAction(type, payload){
action = {
type:'REMOVE',