Skip to content

Instantly share code, notes, and snippets.

@ademidun
ademidun / createTableOfContents.js
Last active March 16, 2022 16:37
Dynamically create table of contents using headings on a given page.
/**
*
* @param parentSelector: Where to insert the new table of contents.
* Leave blank if you only wnat to return the table of contents without
* automatically prepending to the parent component.
* @see: https://css-tricks.com/automatic-table-of-contents/
* @see: Used in https://atila.ca/blog/tomiwa/how-to-embed-a-notion-page-in-a-react-website/
*/
export function createTableOfContents(parentSelector="") {
@ademidun
ademidun / data_loader.py
Created June 18, 2021 23:44
Load data from an external file and save to a database in Django and add some tests to the data loader functionality.
import csv
import gspread
from django.db.models import BooleanField
from google.oauth2.service_account import Credentials
from django.contrib.postgres.fields import ArrayField
from contact.models import Contact
@ademidun
ademidun / solana-bear-case.md
Created January 6, 2022 16:52
Some thoughts on why I think Solana is overvalued
/**
Working version of https://docs.web3auth.io/quick-start?lang=react&chain=eth&customAuthentication=no&customLogin=no&whitelabel=no
**/
import { ADAPTER_EVENTS, CHAIN_NAMESPACES, SafeEventEmitterProvider } from "@web3auth/base";
import { Web3Auth } from "@web3auth/web3auth";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
import { useEffect, useState } from "react";
import "./App.css";
import RPC from "../../services/EVM";

Project Name: Arthouse (github)

Author Name: Tomiwa

Number of OP tokens requested: 50,000

L2 Recipient Address: 0x27F7e8d7C63C414Eae2BB07E1a9B9057a1D382cf

Relevant Usage Metrics: (TVL, transactions, volume, unique addresses, etc.)

@ademidun
ademidun / depay-react-example.tsx
Created July 9, 2022 00:26
Example of how to use the Depay Widget in a React App
import React from 'react'
import DePayWidgets from '@depay/widgets';// https://github.com/DePayFi/widgets
import { Button } from 'antd';
interface CryptoPaymentWidgetProps {
/** Amount that wallet will receive in USD */
amount: number;
}
@ademidun
ademidun / APIMock.js
Last active July 20, 2022 12:27
An example of how to use the axios-mock-adapter
/*
Implementation of https://github.com/ctimmerm/axios-mock-adapter
*/
import Environment from '../Environment';
import ContactsAPI from '../ContactsAPI';
import ContactsQuery1 from './Contacts/ContactsQuery1.json';
import ScholarshipsPreview1 from './Scholarship/ScholarshipsPreview1.json';
import ScholarshipsPreviewOntario1 from './Scholarship/ScholarshipsPreviewOntario1.json';
var axios = require("axios");
@ademidun
ademidun / browser-extension-helpers.js
Last active December 19, 2022 17:59
Helper scripts for using browser extensions.
// To test that your extension is working, we can trigger a request account
// copy the following scripts into your browser console
// source: https://gist.github.com/ademidun/29268d38592a84703812c7984f4863cd
ethereum
.request({ method: 'eth_requestAccounts' })
.then((accounts)=>{
console.log({accounts});
})
.catch((error) => {
@ademidun
ademidun / create-typescript-for-installed-project-react.md
Created December 18, 2022 20:13
How to create a custom typescript definition when using packages that don't already have one.

You have installed a package that doesn't have a typescript definition. Here is how you can create one yourself:

See: Transak/transak-sdk#7 (comment)

Here's how I fixed this:

  1. Create a new file: src/@types/transak-sdk.d.ts
  2. Add the Following: [Transak Declaration File]
  3. Add the Following: [Use Transak Declaration File in component]