Skip to content

Instantly share code, notes, and snippets.

@kangarang
kangarang / ens.ts
Created July 27, 2023 15:57
ens util
import { providers } from 'ethers';
const provider = providers.getDefaultProvider('mainnet');
export async function getEnsName(address: string) {
try {
return provider.lookupAddress(address);
} catch (error) {
// noop
}
@kangarang
kangarang / useEns.ts
Created July 27, 2023 15:57
useEns hook
import { useEffect, useState } from 'react'
import { isAddress } from 'ethers/lib/utils'
import { getEnsAddress, getEnsAvatar, getEnsName } from 'utils/ens'
export function useEns(addressOrEnsName?: string) {
const [ensAvatar, setEnsAvatar] = useState<string>()
const [ensName, setEnsName] = useState<string>()
const [ensAddress, setEnsAddress] = useState<string>()
useEffect(() => {

Keybase proof

I hereby claim:

  • I am kangarang on github.
  • I am kangarang (https://keybase.io/kangarang) on keybase.
  • I have a public key ASD5rPzG8MF2WETbcIoqn1QYOZVgSpAjeYcbcYamfkJSlAo

To claim this, I am signing this object:

Full guide: https://fedoraproject.org/wiki/Bumblebee

Add bumblebee repo:

sudo dnf -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora25/noarch/bumblebee-release-1.2-1.noarch.rpm

Managed NVidia repo:

sudo dnf -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora25/noarch/bumblebee-nonfree-release-1.2-1.noarch.rpm

Git

Git Basics

Git provides amazing benefits for programmers. Git is a version-control tool that keeps a record of snapshots of your code as it changes. Git was invented by Linus Torvalds, the same dude that wrote the Linux kernel (Linux OS, Android OS, Chrome OS).

Git keeps track of the changes (not the whole files) you make in your code. This is very useful when debugging complex code because you can easily see the difference between 2 versions of the same file.

A git repository (repo for short) is the entire group of code that is being tracked by git. It's the folder that contains all the code for your project.

The command git init enables git in the working directory, meaning every change that's made inside that directory will now be tracked by git. This includes creating new files and folders within the working directory. Once git is enabled in a repo/directory, there's n