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 / state.ts
Last active May 25, 2022 20:11
Issue with Duplicate State
//problem is from the useReducer making two changes to say.
const newState = JSON.parse(JSON.stringify(state)) as AppState
newState.lists[targetLaneIndex].tasks.push({
id: uuidv4(),
text: action.payload.text
})
return newState
@adeleke5140
adeleke5140 / .deps...npm...hardhat...console.sol
Created May 30, 2022 16:18
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >= 0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _sendLogPayload(bytes memory payload) private view {
uint256 payloadLength = payload.length;
address consoleAddress = CONSOLE_ADDRESS;
assembly {
@adeleke5140
adeleke5140 / hide.css
Created May 31, 2022 21:11
Visually hide any element accessibly
.sr-only{
clip: rect(0 0 0 0);
clip-path: inset(100%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
@adeleke5140
adeleke5140 / a11y.css
Created June 1, 2022 00:10
Accessibly hiding interactive elements
.element{
position: absolute;
opacity: 0;
width:;
height:;
top:;
left:
}
@adeleke5140
adeleke5140 / checkbox.jsx
Created June 1, 2022 07:59
Work with Multiple checkboxes in React
import { useState } from "react";
import { toppings } from "./utils/toppings";
import "./styles.css";
const getFormattedPrice = (price) => `$${price.toFixed(2)}`;
export default function App() {
const [checkedState, setCheckedState] = useState(
new Array(toppings.length).fill(false)
);
@adeleke5140
adeleke5140 / index.html
Created June 4, 2022 21:29
FreeCodeCamp Landing page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>freeCodeCamp</title>
<style>
@adeleke5140
adeleke5140 / package.json
Last active June 22, 2022 03:16
Starting both client and server
{
"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",
@adeleke5140
adeleke5140 / terminate.sh
Last active July 1, 2022 20:52
Resolve NodeJS / Express: EADDRINUSE, Address already in use
#get process ID
sudo lsof -i :port
#where port is the port you want to kill
#kill process ID
kill -9 PID
@adeleke5140
adeleke5140 / form.jsx
Created August 22, 2022 05:50
Easy way to get Form values in React
//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 / reverseString.js
Created September 16, 2022 13:30
Reverse a string recursively
function reverseString(input){
if(input == ""){
return ''
}
return reverseString(input.substring(1)) + input.charAt(0)
}
reverseString("Kehinde")