Skip to content

Instantly share code, notes, and snippets.

View erikgregorywebb's full-sized avatar
📈

Erik erikgregorywebb

📈
View GitHub Profile
# import libraries
library(tidyverse)
library(rvest)
library(scales)
# get links to data files
url = 'https://github.com/erikgregorywebb/github-actions-demo/tree/main/data'
page = read_html(url)
all_paths = page %>% html_nodes('a') %>% html_attr('href')
paths = all_paths[str_detect(all_paths, '/erikgregorywebb/github-actions-demo/blob/main/data/fm-rates')]
import requests
from bs4 import BeautifulSoup
import pandas as pd
from datetime import datetime
# get page content
url = 'http://www.freddiemac.com/'
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
import requests
import pandas as pd
from scipy import stats
import time
coin_api_key = 'YOUR-KEY-HERE'
slack_token = 'YOUR-KEY-HERE'
# define functions
def COINprices(crypto):
# import libraries
import pandas as pd
import numpy as np
import folium
import matplotlib.cm
# define color vector function
def ColorVector(values, number_of_colors, cmap_name):
buckets = pd.qcut(values, number_of_colors).codes
cmap = matplotlib.cm.get_cmap(name = cmap_name)
# data source: https://www.cargurus.com/Cars/price-trends/
library(tidyverse)
library(dplyr)
library(httr)
library(jsonlite)
library(broom)
library(lubridate)
library(scales)
# import
library(webshot)
# set working directory
setwd("~/Downloads")
# extract as .pdf files
webshot("https://www.getdbt.com/analytics-engineering/start-here/", "dbt-1-start-here.pdf")
webshot("https://www.getdbt.com/what-is-analytics-engineering/", "dbt-2-what-is-analytics-engineering.pdf")
webshot("https://www.getdbt.com/analytics-engineering/why/", "dbt-3-why.pdf")
# demo
import pyautogui
import winsound
frequency = 1500 # in Hertz
duration = 200 # 1000 ms == 1 second
winsound.Beep(frequency, duration)
path = r'C:\Users\erikgregorywebb\Documents\..\my_screenshot.png'
pyautogui.screenshot(path)
from twilio.rest import Client
# create client
account_sid = 'YOUR-ACCOUNT-SID'
auth_token = 'YOUR-AUTH-TOKEN'
client = Client(account_sid, auth_token)
# define message function
def sendMessage(body, from_, to):
message = client.messages.create(body = body, from_ = from_, to = to)
from twilio.rest import Client
try:
# run some code
message = 'Success!'
except:
# if it fails
message = 'Job failed!'
library(rvest)
url = 'https://genius.com/#top-songs'
page = read_html(url)
top_songs = page %>% html_nodes('.qsIlk') %>% html_attr('href')