Skip to content

Instantly share code, notes, and snippets.


Arjun Venkataswamy arjunvenkat

View GitHub Profile
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!


Git Guide

Cloning down a project

In your web browser, navigate to the project page that you want to clone down and copy the clone URL on the middle-right side of the project page. It should look something like

Then in terminal, navigate to the parent folder that you want to download the project into and and use the following command, replacing [project_url] with your project's URL:

git clone [project_url]
arjunvenkat / gist:1115bc41bf395a162084
Last active Jul 26, 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.


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 Aug 29, 2015
Basic Rails connections

The CRUD flow

Named route helpers

in the index page...

arjunvenkat / gist:089711002874018232b6
Created Mar 25, 2015
issues setting up API
View gist:089711002874018232b6

One thing I was confused about was what hostname meant in

ReplitClient(hostname, port, language, token)

I assumed it meant the host of my development/production server. I'm using Rails, which is hosted by default in development at localhost:3000. However, when I tried initializing a new client with:

var token = {
arjunvenkat / gist:6980815
Created Oct 14, 2013
Front-end Sublime Preferences
View gist:6980815
"auto_complete_commit_on_tab": true,
"auto_complete_with_fields": true,
"caret_style": "smooth",
"color_scheme": "Packages/Color Scheme - Default/Dawn.tmTheme",
"create_window_at_startup": false,
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,
arjunvenkat / gist:6980604
Created Oct 14, 2013
sublime package manager installation
View gist:6980604
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen(''+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
View gist:6771204
<p "I like things.">
<h1>My favorite things:<h1>
<li><h3>Evernote</h3><img src=""></li>
<h3>Louis C.K.</h2>
arjunvenkat / 0_reuse_code.js
Created Sep 30, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console