Skip to content

Instantly share code, notes, and snippets.

@arirusso
arirusso / remove_spaces.sh
Created June 6, 2013 17:28
One-liner to remove spaces from the names of all files in the current directory
#!/bin/sh
#
# Remove spaces from the names of all files in the current directory
#
ls -1 | while read file; do new_file=$(echo $file | sed s/\ //g); mv "$file" "$new_file"; done
@arirusso
arirusso / gifmp3.sh
Last active December 22, 2015 13:29
Create a quicktime movie that combines a looping animated gif with an mp3. The resulting movie will be the same length as the audio file.
#!/bin/sh
#
# Create a quicktime movie that combines a looping animated gif with an mp3. The resulting movie will
# be the same length as the audio file.
#
if [ $(( $# - $OPTIND )) -lt 4 ]; then
echo "Usage: $0 input.gif input.mp3 output.mov [framerate] [resolution]"
exit 1
fi
@arirusso
arirusso / transcriber.rb
Created January 3, 2014 04:52
Basic usage of the CMU Sphinx voice recognition toolkit in JRuby
require "java"
require "benchmark"
# To install and build CMU Sphinx, from the directory where you wish to run this script:
#
# svn co https://svn.code.sf.net/p/cmusphinx/code/trunk/sphinx4
# cd sphinx4
# ant
#
@arirusso
arirusso / gifcut.rb
Created January 20, 2014 07:27
Extract animated gif from mp4 video
input_file,
output_file,
start_time,
duration,
fps,
scale = *ARGV
options = "-ao null -nosound -vo gif89a:fps=#{fps}:output=#{output_file} -ss #{start_time} -endpos #{duration} -vf scale=#{scale}"
player_path = "/Applications/MPlayer OSX Extended.app/Contents/Resources/Binaries/mpextended.mpBinaries/Contents/mpextended.mpBinaries/Contents/MacOS/mplayer"
@arirusso
arirusso / duration.sh
Created January 21, 2014 06:31
One-liner to get the total duration for .mov video files in the current directory
#!/bin/sh
#
# Get the total duration for .mov video files in the current directory
#
find *.mov -print0 | xargs -0 /Applications/MPlayer\ OSX\ Extended.app/Contents/Resources/Binaries/mpextended.mpBinaries/Contents/mpextended.mpBinaries/Contents/MacOS/mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
@arirusso
arirusso / webkitSpeechRecognition
Created January 4, 2014 01:52
Hello world for Web Speech API in a browser. Speak into the microphone and the recognized words will be printed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Web Speech API Example</title>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
var final_transcript = '';
@arirusso
arirusso / wav2mp3.sh
Created February 17, 2016 03:16
Convert directory of wav files to mp3 in OSX using lame
for i in *.wav; do lame -b 320 -h "${i}" "${i}.mp3"; done
@arirusso
arirusso / peaks.md
Last active May 4, 2016 23:44
Build Mutable Instruments Peaks software

Build Mutable Instruments Peaks software

This is what I used to build Peaks using OSX 10.11.4

Install GCC ARM Toolchain

brew tap PX4/homebrew-px4
brew update
brew install gcc-arm-none-eabi
@arirusso
arirusso / video-capture-example.rb
Created March 28, 2012 00:36
ruby-processing: video capture processing example
#!/usr/bin/env ruby
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) with video capture
# use "rp5 unpack library" at a command line to install the video library, among others
# tested with Ruby 1.9.2 on OSX with built in web cam
class VideoCaptureTest < Processing::App
@arirusso
arirusso / video-example.rb
Created March 27, 2012 23:54
ruby-processing: video processing example
#!/usr/bin/env ruby
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) with the video library
# use "rp5 unpack library" at a command line to install the video library, among others
# tested with Ruby 1.9.2
# video file: http://bit.ly/H5yBjK
class VideoTest < Processing::App