Skip to content

Instantly share code, notes, and snippets.

View wesbosse's full-sized avatar
🖥️

Wesley Bosse wesbosse

🖥️
View GitHub Profile
@wesbosse
wesbosse / rules.json
Created June 17, 2021 15:07
Brainleap Firebase Rules
{
"rules": {
"permissions": {
"$uid": {
".read":"auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
},
"subscriptions": {
"$uid": {
#define the function, jacket_alert, and name the input variable temp_in_F
def jacket_alert(temp_in_F):
# check if the temperature is above the specified threshold
if temp_in_F > 65:
# if so, return the string "no jacket needed"
return "no jacket needed"
#otherwise we return "jacket needed"
@wesbosse
wesbosse / number_squarer.py
Last active December 6, 2019 17:27
answer key for number_squarer python knowledge check.
#define the function "number_squarer" and specify a single argument called "some_number"
def number_squarer(some_number):
#return the number raised to the second power
return some_number ** 2
@wesbosse
wesbosse / stock_function.py
Created December 6, 2019 16:47
custom function for "Recalling the Anatomy of a Function"
#define the function and accept one argument, a string, called ticker_symbol. Give the ticker_symbol a default value of "GOOG" for Google.
def stock_info_collector(ticker_symbol = "GOOG"):
#using the ticker symbol, create the appropriate url for marketwatch.com
url = "https://www.marketwatch.com/investing/stock/" + ticker_symbol
#use the url to request the page and save the response
response = requests.get(url)
#pass the response to our HTML parser function (another custom function defined outside of this example).
def say_hello( first_name, last_name ):
# combine the first and last names into a full_name string, seperating the names with a space.
full_name = first_name + " " + last_name
# use the full name variable to create a complete, formatted string.
formatted_output = "Hello, " + first_name + "!"
# return our formatted output
return formatted_output
Test A B
0 1 1
1 0 0
2 1 2
@wesbosse
wesbosse / page_parse.py
Created July 24, 2019 22:31
Cleaning up the page_parse func
def page_parse(name, soup, city, state):
unit_list = []
for row in soup.find_all('tr'):
prop = {}
prop['city'] = city
prop['state'] = state
prop['name'] = name
try:
@wesbosse
wesbosse / scraper.py
Created July 2, 2019 16:37
P3 Scraper
import requests, time, pandas as pd
posts = []
after = None
for _ in range(4):
if after == None:
params = {}
else:
params = {'after': after}

Parse Jupyter

This is a basic class that makes it convenient to parse notebooks. I built a larger version of this that was used for clustering documents to create symantic indeices that linked related content together for a personal project. You can use this to parse notebooks for doing things like NLP or preprocessing.

Usage

parser = ParseJupyter("./Untitled.ipynb")
parser.get_cells(source_only = True, source_as_string = True)
@wesbosse
wesbosse / max.py
Created October 15, 2018 21:46
Dodge's FF Optomizer
#library imports
import pandas as pd
from itertools import combinations
#read in sample csv
df = pd.read_csv('/Users/teaching/Downloads/mnf.csv', index_col='Unnamed: 0')
#turn our df into a list of rows
data = df.apply(lambda x: x.tolist(), axis=1)