Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View asdfgeoff's full-sized avatar

Geoff Ruddock asdfgeoff

View GitHub Profile
@asdfgeoff
asdfgeoff / compress_videos.py
Last active September 14, 2023 22:10
Bulk compress phone videos using H.265 HEVC encoding 🔥 More info: https://geoffruddock.com/bulk-compress-videos-x265-with-ffmpeg/
import click
from pathlib import Path
from subprocess import call, check_output
from tqdm import tqdm
@click.command()
@click.argument('directory', type=click.Path(exists=True))
@click.option('--recursive', is_flag=True, help='Recursive')
@click.option('--file-ext', help='File format to process')
def main(directory, file_ext='mp4', recursive=False):
from typing import Optional, Union
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression, LogisticRegression
from sklearn.base import BaseEstimator
from sklearn.utils.estimator_checks import check_estimator
from sklearn.utils.validation import check_X_y, check_array, check_is_fitted
from lightgbm import LGBMClassifier, LGBMRegressor
@asdfgeoff
asdfgeoff / lp-inline-embeds.css
Created March 31, 2022 13:57
Obsidian » Live Preview » Inline block references
/*
Render embeds inline in Live Preview mode
Source: https://gist.github.com/asdfgeoff/e6116873daa81ae92a6755af1d3c19e5
*/
/***********
BLOCK EMBEDS
************/
/* Make a bunch of block-level elements involved in embed display as inline */
@asdfgeoff
asdfgeoff / NaiveBayesFromScratch.py
Last active November 9, 2020 11:22
A DIY implementation of Multinomial Naive Bayes using NumPy | Details → https://geoffruddock.com/naive-bayes-from-scratch-with-numpy/
from typing import Callable, Union
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.utils.validation import check_X_y, check_array
from IPython.display import display
array_like = Union[list, np.ndarray]
matrix_like = Union[np.ndarray, pd.DataFrame]
from airflow.operators.python_operator import PythonOperator
class SQLTemplatedPythonOperator(PythonOperator):
""" Extend PythonOperator to receive a templated SQL query and also to display it in the "Rendered Template" tab in Airflow's UI.
This is very helpful for troubleshooting specific task instances, since you can copy a propertly formatted query directly from
the web UI rather than copying the contents of "templates_dict" and parsing it manually.
Args:
@asdfgeoff
asdfgeoff / toggle.tpl
Created December 9, 2019 11:03
A slightly modified version of the nbconvert template originally found here: http://damianavila.github.io/blog/posts/mimic-the-ipython-notebook-cell-execution.html
{%- extends 'full.tpl' -%}
// Source: http://damianavila.github.io/blog/posts/mimic-the-ipython-notebook-cell-execution.html
{% block input_group -%}/Users/geoffruddock/Library/Jupyter/nbconvert/templates
<div class="input_hidden">
{{ super() }}
</div>
{% endblock input_group %}
{%- block header -%}
import datetime as dt
from typing import List, Tuple
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as plticker
from scipy.stats import norm
plt.rcParams['figure.facecolor'] = 'white'
@asdfgeoff
asdfgeoff / 3.4_alarm_example.ipynb
Created August 22, 2018 17:03
A python version of the earthquake example given in ISYE 6420 Unit 3.4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asdfgeoff
asdfgeoff / python_resources.md
Last active August 29, 2015 14:24 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides