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
function Calculator(){
this.add = function(num1, num2){
if(this.isNumber([num1,num2]) == false){
throw "error: invalid input to function.";
}else{
return num1 + num2;
}
}
<?php
// Classes vs Objects
class User{
private $email;
private $password;
const MINCHARS = 8;
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(){
var Person = {
firstName: "Jacob",
lastName: "Clark",
sayName: function(){
return "My name is " + this.firstName + " " + this.lastName;
}
}
var jacobClark = Object.create(Person, {
firstName: {
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"
# 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 = []
# 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 = []
var Router = Backbone.Router.extend({
routes: {
"" : "main",
"about" : "about"
},
main: function() {
Session.set('page', 'main');
this.navigate('');
},
<template name="about">
{{#if interface}}
This is the about template!
{{/if}}
</template>
<template name="main">
{{#if interface}}
Hello World! This is the main template!
{{/if}
</template>