Skip to content

Instantly share code, notes, and snippets.

export const power = (x, y) => {
if (y < 0) {
throw new Error(
'exponent must be greater than or equal to 0 (for the purposes of this example)'
);
}
if (y === 0) {
return 1;
}
export const factorial = (x) => {
if (x < 0) {
throw new Error('x must be greater than or equal to 0');
}
if (x <= 1) {
return 1;
}
return x * factorial(x - 1);
export const factorial = (x) => {
if (x < 0) {
throw new Error('x must be greater than or equal to 0');
}
if (x <= 1) {
return 1;
}
let result = 1;
@thawkin3
thawkin3 / App.js
Created July 14, 2022 03:36
Crowdfunding app UI written in React - Let's buy Twitter!
import React, { useEffect, useState } from 'react';
import Web3 from 'web3';
import Contract from 'web3-eth-contract';
import CoinbaseWalletSDK from '@coinbase/wallet-sdk';
import CrowdfundingContract from './contracts/Crowdfunding.json';
import elon from './elon.jpg';
import './App.css';
const APP_NAME = 'Coinbase Crowdfunding App';
const APP_LOGO_URL = './elon.jpg';
@thawkin3
thawkin3 / Crowdfunding.sol
Created July 14, 2022 03:34
Crowdfunding smart contract written in Solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
/*********************************/
/* Learning Purposes ONLY */
/* DO NOT USE IN PRODUCTION */
/*********************************/
contract Crowdfunding {
uint256 fundGoal = 10 ether;
@thawkin3
thawkin3 / istodaymybirthday2.js
Created July 5, 2022 21:12
Snippet for determining if today is my birthday (date-fns v2.28.0)
const format = require('date-fns/format');
const express = require('express');
const router = express.Router();
router.get('/', function (req, res) {
if (!req.query.birthday) {
return res.json({ data: 'Please provide your birthdate' });
}
@thawkin3
thawkin3 / istodaymybirthday1.js
Last active July 5, 2022 21:13
Snippet for determining if today is my birthday (date-fns v1.30.1)
const format = require('date-fns/format');
const express = require('express');
const router = express.Router();
router.get('/', function (req, res) {
if (!req.query.birthday) {
return res.json({ data: 'Please provide your birthdate' });
}
@thawkin3
thawkin3 / main.js
Created June 8, 2022 18:06
insomnia-plugin-requests-desktop-notification
const notifier = require('node-notifier');
const path = require('path');
module.exports.requestGroupActions = [
{
label: 'Send All Requests',
action: async (context, data) => {
const { requests } = data;
for (const request of requests) {
@thawkin3
thawkin3 / skyflow06.js
Created March 23, 2022 04:27
Skyflow 06
const addFormSubmissionEventListener = (collectContainer) => {
const submitCreditCardForm = (e) => {
e.preventDefault();
const resultContainer = document.querySelector('#result');
const collectResponse = collectContainer.collect();
collectResponse
.then((data) => {
resultContainer.textContent = `Success! Stored tokenized data with ID: ${data.records[0].fields.skyflow_id}`;
resultContainer.classList.remove('hidden');
@thawkin3
thawkin3 / skyflow05.js
Created March 23, 2022 04:25
Skyflow 05
const mountCollectElements = (
cardHolderNameElement,
cardNumberElement,
expiryDateElement
) => {
cardHolderNameElement.mount('#collectCardholderName');
cardNumberElement.mount('#collectCardNumber');
expiryDateElement.mount('#collectExpiryDate');
};