Skip to content

Instantly share code, notes, and snippets.

View bloopletech's full-sized avatar

Brenton 'B-Train' Fletcher bloopletech

View GitHub Profile
# Radiant CMS grab-bag of features.
# Some of there are quite hackish in that that they copy+paste and then modify code from Radiant itself; thus a lot of this code might only work against version 0.6.9 of Radiant.
# Page extensions; in your extension create a file called lib/page_extensions.rb with the content:
module PageExtensions
def self.included(base)
base.class_eval <<-EODATA
#this snippet adds a has_content="true|false" attribute to the if_content tag, so that the tag only expands of content if the part exists, and if the part has non-blank content.
tag 'if_content' do |tag|
require 'rubygems'
require 'net/smtp'
require 'net/dns/resolver'
require 'net/dns/rr'
require 'time'
def send_mail_hardcore(recipient, recipient_name, from, from_name, subject, message)
username, domain = recipient.split('@', 2) #yeah yeah, username can contain @ sign, will fix later
mxrs = Net::DNS::Resolver.new.mx(domain)
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 }
@bloopletech
bloopletech / gist:141786
Created July 7, 2009 00:16
Humanize numbers with a 1-99 cache
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
#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
@bloopletech
bloopletech / mini_humanize_numbers.rb
Created July 9, 2009 14:54
Humanize numbers with a 1-999 cache
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
require 'benchmark'
def bench
tests = [
[-1, "negative one"],
[0, "zero"],
[8.15, "eight point one five"],
[8, "eight"],
[11, "eleven"],
class Numeric
def humanize
num, output = self.to_i, ''
if self < 0
output << 'negative '
num = -num
end
output << if num == 0
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
wget -mEkp <url>