Skip to content

Instantly share code, notes, and snippets.

View MilanGrubnic70's full-sized avatar

Milan Grubnic MilanGrubnic70

View GitHub Profile
helpers do
def current_user
User.find_by_id(session[:user_id])
end
def login_user(user)
sesson[:user_id] = user.id
end
@MilanGrubnic70
MilanGrubnic70 / forms.html
Last active August 29, 2015 14:02
Login, Signin, Edit Forms
<h3>Please Log in:</h3>
<form name="input" action="/signup" method="post"><br>
First Name: <input type="text" name="new_user[first_name]"><br>
Last Name: <input type="text" name="new_user[last_name]"><br>
Email: <input type="text" name="new_user[email]"><br>
Password: <input type="password" name="new_user[password]"><br>
<input type="submit" value="Sign Up!">
</form>
<br>
<hr>
@MilanGrubnic70
MilanGrubnic70 / die.js
Last active August 29, 2015 14:02
JavaScript Die Function
var Die = function() {
this.roll = function() {
// Math.random() generates a float, so we use
// Math.floor() to round down to the nearest integer
return Math.floor(1 + Math.random()*6);
};
};
// this says:
// "We're defining a new constructor function called Die"
@MilanGrubnic70
MilanGrubnic70 / javascript_for_loop.md
Last active January 24, 2023 16:17
JavaScript For Loop

#For Loops

##for A for loop, as mentioned above, is useful for looping with a given number of iterations. Use it when you want to do something x times, such as changing the values in an array or counting the number of vowels in a string.

The common and fundamental syntax for a for loop in JavaScript is as follows:

for (var i = 0; i < n; i++) {
  // block of code
}
@MilanGrubnic70
MilanGrubnic70 / javascript_while_loop.md
Last active August 29, 2015 14:02
JavaScript While Loop

#While Loops

####A while loop is the simplest type of looping operation: do something until a condition evaluates to false. Here is an example of a basic while loop:

var n = 1;

while (n <= 5) {
  console.log("n is equal to " + n);
  n = n + 1;
}
@MilanGrubnic70
MilanGrubnic70 / javascript_basics.md
Last active August 29, 2015 14:02
JavaScript Basics

#JavaScript Basics

truthy and falsey

####Objects that evaluate to true:

Any Number besides 0
Any String with a length greater than zero
Any defined object
The Boolean object true

@MilanGrubnic70
MilanGrubnic70 / ===.md
Created June 1, 2014 17:36
=== vs. == in JavaScript

#=== vs. ==

The equality operator is THREE = signs, not two. JavaScript does provide a == comparison operator as well, but it performs type conversion before comparing and thus is not testing for true equality. As a rule of thumb, always use the === operator in JavaScript unless you know that you want ==.

#JavaScript Functions

var foo = function(bar) { bar + 'baz'; };

// Literally, the parts of the function:
var name = function(parameter, parameter) { body; };

When invoking a function in JavaScript the parentheses are required even if the function does not take any parameters.

@MilanGrubnic70
MilanGrubnic70 / github_clone_branch.md
Created June 1, 2014 14:54
GitHub Clone Branch to Another Computer

, How to pull your remote branch to a different computer. In order to pull what you have to your personal computer follow this format:

git clone -b <branch> <remote_repo>

Example:

git clone -b Milan https://github.com/nighthawks-2014/ruby-flashcards-2-mvc-pattern-more-challenge.git