Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Waldo Lavaut waldothedeveloper

🏠
Working from home
View GitHub Profile
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018
Another workaround for the random quotes assuming you save a bunch of quotes in an array
View app.js
$(document).ready(()=> {
console.log("ready");
let quotesArray = ["quote1", "quote2", "quote3", "quote4", "quote5", "quote6", "quote7", "quote8", "quote9", "quote10"];
function randomQuote() {
let randQuote = Math.floor(Math.random() * quotesArray.length);
return $("p#quote").text(quotesArray[randQuote]);
};
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018
The full javascript file about the freecodecamp quote app
View app.js
$(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
Creating a tweetQuote function to tweet a quote
View app.js
$(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
Making a getJSON request to the forismatic API and showing the data back in the HTML card.
View app.js
$(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
Grabbing the icon with the id of quote-icon and creating an event listener to be able to tweet a quote after a click
View app.js
$(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
The HTML file for this challenge
View index.html
<!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
FreeCodeCamp Random Quotes App
View app.js
$(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=?';
View capybara cheat sheet
=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')
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 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
end
def show
end