Skip to content

Instantly share code, notes, and snippets.

View jongan69's full-sized avatar
🎯
WEB3D

Jongan69 jongan69

🎯
WEB3D
View GitHub Profile
@jongan69
jongan69 / Blink.js
Last active January 30, 2023 05:57
GPIO Node interfacing
@jongan69
jongan69 / Readme.md
Last active January 30, 2023 05:27
React Form

Form

This is a simple form component created using React. It is used to collect data from the user and submit it to the server.

Features

This component has the following features:

@jongan69
jongan69 / Readme.md
Last active January 30, 2023 05:01
A Custom React Hook using Ref Pattern

useTimeout

A custom React Hook that allows you to call a callback after a specified delay.

Usage

import { useTimeout } from './useTimeout';

const callback = () => {
@jongan69
jongan69 / Readme.md
Created January 30, 2023 05:22
A smart contract for managing todo tasks

TaskContract

A smart contract for a Todo App on the Ethereum blockchain.

Overview

TaskContract is a smart contract for a Todo App on the Ethereum blockchain. It allows users to add tasks and delete tasks. It also allows users to view their own tasks.

Functions

TaskContract has the following functions:

  • addTask(string memory taskText, bool isDeleted) - adds a new task to the contract.
@jongan69
jongan69 / CheckboxWithLabel-test.js
Last active January 30, 2023 19:19
An example Jest Test for Checkbox With Label
import {cleanup, fireEvent, render} from '@testing-library/react';
import CheckboxWithLabel from '../CheckboxWithLabel';
// Note: running cleanup afterEach is done automatically for you in @testing-library/[email protected] or higher
// unmount and cleanup DOM after the test is finished.
afterEach(cleanup);
it('CheckboxWithLabel changes the text after click', () => {
const {queryByLabelText, getByLabelText} = render(
<CheckboxWithLabel labelOn="On" labelOff="Off" />,
@jongan69
jongan69 / MyNFTMinter.sol
Created February 1, 2023 05:34
An Nft Minting Smart Contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./IContent.sol";
@jongan69
jongan69 / [email protected]@4.8.1...access...Ownable.sol
Created February 1, 2023 06:26
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.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
@jongan69
jongan69 / Readme.md
Created February 1, 2023 23:07
Returns if true a month ends mid week and false if not

Split Weeks

This code finds split weeks for a given year.

Usage

To use the code, define year as the year to find split weeks for. Then call the getMonthlyDates and isSplitWeek functions.

let year = new Date().getFullYear()

CheckBox

Checkbox is a React component used to allow users to select or deselect an option.

Usage

To use the CheckBox component, import it into your React component:

import CheckBox from 'react-checkbox';
@jongan69
jongan69 / dynamicHandleSubmit.js
Created February 6, 2023 23:10
A dynamic form post function
const handleSubmit = async e => {
e.preventDefault();
// @TODO - handle validation
// ...
// @TODO - handle submit based on operation
switch (operation) {
case 'add':
console.log(dataType, state);