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
def random_bytes | |
100_000 + rand(128849018880) | |
end | |
require 'benchmark/ips' | |
file_sizes = 350_000.times.map { random_bytes } | |
MEGA_BYTE = 1048576.0 | |
Benchmark.ips do |x| |
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
module Digg | |
class Digger | |
attr_reader :path | |
def initialize(*path) | |
@path = path | |
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
raise "Remove patch after rails 3.2" if Rails.version =~ /\A4/ | |
# copy of lib/active_record/relation/spawn_methods.rb | |
# Because updating to this version 3.2.16 might change the behaviour of some of our queries, | |
# we took a copy of this class and remove the behaviour where | |
module ActiveRecord | |
module SpawnMethods | |
def merge(r) | |
return self unless r | |
return to_a & r if r.is_a?(Array) |
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
# I18n Interpolation plan | |
## Introduction | |
### Inline pluralisation | |
These propositions different interpolations indicators are used. `%{}'` and `%<{}>` are 2 of them. In this discussion we should focus on the content of these tags. What type of indicators we would be using is more of a compatibility and/or performance question. | |
#### Value interpolations |
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 MigrateUserToDevise < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.string :encrypted_password, :null => false, :limit => 128 | |
# ... | |
end | |
end | |
def self.down | |
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
These are some snips to help you converting video to flash and thumbnails using ruby and paperclip. | |
Needed: ffmpeg & flvtool, RVideo gem, paperclip | |
Converting the video is done using outside of paperclip, as this could take quite a while. Paperclip by default does it's conversions during the request, and the last thing you want is a request hanging for 10minutes while ffmpeg does it's thing. It is advised to do this conversion somewhere in the background using Resque or DelayedJob. (make sure not to run to many conversions at one time on your machine) | |
Most video thumbnailing solutions out there will create all thumbnails from the video. This solution (on paperclip 2.3.0) however will create one large "temp_thumbnail" once and all consequent thumbnails can use this temporary version. | |
VideoGeometry will make sure that the target dimensions for ffmpeg are always a multiple of 2 and as close as possible to the desired dimensions without breaking the aspect ratio of the original video. |