Posts

How to create Safe mailto links using JQuery

Here is a small piece of code that you can use to create safe mailto (spam emails free) links in your web application, Firstly you need to create a link which is in the example below <a href="info[at]example[dot]com"></a> <a href="info[at]example[dot]com">Custom Text</a>   As you can see, we have replaced @ with [at] and . with [dot], Now we will use JQuery to loop through all the links and do the exact opposite. $(document).ready(function() { $('a[href*="[at]"][href*="[dot]"]').each(function() { var addr = $(this).attr('href').split('[at]').join('@').split('[dot]').join('.'); $(this).attr('href', 'mailto:' + addr.toLowerCase()); if ($(this).text().length == 0) $(this).text(addr); }); });   This JQuery code will generate the following links. <a href="mailto:info@example.com">info@example.com</a>   <...

Git Visual Cheat Sheet

Image
Reference : https://github.com/nerdgirl/git-cheatsheet-visual

Gems for Development Group

Here are the list of gems which you can use in your development machine or inside the development group in your gemfile, Basically these gems helps to make things faster and bring simplicity to the development process. gem 'debugger' gem "better_errors" gem "binding_of_caller" gem 'annotate' gem 'rails-footnotes' gem 'rails_best_practices' gem 'bullet' gem 'flay' gem 'pry' gem 'pry-doc' gem 'quiet_assets' gem 'rack-mini-profiler' gem 'railroady' gem 'reek' gem 'request-log-analyzer' gem 'smusher' gem 'hirb' gem 'localtunnel' gem 'lol_dba' gem 'mailcatcher' gem 'meta_request','0.2.1' Other then the above mentioned gems there is one gem which you must have gem install zeus You don't need to mention this inside your Gemfile, This really helps to improve the deve...

How to Handle OAuth::Unauthorized error for Omniauth provider?

Add this piece of code in your initializer file Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, twitter_consumer_key, twitter_consumer_secret end OmniAuth.config.on_failure = Proc.new { |env| OmniAuth::FailureEndpoint.new(env).redirect_to_failure } This will redirect user to the failure page, instead of showing an error.

Rake Routes for a Single Controller

You can list routes in your Rails application with: rake routes If in-case you were looking for some specific route and grep doesn't solve your problems rake routes | grep 'users' Here is a tip which you can try rake routes CONTROLLER=controller_name

Handling JavaScript Confirm in Selenium and Capybara

page.driver.browser.switch_to.alert.accept This will accept the confirm box.

Public wildcard domain name that resolves to IP address 127.0.0.1

These are the various options for the public wildcard domain, It's good for testing sub-domains on localhost. So we don't need to make any sort of changes in hosts file. lvh.me 42foo.com smackaho.st