Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, December 10, 2013

Try Objective C: Level 1 Challenge 14


//sample solution

NSLog(@"Lettertouch has a rating of %@.", appRatings[@"Lettertouch"]);


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 13


//sample solution

NSDictionary *appRatings = @{@"AngryFowl": @3, @"Lettertouch": @5};


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 12


//sample solution

apps = @[@"AngryFowl", @"Lettertouch", @"Tweetrobot", @"Instacanvas"];


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 11

Try Objective C: Level 1 Challenge 10


//sample solution

NSArray *apps = @[@"AngryFowl", @"Lettertouch", @"Tweetrobot"];


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 9

//sample solution

NSLog(@"%@ is %@ years old", firstName, age);


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 8

Try Objective C: Level 1 Challenge 7

//sample solution

NSLog(@"%@ %@", firstName, lastName);


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 6

//sample solution

NSString *lastName = @"YourLastName";


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 5

//sample solution

NSLog(@"%@ %@", firstName, firstName);


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 4

//sample solution

NSLog(@"Hello there, %@.", firstName);


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 3

Try Objective C: Level 1 Challenge 2

//sample solution

NSString *firstName = @"YourFirstName";


Back to the list of sample solutions for Try Objective C: Level 1 challenges

Try Objective C: Level 1 Challenge 1

What is another term for tattooing?

stippling

What type of fracture is produced by a tangential or glancing approach of a bullet?

gutter fracture

How many days have elapsed if a contusion's color has changed to green?

4 to 5 days

What is edema aquosum?

This is caused by the entrance of water into the air sacs which makes the lungs doughy, readily pits on pressure, exuding water and froth

What is a histotoxic type of asphyxial death?

This happens when oxygen is delivered to the tissues but cannot be utilized properly due to failure of cellular oxidative process

What is burking?

A form of asphyxial death wherein pressure on the trachea is caused by placing the neck at the bend of the elbow

Friday, December 6, 2013

What is overlaying?

This is the term used when the accidental death of a young child by suffocation either from the pressure of the beddings and pillows or from the pressure of the unconscious or drunk mother 

What is "Tete de negri"?

This is the bronze coloration of the head and the neck of a dead person observed in cases of drowning

What is the whitish foam in the mouth and nostrils signifying drowning called?

champignon d'ocume

How soon after drowning does the body float?

within 24 hours

What is the most important determinant of a bullet's wounding capacity?

its momentum

How does a post-mortem wound differ from an ante-mortem wound?

there is no clotting of blood

In a murder, when the body found is already a skeleton, how long has it been since the time of death?

about one month or more

What are Tardieu spots associated with?

Hanging

Thursday, November 28, 2013

What is another term for Exhumination?

disinterment

What is the willful deliberate and painless acceleration of death of a person called?

Euthanasia

What does Cutis Galina signify?

This signifies that the corpse has been in water for sometime

What manner of death is NOT autopsied?

death occurring in a natural manner

What is Post-mortem lividity?

This happens when blood accumulates in the most dependent portions of a dead body

What does Algor Mortis refer to?

cooling of the body

What is Adioocere formation?

In a cadaver, this is the soft brownish white substance that results from the chemical change of body fat which takes place in wet conditions

What is Marbolization?

The prominence and coloration of superficial veins more visible among people with fair complexion during decomposition.

Sunday, November 24, 2013

What is the biological test of farnum used for?

To determine whether semen is of human origin or not

What is Gettler's test?

It is a quantitative determination of the chloride content of the blood in the right and left ventricle of the heart

Which bone can be most informative regarding the sex of the owner of the skeleton?

Pelvis

What characteristic of the face is indicative of approaching death?

Hippocratic facies

What method can be used to approximate the height of a cadaver with the extremities missing?

measure the length of the head and multiply by 8

How can one determine whether hair is of human or animal origin?

by determination of medullary index

How long do undisturbed fingerprints last in a crime scene?

Years

What characterizes the hair of an old person?


  • fine
  • deficient of pigments
  • devoid of medulla

What chemical test can be used to determine if a stain is of blood origin?

Benzidine test

Friday, November 22, 2013

Which characteristics of a person are not easily changed?

gait, mannerisms and speech

What is Dactylography?

It is the art and study of recording fingerprints as a means of identification

What is the DNA typing method where a small sample size is chemically amplified to produce large amounts?

Polymerase Chain Reaction (PCR) Method

Which test is used to determine whether or not semen is of human origin?

Precipitin

Which test is positive to any substance containing hemoglobin?

The Takayama test

How is diaphanus test done to determine peripheral circulation?

Spread fingers wide and view through strong light

When are fingerprints formed?

They are formed in the fetus during the fourth week of pregnancy.

Monday, October 28, 2013

#Python #Codecademy File Input/Output Case Closed?

# Sample solution


with open("text.txt", "w") as my_file:
my_file.write("Kumbaya Sharkey!")

if not my_file.closed:
    my_file.close()
print my_file.closed

#Python #Codecademy File Input/Output Try It Yourself

# Sample solution


with open("text.txt", "w") as my_file:
my_file.write("Kumbaya Sharkey!")

#Python #Codecademy File Input/Output PSA: Buffering Data

# Sample solution


# Open the file for reading
read_file = open("text.txt", "r")

# Use a second file handler to open the file for writing
write_file = open("text.txt", "w")
# Write to the file
write_file.write("Not closing files is VERY BAD.")

write_file.close()

# Try to read from the file
print read_file.read()
read_file.close()

#Python #Codecademy File Input/Output Reading Between the Lines


# note: The instructions state to use "text.txt" but an error comes up stating that the file does not exist
# as a work around, I used "output.txt" instead

