Skip to content

Instantly share code, notes, and snippets.

View Seanny123's full-sized avatar
💭
>.<

Sean Aubin Seanny123

💭
>.<
View GitHub Profile
@Seanny123
Seanny123 / csv_chunker.py
Created October 28, 2020 18:26
Break CSV into N chunks using Python
from tqdm import tqdm
def chunker(seq, size):
for pos in range(0, len(seq), size):
yield seq[pos:pos + size]
with open("input.csv") as csv_fi:
csv_lines = csv_fi.readlines()
@Seanny123
Seanny123 / gist:0e49f61d60c3969d87409c0fd7b0402d
Created July 15, 2020 01:12
Example of using Yelp rest API
import json
import requests
yelp_auth = "nope"
def get_events( city ):
headers = { "Authorization": f"Bearer {yelp_auth}" }
params = {"location": city, "limit": 5, "term": "seafood"}
req = requests.get(
@Seanny123
Seanny123 / nvidia.sh
Created January 3, 2020 20:08
Dell XPS 15-7590 NVidia Install
sudo dnf install kernel --enablerepo=updates-testing --best --allowerasing
sudo dnf config-manager --add-repo=https://negativo17.org/repos/fedora-nvidia.repo
sudo dnf update
sudo dnf -y remove "nouveau*"
sudo dnf -y install nvidia-driver akmod-nvidia nvidia-driver-cuda
@Seanny123
Seanny123 / add_shortcut.py
Last active November 19, 2019 16:25
Add keyboard shortcut to Gnome
"""Adapted from https://askubuntu.com/a/597414/168094
Example usage: python3 add_shortcut.py "xkill-short" "xkill" "<Alt><Ctrl><Shift>x"
"""
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("name", help="Name of keyboard shortcut")
@Seanny123
Seanny123 / highlight_missing.py
Last active July 2, 2019 20:18
Highlight missing date ranges given a Pandas DataFrame with a DateTimeIndex
import numpy as np
import matplotlib.pyplot as plt
def plot_missing(df: pd.DataFrame, reg_diff, color="red"):
d_diff = np.diff(df.index)
gaps = d_diff > np.timedelta64(int(reg_diff), 'ns')
gap_sizes = d_diff[gaps]
for win_start, g_s in zip(df.index[:-1][gaps], gap_sizes):
@Seanny123
Seanny123 / date_csv.py
Created June 26, 2019 15:37
Parse CSV with DateTimeIndex
date_col = "datetime"
data_col = "data"
filename = "whatevs.csv"
in_df = pd.read_csv(filename,
usecols=[date_col, data_col],
infer_datetime_format=True, index_col=data_col, parse_dates=data_col)
@Seanny123
Seanny123 / savemytime_mlh.py
Created June 13, 2019 00:44
Get amount of time working for MLH from SaveMyTime tracker.
import pandas as pd
def mili_to_h(mili):
return mili / 60 / 60 / 1000
df = pd.read_csv("SaveMyTime export 12_06_2018 to 13_06_2019.csv")
mlh = df[df["activityName"] == "MLH"]
gitkraken_start = pd.Timestamp("2019-05-01 00:00")
ibm_start = pd.Timestamp("2019-05-20 00:00")
@Seanny123
Seanny123 / genie_rest.jl
Created January 2, 2019 18:42
Basic Genie REST-like server
using Genie
import Genie.Router: route, @params
import Base.convert
convert(::Type{Int}, s::SubString{String}) = parse(Int, s)
route("/sum/:x::Int/:y::Int") do
@Seanny123
Seanny123 / create_points.py
Created November 23, 2018 17:41 — forked from zsunberg/create_points.py
PyJulia Example Use Case
import numpy as np
r = np.arange(1.0, 11.0, 0.1)
n = len(r)**3
pts = np.empty((n, 3))
i = 0
for x in r:
for y in r:
for z in r:
@Seanny123
Seanny123 / table.txt
Created June 19, 2018 16:46
Uncopyable table
+----+-----------------+--------+---------------------+---------------------+---------+
| id | address | build | updated_at | started_at | is_live |
+----+-----------------+--------+---------------------+---------------------+---------+
| 1 | localhost:26257 | v2.0.3 | 2018-06-19 16:39:33 | 2018-06-19 16:31:13 | true |
| 2 | localhost:26258 | v2.0.3 | 2018-06-19 16:39:33 | 2018-06-19 16:35:43 | true |
| 3 | localhost:26259 | v2.0.3 | 2018-06-19 16:39:31 | 2018-06-19 16:37:01 | true |
+----+-----------------+--------+---------------------+---------------------+---------+