Skip to content

Instantly share code, notes, and snippets.

View MilanGrubnic70's full-sized avatar

Milan Grubnic MilanGrubnic70

View GitHub Profile
@MilanGrubnic70
MilanGrubnic70 / Ready
Created March 22, 2015 20:19
Document Ready in JavaScript
Full version:
$(document).ready(function)(){
// do something on document ready
}; // end of ready function
shorthand version:
$(function(){
// do something on document ready
@MilanGrubnic70
MilanGrubnic70 / rspec_gemfile.rb
Last active August 29, 2015 14:02
RSPec Gemfile
group :test, :development do
gem 'rspec-rails'
end
<h2>Contacts</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Phone</th>
<th>Email</th>
<div class="container">
<h1>User Skills and Levels</h1>
<%# TODO: display the skills and proficiency levels for each user ... %>
<table>
<thead>
<tr>
<th>Name</th>
<th>Skill</th>
function Animal(name, legs){
this.name = name;
this.legs = legs;
};
var Zoo = {
init: function(arg){
var animals = arg;
}, // init
@MilanGrubnic70
MilanGrubnic70 / mac3.js
Last active August 29, 2015 14:02
mac3
$(document).ready(function(){
$('#get_color').click(function(event){
event.preventDefault();
$.post('/color', function(response){
$("#color_me li:nth-child(" + response.cell +")").css( "background-color", response.color );
}, 'json');
});
});
html {
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
body {
margin: 0;
padding: 0;
}
header {
@MilanGrubnic70
MilanGrubnic70 / associations_with _source.rb
Last active August 29, 2015 14:02
Associations with Source
class OrangeTree < AR::Base
has_many :oranges
has_many :seeds, through: :oranges, source: :seedlings
end
class Orange < AR::Base
belongs_to :orange_tree
has_many :seedlings, class_name: "Seed"
end
@MilanGrubnic70
MilanGrubnic70 / errors.html
Created June 8, 2014 16:21
Error Display
<%= display_errors(@user) %>
<% unless @user.errors.eppty? %>
<div class="errors">
<% @user.errors.full_messages.each do |message| %>
<p><%= message %></p>
<% end %>
</div>
<% end %>
@MilanGrubnic70
MilanGrubnic70 / controller.rb
Last active August 29, 2015 14:02
Controller File
get '/' do
# Look in app/views/index.erb
erb :index
end
get '/signin' do
user = User.authenticate(params[:email], params[:password])
if user
session[:user_id] = user.id