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
<h1>Cats</h1> | |
<a id='meow' href='#'>its the cats</a><br> | |
<form id='cat-form'> | |
<input type='text' name='name' placeholder='name'><br> | |
<input type='text' name='product' placeholder='product'><br> | |
<input id='add-cat' type='submit'> | |
</form> |
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
$(document).ready(function() { | |
$('#meow').click(function(e) { | |
e.preventDefault(); | |
console.log("WE ARE NOT BEING REDIRECTED, yes"); | |
$.ajax({ | |
type : 'GET', | |
url : '/cats', |
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
{ | |
cats: [ | |
{ | |
id: 1, | |
name: "Pierre O'Reilly V", | |
product: "Small Cotton Car" | |
}, | |
{ | |
id: 2, | |
name: "Gabriel Prohaska 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
<h1>Cats</h1> | |
<p id='notification'></p> | |
<a id='get-cats-button' href='#'>its the cats</a><br> | |
<form id='new-cat-form'> | |
<input type='text' name='name' placeholder='name'><br> | |
<input type='text' name='product' placeholder='product'><br> | |
<input type='submit'> |
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
$(document).ready(function() { | |
$('#get-cats-button').click(function(e) { | |
e.preventDefault(); | |
$.ajax({ | |
type : 'GET', | |
url : '/cats', | |
success : function(res) { | |
var cats = JSON.parse(res); | |
$('#cat-container').empty(); |
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
$(document).ready(function() { | |
$('#new-item-form').on('submit', function (e) { | |
e.preventDefault(); | |
var data = $(e.target).serialize(); | |
$.ajax({ | |
type: 'POST', | |
url: '/api/items', | |
data: data, |
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
#### CONTROLLER #### | |
get '/cats' do | |
@cats = Cat.all | |
erb :index | |
end | |
post '/cats' do | |
cat = Cat.new(name: params[:name], product: params[:product]) | |
cat.save ? (redirect '/cats') : (status 400) |
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
function Cell () { | |
this.alive = Math.random() > 0.7; | |
this.neighbors = 0; | |
} | |
function Conway (size) { | |
this.size = size; | |
this.grid = this.generateGrid(size); | |
this.directions = [ [-1,-1], [-1, 0], [-1, 1], [ 0,-1], [ 0, 1], [ 1,-1], [ 1, 0], [ 1, 1] ]; | |
} |
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
<h1>cats</h1> | |
<a id='get-cats' href='#'>get cats</a> | |
<ul id='cats-container'></ul> | |
<form id='new-cat-form'> | |
<input type='text' name='name' placeholder='name'> | |
<input type='text' name='bitcoin' placeholder='bitcoin'> | |
<input type='submit'> |
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
array = ["9","8","7","6","5","4","3","2"] | |
array.length.times { |i| p array[i] } | |
array.each { |char| p char } | |
array.each_with_index { |char,i| p "#{char} || #{i}" } | |
matrix = Array.new(10) { Array.new(10) {"a"}} |