Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / location.html
Created June 8, 2016 15:50
Using HTML5 Location
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Location Example</title>
<!-- jQuery (included in Rails out of the box) -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
</head>
@raghubetina
raghubetina / lti_rails_engine_template.rb
Created July 15, 2016 14:00 — forked from coderberry/lti_rails_engine_template.rb
Rails template for creating LTI apps (as mountable rails engines)
# rails plugin new my_lti_app -T --mountable --dummy-path=spec/test_app -m URL_TO_THIS_RAW_GIST
def ask_wizard(question)
ask "\033[1m\033[30m\033[46m" + "prompt".rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m"
end
def yes_wizard?(question)
answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
case answer.downcase
when "yes", "y"
@raghubetina
raghubetina / windows_fixes.md
Last active December 7, 2016 21:19
First Draft Windows Fixes

Windows Fixes

Unfortunately with the recent releases of Rails 5 and Windows 10, and with RailsInstaller falling behind on updates, we need to take a few steps to fix some annoying incompatibilities once and for all.

First of all, the very first time you bundle for an app, remember to use the verbose command bundle install --without production instead.

SSL Errors

If you are experiencing one of the following issues:

@raghubetina
raghubetina / very_best_user_stories.md
Created January 4, 2017 20:22
Very Best User Stories

Very Best User Stories

As a user, I should be able to...

On the Dishes page

  • See the bucket list of dishes
  • See which venue I have bookmarked for each dish, or choose one if I haven't
  • Filter dishes by cuisine
  • Search dishes by name
@raghubetina
raghubetina / web_console_bug.md
Last active January 23, 2017 00:35
Web Console Live Reloading Bug

If, as you’re working on Omnicalc, you are running in to a very confusing issue:

You have made changes to your code in calculations_controller.rb in Atom, (auto)saved it, gone back to Chrome, and refreshed — but nothing happens!

Then read on.

The Problem

As I mentioned in class, this quarter we were trying something new with the interactive Ruby console appearing within Chrome.

@raghubetina
raghubetina / dsgn425_waiver.md
Last active February 7, 2020 22:37
Should I waive DDII?

Should I waive DDDII?

So you've done some programming in the past, and are wondering whether you should waive DDDII.

Here are some reasons that students in the past have still found it worthwhile:

  • A primary focus of the course is familiarizing future managers with modern software development workflows, mostly centering around GitHub: version control, pull requests, code reviews, continuous integration, automated deployment, project management, etc. If you don't already have a solid process in place, then it might be worth seeing this one.
  • If you haven't built full-stack applications in the past, particularly with Ruby on Rails — it's just a joy. In the past, students who already knew how to program but had never done full-stack applications from soup to nuts got even more out of the class than beginners, because agile web development with Rails is like a superpower.
  • You're welcome to outpace the rest of the class and work on your own advanced projects, with guidance from me and the TAs.
1, Create a new public blank workspace
2, Enable AutoSave in Preferences -> Auto-Save
3, Install formathtmlerb
- Install gem install htmlbeautifier
4, Install Rubysnippets
5, Install formatruby
- Install gem install formatruby
5, Manually install manual
https://github.com/wting/autojump
6, Add railsrc