Skip to content

Instantly share code, notes, and snippets.


Arjun Venkataswamy arjunvenkat

View GitHub Profile
arjunvenkat / gist:1115bc41bf395a162084
Last active Jul 7, 2021
Seeding a Rails database with a CSV file
View gist:1115bc41bf395a162084

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.

arjunvenkat / scraper_lab_p2.rb
Created Dec 12, 2012
scrape multiple pages using Nokogiri and Mechanize
View scraper_lab_p2.rb
# nokogiri requires open-uri
require 'nokogiri'
require 'open-uri'
# csv will be used to export data
require 'csv'
require 'mechanize'
# pp is useful to display mechanize objects
require 'pp'
arjunvenkat /
Last active May 24, 2018 — forked from raghubetina/
CarrierWave Cheatsheet

CarrierWave Cheatsheet

The CarrierWave gem provides us with an easy way to allow file uploads through forms.


In your Gemfile, include

gem 'carrierwave'
arjunvenkat /
Created Apr 11, 2017
App Dev Troubleshooting notes

Week 3



  • Make sure students are running rails s in their app folder, not the app's parent folder
  • Make sure students test output variables after hitting submit, since the forms wont show any work from the controller
arjunvenkat /
Last active Feb 28, 2017
Creating Pull Requests
  1. Fork the repo that you're working on into your own account.
  2. Clone down the fork
  3. Create a new branch in the fork using git branch [branch_name] replacing [branch_name] with a short phrase describing the feature your'e working on
  4. Check the current status of your branches by using git branch. You should see all the branches you have access to. Your current branch will have an * next to it
  5. Check out the new branch using git checkout [branch_name]
  6. Make your changes in the code
  7. Add and commit your changes
  8. Pull down any changes from the original repo:
  9. Add the original repo as an upstream remote with git remote add upstream Make sure to use the actual owner and repository names.
  10. Pull changes into your branch from the upstream remote with git pull upstream master
arjunvenkat /
Last active Feb 28, 2017
Creating your own branchs

Creating and working with branches in Git

  1. Create a branch with git branch [your_branch_name]
  2. Checkout the branch with git checkout [your_branch_name]
  3. Publish your branch with git push origin [your_branch_name]
  4. Do some work, commit your changes
  5. When your branch is done, checkout master with git checkout master
  6. Pull down any changes from master with git pull
  7. Checkout your branch again and make sure it is up to date with master using git merge master
  8. If there are any conflicts, fix them. If not, you may need to exit the Vim text editor using :wq

Authentication and Authorization with Devise

We will be using the [Devise gem][2] to help us get started with authentication (are you who you say you are?) and authorization (are you allowed to do/see this?).

Add sign-in/sign-out

  • Add gem 'devise' to your Gemfile and bundle
  • rails g devise:install

Devise will give you some setup instructions. We don't need to worry about most of them, but we do need to set a root URL. Usually, you will point the root URL to the index action of some important resource in your application: In config/routes.rb:

arjunvenkat /
Last active Jul 25, 2016
the RCAV flow

Our apps are nothing more than a collection of URLs that we decide to allow users to access:


So remember: everything always starts with a route between a URL we want to support and a Ruby method that will be responsible for generating a response to the user's browser.

In order to support a URL in your app such as http://localhost:3000/signin, there are a lot of dots to connect!

arjunvenkat /
Last active May 15, 2016
Grading bash script for MBA courses
# edit the project name and any feature specs if they're being copied in
mkdir ${project_name}_grades
cd $project_name
for branch in $(git for-each-ref --format='%(refname)' refs/remotes/); do
echo $short_name
git add -A