Skip to content

Instantly share code, notes, and snippets.

View stemwinder's full-sized avatar

Joshua Smith stemwinder

View GitHub Profile
@stemwinder
stemwinder / LVM on Ubuntu howto
Created March 6, 2018 21:22 — forked from runozo/LVM on Ubuntu howto
Using LVM on Linux and resize swap partition
# RESCAN FOR NEWLY ADDED HDS
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
# NEW LOGICAL VOLUME
sudo fdisk /dev/sdb
# then create a new partition of type 8e (Linux LVM)
# create a phisical volume
sudo pvcreate /dev/sdb1
# create new volume group
@stemwinder
stemwinder / ffmpeg-multi-instances-xargs.md
Created October 7, 2017 18:07 — forked from Brainiarc7/ffmpeg-multi-instances-xargs.md
This gist will show you how to launch multiple ffmpeg instances with xargs, very useful for NVIDIA NVENC based encoding where standard GPUs limit the maximum simultaneous encode sessions to two.

Spawning multiple ffmpeg processes with xargs:

On standard NVIDIA GPUs (Not the Quadros and Tesla lines), NVENC encodes are limited to two simultaneous sessions. The sample below illustrates how to pass a list of AVI files to ffmpeg and encode them to HEVC on two encode sessions:

$ find Videos/ -type f -name \*.avi -print | sed 's/.avi$//' |\
  xargs -n 1 -I@ -P 2 ffmpeg -i "@.avi" -c:a aac -c:v hevc_nvenc "@.mp4"

This will find all files with the ending .avi in the directory Videos/ and transcode them into HEVC/H265+AAC files with the ending .mp4. The noteworthy part here is the -P 2 to xargs, which starts up to two processes in parallel.

@stemwinder
stemwinder / transient-clustering-gnu-parallel-sshfs.md
Created October 7, 2017 05:10 — forked from Brainiarc7/transient-clustering-gnu-parallel-sshfs.md
How to set up a transient cluster using GNU parallel and SSHFS for distributed jobs (such as FFmpeg media encodes)

Transient compute clustering with GNU Parallel and sshfs:

GNU Parallel is a multipurpose program for running shell commands in parallel, which can often be used to replace shell script loops,find -exec, and find | xargs. It provides the --sshlogin and --sshloginfile options to farm out jobs to multiple hosts, as well as options for sending and retrieving static resources and and per-job input and output files.

For any particular task, however, keeping track of which files need to pushed to and retrieved from the remote hosts is somewhat of a hassle. Furthermore, cancelled or failed runs can leave garbage on the remote hosts, and if input and output files are large, sending them to local disk on the remote hosts is somewhat inefficient.

In a traditional cluster, this problem would be solved by giving all nodes access to a shared filesystem, usually with NFS or something more exotic. However, NFS doesn't wo

@stemwinder
stemwinder / array_remove_similar.php
Created August 15, 2017 17:12 — forked from danielmartins/array_remove_similar.php
PHP: Remove duplicates items of an array based on similarities
<?php
/**
* This functions runs like array_unique but is based on similarity
* and the math is based on similar_text to know better, see: php.net/similar_text
*
* @param [type] $array [description]
* @param integer $howMuch [description]
* @param [type] $callback [description]
* @return [type] [description]
@stemwinder
stemwinder / README.md
Created February 3, 2017 18:04 — forked from jehaby/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
#!/bin/bash
function switch_files {
mv $1.png $1.tmp.png
mv $1-inverse.png $1.png
mv $1.tmp.png $1-inverse.png
mv $1@2x.png $1@2x.tmp.png
mv $1-inverse@2x.png $1@2x.png
mv $1@2x.tmp.png $1-inverse@2x.png
}
/*
* Subtler, clearer colors and edges
* Emphsasize first two lists
* -- can be modified in CSS to include fewer or more lists
*/
* {
border-radius: 0 !important;
}
@stemwinder
stemwinder / xfdf.php
Created August 16, 2013 15:25 — forked from collegeman/xfdf.php
Converts array to xFDF XML format
<?php
/*
KOIVI HTML Form to FDF Parser for PHP (C) 2004 Justin Koivisto
Version 1.1
Last Modified: 2010-02-17
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
<select name="time" id="time">
<option value="5:00 AM">5:00 AM</option>
<option value="5:15 AM">5:15 AM</option>
<option value="5:30 AM">5:30 AM</option>
<option value="5:45 AM">5:45 AM</option>
<option value="6:00 AM">6:00 AM</option>
<option value="6:15 AM">6:15 AM</option>
<option value="6:30 AM">6:30 AM</option>
<option value="6:45 AM">6:45 AM</option>
@stemwinder
stemwinder / states.html
Created December 4, 2012 16:58 — forked from eyeseast/states.html
For those times you need a state <select>
<option value="">State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>