Skip to content

Instantly share code, notes, and snippets.

View JnyJny's full-sized avatar
👽
👽

Erik OShaughnessy JnyJny

👽
👽
View GitHub Profile
@JnyJny
JnyJny / find_imports.py
Last active July 27, 2023 08:46
Find Python Import Statements
"""Find import and import from statements
"""
import ast
from pathlib import Path
class ImportRecord:
@classmethod
def toplevel_imports(cls, root: Path, prune: list[str] = None) -> list[str]:
@JnyJny
JnyJny / example.py
Created August 30, 2021 22:16
PDM Classes 101
""" short module description goes here.
Longer module description goes here.
"""
from typing import List, Union
__author__ = "[email protected]"
@JnyJny
JnyJny / book_thing.py
Created July 15, 2021 22:10
Playing with Google Books API
#!/usr/bin/env python3
""" a quick and dirty books query thing
"""
from pprint import pprint
import requests
@JnyJny
JnyJny / reversed_numbers_sum.py
Created July 3, 2021 16:48
Which list of numbers is bigger?
#!/usr/bin/env python3
from string import digits
from typing import List, Tuple
def make_number_lists(base: str = None) -> Tuple[List[str], List[str]]:
base = base or digits[1:]
@JnyJny
JnyJny / panic-full-2021-05-19-163012.0003.ips
Created May 19, 2021 16:42
MacOS Panic, python3, hidapi, write
This file has been truncated, but you can view the full file.
{"caused_by":"macos","macos_version":"Mac OS X 11.3.1 (20E241)","os_version":"Bridge OS 5.3 (18P4556)","macos_system_state":"running","incident_id":"5D23D70E-B825-42B6-AA03-135B7361F5C4","timestamp":"2021-05-19 16:30:12.00 +0000","bug_type":"210"}
{
"binaryImages" : [
[
"3fa744a7-0f34-36da-aa6d-f6503a3176ed",
18446744005107531776,
"K"
],
[
"00000000-0000-0000-0000-000000000000",
import hid
d = hid.device()
d.open(0x2c0d, 1)
@JnyJny
JnyJny / Makefile
Last active March 18, 2020 13:42
Generate HTML, PDF, EPUB and MOBI from ASCIIDoctor Source
# Makefile - Generate HTML, PDF, EPUB, MOBI from ASC
# This is how you assign a string to a variable name in 'make'. The
# variable name doesn't have to be all caps and the equal doesn't have
# to be snugged up to the variable name; it's just how I write
# Makefiles
FILENAME= the_document
# $(IDENTIFIER) is how you reference a 'make' variable, you can use
@JnyJny
JnyJny / eriks_178_solution.py
Created March 12, 2020 16:42
How I would implement 178
#!/usr/bin/env python3
""" short module description
Longer module description goes here.
"""
from collections import defaultdict
from dateutil.parser import parse
@JnyJny
JnyJny / 178_comments.py
Created March 12, 2020 16:39
Comments for PyBites 178
from dateutil.parser import parse
import re
import datetime
def get_min_max_amount_of_commits(
commit_log: str = commits, year: int = None
) -> (str, str):
"""
Calculate the amount of inserts / deletes per month from the
@JnyJny
JnyJny / grade_csv.py
Last active February 10, 2020 02:50
Compile Student Grades from CSV Data
#!/usr/bin/env python3
import click
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Requirements:
# python3 -m pip install -U click pandas matplotlib numpy xlwt