Skip to content

Instantly share code, notes, and snippets.

@smj10j
smj10j / Register a Protocol Handler in Chrome.js
Created February 22, 2015 10:11
Register a Protocol Handler in Chrome
document.getElementsByTagName('body')[0].innerHTML+= ('<a href=\'javascript:navigator.registerProtocolHandler("web+alfred","%s.alfredworkflow","Alfred 2");\'>a link</a>')
@smj10j
smj10j / dynv6.sh
Last active March 21, 2017 11:50 — forked from corny/dynv6.sh
OSX Version of a script to update IPv4 and IPv6 on http://dynv6.com
#!/bin/sh -e
##
## 03/03/2015
## Updates IPv4 and IPv6 on DynV6.com on OSX
## https://gist.github.com/smj10j/6730d6136eb206e9b9bc
## Original at https://gist.github.com/corny/7a07f5ac901844bd20c9
##
## Example call:
## token=<token> ./dynv6.sh <your dynv6 hostname>
@smj10j
smj10j / ssh-and-tail-error-logs.sh
Created March 12, 2015 01:48
Quickly merge for viewing error logs on separate servers
#!/bin/bash
hosts="1.1.1.1 2.2.2.2 3.3.3.3"
for host in $hosts; do
nohup bash -c "ssh -t $host 'sudo tail -f /mnt/log/nginx/*.error_log' >> /mnt/log/combined_error_log" >/dev/null 2>&1 &
done
# To end
#
@smj10j
smj10j / create-aws-configuration-files.sh
Last active August 29, 2015 14:20
Create AWS Configuration Files
#!/bin/bash
# Usage example
#
# curl "https://gist.githubusercontent.com/smj10j/a4fe775b0e4f4fa68b45/raw/create-aws-configuration-files.sh" | \
# bash -s 'access key' 'secret key' 'us-east-1' && \
# aws iam list-access-keys --user-name SomeUser
#
ACCESS_KEY=$1
@smj10j
smj10j / check-railgun-status.sh
Last active April 25, 2016 21:35
Check Railgun status on CloudFlare
#!/bin/bash
# Requires [jq](https://stedolan.github.io/jq/)
# Can be installed via brew with `brew install jq`
ZONE_ID=
RAILGUN_ID=
API_KEY=
EMAIL=
curl -s -o - -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/railguns/$RAILGUN_ID/diagnose" \
@smj10j
smj10j / convert-audio.command
Last active August 12, 2016 04:55
Shell script that converts ac3 audio files to mp3 using ffmpeg
#!/bin/bash
# ac3 => mp3 conversion for files in same dir
# Converting....
# echo "Starting 5 runs of ffmpeg for conversion..."
# for i in $(seq 5); do
# ( find . -regex '.*\.mp3$' -exec ffmpeg -n -i "{}" -pix_fmt rgb24 -vsync 2 -b:a 192K -aq 2 -f mp3 "{}.done" \;
# done
@smj10j
smj10j / download-youtube-videos.sh
Last active November 19, 2015 21:42
Download YouTube Videos
#
# Made for use with IFTTT
# Wrapped in an Automator Folder Action Workflow
#
#
property bundlePath : the path to me as text
property binPath : bundlePath & "Contents:bin"
on run {input, parameters}
@smj10j
smj10j / test-extract.sh
Last active August 12, 2016 04:52
Quick exraction speed test for archive applications on OSX
#!/bin/bash
########################################
# Tests zip capabilities of given apps #
########################################
if [[ "$#" == 0 ]]; then
echo "Usage: $0 [directory] [apps...]"
exit 1
fi
@smj10j
smj10j / test-bs.command
Last active February 14, 2017 16:44
Simple bash script to test optimal dd block size on OSX and Linux
#!/bin/bash
###
### Example usage: "sudo ./test-bs.sh -p -s 134217728 -w -f /Volumes/SDCARD/dd_test"
###
### This would test the write speed (-w) of the (presumably) attached SD Card by writing
### 134217728 (-s) bytes to /Volumes/SDCARD/dd_test_output (-f) using each block size.
### Before each test is run, the disk cache will be purged (-p)
###
### Generating results
@smj10j
smj10j / compress.command
Last active May 20, 2017 06:29
Finds, compresses, and moves video files to their proper locations on my WD MyBook drive
#!/usr/bin/env bash
# set -x
CWD=$(pwd)
DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PREFIX='screencast'
INCOMINGDIR='Incoming'
SRCDIR=$CWD