Skip to content

Instantly share code, notes, and snippets.

@tcg
tcg / README.md
Created February 22, 2024 22:17
ffmpeg "crush"

ffmpeg "crush"

This is a function from one of my "dotfiles".

VERY useful on QuickTime/iMovie exports of screencaps for bug reports, etc.

Preserves aspect ratio, but sets some maximums: 720p, 24fps, 44.1 audio (hardly touched).

@tcg
tcg / eff_short_wordlist_2_0.py
Created January 12, 2022 05:19
EFF Short Wordlist 2.0, in Python
"""
EFF Short Word List, from https://www.eff.org/files/2016/09/08/eff_short_wordlist_2_0.txt
For details see: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
See also: https://www.eff.org/dice
From https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases:
- "Each word has a unique three-character prefix. This means that future
software could auto-complete words in the passphrase after the user has typed
the first three characters"
@tcg
tcg / http_status_code_output.txt
Created December 18, 2018 06:10
HTTP Status codes in Python 3
>>> from http import HTTPStatus
>>> for s in HTTPStatus:
... print(f"{s.value}: {s.phrase}")
...
100: Continue
101: Switching Protocols
102: Processing
200: OK
201: Created
202: Accepted
@tcg
tcg / html_entity_decode.py
Last active September 5, 2018 15:18
Decoding HTML entities to UTF-8 text in Python 2
def html_entity_decoder(s):
"""
Decodes HTML entities like `&` and `“` into their
plain-text counterparts.
NOTE: This is Python2 specific, and will require changes when
porting to Python3.
Args:
s: string of of HTML to filter.
@tcg
tcg / dates_for_year.py
Created July 27, 2018 20:15
Ended up not needing this. A Python Generator for getting a `datetime.date` for every day in a given year.
def _dates_for_year(year):
"""
A generator of all `datetime.date`s for a given integer year.
"""
if year != int(year):
raise ValueError(f"Year provided does not appear to be an integer. Provided: {year}")
for month in range(1, 12 + 1):
# Leaning on the calendar module to give the correct number of
# days for leap year February.
@tcg
tcg / gulpfile.js
Created February 14, 2018 05:09
Gulpfile example that builds Hugo site, scss/css, asset hashing, and html minification
/**
* This gulpfile inspired by http://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/
*
* Tasks for building sass/scss, and hashed assets, in combination with the
* hugo generated blog.
*
*/
var gulp = require("gulp"),
sass = require("gulp-sass"),
@tcg
tcg / how-i-configure-my-logitech-g502-mouse-to-make-me-more-productive.md
Created August 29, 2017 03:09
How I configure my Logitech G502 mouse to make me more productive

How I configure my Logitech G502 mouse to make me more productive

I use a "gaming mouse" as my current favorite every-day computer mouse, when I'm not just using the trackpad.

If you're not familiar with it, it's a great computer mouse that has some extra buttons that can be arbitrarily assigned key combos, macros, and various functions.

Recently, I decided to tweak some settings for every day desktop/work use, and I've been quite pleased. Here's a couple things I did:

Middle scroll wheel: left/right tilt

@tcg
tcg / README.md
Created June 9, 2017 16:25
Raspberry Pi Zero W as Internet connected Access Point *and* Wireless Client

I wanted this capability for various reasons. It's not necessarily stable, because uap0 has to use the same channel as wlan0, and if you're traveling/mobile, wifi channels aren't necessarily predictable.

This is not a guide. This is just so I remember how to get back where I started, in case I wipe this thing. =)

Extremely helpful guides that got me here:

@tcg
tcg / .zshrc
Created June 7, 2017 18:42
List Git branches by date; Helpful if you jump around a lot.
# List Git branches in order of most-recently-updated.
alias gitbranchesbydate="git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:iso8601) %09 %(refname) %09 %(authorname)' | sed -e 's-refs/heads/--'"
# Output looks like:
# 2014-06-06 12:58:53 -0500 tcg/donate_language_updates Tommy George
# 2014-06-06 10:28:04 -0500 integration Brad
# 2014-06-05 16:13:30 -0500 super_dev_branch Chris
@tcg
tcg / iterm2-solarized.md
Created May 30, 2017 20:02 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k