Skip to content

Instantly share code, notes, and snippets.

View drbh's full-sized avatar
🕳️
a for AI

drbh drbh

🕳️
a for AI
  • drbh
  • state space
  • 20:16 (UTC -04:00)
View GitHub Profile
@drbh
drbh / columbus-4-terra-node.sh
Created September 7, 2021 18:30
How to run a mainnet Terra node
# clone release branch
git clone [email protected]: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 April 29, 2021 02:56
Showing the importance of using pointer receivers
package main
import (
"fmt"
)
type Item struct {
TestChan chan int64
}
@drbh
drbh / percent_money_printed_fed.py
Last active March 10, 2021 21:00
A snippet to see how much money is added to USD M2 every year - data from the St. Louis Federal Reserve
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 February 22, 2021 16:30
fetch all emsi skills with pandas and requests in Python3
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 August 5, 2020 17:04
When you only wanna update users on even weeks of the year
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 August 4, 2020 15:03
Get the numbers 0 to 50 as cardinal, ordinal, english and ints
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 July 26, 2020 01:03
Simple door state checker - truncated to ignore networking code
#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 July 26, 2020 00:58
Deep sleep enabled door state tracker that connects to WIFI and sends HTTPS request if state is changed. build target: WEMOS D1 ESP8266
// 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 July 26, 2020 00:44
Write door state updates to dynamo
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 July 26, 2020 00:41
Get human readable state of the door from dynamo table
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)