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 / 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",
@adeleke5140
adeleke5140 / index.html
Created Jun 4, 2022
FreeCodeCamp Landing page
View index.html
<!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 / checkbox.jsx
Created Jun 1, 2022
Work with Multiple checkboxes in React
View checkbox.jsx
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 / a11y.css
Created Jun 1, 2022
Accessibly hiding interactive elements
View a11y.css
.element{
position: absolute;
opacity: 0;
width:;
height:;
top:;
left:
}
@adeleke5140
adeleke5140 / hide.css
Created May 31, 2022
Visually hide any element accessibly
View hide.css
.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 / .deps...npm...hardhat...console.sol
Created May 30, 2022
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=
View .deps...npm...hardhat...console.sol
// 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 / state.ts
Last active May 25, 2022
Issue with Duplicate State
View state.ts
//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 / environmental-variables.md
Created May 12, 2022
Regarding Environmental Variables
View environmental-variables.md

When using Vite to bootstrap a react app, the .env file must be in the same directory as the package.json and not in the src directory.

After that, import it with import.meta.env.VITE_API_KEY

P.S: VITE_API_KEY is the name of the environmental variable you initally created.

@adeleke5140
adeleke5140 / Form.js
Last active May 12, 2022
Submitting a form to a remote server
View Form.js
const myForm = document.getElementById('my-form');
const url = 'http://localhost:8080/';
myForm.addEventListener('submit', async event => {
event.preventDefault();
const formData = new FormData(myForm);
const response = await fetch(url, {
method: 'post',
body: formData
});