Javascript functions are being called twice and you are annoyed? Rails asset pipeline

I was working on an application and was trying to submit a HTML form using Javascript and the function I was calling was being called twice for some reasons. After struggling with it for about an hour and asking for help I realized that I compiled my assets on my development machine It was an easy fix since it was just one command. Here’s that magic command:

$ rake assets:clean

Preparing your SD card using a Mac – Setting up Raspbian/Raspberry for first boot

Its fairly simple to setup a SD card for your all new Raspberry Pi just follow the instructions below:

  • Download the Raspbian from the the raspberry pi website, I’m using the Raspbian “Wheezy” for demonstration purposes:
  • Extract the zip file, if you are on Max  OS just double tap on it:
  • Just use this step by step tutorial to prepare the SD card:
    • http://alltheware.wordpress.com/2012/12/11/easiest-way-sd-card-setup/
  • Wait! Wait! Wait!

That’s all just plug it in your Raspberry Pi and have fun.

ALERT: Security loophole found in Rails – If you are not on 3.2.11, 3.1.10, 3.0.19, and 2.3.15 you are unsafe By admin on January 11, 2013 in Uncategorized

If you are not on Rails version 3.2.11, 3.1.10, 3.0.19, and 2.3.15 then your application is probably unsecured since a security loophole has been discovered in other version of Rails.

FINDING THE ISSUE:

If all your apps are on Heroku please use the following ruby script to list all the vulnerable Rails application on your account.

If you are not on Heroku and you want to check if your application is vulnerable or not, well its simple enough, just follow the steps below:

  • Open up your “Gemfile”
  • Check the Rails version by looking at the line that looks like this >> (gem ‘rails’, ’3.2.9′) <<  In this case Rails version in 3.2.11
  • or you can type the following in your terminal:
    • rails -v    => #Rails 3.2.8
  • If you are not on any of the following Rails version your app is under security vulnerability:
FIXING THE ISSUE:

Well, we have discussed that how we can find out the issue, now we can fix it. Lets talk about that:

Its pretty simple, you just have to update your Gemfile:

  • rails '3.2.11' You just have to specify the closest version of the patched version, this one will fix 3.2.9 without breaking any gems.
  • Go back to your terminal and run the following:
    • $ bundle update rails
  • That’s it, Commit and push your changes to the server.

Awesome that’s why I like Ruby on Rails. The community is active and the security loophole was resolved very quickly and the patch was resolved right away. With a seamless patch.

SOURCE: http://weblog.rubyonrails.org/2013/1/8/Rails-3-2-11-3-1-10-3-0-19-and-2-3-15-have-been-released/

Heroku – Taps Server Error: PGError: ERROR: time zone displacement out of range

The following error becomes very annoying when you are trying to setup a staging environment and you try to push your production database to the staging environment.

images

Well! its a very simple fix. The ruby version running on Heroku is 1.9.2 and it is possible that you are on 1.9.3+ so just install rvm and downgrade your ruby version to ruby-1.9.2-p290 by running the following commands(just copy paste the commands):

Install RVM with ruby:

$ curl -L https://get.rvm.io | bash -s stable --ruby

Additionally with rails:

$ curl -L https://get.rvm.io | bash -s stable --rails

Or with rubinius, rails and puma:

$ curl -L https://get.rvm.io | bash -s stable --ruby=rbx --gems=rails,puma

Finally, to install without the “rubygems-bundler” or “rvm” gems:

$ curl -L https://get.rvm.io | bash -s stable --without-gems="rvm rubygems-bundler"

Now, its time to install ruby 1.9.2, run the following command to install it
$ rvm install ruby-1.9.2-p318
switch to ruby-1.9.2-p318
$ rvm use ruby-1.9.2-p318
Run bundle to install gems on that version
$ bundle
Finally, push database
$ heroku db:push

Discover & Publish iOS 6 Passbook friendly coupons & deals! Built for forward thinking Businesses & Customers (use on iPhone & Android)

Wondering, what I was doing over the weekend?

