%Q, %q, %W, %w, %x, %r, %s

You can find some useful shortcuts in this article for rails.

Simple Ruby on Rails

%Q | %q | %W | %w | %x | %r | %s

This is an alternative for double-quoted strings, when you have more quote characters in a string.Instead of putting backslashes in front of them, you can easily write:

>> %Q(Joe said: "Frank said: "#{what_frank_said}"")
=> "Joe said: "Frank said: "Hello!"""

The parenthesis “()” can be replaced with any other non-alphanumeric characters and non-printing characters (pairs), so the following commands are equivalent:

>> %Q!Joe said: "Frank said: "#{what_frank_said}""!
>> %Q[Joe said: "Frank said: "#{what_frank_said}""]
>> %Q+Joe said: "Frank said: "#{what_frank_said}""+

You can use also:

>> %/Joe said: "Frank said: "#{what_frank_said}""/
=> "Joe said: "Frank said: "Hello!"""

Used for single-quoted strings.The syntax is similar to %Q, but single-quoted strings are not subject to expression substitution or escape sequences.

>> %q(Joe said: 'Frank said: '#{what_frank_said} ' ') => "Joe said: 'Frank said: '#{what_frank_said} '…

View original post 131 more words

Google Recaptcha With Ruby On Rails Integration.

gurudath bn Ruby On Rails

Google Recaptcha With Ruby On Rails Integration.

Google Recaptcha protects the websites you love from spam and abuse.

Below the steps to be followed to develop a sample ROR application with Google Recaptcha:-
Step 1. Create a Ruby on Rails application:-

a)Open a terminal, navigate to a directory where you have rights to create application and type:
rails new recap

b)After you create the application, switch to its folder:
cd recap

c)Type and run bundle install:
bundle install

Step 2. Create models, views, and controllers:-

a)For this application we will generate a scaffold, which is a starter template provided by Rails that bundles a model, a controller, and the relevant views for our application:
rails generate scaffold User name:string

b)After generating the scaffold we need to create the actual User table in our development database so we need to run migration:
rake db:migrate

c)To start the application run below command…

View original post 321 more words

A Bluetooth beacon in your fridge could help you eat less


Most applications for beacon technology so far have been targeted towards retailers and marketers — for instance, beacons have been used to push coupons for McNuggets when you walk by a McDonalds. Taking a different approach to the Bluetooth Low Energy protocol, a new free app from developer Brian Mueller employs beacons to help you eat less.carrot-hunger-screneshotCarrot Hunger, which launched for iOS on Thursday, has a nifty feature that requires a beacon in your fridge. Like a digital version of a “nothing feels as good as skinny feels” magnet on your fridge, the Carrot Hunger app can push a notification when you’re nearby a iBeacon reminding you to log the food you’re about to eat — effectively, a reminder not to stuff your face. Carrot Hunger recommends sticking the beacon in a fridge, but you can also stick a iBeacon in, say, your office’s kitchen.

carrot screenshot ibeacon

Unfortunately, Carrot won’t provide an iBeacon. You’ll have to bring your own beacon hardware — some iBeacon-capable beacons cost as little…

View original post 206 more words

My Experience with AngularJS: A Sound Framework of JavaScript

AngularJS is a sound JavaScript framework, and it makes the job of the programmer really easy and helps the programmer deliver a good UI(User Interface) with a great UX(User Experience) in a short span of time. Some of the great features of angularJS are as follows-

1. It’s an MVC framework of JavaScript:

It separates the developments in 3 sections: Model, View and Controller.

Model: The collection of data. AngularJS provides a special variable called $scope which is used to make the data available to the view.

View: This is the html template. In view we use a concept called “data binding” which facilitates use of the the data(in the model, i.e. $scope).

Controller: This is where the business logic is kept that explains how the data needs to be handled

2. Data Binding:

This is the most frequently used feature of angularJS that reduces the programmers job of handling the the reflection of change of data in the view. Consider the following code snippet


No of employees: <div>{{employees.length}}</div>

In this code we want to reflect in view as and when the count of employees change in the model. In case you had used JQuery to achieve the same you might have to do the DOM manipulation in your javascript code like as follows:


<div id="emp_count"></div>



and run this JS code as and when the employees count changes. So you need to keep track when this variable is changing which is a huge overhead. AngularJS even gives us a method called $watch which helps to keep track any change in the variable or object and handle the change in the $watch function block block

This examples shows you how simple it is with angularJS.

3. Directives:

You can define behaviour of a DOM element using directive. With its help you can define custom DOM elements, attributes for your project and define their behaviour in your angularJS code.


     <ang-alert alert-text="clicked 1">click me</ang-alert>
     <ang-alert alert-text="clicked 2">click me</ang-alert>


