So in order to save your fingers the pain I updated the ffmpeg gem today. You see, previously you had to do this:
convert "finding_that_nemo_dude.avi", :to => "finding_that_nemo_dude.flv" do
...
end.run
Doesn’t look to bad, right? Well, maybe not, but if you pay attention you would notice some repetition here, since the only thing different about the filenames is the extension. So, to keep things nice and dry you can now do this instead:
convert "finding_that_nemo_dude.avi", :to => :flv do
...
end.run
The old way still works if you really want a different filename all together or if you just really like to type
Posted in
Ruby,
Utilities,
gems at August 15th, 2009.
2 Comments
Tagged with
dsl,
ffmpeg,
gems,
Ruby. Written by:
Patrik Hedman
FFmpeg is a great tool for recording, converting and streaming audio and video. It can, however, be quite cumbersome to use. For example consider the following command:
ffmpeg -i some_file.flv -ss 00:00:20 -t 00:01:30 -s hd1080 -aspect 16:9 some_file.avi
Now, even though this is a simple example, it’s still kind of hard to know exactly what it does, so you can imagine what it will look like once you need to accomplish more complex tasks. By contrast, here is the same example using my ffmpeg gem (gem install polly-ffmpeg):
require "rubygems"
require "ffmpeg"
include FFMpeg
convert "some_file.flv", :to => "some_file.avi" do
seek "00:00:20"
duration "00:01:30"
resolution "hd1080"
aspect "16:9"
end.run
This is in my opinion much easier to understand and use.
For more information checkout the documentation and the source code
Posted in
Ruby,
Utilities,
gems at August 5th, 2009.
2 Comments
Tagged with
dsl,
ffmpeg,
gems,
Ruby. Written by:
Patrik Hedman
In my last post I showed how you can install my suppress_validations gem on a per-project basis but that’s a bit cumbersome. Wouldn’t it be nicer if it always was available in the console on every project?
I think it would, so here’s how you can accomplish just that:
Edit your ~/.irbrc (or create it if you don’t already have one):
require "rubygems"
if ENV['RAILS_ENV']
IRB.conf[:IRB_RC] = Proc.new do
require "suppress_validations"
include SuppressValidations
end
end
And thats it, you can now fire up script/console and start suppressing validations
$ script/console
Loading development environment (Rails 2.3.2)
>> post = Post.new
=> #
>> post.save
=> false
>> suppress_validations { post.save }
=> true
>> Post.last
=> #
Posted in
Rails,
Ruby,
gems at July 28th, 2009.
No Comments
Tagged with
gems,
irb,
Rails,
Ruby. Written by:
Patrik Hedman
Validations on ActiveRecord models can really get in the way while trying things out in the console sometimes so the other day when I stumbled over this railscast episode: http://railscasts.com/episodes/62-hacking-activerecord I thought, hey, with some modification that could easily be turned into a plugin.
Install it with:
$ gem install polly-suppress_validations
then add this to your config/environment.rb file:
config.gem "polly-suppress_validations", :source => "http://gems.github.com", :lib => "suppress_validations"
and then unpack it with:
$ rake gems:unpack
or just install it as a plugin:
$ script/plugin install git://github.com/polly/suppress_validations.git
Now say we have a model like this:
class Post < ActiveRecord::Base
validates_presence_of :title, :body
end
Now lets enter script/console and include the SuppressValidations module
$ script/console
Loading development environment (Rails 2.3.2)
>> include SuppressValidations
=> Object
However, trying to create a new post without the required attributes still fails as this example shows:
>> post = Post.new
=> #
>> post.save
=> false
To suppress validations just wrap the call to post.save in a suppress_validations block, like so:
>> suppress_validations { post.save }
=> true
>> Post.last
=> #
Posted in
Projects,
Rails,
Ruby,
gems at July 20th, 2009.
No Comments
Tagged with
activerecord,
gems,
plugin. Written by:
Patrik Hedman
Just released a new version of capistrano_colors. This is a total rewrite from the last version. This post show some of the bigger changes.
Read More…
Posted in
Programming,
Projects,
Rails,
Ruby,
gems at January 4th, 2009.
No Comments
Tagged with
capistrano,
colorize,
colors,
gems,
release,
Ruby. Written by:
Mathias Stjernström
I got so tired of all the messy capistrano output so today I released my first public gem.
The name of the gem is capistrano_colors and the aim of the gem is to put some nice and shiny colors on capistrano output. The gem has only been tested with rails but should work wherever capistrano works.
Keep on reading to see some screenshots!
Read More…
Today I got the chance to give Ruby Enterprise Edition a try. We are currently working with a really fun new environment and you do not get better opportunities to try new stuff as when you have a complete new environment thats not in production. So we gave REE a shoot. When compiling REE with got in trouble really fast and this post is about the quick fix to solve it and some of our early performance results.
Read More…
Yesterday I upgraded merb to 1.0 and I got in some trouble that I solved pretty fast. Last night I started an empty application an got trouble again, but this time for real. I did a fresh install (removed all merb gems and datamapper gems). I generated a fresh merb app with merb-gen but i could not get it to work and all i got from merb was empty replies.
In this post I will try to describe the steps I took to track the problem down and how I solved it.
Read More…
Posted in
Merb,
Programming,
Ruby at November 16th, 2008.
4 Comments
Tagged with
gems,
Merb,
Ruby. Written by:
Mathias Stjernström
Today i thought that i should give the new merb release a try. When updating my merb gems i got the following message.
[cc lang="bash"]
> sudo gem update
Password:
Updating installed gems
Updating merb
ERROR: While executing gem … (Gem::InstallError)
merb-core requires RubyGems version >= 1.3.0
[/cc]
This post is how i solved my problem updating RubyGems to 1.3.1 on Mac OS X 10.5.5
Read More…
Posted in
Merb,
Ruby at November 14th, 2008.
2 Comments
Tagged with
gems,
Merb,
osx. Written by:
Mathias Stjernström
Yesterday i was updating all my ruby gems. During the update a got disturbed by something so i did not pay attention what gems got updated.
This morning i found my current app not starting up.
This is how i solved it
Read More…
Posted in
Ruby at May 13th, 2008.
4 Comments
Tagged with
gems,
Ruby. Written by:
Mathias Stjernström