Skip to content

Instantly share code, notes, and snippets.

View waldothedeveloper's full-sized avatar
Never give up!

Waldo Lavaut waldothedeveloper

Never give up!
View GitHub Profile
waldothedeveloper / repl_game.rb
Created July 11, 2017 16:38
Purrfect Insane Cats
View repl_game.rb
# Title and Rules of the Game
puts "Welcome to the Purrfect Game of Insane Cats =ˆ.ˆ= "
puts "Rule 1: Choose your cat"
puts "Rule 2: Type A or B only to select an option"
puts "Ready? Here we go"
# Starting the actual game
puts "Choose your cat (Type just the name):"
puts "Vivaldi =ˆ.ˆ="
puts "Adele =ˆ.ˆ="
waldothedeveloper / bank_account.rb
Last active July 17, 2017 19:12
Bank Account HM
View bank_account.rb
class BankAccount
attr_reader :balance
@@minimum_balance = 200
def initialize(opening_balance, account_holder)
raise ArgumentError if opening_balance < @@minimum_balance
@balance = opening_balance
def deposit amount
waldothedeveloper / url_parser.rb
Last active July 18, 2017 01:13
URL_PARSER homework
View url_parser.rb
class UrlParser
def initialize(new_url)
@new_url = new_url
def scheme
View index.html
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/script.js"></script>
waldothedeveloper / filters.markdown
Created August 10, 2017 20:38 — forked from jcasimir/filters.markdown
Controller Filters
View filters.markdown

Controller Filters

The Rails REST implementation dictates the default seven actions for your controllers, but frequently we want to share functionality across multiple actions or even across controllers. Controller filters are the easiest way to do that.

Before, After, and Around

There are three types of filters implemented in Rails:

  • a before_filter runs before the controller action
  • an after_filter runs after the controller action
View dry_controller.rb
class UsersController < ApplicationController
after_action :notify_slack, only: [:create, :update, :destroy]
before_action :set_user, only: [:show, :edit, :update, :destroy]
def index
@users = User.all
def show
View gist:d08320a8033327c33dcf9764ada688b3

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
waldothedeveloper / app.js
Created May 17, 2018 22:29
FreeCodeCamp Random Quotes App
View app.js
$(document).ready(() => {
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());`${quote}`);
let endpoint = '';
waldothedeveloper / index.html
Created May 18, 2018 11:36
The HTML file for this challenge
View index.html
<!doctype html>
<html lang="en">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"