my_file = open("output.txt","r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()

#Python #Codecademy File Input/Output Reading

# Sample solution


my_file = open("output.txt","r")
print my_file.read()
my_file.close()

#Python #Codecademy File Input/Output Writing

# Sample solution


my_list = [i**2 for i in range(1,11)]

my_file = open("output.txt", "r+")

# Add your code below!

for i in my_list:
  my_file.write(str(i)+"\n")
my_file.close()

#Python #Codecademy File Input/Output The open() Function

# Sample Solution

my_file = open("output.txt","r+")

Saturday, October 26, 2013

How to implement an image Carousel using Twitter Bootstrap?

<!-- Sample Code for implementing Carousel -->


<div id="myCarousel" class="carousel slide">
     <ol class="carousel-indicators">
          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  <li data-target="#myCarousel" data-slide-to="1"></li>
  <li data-target="#myCarousel" data-slide-to="2"></li>
  <li data-target="#myCarousel" data-slide-to="3"></li>
  <li data-target="#myCarousel" data-slide-to="4"></li>
     </ol>
     <!-- Carousel items -->
     <!-- images are stored in the img folder which is at the same location or directory as the HTML file-->
     <div class="carousel-inner">
          <div class="active item"><img src="img/img1.jpg" width="100%" ></div>
  <div class="item"><img src="img/img2.jpg" width="100%" ></div>
  <div class="item"><img src="img/img3.jpg" width="100%" ></div>
  <div class="item"><img src="img/img4.jpg" width="100%" ></div>
  <div class="item"><img src="img/img5.jpg" width="100%" ></div>
     </div>
     <!-- Carousel nav -->
     <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
     <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

<!-- Make sure you include the necessary Bootstrap files -->
<!--The link to the CSS file in between the <head> and </head> tags -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">

<!--It is recommeneded that you place the following files near the closing </body> tag-->

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>

Thursday, October 24, 2013

#Codeschool CSS Level 1 Sample Solution Columns

//sample solution to style.css


article {
  float: left;
  width: 120px;
}
aside {
  float: right;
  width: 120px;
}

#Codeschool CSS Level 1 Sample Solution Floats

//sample solution to style.css


aside {
  width: 120px;
  float: right;
  margin: 0px 0px 10px 10px;
}

#Codeschool CSS Level 1 Sample Solution Style Specificity

<!-- Sample solution to index.html-->


<!doctype html>
<html lang="en">
  <head>
    <title>Sven's Snowshoe Emporium</title>
    <link rel="stylesheet" href="style.css" />
  </head>
 
  <body>
    <section class="content home">
      <header>
        <h1>Sven's Snowshoe Emporium</h1>
        <h2>"For the Snow-Savvy Shoe-Shopper"</h2>
      </header>
    </section>
  </body>
</html>

//Sample solution to style.css


header {
  background: #e0e2e6;
}


#Codeschool CSS Level 1 Sample Solution Compound Selector

//Sample solution to style.css


.content {
  border: 2px solid #ccc;
}
.content.home {
  border: 0px;
}

#Codeschool CSS Level 1 Sample Solution ID Selector

//Solution to style.css


#slogan {
  text-align: center;
  font-style: italic
}

#Codeschool CSS Level 1 Sample Solution External Stylesheets


<!--Solution for index.html-->

<!doctype html>
<html lang="en">
  <head>
    <title>Sven's Snowshoe Emporium</title>
    <link rel="stylesheet" href="style.css" />
  </head>
 
  <body>
    <section class="content">
      <header>
        <h1>Sven's Snowshoe Emporium</h1>
      </header>
    </section>
  </body>
</html>

//Solution for style.css


body {
        color: #4b4648;
        font-family: tahoma, arial, sans-serif;
        font-size: 14px;
      }
.content {
        border: 1px solid #cac3c6;
        margin: 0 auto;
        padding: 20px;
        width: 260px;
}
h1 {
        color: #6d9fac;
        font-size: 22px;
        text-align: center;
}


Tuesday, October 22, 2013

#Codeschool Backbone.js Sample Solution to Render the View


appointmentView.render();
$('#app').html(appointmentView.el);

#Codeschool Backbone.js Sample Solution to Set The Title

appointment.set({'title':'My Backbone Hurts'});

#Codeschool Backbone.js Sample Solution to Define Render


var AppointmentView = Backbone.View.extend({
  render: function() {
    var html = '<li>' + this.model.get('title') + '</li>';
    $(this.el).html(html);
  }
});

#Codeschool Backbone.js Sample Solution to View Instance


var appointmentView = new AppointmentView({
  model: appointment
});

#Codeschool Backbone.js Sample Solution to View Class

var AppointmentView = Backbone.View.extend({});

#Codeschool Backbone.js Sample Solution to Model Instance

var appointment = new Appointment({'title':'Lunch Meeting'});

#Codeschool Backbone.js Sample Solution to Model Class

var Appointment = Backbone.Model.extend({});

In R, how do you test if the correlation between two vectors is statistically significant?

Answer:

cor.test(VectorA, VectorB)

// this will display a report showing the p-value
// a p-value less than 0.05 is considered statistically significant

In R, how do you read the contents of a .txt file into a data frame?

Answer:

someDataframe <- read.table("someFile.txt", sep="\t", header=TRUE)

//in this example, the columns in the .txt file are separated by tabs (tab delimited)
//header = TRUE indicates that the first row in the .txt file represents the headers of the data frame
//change this to FALSE if the first row already represents raw data

In R, how do you store the contents of a .csv file into a data frame?

Answer:

someDataframe <- read.csv("someFile.csv")

In R, how do you determine the unique elements in a vector?

Answer:

someFactor <- factor(someVector)
//convert the vector to a factor using the factor function

levels(someFactor)
//use the levels function to identify the unique elements in the vector

In R, how do you compute for the standard deviation of a vector composed of numbers, numVector?

Answer:

sd(numVector)

In R, what are the ways you can plot a matrix someMatrix?

Possible answers:

contour(someMatrix)

persp(someMatrix, expand=0.2)
//this creates a 3D-plot where the z-axis is dependent on the values of the elements of the matrix

image(someMatrix)
//this creates a heat map of the matrix, kind of a colored version of contour

In R, how do you access an element in a matrix someMatrix?

Answer:

someMatrix[rowIndex, columnIndex]

In R, how can you re-shape a vector?

Answer:
dim(someVector) <- c(numRows, numCols)

//note, the length of someVector must be equal to the product of numRows and numCols

In R, how do you create an n row by m column matrix?

Answer:

matrix(elementValues, n, m)

//this will create an n x m matrix where all elements have a value of elementValues

//if elementValues = 0 , all the elements of the n x m matrix will be 0
//if elementValues is a vector of length equal to the product of n and m, then the matrix will contain all the elements of the vector populated from top to bottom, then left to right

In R, how do you neglect elements with an assigned value NA in a vector when it is used in someFunction?

Answer:

//use
help(someFunc)

//if someFunc has the provision, na.rm = FALSE, then

someFunc(someVector, na.rm = TRUE)

//this will neglect the elements in the vector someVector with NA values

In R, how do you create a scatter plot given two vectors, x and y?

Answer:

plot(x, y)

//where the x vector will represent the x-axis and the y vector will represent the y-axis

In R, how do you access the nth element in a vector someVector?

Answer:
someVector[n]

//note: unlike most programming languages where array indices are zero-based, in R, the first element's index is 1

In R, how could you make a vector filled with values from 1 to 50?

Answer:

Method 1

c(1:50)

//note, this uses the c (combine) function and start:end notation

Method 2

seq(1,50)

//note, this uses the seq function, and instead of a colon (:), a comma is placed between the start and end numbers

In R, what happens when you try to create a vector with different types (modes)?

Answer:
R will convert all values to a single mode, usually to a string, since a vector's elements need to be of the same type (mode)

In R, how do you run a script names someScript?

Answer:
source("someScript")

In R, how can you list files in the current working directory?

Answer:
list.files()

In R, how do you find help on a function?

