The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the
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
Credit to | |
https://medium.com/javascript-in-plain-english/react-controlled-forms-with-hooks-538762aab935 | |
import React, { ChangeEvent, FormEvent, useReducer } from "react"; | |
const useForm = (initialState: any) => { | |
const reducer = ( | |
state: typeof initialState, | |
payload: { field: string; value: string } | |
) => { |
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
//Basic fibonacci function | |
function fib(value) { | |
if (value <= 1) { | |
return value; | |
} | |
return fib(value - 1) + fib(value - 2); | |
} | |
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
// Object literals | |
let myObjectLiteral = { | |
variableKey: "variableValue", | |
functionKey: function (params) { | |
// magic goes in here | |
}, | |
}; | |
// module defined with object literal |
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 Queue() { | |
let items = []; | |
this.enqueue = function (element) { | |
items.push(element); | |
}; | |
this.dequeue = function () { | |
items.shift(); | |
}; | |
this.front = function () { | |
return items[0]; |
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
// https://www.codewars.com/kata/simple-fraction-to-mixed-number-converter/ | |
var greatest = (a,b) => (b===0) ? a : greatest(b,a%b) | |
function mixedFraction(s){ | |
arr = s.split('/') | |
dividend = Number(arr[0]) | |
divisor = Number(arr[1]) | |
if(divisor === 0){ | |
throw "ZeroDivisionError"; | |
} else { | |
if(dividend%divisor === 0){ |
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 diffArray(arr1, arr2) { | |
//create a placeholder array that will contain the resultant values | |
var newArray = []; | |
//iterate through arr1 | |
for (var i = 0; i < arr1.length; i++) { | |
//if arr2 doesn't contain items in arr1 | |
if (arr2.indexOf(arr1[i]) === -1) { | |
//save it in newArray | |
newArray.push(arr1[i]); | |
} |
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
$(document).ready(function() { | |
var quote; | |
var author; | |
function getNewQuote() { | |
$.ajax({ | |
url: "http://api.forismatic.com/api/1.0/", |
NewerOlder