angular.module("myApp", []).
directive("angAlert", function () {
    return {
        restrict: 'E',
        link: function (scope, element, attributes) {
            //setting style
            $(element).css("display", "block");
            //defining event handler
            $(element).on("click", function () {

See demo here: http://jsfiddle.net/9tbeo0qt/

In this code ang-alert is a directive whose behaviour is defined completely in the javascript code. so HTML is kept clean of any event handler. and the html code itself is self-explanatory. This way the programmer can cocentrate on the module he is developing i.e. either the UI or the javascript and the final product is a clean code. Which is the best thing about angularJS.

Here comes the benefits of using AngularJS in you code:

  • Code becomes cleaner and maintainable: Its sound MVC framework governs you a good coding standard to follow throughout your code, which was not given by some other framework like Backbone.js.
  • Code becomes self-explanatory: Even a non-technical person can understand the high level logic by going through the code if written properly.
  • Increased Reusability of components: The directives provide you a  way to make reusable components without any alteration most of the time.
  • Unit testing becomes easy: If you use a Directives, many times in you application, a bug found in one section for the directive code, needs to be fixed only once, and the bug will be fixed in all the places wherever the directive is used
  • It provides the control for animation: Setting css animation rules on the classes that get applied on the DOM elements while transition happens for the rule set by the directives, you can achieve animation easily. For more check AngularJS animation documentation.

If this made you like angularJS, please read more on https://docs.angularjs.org/api. There are lot more in this magical framework.


Using jsFiddle with AngularJS


AngularJS is an awesome framework and its google group is very active. AngularJS community figured out quite early that it is so much easier to collaborate having a live code snippet.

There are many code snippet sharing tools out there but the jsfiddle is great and is used very often by the AngularJS community.

This post tries to dive into several usage scenarios of jsfiddle with AngularJS framework. The aim here is to make sure that people can quickly and easily prepare their jsfiddle which is crucial for getting help from  the AngularJS community.

Start safe

The easiest way to have a working jsfiddle with AngularJS is to start from a template prepared by the AngularJS team: http://jsfiddle.net/IgorMinar/ADukg/. The jsfiddle under this URL is updated with each release so you can just bookmark it and use it a starting point for your fiddles.

One remark: when using http://jsfiddle.net/IgorMinar/ADukg/as a stating point make sure to fork it instead of editing the original one.

View original post 797 more words

When is AngularJS Superior to jQuery?

angular-over-jqueryOne of the most common questions asked by neophyte web developers is “Which framework should I use?” While there is no one ‘right’ answer to this question, a common subject of discussion is the differences between AngularJS and jQuery. While in some respects comparing the two is akin to comparing apples and oranges, there are undoubtedly reasons to choose one web framework over the other as the primary implementation target for a web application’s front-end. Below we will look at a few scenarios where AngularJS is a superior choice to jQuery.

When DOM Manipulation Isn’t a Priority

jQuery is highly focused on DOM scanning and manipulation for achieving its goals. A common practice is adding and modifying DOM elements based upon user interactions, such as presenting the results of a query retrieved over AJAX by simply placing pre-rendered HTML into an existing DIV. With AngularJS, the focus of development is on the data presentation itself. Through use of two-way data binding, these kinds of updates can be achieved automatically without destroying and rebuilding the DOM. It may not be entirely possible to avoid DOM manipulation, but on average you will be doing less of it with AngularJS than you would with a pure jQuery implementation.

When Focused on Productivity

AngularJS, despite having a steep learning curve, has a high focus on the productivity of its developers. Many of the features of AngularJS are focused on increasing developer throughput. One example is extensive support for unit testing built-in to the framework. This focus on testing allows developers to focus on processes that produce more robust and dependable code by easing the development of unit tests. Additionally, by decoupling the DOM manipulation from the logic of the application, developers can focus on the “why” rather than the “how”. On average, this results in a smaller code base with improved stability and easier debugging.

When Taking Advantage of a Declarative Interface

One of the common issues with jQuery is that it takes an imperative approach to programming. In essence, it is telling the computer how to achieve a certain goal, and what you want is the result of that process. Declarative programming, on the other hand, switches the focus – it tells the machine what you want, and lets it figure out how to make that happen. JavaScript in general is designed with an imperative approach in mind, while HTML – and the directives that AngularJS add to it – is designed to be declarative. By working in AngularJS, you end up using a declarative approach that more closely matches the original intention of HTML – telling the computer what you want the presentation to look like, and then letting the computer handle the details. With this approach, the lines of code required to accomplish a specific task are often greatly reduced, resulting in more readable and maintainable code.


As mentioned above, comparing AngularJS and jQuery is in many ways comparing apples and oranges. The two frameworks were created with different goals in mind, and solve separate problems. That being said, there are many gains to be made in terms of programmer throughput for a certain subset of applications that focus on data presentation and manipulation as opposed to data analysis, and in that realm AngularJS has a large advantage over jQuery. Ultimately choosing a framework comes down to a number of factors related to your organizational strengths and the core competencies of the tool itself, but in many ways AngularJS is an excellent choice for enhancing developer throughput and reducing maintenance costs for your web application.

From: http://blog.backand.com/

10 Bad Habits That Are Killing Your Productivity

Being productive isn’t easy, regardless of how badly you’d like to be and how hard you think you’re willing to work. But increasing your output at work and in life is a much more attainable goal if you’re not sabotaging yourself with bad habits.
Here are 10 things you should stop doing right now:
1. Impulsive web browsing: Since most of us work with access to the internet, it’s easy to get side-tracked looking up the answer to a random question that just popped into your head.
That’s why Quora user Suresh Rathinam recommends writing down these thoughts or questions on a notepad. This way, you can look up the information you want later, when you’re not trying to get work done.
2. Moral licensing: Whether it’s a new diet, workout routine, or work schedule, one of the most difficult things about forming a new habit is the urge to cheat as a reward for sticking to a routine for a while. This idea that we “deserve” to splurge on fancy meal after being thrifty for a week is called “moral licensing,” and it undermines a lot of people’s plans for self-improvement
Instead, try making your goal part of your identity, such that you think of yourself as the kind of person who saves money or works out regularly, rather than as someone who is working against their own will to do something new.
3. Putting off your most important work until later in the day:People often start off their day by completing easy tasks to get themselves rolling and leave their more difficult work for later. This is a bad idea, and one that frequently leads to the important work not getting done at all.
As researchers have found, people have a limited amount of willpowerthat decreases throughout the day. That being the case, it’s best to get your hardest, most important tasks done at the beginning of the day.
4. Taking many meetings: Nothing disrupts the flow of productivity like an unnecessary meeting. And with tools like email, instant messenger, and video chat at your fingertips, it’s best to only use meetings for introductions and serious discussions that can only be held in person.
BlueGrace Logistics founder Bobby Harris recommends that people don’t accept a meeting unless the person who requested it has put forth a clear agenda and stated exactly how much time they will need. And even then, Harris recommends giving the person half of the time they initially requested.
5. Multi-tasking: While many people believe they are great at doing two things at once, scientific research has found that just 2% of the populationis capable of effectively multi-tasking.
For the rest of us, multi-tasking is a bad habit that decreases our attention spans and makes us less productive in the long run.
6. Hitting the snooze button: It might feel like pressing the snooze button in the morning gives you a little bit of extra rest to start your day, but the truth is that it does more harm than good.
That’s because when you first wake up, your endocrine system begins to release alertness hormones to get you ready for the day. By going back to sleep, you’re slowing down this process. Plus, nine minutes doesn’t give your body time to get the restorative, deep sleep it needs.
7. Failing to prioritize: It’s only natural for people to hedge against failure by keeping their options open and trying to pursue a bunch of different goals simultaneously. Take, for instance, the person who is five years into a career in marketing, but preparing themself for law school just in case. Unfortunately, this sort of wavering can be extremely unproductive.
Warren Buffett has the perfect antidote. Seeing that his personal pilot was not accomplishing his life goals, Buffett asked him to make a list of 25 things he wanted to get done before he died. But rather than taking little steps toward completing every one of them, Buffett advised the pilot to pick five things he thought were most important and ignore the rest.
8. Over-planning: Many ambitious and organized people try to maximize their productivity by meticulously planning out every hour of their day. Unfortunately, things don’t always go as planned, and a sick child or unexpected assignment can throw a wrench into their entire day.
Instead, you might want to try planning just four or five hours of real work each day, that way you’re able to be flexible later on.
9. Under-planning: With that being said, you should take time to strategize before attempting to achieve any long-term goal. Trying to come up with the endgame of a project you’re doing midway through the process can be extremely frustrating and waste a huge amount of time.
Harvard lecturer Dr. Robert Pozen recommends that you first determine what you want your final outcome to be, then lay out a series of steps for yourself. Once you’re halfway through, you can review your work to make sure you’re on track and adjust accordingly.
10. Keeping your phone next to your bed: The LED screens of our smartphones, tablets, and laptops give off what is called blue light, which studies have shown can damage vision and suppress production of melatonin, a hormone that helps regulate the sleep cycle.