Answer:
help(functionName)

example:
help(sqrt)

//will bring up the R documentation on the sqrt function

In R, wow do you store a value in a variable someVar?

someVar <- 7

// this assigns the value 7 to someVar

someVar <- "Hello World!"

//this assigns a string to someVar

someVar <- TRUE

//this assigns the logical value of TRUE to someVar

In R, what is the shorthand for FALSE?

Answer: F

In R, what is the shorthand for TRUE?

Answer: T

Sunday, October 20, 2013

#Javascript - How can I reverse a string?

The reverse() method for arrays can be used together with the split() and join() methods to reverse a string.

Given:
var someString = "Hello World!";
var reversedString = someString.split("").reverse().join("");

Test it out below!

{{someText.split("").reverse().join("")}}

Saturday, October 19, 2013

#Codeschool Sample Solution to Convert Blocking


var fs = require('fs');

var contents = fs.readFile('index.html', function (err, contents) {
  if (err) throw err;
  console.log(contents);
});
console.log(contents);

#Codeschool Sample Solution to Hello You


var http = require('http');

http.createServer(function(request, response) {
  // Answer goes here.
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello, this is World");
  response.end();
}).listen(8080);

Friday, October 11, 2013

#LearnStreet: Teacher's Preview Assignment Lesson 10 Sample Solution

def who_are_you(green, large):
    # Write if-elif-else statements below
    if green and large:
        return "hulk"
    elif green:
        return "alien"
    elif large:
        return "elephant"
    else:
        return "Bruce Banner"
#This is just for you to see what happens when the function is called
print who_are_you(True, True)

#LearnStreet: Teacher's Preview Assignment Lesson 9 Sample Solution

def kitchen_or_bed(hungry, thirsty):
    # your if statement here
    if hungry or thirsty:
        return "go to kitchen"
    else:
        return "go to bed"

#This is just for you to see what happens when the function is called
print kitchen_or_bed(True, True)

#LearnStreet: Teacher's Preview Assignment Lesson 8 Sample Solution

def should_eat(hungry, awake):
    #your if statement here
    if hungry and awake:
        return "eat"
    else:
        return "don't eat"

#This is just for you to see what happens when the function is called
print should_eat(True, True)

#LearnStreet: Teacher's Preview Assignment Lesson 7 Sample Solution

def check_interval():
    #Your code here
    if num >= 1 & num <=5:
        return "1-5"
    elif num >= 6 & num <=10:
        return "6-10"
    elif num >= 11 & num <=15:
        return "11-15"
    elif num >= 16 & num <=20:
        return "16-20"  
    else:
        return "not in between 1-20"

#This is just for you to see what happens when the function is called
print check_interval()

#LearnStreet: Teacher's Preview Assignment Lesson 6 Sample Solution

def check_length(phrase):
    # your if condition here
    if len(phrase) < 30:
        return 1
    # your elif condition here
    elif len(phrase) == 30:
        return 2
    # your else condition here
    else:
        return 3

#This is just for you to see what happens when the function is called
print check_length("hi, i am a phrase")

#LearnStreet: Teacher's Preview Assignment Lesson 5 Sample Solution

def colorful_conditions():

    color = "blue"

    if  color == "red":
        return "first block"
    elif  color == "white":
        return "second block"
    elif  color == "blue":
        return "third block"
    else:
        return "fourth block"

#This is just for you to see what happens when the function is called
print colorful_conditions()

#LearnStreet: Teacher's Preview Assignment Lesson 4 Sample Solution

def check_condition():
    #return this if the condition is True
    ifRun = "if code block run"

    #return this is if the condition is False
    elseRun = "else code block run"

    if condition == True:
        return ifRun
    else:
        return elseRun

#This is just for you to see what happens when the function is called
print check_condition()

#LearnStreet: Teacher's Preview Assignment Lesson 3 Sample Solution

flag = "unchanged"
def always_false():
    global flag
    if False:
        flag = "changed"

#This is just for you to see what happens when the function is called
always_false()
print flag

#LearnStreet: Teacher's Preview Assignment Lesson 2 Sample Solution

def always_true():
    if 1 == 1:
        #insert your code here
        return "complete"

#This is just for you to see what happens when the function is called
print always_true()

#LearnStreet: Teacher's Preview Assignment Lesson 1 Sample Solution

def check_wounds():
    #your code here
    arms = 0
    if arms == 1:
        return "tis but a scratch"
    elif arms == 0:
        return "flesh wound"
    else:
        return "cross bridge"

#This is just for you to see what happens when the function is called
print check_wounds()

Wednesday, September 4, 2013

SQL Problem: Select all columns for everyone whose last name ends in "ith".

Solution: SELECT * FROM employee WHERE last LIKE '%ith';

SQL Problem: Select all columns for everyone over 80 years old.

Solution: SELECT * FROM employee WHERE age > 80;

SQL Problem: Select the first name for everyone whose first name equals "Potsy".

Solution: SELECT first FROM employee WHERE first = 'Potsy';

SQL Problem: Select all columns for everyone whose last name contains "ebe".

Solution: SELECT * FROM employee WHERE last LIKE '%ebe%';

SQL Problem: Select first name, last name, and salary for anyone with "Programmer" in their title.

Solution: SELECT first, last, salary FROM employee WHERE title = 'Programmer';

SQL Problem: Select first and last names for everyone that's under 30 years old.

Solution: SELECT first, last FROM employee WHERE age < 30;

SQL Problem: Select all columns for everyone with a salary over 30000.

Solution: SELECT * FROM employee WHERE salary > 30000;

SQL Problem: Select all columns for everyone in your employee table.

Solution: SELECT * FROM employee;

SQL Insert Problem

Problem: Enter these employees into your table Jonie Weber, Secretary, 28, 19500.00 Potsy Weber, Programmer, 32, 45300.00 Dirk Smith, Programmer II, 45, 75020.00 Solution: insert into employee (first, last, title, age, salary) values ('Jonie', 'Weber', 'Secretary', 28, 19500.00); insert into employee (first, last, title, age, salary) values ('Potsy', 'Weber', 'Programmer', 32, 45300.00); insert into employee (first, last, title, age, salary) values ('Dirk', 'Smith', 'Programmer II', 45, 75020.00);

SQL Create Table Problem

Problem: Create a table that will contain the following information about your new employees: firstname, lastname, title, age, and salary. Solution: create table employee (first varchar(20), last varchar(20), title varchar(20), age number(3), salary number(10));

SQL Problem: Display all columns for everyone whose first name contains "Mary".

Solution: SELECT * FROM table_name WHERE first_name LIKE '%Mary%';

SQL Problem: Display all columns for everyone whose first name equals "Mary".

Solution: SELECT * FROM table_name WHERE first = 'Mary';

SQL Problem: Display the first and last names for everyone whose last name ends in an "ay".

