This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| =begin | |
| Depends on recent mplayer with libfaac and libx264 installed before compiling/installing mplayer. | |
| Also, to read AAC audio, libfaad, and to read MP3 audio, libmp3lame, must be installed before compiling/installing mplayer. | |
| If these requirements are not met, don't even try to run this script. | |
| Mencoder may warn about "REMEMBER: MEncoder's libavformat muxing is presently broken"; this is irrelevant for encoding videos in H.264 for the iPod Touch/iPhone, | |
| as they don't use B-frames. | |
| Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| require 'csv' | |
| out = "" | |
| rows = [] | |
| CSV.open(ARGV[0] || "changes.csv", 'r').each { |row_in| rows << row_in.map { |cell| cell.nil? ? "" : cell.to_s } } | |
| max_lengths = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wget -mEkp <url> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| First step: | |
| Note that vf scale/expand sizes will need to be tweaked for different input sizes. | |
| mencoder <input file> -o output.avi -vf scale=480:270,expand=0:-50:0:0:1,harddup -subfont-autoscale 0 -subfont-text-scale 20 -subpos 99 -subfont-blur 2 -subfont-outline 1 -noskip -mc 0 -oac faac -faacopts mpeg=4:object=2:raw:br=128 -ovc x264 -x264encopts bframes=0:nocabac:global_header:threads=2:no8x8dct | |
| Second step: | |
| ffmpeg -i output.avi -acodec copy -vcodec copy <output file>.m4v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Numeric | |
| def humanize | |
| num, output = self.to_i, '' | |
| if self < 0 | |
| output << 'negative ' | |
| num = -num | |
| end | |
| output << if num == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| def bench | |
| tests = [ | |
| [-1, "negative one"], | |
| [0, "zero"], | |
| [8.15, "eight point one five"], | |
| [8, "eight"], | |
| [11, "eleven"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Numeric | |
| def humanize | |
| if ONE_TO_NINE_NINETY_NINE_CACHE.length == 1 | |
| 1.upto(999) do |n| | |
| ONE_TO_NINE_NINETY_NINE_CACHE << if n < 10 | |
| HUMANIZE_ONES_TEXT[n] | |
| elsif n < 20 | |
| HUMANIZE_ELEVEN2NINETEEN_TEXT[n - 10] | |
| elsif n < 100 | |
| d = n % 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Whack this after require boot.rb in your environment.rb file to help debug problems with the I18n load path. | |
| module I18n | |
| class << self | |
| alias_method :orig_load_path, :load_path | |
| def load_path | |
| out = orig_load_path | |
| puts "I18n.load_path called in #{caller[0..3].inspect}, returning #{out.inspect}" | |
| out | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Numeric | |
| def humanize | |
| if ONE_TO_NINETY_NINE_CACHE.length == 1 | |
| 1.upto(99) do |n| | |
| ONE_TO_NINE_NINETY_NINE_CACHE << if n < 10 | |
| HUMANIZE_ONES_TEXT[n] | |
| elsif n > 9 && n < 20 | |
| HUMANIZE_ELEVEN2NINETEEN_TEXT[n - 10] | |
| else | |
| d = n % 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| def bench_small | |
| puts Benchmark.measure { | |
| 1.upto(10_000) { |n| n.humanize } | |
| } | |
| end | |
| def bench_large | |
| puts Benchmark.measure { | |
| 1_000_000_000_000_000_000_000_000_000_000_000_000_000_000.upto(1_000_000_000_000_000_000_000_000_000_000_000_000_010_000) { |n| n.humanize } |