Skip to content

Instantly share code, notes, and snippets.

View nchapman's full-sized avatar

Nick Chapman nchapman

View GitHub Profile
@tripflex
tripflex / post.sh
Created February 23, 2017 04:38
Plex DVR Post Process remove Commercials with Comskip
#!/bin/csh
# Add bash path to Plex path.
set path = ($path /usr/local/bin)
# Sleep for a pseudorandom period (up to 10 seconds) to limit the number of instances that start at once
sleep `echo $$%10 | bc`
/root/comchap/comcut --ffmpeg=/usr/local/bin/ffmpeg --comskip=/root/comskip/comskip --lockfile=/tmp/comchap.lock --comskip-ini=/usr/local/etc/comskip.ini "$1"
HandBrakeCLI -i "$1" -o "$1".mkv --format mkv --encoder x264 --quality 20 --loose-anamorphic --decomb fast --x264-preset fast --h264-profile high --h264-level 4.1
find /mnt -name "*.ts" -not -path "*/\.*" -delete
@gruber
gruber / Liberal Regex Pattern for Web URLs
Last active April 22, 2024 19:02
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@nchapman
nchapman / setup.sh
Last active December 5, 2017 19:53
Ubuntu setup
# wget -O - https://raw.github.com/gist/4211882/<REVISION>/setup.sh | bash
# Get updates
apt-get -y update
apt-get -y upgrade
# Install build tools
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core mysql-client libmysqlclient-dev libxslt-dev libxml2-dev python-software-properties
# Install Ruby
@nhoffmann
nhoffmann / deploy.rb
Created April 3, 2012 14:07
Capistrano recipe for deploying static content.
set :application, "My Static Content"
set :servername, 'test.example.com'
# no git? simply deploy a directory
set :scm, :none
set :repository, "." # the directory to deploy
# using git? deploy from local git repository
# set :scm, :git
# set :repository, 'file//.' # path to local git repository
@masqita
masqita / type_caster.rb
Created November 4, 2011 15:13
TypeCaster module
class Boolean
def self.from_json(value)
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
return value
elsif value.is_a?(String)
return value == ("true" || "1")
elsif value.is_a?(Integer)
return value == 1
else
nil
@mudge
mudge / gist:1076046
Created July 11, 2011 15:06
JavaScript version of ActiveSupport's to_sentence method.
function toSentence(array) {
var wordsConnector = ", ",
twoWordsConnector = " and ",
lastWordConnector = ", and ",
sentence;
switch(array.length) {
case 0:
sentence = "";
break;
@zumbojo
zumbojo / bijective.rb
Created July 9, 2011 22:09
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@powdahound
powdahound / hipchat_bot.js
Created April 25, 2011 18:35
Basic XMPP bot example for HipChat using node.js
// Basic XMPP bot example for HipChat using node.js
// To use:
// 1. Set config variables
// 2. Run `node hipchat_bot.js`
// 3. Send a message like "!weather 94085" in the room with the bot
var request = require('request'); // github.com/mikeal/request
var sys = require('sys');
var util = require('util');
#!/usr/bin/env ruby
require 'logger'
require 'rest_client'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
#!/usr/bin/env ruby
require 'logger'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
file.sync = true