Avoid Username and password while pushing git commits.

Avoid git prompt for password Locate the file ~/.netrc on linux based system (generally its hidden file in Home folder). Add following details in this file for github. machine github.com    login < username >    password < password > and save it On next git pull, git push, it will not prompt for username/password. Attached sample ~/.netrc file

Reek Gem

Reek gem is a code smell detector for ruby. It examines Ruby classes, modules, methods and reports any code smells it finds. To install this gem, use: gem install reek USAGE: 1/ Scan the current directory: <pre>$ reek .</pre> 2/ scan specific directories like: <pre>$ reek lib/your/files</pre> To read more about reek gem click here(reek doc) To find up to date details of what exactly reek will check in your code check this(reek wiki)

Draw architectural design of the project using "railroady" gem

As a developer no one likes to write a complete documentation for a project. Butsometime we have to give some document which explain at least our architectural design of project. If in future anyone else work on same project then he can easily understand the overview and business logic before look into the code.We should draw a simple architectural design of our project models, controller and their relationship. There is a gem which provides all necessary diagrams - add it into development group. gem 'railroady' System Requirements $ sudo apt-get install graphviz run $ rake diagram:all It generates all diagrams

Use syntax_fix gem to change old ruby hash style

Change old Ruby 1.8 hash syntax to new one in Rails app. syntax_fix gem changes the hash style from ':key => "value"' to 'key: "value"' Put this line in your Gemfile: gem 'syntax_fix' syntax_fix This command will check and rewrite all files with the new syntax. options: v <-- be verbose about the actions p [PATH] <-- specify the relative path to start actions from Reference: https://github.com/HeeL/syntax_fix

Check Unused CSS Code.

Dust-Me Selectors - Firefox plugin for checking unused css code. We can simply right click on page and do 'Spider this page'. It allows to view Unused selectors on the page. Download link: https://addons.mozilla.org/en-us/firefox/addon/dust-me-selectors/ More Info: http://www.pontikis.net/blog/remove-unused-css

Download or Export excel records from active admin

activeadmin-axlsx gem [activeadmin-axlsx][1] gem is very useful to download or export excel records from active admin. It provides "XLSX" links to download Active Admin resources. We can use this gem by include this line in gem file: gem 'activeadmin-axlsx' then run: bundle install Now all resources of active admin index page include a 'XLSX' link. There is some example to customize 'activeadmin-axlsx'. Remove unnecessary column: app/admin/orders.rb ActiveAdmin.register Order do config.xlsx_builder.delete_columns :created_at, :updated_at end Change the style of column header: app/admin/orders.rb ActiveAdmin.register Order do

Quick Tips for Programming

I thought to create a quick tip post which is kind of lesson learnt, so that every time I learn something can add here and which could help others too. These examples here are not something I have created to support the points which I have mentioned below. Whereas these are the real code snippets of a project. Where team has written code in this manner and given feedback to improve their code. So I thought it would be better if I write a Lesson learnt post which could help other to be aware of mistake they can make while

Git aliases and load it through a file in to terminal

Git Aliases and set it up in UNIX I have created a list of git aliases that can be used in our day to day work. Most of us might have configured this. But I have listed few more aliases that are normally not used. like 'ggr' # Add and Removes alias "ga"='git add' alias "gai"='git add -i' alias 'grm'='git rm' alias 'gra'='git remote add' alias "grr"='git remote rm' # Commit and Pushes alias "gcm"='git commit -m' alias "gca"='git commit -am' alias "gp"='git push' alias "gpu"='git pull' alias "gpo"='git push origin' alias

Example usage of Redis - LUA script in Rails

This topic is about using Redis and LUA script in Rails. Before proceeding, you may like to read [ Introduction to LUA script with Redis][1] Redis doesn't have any command to calculate total number of keys We'll use [zrangebyscore][2] to find number of members between index range. Instal [redis-rb][3] Start rails console Prepare a dataset based on timestamp > t10 = 10.minutes.ago => 1386935151 > t20 = 20.minutes.ago => 1386934568 > t30 = 30.minutes.ago => 1386933971 > t40 = 40.minutes.ago => 1386933374 This is non-realistic data, may vary for you. Populate redis with Sorted Set > redis = Redis.new # initialize redis => # zadd -

Introduction to LUA script with Redis

What is Redis ? We all might be familiar with [Redis][1] . For those who are not - It's a "NoSQL" key-value data store. More precisely, it is a data structure server. To read more - [Redis-Wiki][2] Do [try redis][3] it has a nice interactive tutorial. To install and setup redis on your machine see [how-to-install-and-use-redis][4] What is LUA ? LUA is an embeddable scripting language. About LUA - http://www.lua.org/about.html Redis >= 2.6 supports embedded scripting language. Lets give a try to it. To run a script in redis we need