Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
we can create the future we want

Kenny adeleke5140

💭
we can create the future we want
View GitHub Profile
@adeleke5140
adeleke5140 / Form.jsx
Created Nov 21, 2022
creating initial formData and updating formData
View Form.jsx
import { useState } from "react"
const defaultFormData = {
title: "",
body: ""
}
export default function Form() {
const [formData, setFormData] = useState(defaultFormData)
const { title, body } = formData
@adeleke5140
adeleke5140 / closure.js
Last active Oct 21, 2022
Javascript filter method using the closure feature
View closure.js
let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween(a,b){
return function(num){
return (num >=a && num <= b)
}
}
function inArray(arr){
@adeleke5140
adeleke5140 / spinner.vue
Created Oct 11, 2022
Styling for basic spinner
View spinner.vue
<template>
<div class="spin"></div>
</template>
<style>
.spin{
display: block;
width: 40px;
height: 40px;
@adeleke5140
adeleke5140 / async.js
Created Oct 11, 2022
fetching data asynchronously with error catching
View async.js
const data = [];
const error = null;
const load = async () => {
try{
let response = await fetch('')
if(!data.ok){
throw Error('error message')
}
data = await response.json()
@adeleke5140
adeleke5140 / DecimalToBinary.java
Created Sep 16, 2022
Convert decimal to Binary recursively
View DecimalToBinary.java
public class DecimalToBinary{
public state void main(String[] args){
String binary = findBinary(233, "");
}
public state String findBinary(int decimal, String result){
if(decimal == 0){
return result;
}
@adeleke5140
adeleke5140 / palindrome.js
Created Sep 16, 2022
Check if a string is a palindrome with recursion
View palindrome.js
function isPalindrome(input){
if(input.length == 0 || input.length ==1 ){
return true
}
if(input.charAt(0) == input.charAt(input.length -1 )){
return isPalindrome(input.substring(1, input.length -1)
}
return false;
@adeleke5140
adeleke5140 / reverseString.js
Created Sep 16, 2022
Reverse a string recursively
View reverseString.js
function reverseString(input){
if(input == ""){
return ''
}
return reverseString(input.substring(1)) + input.charAt(0)
}
reverseString("Kehinde")
@adeleke5140
adeleke5140 / form.jsx
Created Aug 22, 2022
Easy way to get Form values in React
View form.jsx
//Given a form,
<form onSubmit={props.submitLaunch}>
<label htmlFor="launch-day">Launch Date</label>
<input type="date" id="launch-day" name="launch-day" min={today} max="2040-12-31" defaultValue={today} />
<label htmlFor="mission-name">Mission Name</label>
<input type="text" id="mission-name" name="mission-name" />
<label htmlFor="rocket-name">Rocket Type</label>
<input type="text" id="rocket-name" name="rocket-name" defaultValue="Explorer IS1" />
<label htmlFor="planets-selector">Destination Exoplanet</label>
@adeleke5140
adeleke5140 / terminate.sh
Last active Jul 1, 2022
Resolve NodeJS / Express: EADDRINUSE, Address already in use
View terminate.sh
#get process ID
sudo lsof -i :port
#where port is the port you want to kill
#kill process ID
kill -9 PID
@adeleke5140
adeleke5140 / package.json
Last active Jun 22, 2022
Starting both client and server
View package.json
{
"name": "name-of-project",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"install-client":"yarn --cwd client install",
"install-server":"yarn --cwd server install",
"server": "yarn --cwd server run watch",
"client": "yarn --cwd client start",