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
# 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
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
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
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
<?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 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
function Calculator(){ | |
this.add = function(num1, num2){ | |
if(this.isNumber([num1,num2]) == false){ | |
throw new Error('Invalid argument specified to add method.'); | |
}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
package models; | |
import java.util.*; | |
import play.modules.mongodb.jackson.MongoDB; | |
import net.vz.mongodb.jackson.JacksonDBCollection; | |
import net.vz.mongodb.jackson.Id; | |
import net.vz.mongodb.jackson.ObjectId; | |
import org.codehaus.jackson.annotate.JsonProperty; | |
import net.vz.mongodb.jackson.*; |
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
extern crate rand; | |
use std::io; | |
use std::cmp::Ordering; | |
use rand::Rng; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1, 101); |