Skip to content

Instantly share code, notes, and snippets.

View adeleke5140's full-sized avatar
💭
crafting software

Kenny adeleke5140

💭
crafting software
View GitHub Profile
@adeleke5140
adeleke5140 / palindrome.js
Created September 16, 2022 14:10
Check if a string is a palindrome with recursion
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 / DecimalToBinary.java
Created September 16, 2022 16:37
Convert decimal to Binary recursively
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 / async.js
Created October 11, 2022 01:10
fetching data asynchronously with error catching
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 / spinner.vue
Created October 11, 2022 01:34
Styling for basic spinner
<template>
<div class="spin"></div>
</template>
<style>
.spin{
display: block;
width: 40px;
height: 40px;
@adeleke5140
adeleke5140 / closure.js
Last active October 21, 2022 00:37
Javascript filter method using the closure feature
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 / Form.jsx
Created November 21, 2022 12:21
creating initial formData and updating formData
import { useState } from "react"
const defaultFormData = {
title: "",
body: ""
}
export default function Form() {
const [formData, setFormData] = useState(defaultFormData)
const { title, body } = formData
@adeleke5140
adeleke5140 / component.tsx
Last active December 19, 2022 17:18
Different ways of adding props to react component
interface childProps {
name: string;
}
export const Child = (props: childProps) => <></>
export const ChildWithFC: React.FC<childProps> = (props) => <></>
//Notes:
@adeleke5140
adeleke5140 / custom-plugin.tsx
Created January 6, 2023 13:56
My version of unpkgPathPlugin
import * as esbuild from 'esbuild-wasm'
import axios from 'axios'
export const unpkgPathPlugin = () => {
return {
name: 'unpkg-path-plugin',
setup(build: esbuild.PluginBuild) {
build.onResolve({ filter: /.*/ }, async (args) => {
console.log('onResolve', args)
if(args.path === 'index.js'){
@adeleke5140
adeleke5140 / cons.js
Created January 27, 2023 23:22 — forked from abiodun0/cons.js
For next blog post con cdr car
const cons = (x, y) => (m) => m(x, y)
const car = (z) => z((p, q) => p)
const cdr = (z) => z((p, q) => q)
const someLinkedList = cons(1, cons(2, cons(3 , null)))
// iterating
@adeleke5140
adeleke5140 / useLocalStorage.ts
Created February 7, 2023 13:27
a hook to useLocalStorage in NextJS
import { useState, useEffect } from "react";
const useLocalStorage = (key: string, initialValue: any) => {
const isServer = typeof window === "undefined";
const [value, setValue] = useState(() => {
if (isServer) {
return initialValue;
}