Regex useful tricks with Lookahead and Lookbehind

Lookahead and Lookbehind in regex : Lookahead and lookbehind, collectively called “lookaround” is a very useful concept at times which would be otherwise next to impossible to solve by any other means. Found a great article explaining the cases where we can use this: Regex – Lookahead and Lookbehind Zero-Length Assertions

Few useful bits to understand the concept :

Related image

Image result for lookahead and lookbehind in regex

Image result for lookahead and lookbehind in regex

Advertisements

%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


%Q
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!"""


%q
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.

Web Technology Guide By Gurudath BN

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

Gigaom

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

Using jsFiddle with AngularJS

pkozlowski.opensource

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

Updated: Virgin Galactic’s SpaceShipTwo space plane crashes with two pilots on board, one killed

Gigaom

Virgin Galactic‘s SpaceShipTwo crashed during a test flight today over the Mojave Desert of Southern California, resulting in its destruction. One pilot is dead and another seriously injured, officials confirmed at a press conference Friday afternoon.

An ABC report showed the plane in pieces on the ground.

“Space is hard and today was a tough day,” Virgin Galactic CEO George Whitesides said at the press conference. “We are going to be supporting the investigation as we figure out what happened today, and we’re going to get through it. The future rests in many ways on hard days like this. But we…

View original post 581 more words

Google Drive storage goes unlimited for Education users

Gigaom

Suggesting that educators and students shouldn’t have to worry about the technology that helps them teach and learn, Google introduced Drive for Education on Tuesday. In the coming weeks, all [company]Google[/company] Apps for Education users will gain unlimited data storage on Google Drive, although single files are limited to 5 terabytes in size. Also included with Drive for Education is free access to the Google Apps Vault, used for email compliance, and enhanced auditing for file activity. The company also stressed that data stored in Drive for Education is encrypted and private, saying: “As always, the data that schools and students put into our systems is theirs.”

View original post