Skip to content

Instantly share code, notes, and snippets.

View sjwilliams's full-sized avatar

Josh Williams sjwilliams

View GitHub Profile
http://cfenollosa.com/misc/tricks.txt
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
@sjwilliams
sjwilliams / uap-reboot.sh
Created September 26, 2016 00:28 — forked from stevejenkins/uap-reboot.sh
Simple shell script to remotely reboot a Ubiquiti UBNT UniFi Access Point (UAP, UAP-PRO, UAP-AC, etc.)
#!/bin/sh
# A simple script for remotely rebooting a Ubiquiti UniFi access point
# Version 1.0 (Dec 15, 2015)
# by Steve Jenkins (http://www.stevejenkins.com/)
# Requires sshpass (https://sourceforge.net/projects/sshpass/) which
# is probably available via dnf, yum, or apt on your *nix distro.
# USAGE
ffmpeg -i intro.mov -vf "boxblur=5:1" intro-blur.mov
@sjwilliams
sjwilliams / gist:0b7345440b74087b77f8e2ea6eacb535
Created February 7, 2020 19:12
convert list of filenames into full URLs
for filename in *.mp4; do base=${filename#mp4} echo "https://youdomain.com/${filename%.mp4}-900w.mp4"; done
@sjwilliams
sjwilliams / videostack
Created April 19, 2019 16:18
Stack video frames onto a single image
#!/bin/bash
# https://stackoverflow.com/questions/46145576/stack-multiple-images-in-semitransparent-layers-with-imagemagick
FRAMESDIR=frames
INPUTVIDEO=input.mp4
curl https://cdn.joshwilliams.com/projects/2019/videostack/input.mp4 -o $INPUTVIDEO
mkdir -p $FRAMESDIR
@sjwilliams
sjwilliams / gist:3929462
Created October 22, 2012 03:18
Merge an array of jQuery objects into a single usable selector
// Based on pieces from this thread:
// http://stackoverflow.com/questions/1881716/merging-jquery-objects
// use: var currentRowEls = []; // array of various jQ ojbects
// $.mergeSelectors(currentRowEls).css({width:'200px'});
(function($){
$.mergeSelectors = function(objs) {
var ret = objs.shift();
while (objs.length) {
ret = ret.add(objs.shift());
@sjwilliams
sjwilliams / grid.jsx
Created January 31, 2019 21:43 — forked from hughsk/grid.jsx
Generating Large Image Grids in Photoshop using Javascript
var shuffleAndValidateFiles = function(files) {
var F = new Array();
while (files.length > 0) {
var N = Math.floor(Math.random()*files.length);
if ((files[N] instanceof File) && !files[N].hidden) {
F.push(files[N]);
}
files.splice(N,1);
@sjwilliams
sjwilliams / bayphotosizes.js
Last active February 15, 2018 20:00
Return BayPhoto print sizes as list of height/width ratios. Markup on the https://order.bayphoto.com page.
[].slice.call(document.querySelectorAll('#panel_content_4932_template li')).map(function(el){ return el.textContent.trim();}).filter(function(str){ return /^\S+x\S+$/.test(str) }).forEach(function(str){ var wh = str.split('x'); console.log(str, wh[1]/wh[0]) })
@sjwilliams
sjwilliams / gist:3903157
Created October 17, 2012 01:03 — forked from lucasfais/gist:1207002
Sublime Text 2 Cheat Sheet. Shortcuts, including Vintage mode.

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘KB toggle side bar
⌘⇧P command prompt
⌃ ` python console
⌘⇧N new window (useful for new project)
const isAutoplaySupported = function (callback) {
var timeout;
var waitTime = 200;
var retries = 5;
var currentTry = 0;
var elem = document.createElement('video');
var elemStyle = elem.style;
function testAutoplay(arg) {
currentTry++;