Skip to content

Instantly share code, notes, and snippets.

View jongan69's full-sized avatar
🥀

Jonathan Gan jongan69

🥀
View GitHub Profile
@jongan69
jongan69 / removeYouTubeTranscriptTimestamp.js
Created November 23, 2022 19:02
Console Script for Removing YouTube Video Transcript Timestamps
javascript:document.querySelectorAll('div.segment-start-offset').forEach(r => r.remove())
@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 / 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/react@9.0.0 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 / 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()
@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);
@jongan69
jongan69 / Readme.md
Last active November 10, 2023 07:10
usePagination Hook

React usePagination Hook

This hook returns a pagination range based on the current page, total number of items, and page size.

Usage

Import the usePagination hook in your React component as follows:

import { usePagination } from './usePagination';
@jongan69
jongan69 / Css_In_Consolelog.js
Created November 29, 2023 22:25
CSS in Console Log
console.log("%c sylish ash ","color: red; background-color: lightblue; border: solid");
@jongan69
jongan69 / Readme.md
Last active November 26, 2025 07:19
Option Premium Calculator This Python script calculates the total option premiums for a given set of stock options using the Black-Scholes option pricing model. The Black-Scholes model is widely used for estimating the theoretical price of European-style options.

Option Premium Calculator

A Python script using Black-Scholes model to calculate total option premiums for given stock options. Customize with your data and parameters.

Components: Black-Scholes Formula: The calculate_option_premium function implements the Black-Scholes formula, taking into account the current stock price (S), option strike price (K), time to expiration (T), risk-free interest rate (r), and volatility of the underlying asset (sigma). It supports both call and put options.

Black-Scholes Formula

The Black-Scholes formula is a mathematical model used for calculating the theoretical price of European-style options. The formula for the call option is given by: