Skip to content

Instantly share code, notes, and snippets.

@arirusso
arirusso / gifcut.rb
Created Jan 20, 2014
Extract animated gif from mp4 video
View gifcut.rb
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 / transcriber.rb
Created Jan 3, 2014
Basic usage of the CMU Sphinx voice recognition toolkit in JRuby
View transcriber.rb
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 / gifmp3.sh
Last active Dec 22, 2015
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.
View gifmp3.sh
#!/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 / remove_spaces.sh
Created Jun 6, 2013
One-liner to remove spaces from the names of all files in the current directory
View remove_spaces.sh
#!/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 / d3basics.html
Created Sep 18, 2012 — forked from ashleybot/d3basics1.js
D3.js Basic Vertical Bar Chart
View d3basics.html
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v2.min.js"></script>
</head>
<body>
<div role="main">
<div class="charts"></div>
<script language="JavaScript">
@arirusso
arirusso / expression_timer.rb
Created Apr 30, 2012
Ruby methods for protecting against timing attacks
View expression_timer.rb
#!/usr/bin/env ruby
#
# Ruby methods for protecting against timing attacks
#
module ExpressionTimer
# a shortcut to ExpressionTimer.send that passes in the object for which this module
# was included
#
@arirusso
arirusso / vidsampler.rb
Created Apr 23, 2012 — forked from marcel/gist:2100703
vidsampler – extract audio samples from online video
View vidsampler.rb
#!/usr/bin/env ruby
#
# vidsampler – extract audio samples from online video
#
# for OSX only
#
# Usage:
#
# ruby vidsampler.rb [youtube url] [minute:second] [duration]
#
@arirusso
arirusso / capture-to-file.rb
Created Mar 28, 2012
ruby-processing: video capture to a file
View capture-to-file.rb
#!/usr/bin/env ruby
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) where
# captured video is written to a QuickTime file
# use "rp5 unpack library" at a command line to install the video library if you haven't
# tested with Ruby 1.9.2 on OSX with built in web cam
class VideoCaptureToFileTest < Processing::App
@arirusso
arirusso / saturation1.rb
Created Mar 28, 2012
ruby-processing: video capture w/ saturation filter
View saturation1.rb
#!/usr/bin/env ruby
# only show pixels that pass a certain threshold of color saturation
class SaturationFilter < Processing::App
load_library :video
include_package "processing.video"
def setup
@arirusso
arirusso / postgresql.conf
Created Dec 14, 2011
tuned /usr/local/var/postgres/postgresql.conf
View postgresql.conf
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed