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 Calculator(){ | |
| this.add = function(num1, num2){ | |
| if(this.isNumber([num1,num2]) == false){ | |
| throw "error: invalid input to function."; | |
| }else{ | |
| return num1 + num2; | |
| } | |
| } |
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
| <?php | |
| // Classes vs Objects | |
| class User{ | |
| private $email; | |
| private $password; | |
| const MINCHARS = 8; |
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 Computer(make,model){ | |
| this.make = make; | |
| this.model = model; | |
| } | |
| Computer.prototype.switchOn = function(){ | |
| console.log("Switching on your " + this.model + "."); | |
| } | |
| Computer.prototype.switchOff = function(){ |
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
| var Person = { | |
| firstName: "Jacob", | |
| lastName: "Clark", | |
| sayName: function(){ | |
| return "My name is " + this.firstName + " " + this.lastName; | |
| } | |
| } | |
| var jacobClark = Object.create(Person, { | |
| firstName: { |
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
| def create_user | |
| begin | |
| if self.username.nil? || self.username == 0 || self.password.nil? || self.password == 0 || self.role.nil? || self.role == 0 | |
| raise "Missing paramiter" | |
| else | |
| user = User.new(:username => self.username, :password => self.password, :created_at => Time.now, :role => self.role) | |
| if user.save | |
| return true | |
| else | |
| raise "Record not saved" |
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
| # Hey Computer, we're talking in Python! | |
| #!/usr/bin/python | |
| # We'll need some random functionality in this game :-) | |
| import random | |
| # The list of words we want the computer to choose from | |
| words = ['dog', 'cat', 'computer', 'science'] | |
| rightGuessedLetters = [] | |
| wrongGuessedLetters = [] |
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
| # We'll need some random functionality in this game :-) | |
| import random | |
| # The list of words we want the computer to choose from | |
| alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','r','v','w','x','y','z'] | |
| words = ['computer', 'science', 'computing', 'school', 'alan', 'turing', 'microsoft', 'macintosh'] | |
| rightGuessedLetters = [] | |
| wrongGuessedLetters = [] | |
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
| var Router = Backbone.Router.extend({ | |
| routes: { | |
| "" : "main", | |
| "about" : "about" | |
| }, | |
| main: function() { | |
| Session.set('page', 'main'); | |
| this.navigate(''); | |
| }, |
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
| <template name="about"> | |
| {{#if interface}} | |
| This is the about template! | |
| {{/if}} | |
| </template> |
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
| <template name="main"> | |
| {{#if interface}} | |
| Hello World! This is the main template! | |
| {{/if} | |
| </template> |