Skip to content

Instantly share code, notes, and snippets.

View sdumetz's full-sized avatar

Sebastien Dumetz sdumetz

View GitHub Profile
@sdumetz
sdumetz / Useful Bash
Last active August 29, 2015 14:15
check command existence, get script dir...
### CHECK IF COMMAND IS AVAILABLE ###
command -v foo >/dev/null 2>&1
if [ $? -eq 0 ]; then
#Command found
else
#command not found
fi
###GET SCRIPT DIRECTORY ####
DIR="$( cd "$( dirname "$0" )" && pwd )"
@sdumetz
sdumetz / vlc-thumb
Last active August 29, 2015 14:15
Make a thumbnail of a video using VLC and imagemagick. No real improvement over using ffmpeg except if you have VLC installed and not ffmpeg.
#!/bin/sh
# usage :
# @param source video
# @param destination
set -e
### USAGE HELPER ######
usage () {
echo "takes a thumbnail from a video"
echo ""
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@sdumetz
sdumetz / recursive-rmdir.js
Created April 22, 2014 15:00
async recursive rmdir for node js
var fs = require('fs');
var rmdir = function(dir,callback){
var i=0;
var count = 0;
var clbk = function(err){
count++;
console.log(" %s vs %s",count,i);
if(count >= i){
fs.rmdirSync(dir);
callback(err)