Me along with 2 other Rails developers and a designer built an application for businesses for a 48 hours long competition called Rails Rumble. The application is built to make merchant’s life easier. Merchants can publish their coupons/discounts online in iOS6 PassBook format(customizable) on our website(we provide them with a custom URL like http://our-domain.com/p/your-company-name for their business page which they can customize) where all their passes will be published.

Once business page and coupons are setup users can login with their facebook account and browse passes published by the merchants. Users download coupons to the passbook app on their iPhone(PassWallet for Android). Users will present these coupons while they are checking out to redeems discounts. We will mark the coupon as invalid on their phones once they redeemed it(we can update the coupon aswell).

We did server setup, designing, planning, and code implementation within those 48 hours with 8 hours of sleep.

Want to give it a shot?
Here’s the link: http://coupono.us
We were on the first page of the HackerNews website yesterday( http://news.ycombinator.com/item?id=4653576 – its a big deal ). So far we have attracted over 700 users since launch(we launched yesterday at 9PM)

Public judging?
Anyone with Twitter or GitHub can judge our application between 16th – 18th Oct. Here’s the link:
http://railsrumble.com/entries/79-couponous

Judging is easy:

We are not allowed to change anything on the website until the end of the judging period. But I would love to listen to your suggestions.

Setup Rails 3.2.13, ruby 2 and testing environment on your Mac OSX

Setting up the Development environment(assuming you have rvm and homebrew installed on your Mac)
INSTALLING RUBY VERSION 2

FOR MAC WITH HOMEBREW

    brew install libyaml
    rvm pkg install openssl #deprecated in Mac OSx
    brew install openssl
    rvm install 2.0.0 --autolibs=1
    rvm use 2.0.0
INSTALLING RAILS VERSION 3.2.13
    sudo gem install rails -v 3.2.13
CREATE A NEW GEMSET (IFCB IS THE NAME OF GEMSET YOU CAN CHANGE IT AS PER YOUR NEEDS)
    rvm use 2.0.0@ifcb --create
GEMS FOR TESTING AND DEBUGGING (Put it in your Gemfile)
    group :development, :test do
        gem 'rspec'
        gem 'rspec-rails'
        gem 'shoulda'
        gem 'guard-rspec' 
        gem 'rb-fsevent' #Mac OSX
        gem 'terminal-notifier-guard'
        gem 'capybara'
        gem 'pry'
        gem 'database_cleaner'
    end
INITIALIZE GUARD
    guard init
RUN GUARD
    gurard

Oh Boy! Sublime videos are not streaming – You need to fix your videos

Yesterday, I wasted almost an hour to figure out the video streaming. Here’s how everything was setup:

  • Video Player: Sublime Video – A free HTML5/Flash video player – http://sublimevideo.net
  •  Ruby on Rails
  • Amazon S3 – Simple Storage Server – It is being used to store the video files.

Its pretty easy to get the sublime video setup on the website but the problem arises when you try to run the video in the player with MP4 and the video doesn’t stream. Video Player try to download the full video on to the local machine. After downloading the full video the player detects the encoding scheme and then plays the video. If you are facing the same problem I’ve the solution for you.

Here’s what I thought could be wrong:

  • Something is wrong on Amazon S3 server(probably its not distributing the file in chunks).
  • Probably something is wrong with the Video player
  • Or the video file is not right.

I started my investigation in the order mentioned above.

I used Amazon CloudFront and hooked it up with my Amazon S3 bucket but nothing really worked.

Video player worked for other websites(http://railscasts.com/ is one of them). So, the Sublime Player is all good.

Culprit: I figured out that the video file was not encoded properly. It should use the following encoding scheme if you want to use that as a streaming video:

H.264/MP4

How to run MongoDB or Mongod as a service or daemon

It could be a pain in the butt if you have installed MongoDB on your virtual private server and you are trying to run it through an SSH client. Or you run it on the server, it works fine until you have the SSH session active. Oh Boy, we have a solutions which is easy and pretty straightforward. Please have a look at the solution below.

Run MongoDB as a service or Daemon as below:

./mongod --fork --logpath /var/log/mongodb.log --logappend
or
sudo mongod --fork --logpath /var/log/mongodb.log --logappend

I hope this would help.

Source

Installing Active State Perl on your windows box

Active Perl

Active Perl is a binary distribution of Perl for Win32 and Win64 edition windows. Here’s how you can download it:

  1. Click on the link to visit the download page of Active Perl: http://www.activestate.com/activeperl/downloads
  2. Select the appropriate version  and release of Active Perl.
  3. Download the .msi file on your computer and double click on the file.
  4. Click Next on the welcome screen of the setup.
  5. Read and accept the license agreement.
  6. Click next on Active Perl’s Custom Setup screen.
  7. Click on next after changing the options on “Choose optional setup actions screen“.
  8. Click Install and then finish.

By following above steps you will be able to install ActivePerl on your computer. To see which code editor is the best for windows click here.

An excelent free and open source code editor for your Windows machine

Notepad++ is a free source code editor which supports several programming languages running under the MS Windows environment.

This project, based on Scintilla edit component (a very powerful editor component) are written in C++ with pure win32 api and STL (that ensures the higher execution speed and smaller size of the program), is under the GPL Licence.

Features:

  • Syntax Highlighting and Syntax Folding: Supported languages : C, C++, Java, C#, XML, HTML, PHP, Javascript, RC resource file, makefile, ASCII art file extension .nfo , screenshot1, screenshot2), doxygen, ini file, batch file, ASP, VB/VBS source files, SQL, Objective-C, CSS, Pascal, Perl, Python, Lua, TCL, Assembler, Ruby, Lisp, Scheme, Properties, Diff, Smalltalk, Postscript and VHDL.Features:
  • WYSIWYG
  • User Defined Syntax Highlighting
  • Multi-Document Tabs
  • Regular Expression Search/Replace supported
  • Full Drag N’ Drop supported
  • Dynamic position of Views
  • File Status Auto-detection
  • Zoom in and zoom out
  • Multi-Language environment supported
  • Bookmark
  • Brace and Indent guideline Highlighting
  • Macro recording and playback

Click here to download Notepad++

include-moneris-donation-form