Skip to content

Instantly share code, notes, and snippets.

View apinanyogaratnam's full-sized avatar
🧐

Apinan Yogaratnam apinanyogaratnam

🧐
View GitHub Profile
@apinanyogaratnam
apinanyogaratnam / Burn.sol
Last active December 18, 2021 00:21
Solidity script to burn Ethereum. The funds sent to the burn() function will be sent to the contract's address and it will self destruct (delete the code) which causes the contract to be unusable again
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Burn {
constructor() {}
function payMe() public payable {}
function getBalance() public view returns (uint) {
return address(this).balance;
@apinanyogaratnam
apinanyogaratnam / rcp.js
Last active May 3, 2022 08:53
All RCP connections for working with the MetaMask API
const networks = {
polygon: {
chainId: `0x${Number(137).toString(16)}`,
chainName: "Polygon Mainnet",
nativeCurrency: {
name: "MATIC",
symbol: "MATIC",
decimals: 18
},
rpcUrls: ["https://polygon-rpc.com/"],
@apinanyogaratnam
apinanyogaratnam / git-steps.sh
Created January 11, 2022 03:25
steps to perform to push to remote repository
# add all contents to git
git add .
# commit all contents to staging index
git commit -m 'some message goes here about the changes made'
# add a remote origin
git remote add origin https://github.com/<username>/<project-name>
# view branch name
@apinanyogaratnam
apinanyogaratnam / bayc-conversion-abi.js
Created February 7, 2022 22:33
bored ape yacht club abi convertion to json
const tokenABI = [
{
inputs: [
{ internalType: "string", name: "name", type: "string" },
{ internalType: "string", name: "symbol", type: "string" },
{ internalType: "uint256", name: "maxNftSupply", type: "uint256" },
{ internalType: "uint256", name: "saleStart", type: "uint256" },
],
stateMutability: "nonpayable",
type: "constructor",
@apinanyogaratnam
apinanyogaratnam / historical_ethereum_prices.py
Created February 9, 2022 00:46
get historical ethereum prices
import requests
date = input("Enter a date in DD-MM-YYYY format: ")
url = f"https://api.coingecko.com/api/v3/coins/ethereum/history?date={date}"
response = requests.get(url).json()
price_at = round(response['market_data']['current_price']['usd'], 2)
print(price_at)
@apinanyogaratnam
apinanyogaratnam / flask_rest_api.py
Last active February 13, 2022 15:01
run a flask app with minimal code
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return {'test': "Hello, World!"}
if __name__ == '__main__':
app.run(debug=True, host='localhost', port=8000)
@apinanyogaratnam
apinanyogaratnam / script.sh
Created November 12, 2022 15:00
Docker without Docker desktop on mac
# Install hyperkit and minikube
brew install hyperkit
brew install minikube
# Install Docker CLI
brew install docker
brew install docker-compose
# Start minikube
minikube start
@apinanyogaratnam
apinanyogaratnam / create_db_script.py
Last active January 1, 2023 16:44
python script boilerplate to create postgres database table
import logging
import os
import sys
from dotenv import load_dotenv
from postgres_database_utils import create_connection, PostgresCredentials
# constants
DROP_TABLE = True
TABLE_NAME = "boilerplate"
@apinanyogaratnam
apinanyogaratnam / script.sh
Last active February 7, 2023 20:44
aws amazon linux ec2 setup with docker
sudo yum install git -y
sudo git config --global user.name "your_username"
sudo git config --global user.email "your_email_address@example.com"
sudo yum update -y
sudo amazon-linux-extras install docker
sudo yum install docker -y
@apinanyogaratnam
apinanyogaratnam / query.sql
Created June 21, 2023 01:22
Query all enums in postgres
SELECT (
col.table_schema,
col.table_name,
col.ordinal_position as column_id,
col.column_name,
col.udt_name,
string_agg(enu.enumlabel, ', ' ORDER BY enu.enumsortorder) AS enum_values
)
FROM information_schema.columns col
JOIN information_schema.tables tab ON tab.table_schema = col.table_schema