Skip to content

Instantly share code, notes, and snippets.

Avatar
🏀
probably watching basketball

Trevor McCormick TrevorMcCormick

🏀
probably watching basketball
View GitHub Profile
@TrevorMcCormick
TrevorMcCormick / rds_example.py
Created Jun 15, 2021
Python Postgres RDS Example Functions
View rds_example.py
# 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 Apr 6, 2021
eBay min bids >=1 and remove sponsored posts
View eBaybids.href
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();
View numDigits.py
# 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)
View cosmetology_scrape.py
#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):
View Fifa non-player card info
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 Nov 21, 2017
Fifa Non-Player Card Ids
View cardinfo.csv
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
R Function to remove outliers
View RemoveOutliers
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 Nov 4, 2014
Finds greatest common divisor of two nonnegative integer values
View GCD.c
// 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);