This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
# This requires tmux 2.1. a lot of these settings will error on anything earlier. | |
# Act like Vim; use h,j,k,l to select panes and move the cursor | |
set-window-option -g mode-keys vi | |
bind-key h select-pane -L | |
bind-key j select-pane -D | |
bind-key k select-pane -U | |
bind-key l select-pane -R | |
# Look good |
module CapybaraWithPhantomJs | |
include Capybara | |
# Create a new PhantomJS session in Capybara | |
def new_session | |
# Register PhantomJS (aka poltergeist) as the driver to use | |
Capybara.register_driver :poltergeist do |app| | |
Capybara::Poltergeist::Driver.new(app) | |
end |
my_array = %w[test one two three] | |
# Inject takes the value of the block and passes it along | |
# This often causes un-intended errors | |
my_array.inject({}) do |transformed, word| | |
puts transformed | |
transformed[word] = word.capitalize | |
end | |
# Output: | |
# {} |
module ActionDispatch | |
module Session | |
class CustomFileStore < ActionDispatch::Session::AbstractStore | |
def get_session(env, session_id) | |
session_data = {} | |
session_id ||= generate_sid | |
File.open(tmp_file(session_id),'r') do |f| | |
data = f.read | |
session_data = ::Marshal.load(data) unless data.empty? | |
end rescue nil |
By default the Rails 3 asset pipeline uses the Uglifier gem to optimize and minify your Javascript. One of its many optimisations is to remove all whitespace, turning your Javascript into one very long line of code.
Whist removing all the newlines helps to reduce the file size, it has the disadvantage of making your Javascript harder to debug. If you've tried to track down Javascript errors in minified Javascript files you'll know the lack of whitespace does make life harder.
Luckily there is a simple solution: to configure Uglifier to add newlines back into the code after it performs its optimisations. And if you're serving your files correctly gzip'd, the newlines add only a small increase to the final file size.
You can configure Uglifier to add the newlines by setting the following in your Rails 3 config/production.rb
file:
template "/tmp/foo.rb" | |
source "foo.rb.erb" | |
cookbook "banana" | |
end |