Solution: SELECT first, last FROM table_name WHERE last LIKE '%ay';

SQL Problem: Display all columns for everyone that is over 40 years old.

Solution: SELECT * FROM table_name WHERE age > 40;

SQL Problem: Display the first name, last name, and city for everyone that's not from New York.

Solution: SELECT first_name, last_name, city FROM table_name WHERE city <> 'New York';

SQL Problem: Display the first name and age for everyone that's in the table

Solution: SELECT first_name, age, FROM table_name;

Tuesday, June 18, 2013

Codecademy Sample Solution: Logging In The User


// The callback URL to redirect to after authentication
redirectUri = "http://external.codecademy.com/skydrive.html";

//sample solution to helper.js
//note: you have to have a Microsoft account in order to log-in and finish the exercise
// Initialize the JavaScript SDK

WL.init({
    client_id: '000000004C0E2C11',
    redirect_uri: redirectUri
});

$(document).ready(function() {
    // Start the login process when the login button is clicked
    $('#login').click(function() {
        WL.login({
            scope: ["wl.skydrive wl.signin"]
        }).then(
            // Handle a successful login
            function(response) {
                $('#status').html("<strong>Success! Logged in.</strong>");
            },
            // Handle a failed login
            function(responseFailed) {
                // The user might have clicked cancel, etc.
                $('#status').html(responseFailed.error.message);
            }
        );
    });
});

Codecademy Sample Solution: Initializing the Javascript SDK


//sample solution to the helper.js file

WL.init({
    client_id: ('000000004C0E2C11')
    redirect_uri: ('http://external.codecademy.com/skydrive.html')
});

Codecademy Sample Solution: Setting Up


<!DOCTYPE html>
<html>
<head>
<title>My SkyDrive Web App</title>
        <!-- Add wl.js here -->
        <script src="http://js.live.net/v5.0/wl.js"></script>
        <script src="helper.js"></script>
</head>
<body>
        <p>Hello there! We'll fill this part out soon.</p>
    </body>
</html>

Friday, June 7, 2013

Codeschool Sample Solution Keyup Event Handler II


$(document).ready(function() {
  $("#nights").on("keyup", function() {
    //var days = $(this).val();
    //var pricePerDay = $(".tour").data('daily-price');
    //var totalPrice = days * pricePerDay;
    //$("#nights-count").text(days);
    //$("#total").text(totalPrice);
    $("#nights-count").text($(this).val());
    $("#total").text($(this).val() * $(this).closest(".tour").data('daily-price'));
  });
});

Codeschool Sample Solution Keyup Event Handler I


$(document).ready(function() {
  $("#nights").on("keyup", function() {
    $("#nights-count").text($(this).val());
  });
});

Codeschool Sample Solution Keyup Event


$(document).ready(function() {
  $("#nights").on('keyup', function(){
  });
});

Codeschool Sample Solution Mouseleave


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
  $(".photos").on("mouseenter", "li", function() {
    $(this).find("span").slideToggle();
  });
  $(".photos").on("mouseleave", "li", function() {
    $(this).find("span").slideToggle();
  });
});

Thursday, June 6, 2013

Codeschool Sample Solution Mouseover II


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
  $(".photos").on("mouseenter", "li", function() {
    $(this).find("span").slideToggle();
  });
});

Codeschool Sample Solution Mouseover I


$(document).ready(function() {
  $("#tour").on('click', 'button', function() {
    $(".photos").slideToggle();
  });
 
  $(".photos").on('mouseenter', 'li', function(){
   
  });
});

Codeschool Sample Solution Slide Effect II


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
});

Codeschool Sample Solution Slide Effect I


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $('.photos').slideDown();
  });
});

Codeschool Sample Solution On Load II


$(document).ready(function() {
  $('#tour').on('click', 'button', function(){
    alert('I was clicked!');
  });
});

Codeschool Sample Solution On Load I


$(document).ready(function(){
  var numPhotos = $('img').length;
  alert(numPhotos);
});

Codeschool Sample Solution New Filter III


$(document).ready(function(){
  $("#filters").on("click", ".on-sale", function(){
    $(".highlight").removeClass();
    $(".tour").filter(".on-sale").addClass("highlight");
  });

  $("#filters").on("click", ".featured", function(){
    $(".highlight").removeClass();
    $(".tour").filter(".featured").addClass("highlight");
  });
});

Codeschool Sample Solution New Filter II


$(document).ready(function(){
  $("#filters").on("click", ".on-sale", function(){
    $(".tour").filter(".on-sale").addClass("highlight");
  });
});

Codeschool Sample Solution New Filter I


$(document).ready(function(){
  //Create the click handler here
  $("#filters").on("click", ".on-sale", function(){
  });
});

Codeschool Sample Solution Better On Handlers


