Skip to content

Instantly share code, notes, and snippets.

View TrevorMcCormick's full-sized avatar
🏀
probably watching basketball

Trevor McCormick TrevorMcCormick

🏀
probably watching basketball
View GitHub Profile
@TrevorMcCormick
TrevorMcCormick / rds_example.py
Created June 15, 2021 12:37
Python Postgres RDS Example Functions
# Import
import json
import pandas as pd
import psycopg2
from sqlalchemy import create_engine
# Client
class Client:
# Create a global psql connection object
def __init__(self, user, password, database, host):
self.user = user
@TrevorMcCormick
TrevorMcCormick / eBaybids.href
Created April 6, 2021 11:21
eBay min bids >=1 and remove sponsored posts
javascript:const params = new URLSearchParams(window.location.search); params.set("_sabdlo", "1"); params.set("LH_Auction","1"); params.set("_ex_kw","sponsored"); params.set("LH_NOB", "1"); window.location.href=window.location.origin+window.location.pathname+"?"+params.toString();
# Given a list of numbers, figure out how many have an even number of digits
import math
def numDigits(num):
digits = math.floor(math.log10(num))+1
return(digits)
@TrevorMcCormick
TrevorMcCormick / cosmetology_scrape.py
Last active May 4, 2020 03:15
Cosmetology Scrape
#Import packages
import requests
from bs4 import BeautifulSoup
import pandas as pd
df = pd.DataFrame(columns=['License Type', 'Name', 'Main Address*', 'Mailing Address',
'Name Type', 'License Number', 'Rank', 'Status', 'Expires'])
#For loop through 103 pages
for page in range(1, 104):
amount,assetid,subtypeid,pile,rareflag,rating,weightrare,year,resourceid,bronze,silver,gold,class,category,level,type
0,7,201,7,0,50,0,2017,5001001,8,2,1,Player,Contract,Bronze,Non-Rare
0,7,201,7,0,65,0,2017,5001002,10,10,8,Player,Contract,Silver,Non-Rare
0,7,201,7,0,80,0,2017,5001003,15,11,13,Player,Contract,Gold,Non-Rare
0,7,201,7,1,60,100,2017,5001004,15,6,3,Player,Contract,Bronze,Rare
0,7,201,7,1,70,100,2017,5001005,20,24,18,Player,Contract,Silver,Rare
0,7,201,7,1,90,100,2017,5001006,28,24,28,Player,Contract,Gold,Rare
0,8,202,7,0,50,0,2017,5001007,8,2,1,Manager,Contract,Bronze,Non-Rare
0,8,202,7,0,65,0,2017,5001008,8,10,8,Manager,Contract,Silver,Non-Rare
0,8,202,7,0,80,0,2017,5001009,11,11,13,Manager,Contract,Gold,Non-Rare
@TrevorMcCormick
TrevorMcCormick / cardinfo.csv
Created November 21, 2017 04:45
Fifa Non-Player Card Ids
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
cardInfo = pd.read_csv("""amount,assetid,subtypeid,pile,rareflag,rating,weightrare,year,resourceid,bronze,silver,gold,class,category,level,type
0,7,201,7,0,50,0,2017,5001001,8,2,1,Player,Contract,Bronze,Non-Rare
0,7,201,7,0,65,0,2017,5001002,10,10,8,Player,Contract,Silver,Non-Rare
0,7,201,7,0,80,0,2017,5001003,15,11,13,Player,Contract,Gold,Non-Rare
0,7,201,7,1,60,100,2017,5001004,15,6,3,Player,Contract,Bronze,Rare
0,7,201,7,1,70,100,2017,5001005,20,24,18,Player,Contract,Silver,Rare
0,7,201,7,1,90,100,2017,5001006,28,24,28,Player,Contract,Gold,Rare
0,8,202,7,0,50,0,2017,5001007,8,2,1,Manager,Contract,Bronze,Non-Rare
0,8,202,7,0,65,0,2017,5001008,8,10,8,Manager,Contract,Silver,Non-Rare
0,8,202,7,0,80,0,2017,5001009,11,11,13,Manager,Contract,Gold,Non-Rare
@TrevorMcCormick
TrevorMcCormick / RemoveOutliers
Created May 12, 2016 17:35
R Function to remove outliers
remove_outliers <- function(x, na.rm = TRUE, ...) {
qnt <- quantile(x, probs=c(.25, .75), na.rm = na.rm, ...)
H <- 1.5 * IQR(x, na.rm = na.rm)
y <- x
y[x < (qnt[1] - H)] <- NA
y[x > (qnt[2] + H)] <- NA
y
}
@TrevorMcCormick
TrevorMcCormick / GCD.c
Created November 4, 2014 04:49
Finds greatest common divisor of two nonnegative integer values
// Program to find the greatest common divisor of two nonnegative integer values
#include <stdio.h>
int main (void)
{
int u, v, temp;
printf ("Please type in two nonnegative integers.\n");
scanf ("%i%i", &u, &v);