Skip to content

Instantly share code, notes, and snippets.

Avatar
🐞

Ben Lopatin bennylope

🐞
View GitHub Profile
@bennylope
bennylope / remotefiles.conf
Created Oct 19, 2011
nginx remote file proxying
View remotefiles.conf
location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) {
# Do not allow people to mess with this location directly
# Only internal redirects are allowed
internal;
# nginx has to be able to resolve the remote URLs
resolver 8.8.8.8;
# Location-specific logging
#access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main;
@bennylope
bennylope / ffmpeg-watermark.md
Created Apr 22, 2016 — forked from webkader/ffmpeg-watermark.md
FFmpeg add a watermark to video
View ffmpeg-watermark.md

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@bennylope
bennylope / LICENSE
Last active Feb 10, 2021
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
View LICENSE
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license
@bennylope
bennylope / gist:1894706
Created Feb 23, 2012
Canonical URLs with Jekyll
View gist:1894706
<link rel="canonical" href="http://yourdomain.com{{ page.url | replace:'index.html','' }}" />
View annotated.py
from functools import wraps
def annotated(annotation_name):
"""
Decorator for returning pre-calculated, annotated values
This should be used with model instance methods that fetch some
kind of related or calculated data. If the method is called on
a single instance in isolation, we should expect the method to
@bennylope
bennylope / ansible.yml
Created Apr 30, 2014
Deployment w/ Capistrano style deployments with Ansible & Capistrano
View ansible.yml
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
@bennylope
bennylope / create_db_restore.sh
Last active Aug 20, 2020
Create a named database and restore from the lastest downloaded file
View create_db_restore.sh
#!/usr/bin/env bash
LATEST_DB="$HOME/Downloads/$(ls -t ~/Downloads | head -1)"
BACKUP_PATH=${2-$LATEST_DB}
DB=$1
echo "Creating database name $DB from $BACKUP_PATH"
psql -c "CREATE DATABASE $DB;"
View remotefile.py
import requests
class RemoteFile:
"""
Context manager for handling remote OR local files
Can be used like so:
>>> with RemoteFile("/path/to/local/file.txt") as f:
@bennylope
bennylope / console.js
Created May 27, 2020
Download your Papertrail gzipped archives
View console.js
/*
Copy and paste into your browser console window after loading
your archives page, e.g. with a selected long date range.
Original: https://www.reddit.com/r/javascript/comments/5my92r/console_script_to_click_all_download_links_on_a/dc7cktr/
The problem I had with my first attempt was that there was no delay,
so I was only downloading the last entry on the page. The linked
solution above pointed to the problem (each subsequent request was
killing the preceding request) which was including a delay. Here
@bennylope
bennylope / stripe_subscription_stream.py
Created Feb 28, 2020
Common (?) pattern for consuming paged objects as a stream in Python, using Stripe Subscriptions as an example
View stripe_subscription_stream.py
import functools
import stripe
from typing import Any, Optional
def stripe_subscriptions(limit: Optional[int] = 100, **params: Any):
"""
Returns an iterator of all matching subscriptions