$(document).ready(function(){
  $(".tour").on("click","button", function(){
    var tour = $(this).closest(".tour");
    var discount = tour.data("discount");
    var message = $("<span>Call 1-555-jquery-air for a $" + discount + "</span>");
    tour.append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Refactoring


$(document).ready(function(){
  $("button").on("click", function(){
    var tour = $(this).closest(".tour");
    var discount = tour.data("discount");
    var message = $("<span>Call 1-555-jquery-air for a $" + discount + "</span>");
    tour.append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Fetching Data from the DOM II


$(document).ready(function(){
  $("button").on("click", function(){
    var discount = $(this).closest(".tour").data("discount");
    //alert(discount); //for checking
    var message = $("<span>Call 1-555-jquery-air for a $"+discount+" discount</span>");
    $(this).closest(".tour").append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Fetching Data from DOM I


$(document).ready(function(){
  $('button').on('click', function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    var discount = $(this).closest(".tour").data("discount");
    $(this).closest(".tour").append(message);
    $(this).remove();
    //alert(discount); //prove that value of data is stored in var discount
  });
});

Codeschool Sample Solution Relative Traversing III


$(document).ready(function(){
  $(".tour").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).closest(".tour").append(message);
    $(this).find(".book").remove();
  });
});

Codeschool Sample Solution Traversing II


$(document).ready(function(){
  $('button').on('click', function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).closest("li").append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Relative Traversing I


$(document).ready(function(){
  $("button").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).parent().append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Removing the clicked button


$(document).ready(function(){
  $("button").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(".usa").append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution On Page Load


$(document).ready(function(){
  $("button").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(".usa").append(message);
    $("button").remove();
  });
});

Codeschool Sample Solution Acting On Click


$(".tour").on("click", function(){
  var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
  $(".usa").append(message);
  $("button").remove();
});

Codeschool Sample Solution Click Interaction


$(".book").on("click", function(event){
  var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
  $(".usa").append(message);
  $(".book").remove();
});

Codeschool Sample Solution Removing from the DOM


var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
$(".usa").append(message);
$(".book").remove();

Codeschool Sample Solution Adding to the DOM II


var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
$(".usa").append(message);

Codeschool Sample Solution Adding to the DOM I


var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
$(".book").before(message);

Codeschool Sample Solution Creating a DOM Node

var message = $("<span>Call 1-555-jquery-air to book this tour</span>");

Codeschool Sample Solution The :even selector

$("#tours > li:ev­en")

Codeschool Sample Solution Traversing Down

$("#tours"­).children­("li")

Codeschool Sample Solution Traversing Up

$(".featur­ed").paren­t()

Codeschool Sample Solution Using prev()

$("#vacati­ons li").­last().pre­v()

Codeschool Sample Solution Using last()

$("#vacati­ons li").­last()

Codeschool Sample Solution Using first()

$("#vacati­ons li").­first()

Codeschool Sample Solution Using find()

$("#vacati­ons").find­(".america­")

Codeschool Sample Solution First Pseudo Selector

$("#tours :firs­t")

Codeschool Sample Solution Selecting Multiple Elements

$(".asia, .sale­")

Codeschool Sample Solution Selecting Direct Children

$("#tours > li")

Codeschool Sample Solution Descendant Selector

$("#tours li")

Codeschool Sample Solution Modifying Multiple Elements

$("h2").te­xt("Vacati­on Packa­ges")

Codeschool Sample Solution Class Selector

$(".americ­a")

Codeschool Sample Solution ID Selector

$("#vacati­ons")

Codeschool Sample Solution Include A Custom Javascript File


<!DOCTYPE html>
<html>
  <head>
    <title>Home</title>
  </head>
  <body>
    <div class="homepage-wrapper">
      <h2>Welcome to jQuery Travels - Traversing the DOM since 2006</h2>
      <p>Fly to New York today for as little as <span>$299.99</span></p>
    </div>
    <script src="jquery.min.js"></script>
    <script src="application.js"></script>
  </body>
</html>

Codeschool Sample Solution Include the jQuery Library


<!DOCTYPE html>
<html>
  <head>
    <title>Home</title>
  </head>
  <body>
    <div class="homepage-wrapper">
      <h2>Welcome to jQuery Travels - Traversing the DOM since 2006</h2>
      <p>Fly to New York today for as little as <span>$299.99</span></p>
    </div>
    <script src="jquery.min.js"></script>
  </body>
</html>

Codeschool Sample Solution DOM Ready


$(document).ready(function() {
  $("span").text("$100");
});

Codeschool Sample Solution Changing Text

$("span").­text("$100­")

Codeschool Sample Solution Text Method

$("span").text()

Codeschool Sample Solution Element Selector II

$("span")

Codeschool Sample Solution Element Selector

$("h2")

Sample Git Command 15

git branch -d someBranchName

note: used to delete someBranchName

Sample Git Command 14

git branch

note: used to determine which branch you are working with

Sample Git Command 13

git checkout -- sampleFileName.txt

Sample Git Command 12

git reset someFolderName/someFileName.txt

note: used to unstage a file

Sample Git Command 11

git diff --staged

Sample Git Command 10

git diff HEAD

Sample Git Command 9

git pull origin master

Sample Git Command 8

git push -u origin master

Sample Git Command 7

git remote add origin https://someSite.com/someFile.git

note: for adding files from a remote location

Sample Git Command 6

git log

note: shows stuff done on git in the past

Sample Git Command 5

git add '*.txt'

note: this command add's multiple text files to the staging area

Sample Git Command 4

git commit -m "some comment about newly added file to repository"

Sample Git Command 3

git add sampleFileName.txt

Sample Git Command 2

git status

Sample Git Command 1

git init

initialized existing Git repository in /.git/

Tuesday, May 21, 2013

Codecademy Sample Solution: Reading Date


$(function() {
    // Put your firebaseRef.on call here!
    firebaseRef.on("value", function(snap){
        $("#result").html(JSON.stringify(snap.val()));
    });
});

Codecademy Sample Solution: Writing Objects to Firebase


$(function() {
    // Call firebaseRef.set here!
    firebaseRef.set({
        type: "fruit",
        name: "apple",
        price: 42.0
    });
});

Codecademy Sample Solution: Writing Simple Data to Firebase


$(function() {
    // Call firebaseRef.set here!
    firebaseRef.set("someValue");
});

Codecademy Sample Solution: Initializing the Firebase JavaScript Library


<html>
    <head>
      <!-- Add your script tag here! -->
      <script src="https://cdn.firebase.com/v0/firebase.js"></script>
    </head>
    <body style="padding: 15px; background-color: #FFFAD5; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;">
        <img src="https://www.firebase.com/images/logo.png"></img>
    </body>
</html>

Codecademy Sample Solution: AJAX


var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
console.log("Success!");
}
};

var url = "http://www.codecademy.com";
// Put your req.open and req.send calls here!
req.open("GET", url, true);
req.send();

Codecademy Sample Solution: Anonymous functions


setTimeout(function() {
  console.log("The callback fired");
}, 500);

Codecademy Sample Solution: Functions are just objects


function myFunction() {
console.log("The callback fired");
}

function startTimer(func) {
func(myFunction, 500);
}

// Put the startTimer call here.
startTimer(setTimeout);

Codecademy Sample Solution: How to use a callback


function myFunction() {
// Put your console.log in here.
    console.log("The callback fired")
}

setTimeout(myFunction, 500);
console.log("Am I the first message?");

Sunday, May 5, 2013

Codecademy Sample Solution: Adding the Parse SDK to your app


<html>
    <head>
        <!-- Add the Parse SDK here! -->
        <script src="http://www.parsecdn.com/js/parse-1.1.15.min.js"></script>
    </head>
    <body>
    </body>
</html>

Sunday, April 28, 2013

Array Element Tally


Say you had an election, and you needed to tally the votes for each candidate. All you need to do is enter the name of each candidate once it is read. Then, click the ADD button (or press the ENTER key) to add it to the array, as an array element. If you made a mistake, just click the REMOVE button to remove the last element added. The tally results are updated automatically. Each name will show the number of votes it received as well as the total votes cast for the entire election.

Type in the ARRAY ELEMENT:

Add

Remove

TALLY:

Saturday, April 27, 2013

Codecademy Sample Solution: Challenge Time


<!DOCTYPE html>
<html>
    <head>
 <title> Challenge Time! </title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <?php
          // Your code here
            class Cat{
                public $isAlive = true;
                public $numLegs = 4;
                public $name;
               
                public function __construct($name){
                    $this->name = $name;
                }
               
                public function meow(){
                    return "Meow meow";
                }
            }
           
            $cat1 = new Cat('CodeCat');
            echo $cat1->meow();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Putting It All Together, Part II


<!DOCTYPE html>
<html>
<head>
 <title> Practice makes perfect! </title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Dog{
                public $numLegs = 4;
                public $name;
               
                public function __construct($name){
                    $this->name = $name;
                }
               
                public function bark(){
                    return "Woof!";
                }
               
                public function greet(){
                    return "My name is $this->name.";
                }
            }
           
            $dog1 = new Dog('Barker');
            $dog2 = new Dog('Amigo');
            echo $dog1->bark();
            echo $dog2->greet();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Putting It All Together, Part I


<!DOCTYPE html>
<html>
<head>
 <title> Practice makes perfect! </title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Dog{
                public $numLegs = 4;
                public $name;
               
                public function __construct($name){
                    $this->name = $name;
                }
               
                public function bark(){
                   
                }
               
                public function greet(){
                   
                }
            }
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: A Method to the Madness


<!DOCTYPE html>
<html>
<head>
 <title>Reconstructing the Person Class</title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Person{
                public $isAlive = true;
                public $firstname;
                public $lastname;
                public $age;
               
                public function __construct($firstname, $lastname, $age){
                    $this->firstname = $firstname;
                    $this->lastname = $lastname;
                    $this->age = $age;
                }
               
                public function greet(){
                    return "Hello, my name is " . $this->firstname . " " . $this->lastname . ". Nice to meet you! :-)";
                }
            }
            $teacher = new Person('boring', '12345', 12345);
            echo $teacher->greet();
            $student = new Person('Anony', 'mous', 100);
            echo $student->greet();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Property Panic (2)


<!DOCTYPE html>
<html>
<head>
 <title>Reconstructing the Person Class</title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Person{
                public $isAlive = true;
                public $firstname;
                public $lastname;
                public $age;
               
                public function __construct($firstname, $lastname, $age){
                    $this->firstname = $firstname;
                    $this->lastname = $lastname;
                    $this->age = $age;
                }
            }
            $teacher = new Person('boring', '12345', 12345);
            $student = new Person('Anony', 'mous', 100);
            echo $student->age;
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Property Panic (1)


<!DOCTYPE html>
<html>
<head>
 <title>Reconstructing the Person Class</title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Person{
                public $isAlive = true;
                public $firstname;
                public $lastname;
                public $age;
            }
            $teacher = new Person();
            echo "$teacher->isAlive";
            $student = new Person();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Building Your First Class


<!DOCTYPE html>
<html>
<head>
 <title>Reconstructing the Person Class</title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
      <p>
        <!-- Your code here -->
        <?php
            class Person{
               
            }
            $teacher = new Person();
            $student = new Person();
        ?>
      </p>
    </body>
</html>

Friday, April 26, 2013

Codecademy Sample Solution: Putting it All Together


<html>
  <head>
    <title>I am the King of Arrays!</title>
  </head>
  <body>
    <p>
      <?php
      // On the line below, create your own associative array:
      $myArray = array('feet'=>'shoes', 'hands'=>'gloves', 'head'=>'hat');

      // On the line below, output one of the values to the page:
      print $myArray['head']."<br/>";
         
      // On the line below, loop through the array and output
      // *all* of the values to the page:
      foreach($myArray as $key => $value){
          print $key .'=&gt;'. $value."<br/>";
      }
   
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Multidimensional Arrays


<html>
  <head>
    <title>Blackjack!</title>
  </head>
  <body>
    <p>
      <?php
        $deck = array(array('2 of Diamonds', 2),
                      array('5 of Diamonds', 5),
                      array('7 of Diamonds', 7),
                      array('8 of Clubs', 8));
       
      // Imagine the first chosen card was the 7 of Diamonds.
      // This is how we would show the user what they have:
      echo 'You have the ' . $deck[3][0] . '!';
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Iterating Over Associative Arrays


<html>
  <head>
    <title>Iteration Nation</title>
  </head>
  <body>
    <p>
      <?php  
        $food = array('pizza', 'salad', 'burger');
        $salad = array('lettuce' => 'with',
                   'tomato' => 'without',
                   'onions' => 'with');
   
      // Looping through an array using "for".
      // First, let's get the length of the array!
      $length = count($food);
   
      // Remember, arrays in PHP are zero-based:
      for ($i = 0; $i < $length; $i++) {
        echo $food[$i] . '<br />';
      }
   
      echo '<br /><br />I want my salad:<br />';
   
      // Loop through an associative array using "foreach":
      foreach ($salad as $ingredient=>$include) {
        echo $include . ' ' . $ingredient . '<br />';
      }
   
      echo '<br /><br />';
   
      // Create your own array here and loop
      // through it using foreach!
      $gadget = array('programming' => 'iMac', 'calls' => 'iPhone', 'ebooks' => 'iPad');
      foreach ($gadget as $key => $value){
        echo "I use the ".$value." for ".$key.".<br/>";
      }

      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Accessing Associative Arrays


<html>
  <head>
    <title>Accessing Associative Arrays</title>
  </head>
  <body>
    <p>
      <?php
        // This is an array using integers as the indices...
        $myArray = array(2012, 'blue', 5, 'BMW');

        // ...and this is an associative array:
        $myAssocArray = array('year' => 2012,
                        'colour' => 'blue',
                        'doors' => 5,
                        'make' => 'BMW');
           
        // This code will output "blue".
        echo $myArray[1];
        echo '<br />';
           
        // Add your code here!
        echo "My car was purchased in $myArray[0] and has ". $myAssocArray['doors'] ." doors.";
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Using Arrays as Maps


<html>
  <head>
    <title>Making the Connection</title>
  </head>
  <body>
    <p>
      <?php
        // This is an array using integers as the indices.
        // Add 'BMW' as the last element in the array!
        $car = array(2012, 'blue', 5, 'BMW');

        // This is an associative array.
        // Add the make => 'BMW' key/value pair!
        $assocCar = array('year' => 2012,
                   'colour' => 'blue',
                   'doors' => 5,
                   'make' => 'BMW');
           
        // This code should output "BMW"...
        echo $car[3];
        echo '<br />';
           
        // ...and so should this!
        echo $assocCar['make'];
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Review of Arrays


<html>
  <head>
    <title>Array Review</title>
  </head>
  <body>
    <p>
      <?php
        $fruits = array("bananas", "apples", "pears");              /* Your code here! */
        echo 'I love eating ' . $fruits[1]/* Your code here! */ . ' too!';
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Practice Makes Perfect


<html>
<head>
<title></title>
</head>
<body>
      <p>
        <?php
            function aboutMe($name, $age){
                echo "Hello! My name is $name, and I am $age years old.";
            }
           
            aboutMe("Anonymous",100);
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Parameters and Arguments


<html>
<head>
<title></title>
</head>
<body>
      <p>
        <?php
            function greetings($name){
                echo "Greetings, $name!";
            }
           
            greetings("Anonymous");
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: The Return Keyword


<html>
<head>
<title></title>
</head>
<body>
      <?php
           
        function returnName(){
            return "Anonymous";
        }
       
        print returnName();
      ?>
    </body>
</html>

Codecademy Sample Solution: Calling Your Function


<html>
<head>
<title></title>
</head>
<body>
      <p>
        <?php
        // Write your function below!
       
        function displayName(){
            echo "Anonymous";
        }
       
        displayName();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Your First Function


<html>
<head>
<title></title>
</head>
<body>
      <p>
        <?php
        // Write your function below!
       
        function displayName(){
            echo "Anonymous";
        }
       
        displayName();
        ?>
      </p>
    </body>
</html>

Codecademy Sample Solution: Function Refresher


<html>
    <head>
<title></title>
</head>
<body>
      <p>
        <?php
            echo strlen("Anonymous");
        ?>
      </p>
    </body>
</html>

Thursday, April 25, 2013

Codecademy Sample Solution: Show What You Know!


<html>
    <p>
<?php
// Create an array and push on the names
    // of your closest family and friends
    $somearray = array();
    array_push($somearray, "Garfield");
    array_push($somearray, "Odie");
    array_push($somearray, "John");
// Sort the list
    sort($somearray);
// Randomly select a winner!
    $arraylength = count($somearray);
    $winner = $somearray[rand(0,$arraylength-1)];
// Print the winner's name in ALL CAPS
    print strtoupper($winner);
?>
</p>
</html>

Codecademy Sample Solution: Array Functions II


<html>
    <p>
<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
    $somearray = array(1,3,4,6,5,7,2);
    sort($somearray);
    print join(", ", $somearray);
?>
</p>
<p>
<?php
// Reverse sort your array and print the joined elements to the screen
    rsort($somearray);
    print join(", ", $somearray);
?>
</p>
</html>

Codecademy Sample Solution: Array Functions I


<html>
    <p>
<?php
// Create an array and push 5 elements on to it, then
    // print the number of elements in your array to the screen
    $fruitbasket = array();
    array_push($fruitbasket, "apple");
    array_push($fruitbasket, "banana");
    array_push($fruitbasket, "grape");
    array_push($fruitbasket, "mango");
    array_push($fruitbasket, "orange");
    print count($fruitbasket);
?>
</p>
</html>

Codecademy Sample Solution: Math Functions I


<html>
    <p>
    <?php
    // Try rounding a floating point number to an integer
    // and print it to the screen
    print round(M_PI);
    ?>
    </p>
    <p>
    <?php
    // Try rounding a floating point number to 3 decimal places
    // and print it to the screen
    print round(M_PI,3);
    ?>
    </p>
</html>

Codecademy Sample Solution: String Functions II


<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    $name = "Anonymous";
    print strpos($name, "o");
    ?>
    </p>
    <p>
    <?php
    // Check for a false value of a letter that is not
    // in your own name and print out an error message
    if(strpos($name, "z")===false){
        print "The letter 'z' was not found in $name.";
    }
    ?>
    </p>
</html>

Codecademy Sample Solution: String Functions I


<html>
  <p>
    <?php
    // Get a partial string from within your own name
    // and print it to the screen!
    $name = "Anonymous";
    print substr($name,3,3);
    ?>
  </p>
  <p>
    <?php
    // Make your name upper case and print it to the screen:
    print strtoupper($name);
    ?>
  </p>
  <p>
    <?php
    // Make your name lower case and print it to the screen:
    print strtolower($name);
    ?>
  </p>
</html>

Codecademy Sample Solution: Introducing Functions


<html>
  <p>
    <?php
    // Get the length of your own name
    // and print it to the screen!
    $namelength = strlen("Anonymous");
    print "<p>$namelength</p>";
    ?>
  </p>
</html>

Tuesday, April 23, 2013

Codecademy Sample Solution: All On Your Own!


<!DOCTYPE html>
<html>
    <head>
<title>Your own do-while</title>
        <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
    <?php
        //write your do-while loop below
        $loopCount = 0;
        do{
            echo "<p>LoopCount value is {$loopCount}.</p>";
            $increment = rand(0,2);
            $loopCount = $loopCount + $increment;
        }while($loopCount<15);
    ?>
    </body>
</html>

Codecademy Sample Solution: Completing the Loop


<!DOCTYPE html>
<html>
    <head>
<title>Much a do-while</title>
</head>
<body>
    <?php
$loopCond = false;
do{
echo "<p>The loop ran even though the loop condition is false.</p>";
}while($loopCond);
echo "<p>Now the loop is done running.</p>";
    ?>
    </body>
</html>

Codecademy Sample Solution: Using Endwhile


<!DOCTYPE html>
<html>
    <head>
<title>A loop of your own</title>
        <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
    <?php
//Add while loop below
        $loopCount = 0;
        while($loopCount < 10):
            echo "<p>The current loop count is $loopCount</p>";
            $loopCount++;
        endwhile;
    ?>
    </body>
</html>

Codecademy Sample Solution: Your First While Loop


<!DOCTYPE html>
<html>
    <head>
<title>A loop of your own</title>
        <link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
    <?php
//Add while loop below
        $loopCount = 0;
        while($loopCount < 10){
            echo "<p>The current loop count is $loopCount</p>";
            $loopCount++;
        }
    ?>
    </body>
</html>

Codecademy Sample Solution: While Loop Syntax


<!DOCTYPE html>
<html>
    <head>
<title>Your First PHP while loop!</title>
</head>
<body>
    <?php
$loopCond = true;
while ($loopCond){
//Echo your message that the loop is running below
echo "<p>The loop is running.</p>";
$loopCond = false;
}
echo "<p>And now it's done.</p>";
    ?>
    </body>
</html>

Sunday, April 21, 2013

Codecademy Sample Solution: All On Your Own


<html>
  <head>
    <title></title>
  </head>
  <body>
    <p>
      <?php
        $yardlines = array("The 50... ", "the 40... ",
        "the 30... ", "the 20... ", "the 10... ");
        // Write your foreach loop below this line
        foreach($yardlines as $yardline){
            echo "$yardline";
        }
       
        // Write your foreach loop above this line
        echo "touchdown!";
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Practicing With ForEach


<html>
  <head>
    <title></title>
  </head>
  <body>
    <p>
      <?php
        $sentence = array("I'm ", "learning ", "PHP!");
       
        foreach ($sentence as $word) {
          echo $word;
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: When To Use 'For'


<html>
  <head>
    <title>Solo For Loop!</title>
  </head>
  <body>
    <p>
      <?php
      // Write your for loop below!
      for( $i = 50; $i > 4; $i = $i - 5){
        echo "<p>$i</p>";
      }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Writing Your First 'For' Loop


<html>
  <head>
    <title>Solo For Loop!</title>
  </head>
  <body>
    <p>
      <?php
      // Write your for loop below!
      for( $i = 10; $i < 101; $i = $i + 10){
        echo "<p>$i</p>";
      }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: 'For' Loop Syntax


<html>
  <head>
    <title>For Loops</title>
  </head>
  <body>
    <p>
      <?php
        // Echoes the first five even numbers
        for ($i = 2; $i < 11; $i = $i + 2) {
          echo $i;
        }
      ?>
    </p>
  </body>
</html>

Saturday, April 20, 2013

Codecademy Sample Solution: Deleting Array Elements


<html>
  <head>
    <title>Modifying Elements</title>
  </head>
  <body>
    <p>
      <?php
        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
        // Write the code to remove Python here!
       
        unset($languages[3]);
       
        // Write your code above this line. Don't
        // worry about the code below just yet; we're
        // using it to print the new array out for you!
       
        foreach($languages as $lang) {
          print "<p>$lang</p>";
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Modifying Array Elements


<html>
  <head>
    <title>Modifying Elements</title>
  </head>
  <body>
    <p>
      <?php
        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
       
        // Write the code to modify
        // the $languages array!
        $languages[2] = "C++";
        echo $languages[2];
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Access by Offset with {}


<html>
  <head>
    <title>Accessing Elements</title>
  </head>
  <body>
    <p>
      <?php
        $tens = array(10, 20, 30, 40, 50);
        echo $tens{2};
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Access by Offset with []


<html>
  <head>
    <title>Accessing Elements</title>
  </head>
  <body>
    <p>
      <?php
        $tens = array(10, 20, 30, 40, 50);
        echo $tens[2];
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Creating Your First Array


<html>
  <head>
    <title>My First Array</title>
  </head>
  <body>
    <p>
      <?php
        $friends = array("Bosh", "Lebron", "Wade");
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Array Syntax


<html>
  <head>
    <title>Woot, More Arrays!</title>
  </head>
  <body>
    <p>
      <?php
        // Add your array elements after
        // "Beans" and before the final ")"
        $array = array("Egg", "Tomato", "Beans", "Chips", "Sausage" );
      ?>
    </p>
  </body>
</html>

Thursday, April 18, 2013

Codecademy Sample Solution: All On Your Own!


<!DOCTYPE html>
<html>
    <head>
<title></title>
</head>
<body>
    <?php
        $GIjoe = 'Snake Eyes';
        switch($GIjoe):
            case 'Lady Jane':
                echo 'Baroness is hotter';
                break;
            case 'Duke':
                echo 'Dead in thirty minutes';
                break;
            case 'Snake Eyes':
                echo 'Silence is deadly';
                break;
            default:
                echo 'Bruce ain\'t no Joe';
        endswitch;
    ?>
</body>
</html>

Codecademy Sample Solution: Using "Endswitch". Syntactic Sugar!


<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
    <?php
    $i = 5;
   
    switch ($i):
        case 0:
            echo '$i is 0.';
            break;
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            echo '$i is somewhere between 1 and 5.';
            break;
        case 6:
        case 7:
            echo '$1 is either 6 or 7.';
            break;
        default:
            echo "I don't know how much \$i is";
            break;
    endswitch;
    ?>
    </body>
</html>

Codecademy Sample Solution: Multiple Cases: Falling Through!


<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
    <?php
    $i = 5;
   
    switch ($i) {
        case 0:
            echo '$i is 0.';
            break;
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            echo '$i is somewhere between 1 and 5.';
            break;
        case 6:
        case 7:
            echo '$1 is either 6 or 7.';
            break;
        default:
            echo "I don't know how much \$i is";
            break;
    }
    ?>
    </body>
</html>

Codecademy Sample Solution: Switch Syntax


<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
    <?php
    $fruit = "Apple";
   
    switch ($fruit) {
        case 'Apple':
            echo "Yummy.";
            break;
        default:
            echo "Mmm. Tasty.";
    }
   
    ?>
    </body>
</html>

Codecademy Sample Solution: Glance at the Past!


<!DOCTYPE html>
<html>
    <head>
<title></title>
</head>
<body>
    <?php
        $var = 1;
        if($var < 1){
            echo "Variable is less than 1.";
        }
        elseif($var > 1){
            echo "Variable is greater than 1.";
        }
        else{
            echo "Variable is less than 1.";
        }
    ?>
    </body>
</html>

Monday, April 15, 2013

Codecademy Sample Solution: All Together Now!


<html>
  <head>
    <title>If, Elseif, and Else</title>
  </head>
  <body>
    <p>
      <?php
        $guess = 7;
        $number = 7;
       
        // Write your if/elseif/else statement here!
        if($guess<$number){
            echo "Too low!";
        }
        elseif($guess>$number){
            echo "Too high!";
        }
        else{
            echo "You win!";
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Else + If = Elseif


<html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items = 1;    // Set this to a number greater than 5 to graduate from the exercise
        if($items == 1){
          echo "Sorry, no discount!";    
        }
        elseif ($items > 5){
          echo "You get a 10% discount!";
        }
        else{
          echo "You get a 5% discount!";  
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Adding an Else


<html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items = 4;    // This might cause an error since the exercise still expects a "TRUE" answer
        if ($items > 5){
          echo "You get a 10% discount!";
        }
        else{
          echo "You get a 5% discount!";  
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Your First 'if'


<html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items = 7;    // Set this to a number greater than 5!
        if ($items > 5){
          echo "You get a 10% discount!";
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Making Comparisons


<html>
  <head>
    <title>Comparing Numbers</title>
  </head>
  <body>
    <p>
      <?php
        $teabags = 3;
        if($teabags < 7)
            echo "true";
      ?>
    </p>
  </body>
</html>

Saturday, March 23, 2013

Scrolling Text Using Javascript


This is the scrolling text.

Code for the scrolling effect is written below:

<style type="text/css">
#scroll{
         position : absolute;
      white-space : nowrap;
              top : 0px;
             left : 200px;
       }
#oScroll{
    margin : 1px;
   padding : 0px;
         position : relative;
            width : 450px; /* width of the scroll box */
           height : 20px;
         overflow : hidden;
        }
      </style>
      <script type="text/javascript">
     function scroll(oid,iid){
          this.oCont=document.getElementById(oid)
          this.ele=document.getElementById(iid)
          this.width=this.ele.clientWidth;
          this.n=this.oCont.clientWidth;
          this.move=function(){
             this.ele.style.left=this.n+"px"
             this.n--
             if(this.n<(-this.width)){this.n=this.oCont.clientWidth}
                              }
                             }
     var vScroll
     function setup(){
         vScroll=new scroll("oScroll","scroll");
         setInterval("vScroll.move()",50) //controls the speed of scrolling, higher means slower
                     }
  onload=function(){setup()}
      </script>
<br />
<div id="oScroll">
<div id="scroll">
This is the <a href="http://questionsans.blogspot.com/2013/03/scrolling-text-using-javascript.html">scrolling text</a></div>
</div>

This is an example of scrolling text using Javascript.

Popular Posts