This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array = [2, 5, 4, 3, 1]; | |
function bubbleSort(array) { | |
let swapped; | |
do { | |
swapped = false; | |
for(let i = 0; i < array.length; i++) { | |
if(array[i] && array[i + 1] && array[i] > array[i + 1]) { | |
[array[i], array[i + 1]] = [array[i + 1], array[i]]; | |
swapped = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an array to sort | |
var array = [9, 2, 5, 6, 4, 3, 7, 10, 1, 12, 8, 11]; | |
// Basic implementation (pivot is the first element of the array) | |
function quicksort(array) { | |
if (array.length == 0) return []; | |
var left = [], right = [], pivot = array[0]; | |
for (var i = 1; i < array.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Split the array into halves and merge them recursively | |
function mergeSort(array) { | |
if (array.length === 1) { | |
// Return once we hit an array with a single item | |
return array | |
} | |
// Get the middle item of the array rounded down by creating a variable | |
const middle = Math.floor(array.length / 2) | |
// Create a variable for the items on the left side |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Heart</title> | |
</head> | |
<body> | |
<div class='container'> | |
<div class='heart'></div> | |
</div> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CSS Animations</title> | |
</head> | |
<body> | |
<div class="small-square"></div> | |
<div class="square"></div> | |
<div class="balloon"><img src="http://www.pngpix.com/wp-content/uploads/2016/08/PNGPIX-COM-Hot-Air-Balloon-PNG-Transparent-Image.png"></div> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Bounce In</title> | |
</head> | |
<body> | |
<div><h1>Bounce In</h1></div> | |
<p>Example from <a href="https://robots.thoughtbot.com/css-animation-for-beginners">CSS Animation for Beginners by Rachel Cope</a>, December 04, 2014</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Bouncing Ball</title> | |
</head> | |
<body> | |
<div class="ball"></div> | |
<div class="shadow"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
before_action :set_destination | |
def create | |
@comment = current_user.comments.create(comment_params) | |
@comment.destination = @destination | |
@comment.save | |
redirect_to destination_path(@destination) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
before_action :configure_permitted_parameters, if: :devise_controller? | |
def after_sign_in_path_for(resource) | |
request.env['omniauth.origin'] || root_path | |
end | |
protected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DestinationsController < ApplicationController | |
def index | |
@destinations = Destination.all | |
end | |
def show | |
@destination = Destination.find(params[:id]) | |
@food = @destination.food | |
if current_user | |
@comment = current_user.comments.build(destination: @destination) |
NewerOlder