Tuesday, July 22, 2014

How to display flash messages using Twitter Bootstrap 3 in Rails 4.1

1. Copy the following helper method to app/helpers/application_helper.rb

  def bootstrap_class_for(flash_type)
    case flash_type
    when "success"
      "alert-success"   # Green
    when "error"
      "alert-danger"    # Red
    when "alert"
      "alert-warning"   # Yellow
    when "notice"
      "alert-info"      # Blue
    else
      flash_type.to_s
    end
  end

2. Create a shared folder in app/views

3. Copy the following code to app/views/_flash_messages.html.erb

<% flash.each do |type, message| %>
 

   
    <%= message %>
 

<% end %>

4. In your layout, add the line :         <%= render '/shared/flash_messages' %>
   above the yield call.

5. Set the flash messages in any of your controllers and you will see the flash messages displayed.

Reference : Stolen from gist.

Final Cut Pro 10.1.2 Crash Course in 10 Minutes

Recording Voice Over

Step 1 : Detach the audio from the video

1. Select the clip from the timeline window.
2. Go to Clip --> Detach audio
3. Select the audio and click delete.

Step 2 : Record Voice Over

1. Click the timeline where you want to start recording the voice over.
2. Go to window, Record Voice Over.
3. Click Record
4. Click the red button to stop recording.

If you make a mistake select the audio track in TL and delete.

Speeding up the Video

1. Select Blade from the dropdown.
2. Select the start and end of the video by using the blade.
3. Modify --> Retime --> 4x
4. Go back to the drop down and select the pointer.

Note : Select before you change the timing so that the rest of the video is unaffected.

Deleting Part of the Clip

1. Select the blade from the drop down.
2. Pick the starting and the end point of the clip
3. Select the pointer from the drop down.
4. Select the clip to reject and click delete.

Audio Enhancement

1. Select the audio
2. Modify --> Auto Enhance Audio
3. Right window, click on Audio Enhancements for any problems

Noise Reduction

1. Select the audio clip
2. Click the wizard inspector
3. Select audio enhancements
4. Background noise removal and hum removal to remove noise

Refer Enhance Audio section in the Help window of FCP.

Preroll

1. Import both videos
2. Drop the title video into the TL and then the video to be processed.

Exporting the Edited Video

1. File --> Share --> Master File

This will export the video in quick-time format.



Recovering from Mistakes

Undo : Command+Z

Thursday, July 17, 2014

Using Figoro Gem with Moonshine

1. Add gem 'figaro' to Gemfile

2. rails g figaro:install

Creates config/application.yml and adds it to .gitignore.

3. Here is the syntax for environment specific configuration

# config/application.yml

pusher_app_id: "2954"
pusher_key: "7381a978f7dd7f9a1117"
pusher_secret: "abdc3b896a0ffb85d373"
google_analytics_key: "UA-35722661-5"

test:
  pusher_app_id: "5112"
  pusher_key: "ad69caf9a44dcac1fb28"
  pusher_secret: "83ca7aa160fedaf3b350"
test:
  google_analytics_key: ~
 
4. Access the values in the code:

 ENV['pusher_secret']

 or

 Figaro.env.pusher_secret

5. Specify required keys in config/initializers/figaro.rb

Figaro.require("pusher_app_id", "pusher_key", "pusher_secret")

6. Add config/application.yml to local directive in Moonshine

7. Deploy the application



Monday, July 14, 2014

How to create .ruby-version and .ruby-gemset in a Rails 4.1 project

$rvm use ruby-2.1.2
Using /Users/bparanj/.rvm/gems/ruby-2.1.2
~/projects/openbay $rvm gemset use openbay
Using ruby-2.1.2 with gemset openbay
$cat .ruby-version
cat: .ruby-version: No such file or directory
$rvm --ruby-version use 2.1.2
Using /Users/bparanj/.rvm/gems/ruby-2.1.2
$rvm --ruby-version use 2.1.2@openbay
Using /Users/bparanj/.rvm/gems/ruby-2.1.2 with gemset openbay
.ruby-version is not empty, moving aside to preserve.
~/projects/openbay $cat .ruby-version
ruby-2.1.2
$cat .ruby-gemset
openbay

Friday, July 11, 2014

Checking if Nodejs is installed using Ruby

node_version = `node -v`

puts node_version

Thursday, July 10, 2014

How to get controller and action name in Rails helper method

In Rails 4 :

    params[:controller]
   
    params[:action]






will give you the name of the controller and the name of the action respectively.

Ternary Operator in Ruby

(Some condition) ? true-case-value : false-case-value

Wednesday, July 09, 2014

How to update all packages in Ubuntu 12.04

If you are logged in as root:

$ apt get-update
$ apt get-update dist-upgrade

otherwise run them as sudo.

$ reboot

This will make the changes to be picked up.

Reference:

How to update all packages in Ubuntu 12

Tuesday, July 08, 2014

rvm rvmrc to [.]ruby-version

WTF? What do we need to do to get rid of this BS? From the root of your Rails project, run:

$ rvm rvmrc to .ruby-version