Skip to content

Instantly share code, notes, and snippets.

View imjacobclark's full-sized avatar
:shipit:
Shipping

Jacob Clark imjacobclark

:shipit:
Shipping
View GitHub Profile
# 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 = []
# 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 = []
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"
var Person = {
firstName: "Jacob",
lastName: "Clark",
sayName: function(){
return "My name is " + this.firstName + " " + this.lastName;
}
}
var jacobClark = Object.create(Person, {
firstName: {
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(){
<?php
// Classes vs Objects
class User{
private $email;
private $password;
const MINCHARS = 8;
function Calculator(){
this.add = function(num1, num2){
if(this.isNumber([num1,num2]) == false){
throw "error: invalid input to function.";
}else{
return num1 + num2;
}
}
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;
}
}
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.*;
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);