Skip to content

Instantly share code, notes, and snippets.

@mcfadden
mcfadden / not.sh
Created January 5, 2021 14:19
Adds a red translucent X over the input file (emoji), and saves the result as a PNG
#!/bin/sh
if [ "$1" = "" ]
then
echo "Usage: $0 [input_file]" 1>&2
echo "Adds a red translucent X over the input file, and saves the result as a PNG"
exit 1
fi
NOT_DATA="iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDAgNzkuMTYwNDUxLCAyMDE3LzA1LzA2LTAxOjA4OjIxICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJyIj8+LUNEtwAAIABJREFUeJztvWmUVNeVJvrtc6eIzIgcIkcSlSWrjBAIIQRlAfITmdgmaUklVK9/vCrV6rWqyr16qC63n9s2AiS/tfpfuSRZILns7rXeq2f7lQdhycNaz41eo7LLksuywAKh0UgMGUMmmUlmzMOdz3k/zr0RkQyCBCJI2dprBVyCGxH33vPtvb89nHPo0H/9ryieOomuj3wEg7eugKiUwIQAUxQQEZgQUBQCEYNCgKIwMACMAFVRwCId4Gem4c/M9CjDy5Zr6z/+tl+rgjwPAEEwgECAEBAACM1/CACAEMFbAAQBJIJjEIhEeBpABHAu/276fHhY/2zTfy344vr5BCLALRbh
@mcfadden
mcfadden / convert_xlive.sh
Last active January 8, 2022 01:40
Convert multitrack WAV files generated by X-Live card into one file per track
#!/bin/bash
# Accepts a single argument, which is a path to the directory containing all the
# WAV files generated by a recordings from the X-Live card.
# Looks for files like 000000.WAV 000001.WAV 000002.WAV etc.
#
# Outputs files like Ch01.WAV Ch02.WAV Ch03.WAV etc.
#
# Requires sox

Keybase proof

I hereby claim:

  • I am mcfadden on github.
  • I am mcfadden (https://keybase.io/mcfadden) on keybase.
  • I have a public key ASCEz4cMl1jVAFGLRnR9N5mjo6xEIcDvc9QKH93bG-1d7Qo

To claim this, I am signing this object:

@mcfadden
mcfadden / set_storage_class_for_s3_files.rb
Created February 12, 2016 23:23
Change the storage class of every item in an AWS bucket
# Ever want to change the storage class of every item in an AWS bucket?
# Requirements:
# Gems:
# fog-aws - http://fog.io
# Usage:
# All items in the bucket:
# set_storage_class_for_s3_files("REDUCED_REDUNDANCY")
# Only items in the 'foobar' folder
@mcfadden
mcfadden / remove_stray_s3_files.rb
Created November 3, 2015 19:32
Remove Stray S3 Files
# Ever had an app/script that created a bunch of files in S3 without a matching database entry?
# This will find and remove any stray s3 files
# Requirements:
# Designed to be run in a rails console, with the `fog` gem installed
# Usage:
# Update `is_stray_file?` method to return the correct value for your use case
# Set ENV['AWS_ACCESS_KEY'] and ENV['AWS_SECRET_KEY']
# Optionally set ENV['AWS_BUCKET']
@mcfadden
mcfadden / Retryable
Created July 14, 2014 17:21
Retryable
# Modifed from original found here: http://stackoverflow.com/a/19364561/1084109
# in lib/retryable.rb
module Retryable
# Options:
# * :tries - Number of tries to perform. Defaults to 1. If you want to retry once you must set tries to 2.
# * :on - The Exception on which a retry will be performed. Defaults to Exception, which retries on any Exception.
# * :log - The log level to log the exception. Defaults to nil.
#
@mcfadden
mcfadden / Instructions.md
Created October 19, 2013 23:54
Making an IP camera with the Raspberry Pi Including on-board motion detection, and a password protected web server for viewing the camera stream

Making an IP camera with the Raspberry Pi

Including on-board motion detection

Requirements

  • Raspberry Pi (512MB rev2 recommended)
  • Raspberry Pi Camera board
  • SD Card (min 2BG, 8GB recommended for good measure. Class 10)

Optionally, a wifi adapter verified to work with raspberry pi ( I used Edimax Wireless Nano USB Adapter - http://www.amazon.com/gp/product/B005CLMJLU/ )

@mcfadden
mcfadden / readme.md
Created July 25, 2013 23:44
Using a Raspberry Pi + Camera Board as a high resolution IP Camera

Making an IP camera with the Raspberry Pi

Requirements

  • Raspberry Pi (512MB rev2 recommended)
  • Raspberry Pi Camera board
  • SD Card (min 2BG, 8GB recommended for good measure. Class 10)

Optionally, a wifi adapter verified to work with raspberry pi ( I used Edimax Wireless Nano USB Adapter - http://www.amazon.com/gp/product/B005CLMJLU/ )

@mcfadden
mcfadden / ping.rake
Created November 25, 2012 02:57
Heroku app pinger
# requires "heroku-api" gem
require 'open-uri'
require 'net/http'
# Shorten timeout in Net::HTTP
module Net
class HTTP
alias old_initialize initialize
def initialize(*args)
@mcfadden
mcfadden / EmptyWidget.php
Created February 1, 2012 17:08 — forked from jonathonbyrdziak/CustomWidgetFile.php
Plugin code to create a single widget in wordpress.
<?php
/**
* @package RedRokk
* @version 1.0.0
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Empty_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com