Skip to content

Instantly share code, notes, and snippets.

View Hoxtygen's full-sized avatar
🎯
Focusing

Wasiu Idowu Hoxtygen

🎯
Focusing
  • Nigeria
View GitHub Profile
@Hoxtygen
Hoxtygen / git-commit-template.md
Created February 22, 2023 20:37 — forked from lisawolderiksen/git-commit-template.md
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

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

@Hoxtygen
Hoxtygen / gist:fa6f761b31e456569660ac970d607489
Created January 28, 2023 06:07 — forked from whisher/gist:c8e0453a5fa76b5d6d952919c77ef0c4
reactjs typescript useForm - a simple custom hook to manage form in react
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 }
) => {
//Basic fibonacci function
function fib(value) {
if (value <= 1) {
return value;
}
return fib(value - 1) + fib(value - 2);
}
// Object literals
let myObjectLiteral = {
variableKey: "variableValue",
functionKey: function (params) {
// magic goes in here
},
};
// module defined with object literal
function Queue() {
let items = [];
this.enqueue = function (element) {
items.push(element);
};
this.dequeue = function () {
items.shift();
};
this.front = function () {
return items[0];
@Hoxtygen
Hoxtygen / mixed-number-converter.js
Created December 27, 2019 09:28 — forked from KimSarabia/mixed-number-converter.js
Simple fraction to mixed number converter
// 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){
@Hoxtygen
Hoxtygen / Diff 2 Arrays
Created April 21, 2017 23:18
FCC Intermediate Algorithm Scripting
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]);
}
@Hoxtygen
Hoxtygen / forismatic
Created December 30, 2016 18:30
how to implement forismatic api
$(document).ready(function() {
var quote;
var author;
function getNewQuote() {
$.ajax({
url: "http://api.forismatic.com/api/1.0/",