Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
d for defi

drbh drbh

🦀
d for defi
View GitHub Profile
@drbh
drbh / columbus-4-terra-node.sh
Created Sep 7, 2021
How to run a mainnet Terra node
View columbus-4-terra-node.sh
# clone release branch
git clone git@github.com:terra-money/core.git --branch=v0.4.6
# move into dir
cd core
# build it
make install
# check that we have the right version... etc
@drbh
drbh / pointer-receivers-tick.go
Created Apr 29, 2021
Showing the importance of using pointer receivers
View pointer-receivers-tick.go
package main
import (
"fmt"
)
type Item struct {
TestChan chan int64
}
@drbh
drbh / percent_money_printed_fed.py
Last active Mar 10, 2021
A snippet to see how much money is added to USD M2 every year - data from the St. Louis Federal Reserve
View percent_money_printed_fed.py
import pandas as pd
# view original data here
# https://fred.stlouisfed.org/series/M2SL
url = "https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=968&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=M2SL&scale=left&cosd=1959-01-01&coed=2021-01-01&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Monthly&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&vintage_date=2021-03-10&revision_date=2021-03-10&nd=1959-01-01"
df = pd.read_csv(url)
#### UNCOMMENT TO ACCOUNT FOR 1.9T
#new_total = df.tail(1)["M2SL"].values[0] + 1900.0
#df = df.append(pd.DataFrame([["2021-03-10", new_total]], columns = ["DATE", "M2SL"]))
@drbh
drbh / fetch-emsi-skills.py
Created Feb 22, 2021
fetch all emsi skills with pandas and requests in Python3
View fetch-emsi-skills.py
import pandas as pd
import requests
CLIENT_ID = "<CLIENT_ID>"
CLIENT_SECRET = "<CLIENT_SECRET>"
CLIENT_SCOPE = "emsi_open"
VERSION = "latest"
url = "https://auth.emsicloud.com/connect/token"
payload = f"client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&grant_type=client_credentials&scope={CLIENT_SCOPE}"
@drbh
drbh / only-even-weeks.py
Created Aug 5, 2020
When you only wanna update users on even weeks of the year
View only-even-weeks.py
import datetime
# get the week of the year
week_number = datetime.datetime.now().isocalendar()[1]
print(f"Its the {week_number} week of the year")
# this is True every other week
should_update_users = week_number % 2 == 0
if should_update_users:
@drbh
drbh / 0-50-mappings.py
Created Aug 4, 2020
Get the numbers 0 to 50 as cardinal, ordinal, english and ints
View 0-50-mappings.py
import string
# mostly copied form here
# https://www.mathsisfun.com/numbers/cardinal-ordinal-chart.html
nth = {
1: "First",
2: "Second",
3: "Third",
4: "Fourth",
5: "Fifth",
@drbh
drbh / door-state-tracker-naive.cpp
Created Jul 26, 2020
Simple door state checker - truncated to ignore networking code
View door-state-tracker-naive.cpp
#include <ESP8266WiFi.h>
#include <EEPROM.h>
// networking and request related
int inputVal = 0;
int addr = 0;
int lastValue;
// networking and request related
void sendMessageToLambda(int currentState) {
// networking and request related
@drbh
drbh / door-state-tracker.cpp
Created Jul 26, 2020
Deep sleep enabled door state tracker that connects to WIFI and sends HTTPS request if state is changed. build target: WEMOS D1 ESP8266
View door-state-tracker.cpp
// memory
#include <EEPROM.h>
// networking
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
@drbh
drbh / write-door-state.py
Created Jul 26, 2020
Write door state updates to dynamo
View write-door-state.py
import json
import boto3
import datetime
import dateutil.tz
eastern = dateutil.tz.gettz('US/Eastern')
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table("<DOOR-STATE-TABLE-NAME>")
def lambda_handler(event, context):
@drbh
drbh / read-door-state.py
Created Jul 26, 2020
Get human readable state of the door from dynamo table
View read-door-state.py
import json
import boto3
import decimal
import datetime
import calendar
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
return float(o)