I love to share what I learn from my dat to day work experiences. My technical experience goes from languages like Ruby on Rails to front-end frameworks like Next.js to DevOps.
Below are the categories where I’ve tried contributing to the Open Source community.
- Amazon Web Services (2)
- Elastic Beanstalk (2)
- Elasticsearch (1)
- iOS (3)
- Languages & Frameworks (13)
- Lifestyle (2)
- MySQL (4)
- PHP (4)
- Ruby (10)
- Ruby On Rails (45)
- Web Server (1)
Below are some of my recent articles
MailChimp API reference guide – Part I of III
Hello Folks, In this introductory article I will walk you through the steps on how to Add your contacts to MailChimp I am not going to elaborate / explain about MailChimp here. I am assuming you have basic knowledge about MailChimp (What it does, Why you need it etc.) and you would like to explore / integrate MailChimp to your project. In the second part of this article, we will see how to: In the…
Connect to Box Explorer Component using Ruby on Rails
Hello Everyone, The target audience of this post is limited. In this article of mine, I will write down the steps of how you can connect with Box Explorer Component to allow users to upload file into your Box account. Requirement: We want to allow our users to upload file to somewhere in the cloud where we (me and my team) can see the files and take further actions on it There are many solutions…
[Rails 6] Using bootstrap with Asset Pipeline or Webpacker
I am working on a sample POC in Rails 6 and came across various articles that shows how can we use bootstrap with Webpacker and host all the js, css and images under /app/javascript folder (Whether we are using app like JS or not). I am not using this Rails 6 PoC for any JS frameworks (like React) for now. This is my simple web application and I would like to have my javascripts remain…
Requests that take more than 60s to complete fails – ElasticBeanstalk
This short post specifically targets: – RoR as web development environment – Can be ignored as this is closely related to nginx configuration settings – Nginx as web server While working with ElasticBeanstalk environments, one of my requirement was to send a heavy job to Worker App that takes > 1 min (60 seconds) to complete and I had no configuration in place. The way beanstalk-app was handling that job was disappointing. That job never…
Configure Delayed Job with Elastic Beanstalk
Recently, I got a chance to work with Elastic Beanstalk and trust me, it is not as friendly as Heroku and it took me a little while to get used to with Beanstalk deployments. I am using delayed_job in my project and the requirement was very simple, i.e. to automate background jobs. On heroku we simply add a worker dyno and jobs start working immediately. But, same is not the case with Beanstalk. I came…
[Ruby]: Update hash values with Array
Hi Folks, In this small tutorial, I am writing a program that updates value of each element in hash with a given array values. Given that: h = { h1: ‘value1’, h2: ‘value2’, h3: ‘value3’, h4: ‘value4’ } a = [ ‘1’, ‘2’, ‘3’, ‘4’ ] Where h is a Hash and a is an Array Output we would like to achieve here is: h = { h1: ‘value1_1’, h2: ‘value2_2’, h3: ‘value3_3’, h4: ‘value4_4’…
Learning RSPEC with Rails 4 (Alpha)
Hi Folks, Hope you all are fine and doing good! I am sure most of you, are using TDD for years now. And, once we think of TDD, the first thing comes into our mind is, RSPEC. We all agree that Rspec is a great framework of Test-Driven-Development and its integration with other libraries (like fixtures etc.) is seamless. With rapid revolution happening in Rails community, Rspec too has evolved over the years, and my motto…
[Ruby] Fetching Emails from Microsoft Outlook
Hi Folks, Hope everyone is fine and doing good. In this article of mine, I am going to narrate, how you can fetch Emails from your Microsoft Outlook account. I am only going to cover ‘Inbox’ here. However, the scope of library (Gem) is very vast and you can customize this as per your need. PREREQUISITE: Ruby ViewPoint Gem: gem install viewpoint For Debugging, I am using viewpoint/logging/config https://gist.github.com/puneetpandey/26035213128e5bc535dc Hope this helps someone! Keep in…
Rails 4: Changeset
Hey Everyone, I know, I am very late in posting this article, as I didn’t get chance to do much hands-on in Rails 4. But now, that we all are on the same page, let me quickly set the summary here. Most of us (1) have already started with Rails4, most of them (2) are planning to and most of them (3) are still on Rails 3. So my target audience for this post is…
Kick-Off: First Rails 4 Application with HABTM Association
Hello Folks, Its been a long time since I’ve not written a post. Now, I realize that it’s time to share some useful snippet with all of you. Recently, I got a chance to get my hands cleaned with Rails 4. So much is happening around Rails community and with the rapid development of Rails 4, I was finding it bit difficult to keep my momentum going. Well, leave all this apart. Now, by putting…
Add duplicate rows in Excel using Ruby
Happy New Year Folks, Few days back a friend of mine came to me and said, “I am a RUBY Programmer and I am stuck in a requirement, wherein I have to read an excel-sheet (that contains multiple records and each record can have multiple entries in it.)” Think of an example like given in the link: timesheet. It says we have 2 columns: EmployeeID and WorkingHours. Each EmployeeID can have multiple working hours. Now, I…
Installing mysql2 gem with Ruby 2.0
Hi Folks, In this short tutorial of mine, I am going to write down the steps of how you can install mysql2 gem with Ruby2.0 on Windows machine. Installing Mysql gem is always a big time pain for most of the developers who are working on Windows machine. But thanks to active folks over the internet for their comments, posts. Prerequisites: 1. Ruby 2.0.0 pre-installed. 2. DevKit installed 3. gem install rails – command should…
Ruby Cheat-Sheet
Hi Folks, In this new tutorial, I am going to show you what most of developers/programmers already know, but not able to keep track of such things. I call it as ‘Ruby cheat-sheet’, you can call it by the name you like. This will also help those people who have just started learning ‘Ruby’. IMPORTANT NOTE: I will keep on updating this article frequently. Also need your valuable response, if you feel there is a…
Rails 3: Polymorphic Associations in Action
Hi Folks, In this short article, I would like to brief about “Rails polymorphic associations”. Below are the high-level pointers. What is Polymorphic Association How Rails handles it Example explained Demo So, Let’s start: What is Polymorphic Association: In OOP, Polymorphic means “of-many”. There is a well documented and well explained Railscasts for this. Refer to this link for more information: http://railscasts.com/episodes/154-polymorphic-association Example Explained: https://gist.github.com/puneetpandey/2810beadd5b888d3f80a Code snippet can be downloaded from Github. The path for…
Rails 3: Single Table Inheritance
Hi Folks/Fellow Developers, As I’ve seen lot many examples, articles over Single Table Inheritance, I decided to write my own. Thanks to the open source contributors. Their Articles/Examples helped me a lot writing this post. As you might know about single table inheritance, let me quickly set the definition for it. Single-Table-Inheritance (STI) allows you to write/create sub-classes of a specific model. You can use a single table, add specific objects and extend the functionality/behavior…
How to index multiple documents with Solr
Hi Folks, Hope you all are fine and doing good. Few weeks back, I was looking into solr to see if it index multiple attachments! The requirement was very simple: A user will upload multiple files and solr will index those. I tried finding the solutions on the internet but found very basic ones. Now, I am sharing my experience with you all with some code snippet, which will tell how to index multiple documents/attachments with…
FREEZE GEMS IN RAILS 3 APPLICATION
I have seen lots of forum, where developers keep on asking: “How would I freeze the gems to my Rails-3 application?” Take this URL for example: http://bit.ly/gFzN6Z One developer says that: localize your gems by running this command: bundle install –vendor/gems Others refuses to go with this way. Here’s why? We are moving away from the concepts of bundler This will install the gem dependencies as well in your vendor/gems directory, which we don’t need at…
CUSTOM VALIDATION IN PAPERCLIP
In this short tutorial, I will explain you how you can add custom validation messages on the Attachment if you’re using Paperclip plugin or gem. Way 1. This will work if you’re running your rails application on Windows Machine. Solution: a) install mimetype-fu plugin. b) Once installed, open Model, where paperclip settings has been defined. In my case, its User Model. Open it and add: has_attached_file :avatar validate :prohibited_ext protected def prohibited_ext errors.add(:avatar, “Format #{File.mime_type?(avatar.path)} is invalid!”) unless File.mime_type?(avatar.path) == “application/exe”…
UPGRADE RAILS PERFORMANCE
In this article, we will try to Enhance our rails application performance. To know, how is your rails application is performing on different environments, you must need some plugin or gem. There are many gems/plugins already available which you can use and analyze the performance. First of all, I would like to list down those, which I will cover in my next tutorials. New Relic Rack Bug Rails Log Analyzer Ruby Prof Once you configure anyone of those,…
JOINS IN SQL
Sometimes, its very hard to keep Joins concept in mind.. Being a beginner, experienced SQL programmer, you should know the concept of JOINS. In this article, I will show you the difference between: 1. JOINS and INCLUDE 2. How to you use JOINS in rails 3. JOINS over INCLUDE 4. JOINS and INCLUDE in RAILS-3 Let’s cover them in detail: What is Join ? The SQL JOIN clause is used whenever we have to select data from 2 or more tables.…
SEND TWEETS FROM RAILS APPLICATION
So, we’re continuing from here: https://techprincipal.wordpress.com/2009/08/12/send-tweets-fr…ls-application/ So far we’ve covered the basics of it, now its time to create some controllers…. Open your command/terminal and fire this command: ruby script/generate controller twitt Once you’re done, open this file and write the below code inside it: class TwittController < ApplicationController gem(‘twitter4r’, ‘>=0.2.0′) require ‘twitter’ require ‘twitter_search’ require ‘rubygems’ before_filter :authorize, :except => [:login, :authenticate, :save_users, :twitter_cred] def login @user = User.new end def authenticate @user = User.new(params[:user])…
INTEGRATE ORACLE WITH RUBY
Since most of the rails application is now using various databases, this article will show you how you can useORACLE database with rails. For that, we need Oracle XE I will update this post as soon as I can…. Apologize for the dealy. However, you can mail me any of your query if you are stuck in configuring Oracle with Rails.
INTEGRATING CUCUMBER & RPSEC WITH RAILS
Hi Guys, In this article I will cover how to use cucumber and Factory Girl to write Stories in Rails. TDD(Test Driven Development) is the most powerful and most approachable concept in most of the programming language. When it comes to rails, it provides a convenient and simplest way to writeUnit test cases and the stories for your controller, without writing complex lines of code. Let’s see how you can cover the test coverage for your rails application. IMPORTANT: The concept behind using cucumber, so…
WHAT IS MONGO-DB
What is MongoDB? I saw many forums, visited many blogs, people/programmers are talking about MongoDB a lot. I was wondering what this is! Why developers are showing more and more interest in this. I started searching around and now sharing with all of you, who are not friendly with MongoDB or who’re familiar but don’t know how to work on it. First of all let’s define mongoDB in terms of technical aspect a) MongoDB has…
DON’T HESITATE TO TRY OUT NEW THINGS IN RUBY
Since last couple of months, I was trying installing Rails-3 on my Windows PC. When I heard, that Rails-3 requires ruby-1.8.7 or higher, I instantly removed Ruby-1.8.6 and all its components and installed 1.8.7 from the fresh point. I was happy, as my new system has Rails-3 now… Wow, what else I need? But later, I found that my few of my old applications, which requires ruby-1.8.6 have stopped working. WTH!! Can’t it work with Ruby-1.8.7 now? With the…
JQUERY ON RAILS3 AUTO SELECT
In earlier post of mine, we have seen, how to implement “Auto Select”, with the help of Prototype and Rails. Now, that Rails-3 has been released, lot of changes are already made. In-built support for Prototype has been removed. Still if you wish to use prototype, all you need is to install its gem. Here, I am covering the same example: – Select ‘Country’ from the first drop down. – Second drop down will populate the list of ‘States’. If you select…
A NEW WAY OF INSTALLING PIK ON WINDOWS
Hi Guys, In my previous article, Don’t hesitate to try out new things in Ruby on Rails, you got to know, how to install and configure pik to support multiple versions of Ruby on Windows. In this article, I will add another simpler way to install pik on windows and configuring it for multiple versions of ruby. For Devkit, you can follow the same old article. NOTE: I will go with Ruby192 and on that…
Learn Core Ruby Concepts
Hello Everyone, We all know basic concepts of Ruby, like classes, objects, methods etc. etc and we integrate this with the concept of rails beautifully. In short I can say we all are very good at Ruby on Rails, and rails specially, but when it comes to Ruby, we are not that much confident tough. In this Post of mine, we will cover all the important concepts of Ruby, some pure ruby code, and how…
Get Yourself Upto date with Ruby 1.9.2 and Rails 3
Hello Everyone, Today, where lots of people are shifting from older versions of ruby to the newer and stable one i.e 1.9.2 and rails 3. I am also shifting to this, and would like to share my thoughts and opinions about upgrading, its advantages, hurdles and future concerns. To try this.. I am using both Linux (Ubuntu) and Windows (windows 7). Let’s cover each topic in detail Setting up Ruby-1.9.2 What’s new in Ruby-1.9.2 Few…
Host Ruby on Rails Application on Heroku
Hello Everyone, In this article we will cover how to run your rails-2+/3 application on Heroku. Requirements: 1. Heroku Account (http://heroku.com/) 2, Github Account (http://github.com/) 3. Heroku Gem (gem install heroku) 4. msysgit 5. Latest version of Git Steps: Step 1: Download msysgit and run it. Once the installation is finished. Create your SSH Public key (if it has not created before.) Steps on creating SSH keys can be found here: Step 2: Once you’re…
