Skip to content

Instantly share code, notes, and snippets.

Avatar

Geoff Ruddock asdfgeoff

View GitHub Profile
@asdfgeoff
asdfgeoff / compress_videos.py
Last active May 13, 2020
Bulk compress phone videos using H.265 HEVC encoding 🔥 More info: https://geoffruddock.com/bulk-compress-videos-x265-with-ffmpeg/
View compress_videos.py
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):
@asdfgeoff
asdfgeoff / NaiveBayesFromScratch.py
Last active Mar 27, 2020
A DIY implementation of Multinomial Naive Bayes using NumPy | Details → https://geoffruddock.com/naive-bayes-from-scratch-with-numpy/
View NaiveBayesFromScratch.py
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]
View HurdleRegression.py
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 / toggle.tpl
Created Dec 9, 2019
A slightly modified version of the nbconvert template originally found here: http://damianavila.github.io/blog/posts/mimic-the-ipython-notebook-cell-execution.html
View toggle.tpl
{%- 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 -%}
View plot_experiment_result.py
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 Aug 22, 2018
A python version of the earthquake example given in ISYE 6420 Unit 3.4
View 3.4_alarm_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View sql_templated_python_operator.py
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 / python_resources.md
Last active Aug 29, 2015 — forked from jookyboi/python_resources.md
Python-related modules and guides.
View python_resources.md

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

You can’t perform that action at this time.