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
waldothedeveloper / app.js
Created May 18, 2018 12:09
The full javascript file about the freecodecamp quote app
$(document).ready(() => {
console.log('ready!');
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());
window.open(`https://twitter.com/intent/tweet?text=${quote}`);
});
let endpoint = 'https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?';
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:06
Creating a tweetQuote function to tweet a quote
$(document).ready(() => {
//Create a tweet function
function tweetQuote() {
window.open(`https://twitter.com/intent/tweet?text=${data.quoteText}`);
}
$("#tweet-icon").on("click", tweetQuote);
};//end of getRandomQuote
$("#quote-button").on("click", getRandomQuote);
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:03
Making a getJSON request to the forismatic API and showing the data back in the HTML card.
$(document).ready(() => {
let endpoint = 'https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?';
let getRandomQuote = () => {
$.getJSON(`${endpoint}`, (data) => {
$("#quote").html(`<i class="fas fa-quote-left"></i> ${data.quoteText} <i class="fas fa-quote-right"></i>`);
//Checking if the quote does not have an author
if (data.quoteAuthor !== "") {
$("#quote-author").html(`${data.quoteAuthor} at <a href="${data.quoteLink}" target="_blank" class="card-link">forismatic</a>`);
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 11:56
Grabbing the icon with the id of quote-icon and creating an event listener to be able to tweet a quote after a click
$(document).ready(() => {
console.log('ready!');
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());
window.open(`https://twitter.com/intent/tweet?text=${quote}`);
});
});// end of document.ready
@waldothedeveloper
waldothedeveloper / index.html
Created May 18, 2018 11:36
The HTML file for this challenge
<!doctype html>
<html lang="en">
<head>
<!-- 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
@waldothedeveloper
waldothedeveloper / app.js
Created May 17, 2018 22:29
FreeCodeCamp Random Quotes App
$(document).ready(() => {
console.log('ready!');
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());
window.open(`https://twitter.com/intent/tweet?text=${quote}`);
});
let endpoint = 'https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?';
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

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
end
def show
end
@waldothedeveloper
waldothedeveloper / filters.markdown
Created August 10, 2017 20:38 — forked from jcasimir/filters.markdown
Controller Filters

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