This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function titleCase(str){ | |
str = str.toLowerCase().split(' '); | |
let final = [ ]; | |
for(let word of str){ | |
final.push(word.charAt(0).toUpperCase()+ word.slice(1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text.replace(/[^a-zA-Z0-9]+/gi, " "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseString(str) { | |
return str.split("").reverse().join(""); | |
} | |
reverseString("hello"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.min(...array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function allows you to sum all the numbers in a given array of numbers only | |
function sumNum(array){ | |
// Check if the argument supplied is an array and not an empty array | |
return Array.isArray(array) && array.length > 0 ? array.reduce((a,b)=> (a + b)) : 'Argument supplied is not an array or an empty array' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}; |
OlderNewer