Skip to content

Instantly share code, notes, and snippets.

View willvincent's full-sized avatar

Will Vincent willvincent

View GitHub Profile
@willvincent
willvincent / parser.php
Created March 25, 2015 05:27
Parse filenames out of a FCPXML file.
<?php
$xml = simplexml_load_file($argv[1]);
$media = array();
$video = array();
$audio = array();
foreach ($xml->sequence->media->video->track->clipitem as $item) {
if (trim($item->name->__toString())) {
@willvincent
willvincent / gist:55bf1e7baeecec564a89
Created April 9, 2015 20:16
Spits out approximate memory usage of an app (passed as an argument) -- mac os 10.9+ (maybe earlier)
<?php
$app = $argv[1];
print exec('hostinfo | grep memory | perl -ne \'$used = `ps aux | grep ' .
$app . ' | awk \'"\'"\'{x+=\$4} END{print x/100}\'"\'"\'` and /Primary memory available: (\d+)/ and printf("' .
$app . ' is using approximately ") and printf($1*$used) and print ("GB\n");\'');
@willvincent
willvincent / RulerGrid
Created April 27, 2017 02:45
custom plugin code for sketch
var doc = context.document;
var page = doc.currentPage();
var current_artboard = page.currentArtboard();
var grid_width = [[doc askForUserInput:"How wide do you want your grid to be?" initialValue:"960"] integerValue]
var column_count = [[doc askForUserInput:"How many columns do you want?" initialValue:"12"] integerValue]
var gutter_width = [[doc askForUserInput:"How wide do you want your gutters to be?" initialValue:"20"] integerValue]
if (grid_width != 0 && column_count != 0 && current_artboard != null) {
var horizontal_rulers = [current_artboard horizontalRulerData]
var gutter_count = column_count + 1;
@willvincent
willvincent / db_backup.sh
Last active October 19, 2017 12:59
Intended for use with cron. This script will backup all (or one specific) database, the specified user has access to on the given DB server, and remove backups older than the specified duration to keep them for. If no params are passed, defaults will be used. and backups created for _every_ database.
#!/bin/bash
USAGE="$0 [-u <user> -p <password> -h <host> -P <PORT> -d <database> -D <destination/directory/without/trailing/slash>]"
DESTINATION=`pwd`
USER=root
PASS=root
HOST=localhost
PORT=3306
# SPECIFY HOW LONG TO RETAIN BACKUPS
@willvincent
willvincent / ddns.sh
Last active December 11, 2018 18:33
DDNS with a Linode domain
#!/bin/sh
# Linode DDNS Updater script
# By Will Vincent <will@willvincent.com>
#
# Requirements:
# - A Linode account (obviously)
# - A domain record already created to update with the script
# - curl & jq
#
@willvincent
willvincent / mrc_client
Last active March 16, 2019 17:33
init.d start/stop script for mrc client
#!/bin/sh
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here
# Description: Put a long description of the service here
### END INIT INFO
@willvincent
willvincent / escapeQuery.js
Last active June 30, 2019 22:30
Reformat a query string so it's safe to use with tsquery() in postgres
const magic_terms = {
and: '&',
or: '|',
not: '!',
OR: '|',
AND: '&',
NOT: '!',
'&': '&',
'|': '|',
'!': '!',

Keybase proof

I hereby claim:

  • I am willvincent on github.
@willvincent
willvincent / laravel-init
Last active February 9, 2020 08:50
Bash script to setup a reasonable base install of laravel with inertiajs + vue
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: laravel-init app_name"
exit 1
fi
### GLOBAL COMPOSER PACKAGES
composer global require hirak/prestissimo friendsofphp/php-cs-fixer
@willvincent
willvincent / transcoder.sh
Last active April 20, 2020 21:41
Batch transcode a directory of video files to another directory, with your desired codecs and whatnot
#!/bin/bash
# These paths should either be relative to the current directory
# or full system paths.
SOURCE_PATH="Camera_Original"
DEST_PATH="Prores"
# wildcard for files to process
FILES="*.MXF"