Skip to content

Instantly share code, notes, and snippets.

@raghubetina
raghubetina / credentials.md
Last active April 23, 2021 00:48
Hiding your credentials from GitHub

Hiding your credentials from GitHub

In many cases, we need to use secret information in our Ruby; most commonly, API keys and email account passwords.

You should never paste these strings directly into your Ruby code. There are bots that can and will steal your API keys the instant you push your code to a public GitHub repository. Even if you pay for private repositories, it's a good idea to not store secrets in your repo -- you may not want all of your collaborators (interns?) to know, for example, the API keys to your payment processor.

(If you have already pushed an API key to a public repository, you should sign into your API dashboard now and invalidate that old key, and get a new one. Assume that the old one has already been stolen. Reverting your commit will do no good.)

But if our Ruby needs to use these secrets, but we can't keep them in our code, what's the solution? Environment variables. We're going to use a gem called Figaro to make this easy.

@raghubetina
raghubetina / seeding.md
Last active December 8, 2020 15:45
Seeding your database

Seeding your database

It is very helpful to take the time to pre-populate your database with some dummy data before you start working on any features. It's nice to have some data to look at to see whether you are going down the right path.

It's also very helpful to other developers on the project, so they can get started quickly right after they clone.

Here are two ways to create seed data:

Manually + seed_dump

@raghubetina
raghubetina / management_readings.md
Last active December 25, 2017 20:55
A few readings on managing software products

A few readings on managing software products

Workflows

A very powerful Git flow

This is behind a paywall (but there's a trial period). It's very low-level and tactical, so probably hard to understand right now; but you should refer developers that you work with to it, and they should either have a flow similar to this one, or good reasons for using something different:

https://thoughtbot.com/upcase/videos/git-thoughtbot-git-flow

@raghubetina
raghubetina / design.md
Last active December 25, 2017 20:52
HTML, CSS, & Design Resources

Everything I Know About Front-End In One Handy List

As you go about designing and coding your application's screens, here are a few resources that you may find useful. In rough order of importance/handiness (in my experience).

Design

  • [Butterick's Typography In Ten Minutes][1] - A ten minute read that is guaranteed to make your content look better.
  • [Google Web Fonts][2] - You'll want this after reading Butterick's.
  • [Beautiful Web Type][3] and [Typographic Project][4] - A curated showcase of Google Web Fonts.
  • [Stock Up][6] - A search engine for free stock photos.
@raghubetina
raghubetina / dates.md
Last active March 21, 2019 19:49
Dates Cheatsheet

Dates Cheatsheet

In this guide, I'll show you how I prefer to handle dates.

We'll

  1. use a gem called Chronic to intelligently parse a wide variety of user input into valid Dates,
  2. I'll also show you a gem that helps create nice looking datepicker controls,
  3. look at some built-in Ruby/Rails methods that help us format dates and times nicely for our users to look at.
@raghubetina
raghubetina / carrierwave.md
Last active December 6, 2018 13:15
CarrierWave Cheatsheet

CarrierWave Cheatsheet

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

Installation

In your Gemfile, include

gem 'carrierwave'
@raghubetina
raghubetina / activeadmin.md
Last active April 5, 2020 12:56
ActiveAdmin Cheatsheet

ActiveAdmin Cheatsheet

The ActiveAdmin gem provides us with a entirely separate administrative sub-site. It's amazingly full-featured out of the box, and also is extremely customizable.

Installation

In your Gemfile, include

gem 'activeadmin', '~> 1.0.0.pre4'
@raghubetina
raghubetina / ransack.md
Last active May 31, 2024 16:36
Ransack Cheatsheet

Ransack Cheatsheet

The Ransack gem provides us with a powerful, flexible, easy-to-integrate search/filter form.

Installation

In your Gemfile, include

gem 'ransack'
@arjunvenkat
arjunvenkat / gist:1115bc41bf395a162084
Last active January 12, 2024 05:04
Seeding a Rails database with a CSV file

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.

@raghubetina
raghubetina / rcav.md
Last active December 25, 2017 20:53
RCAV Flowchart

RCAV Flowchart

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

  • mydomain.com/products
  • mydomain.com/photos/193
  • mydomain.com/signin

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.