Skip to content

Instantly share code, notes, and snippets.

View httpJunkie's full-sized avatar
🏠
Working from home

Eric Bishard httpJunkie

🏠
Working from home
View GitHub Profile
@httpJunkie
httpJunkie / useSwitchNetwork.ts
Created October 18, 2023 19:50
React Hook (JavaScript/TypeScript) that Switches MetaMask user to desired Ethereum chain
import * as contractAbi from '~/lib/contract-abis/MyCOntract.json'
export const config = {
// This config assumes you have access to an ABI like we have imported above
'0x13881': {
name: 'Mumbai',
contractAddress: contractAbi.networks[Number('0x13881')]?.address,
symbol: 'MATIC',
blockExplorer: 'https://mumbai.polygonscan.com',
rpcUrl: 'https://rpc-mumbai.maticvigil.com',
},
@httpJunkie
httpJunkie / switchAddnetwork.js
Last active July 15, 2022 16:17
Switch and or Add a network in MetaMask
try {
await ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xf00' }],
});
} catch (switchError) {
// This error code indicates that the chain has not been added to MetaMask.
if (switchError.code === 4902 || switchError?.data?.orginalError?.code === 4902) {
try {
await ethereum.request({
@httpJunkie
httpJunkie / seg.txt
Created December 6, 2021 23:31
segfault
ericbishard@RMML0522 travel-api % DEBUG=* ts-node src/index.ts
express:router:route new '/' +0ms
express:router:layer new '/' +2ms
express:router:route get '/' +1ms
express:router:layer new '/' +0ms
express:router:route new '/:id' +0ms
express:router:layer new '/:id' +0ms
express:router:route get '/:id' +0ms
express:router:layer new '/' +0ms
express:router:route new '/' +0ms
@httpJunkie
httpJunkie / install-nvm-mac-m1.md
Last active November 22, 2021 00:09
Install Node/NVM on Mac M1

As a web developer these days, we typically need to be able to switch versions of Node on the fly, for this we want to install Node Version Manager on a clean install of our machine, we don't want to start by installin Node on it's own as this will give us a single version of Node (whichever we decide to install)

If you install Node first and then try to install NVM, things can get complicated, so if you have already installed Node, my suggestion is to completely remove it before installing NVM.

As well, NVM is explicitly not supported when installed via homebrew - the only correct way to install it is with the install script in NVM's Readme.

So if you have a brand new Mac M1 these are the steps you need to go through.

  1. Navigate to your home directory
@httpJunkie
httpJunkie / gist:25179edfb81301add1aeb5b977f65176
Last active March 31, 2021 18:16
Docker Instance for Couchbase latest
docker pull couchbase
docker run -d --name cblatest -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase
@httpJunkie
httpJunkie / new-gatsby-novela-site
Last active April 12, 2020 19:48
Create Gatsby Novela site from scratch
# Setting Up a New Gatsby Novela Themed Site
This is a step-by-step unstructional on how to set up The Novela Gatsby theme by Narative for your own blog or website.
## Prerequisites
- GitHub Account/Repo
- Git installed
- Node installed
- An editing environment (VS Code)
@httpJunkie
httpJunkie / readme.md
Last active April 4, 2020 09:05
Run Mongo with Docker

Run Mongo using Docker

This guide will get you up and running with Mongo

Download latest Image

docker pull mongo:X.X.X

Installing and Running Mongo in Detached Mode (In Background and able to connect from server)

@httpJunkie
httpJunkie / Readme.md
Last active April 4, 2020 08:57
Run Couchbase with Docker at Prior Version

Run Couchbase using Docker at Specific Version Number

We may need to sometimes run an older version of Couchbase to repro a bug or issue, sometimes we need a certain version of the SDK and Couchbase.

There are many versions of Couchbase that we may want to junmp to for some reason, here are the version numbers that you can add after the colon in the command below.

  • 4.0.0
  • 4.1.0
  • 4.5.0
  • 4.6.0
@httpJunkie
httpJunkie / file-new-project-js.md
Last active March 9, 2020 17:06
File New Project JavaScript

mkdir xxx && cd $_ && npm init -y && touch .gitignore && echo "/node_modules/*" >> .gitignore && touch readme.md && echo "# Getting Started" >> readme.md && touch .env && echo -e "user=administrator\npass=password" >> .env && npm i dotenv && git add . && code .

@httpJunkie
httpJunkie / couchbase-javascript-developer-resource.md
Last active August 26, 2020 17:41
Couchbase JavaScript Developer Resource