Skip to content

Instantly share code, notes, and snippets.

View SMaguina's full-sized avatar

Sylvia Maguiña SMaguina

View GitHub Profile
@SMaguina
SMaguina / lesson1
Last active August 29, 2015 14:17
Javascript/jQuery lesson 1 - script.js
Javascript Code: A textarea with it's background color changed via JavaScript
$("#message").ready(function(){
$("#message").css("background-color", "pink");
});
Javascript Code: User input appears in the DOM on Submit
$("button").on("click", function(){
console.log( "clicked" );
@SMaguina
SMaguina / lesson2
Last active August 29, 2015 14:17
lesson 2-javascript/jquery
$("#message").on("keyup", function() {
console.log("keyup happened"); // This console log ensures the .on() method event listener is in effect
var charCount = $("#message").val().length; // Method chaining occurs to return the # of characters in a DOM element; variable contains multiple data types/methods
console.log(charCount); // This console log ensures the variable for character count is in effect and the # of characters are printed in the console
$("#char-count").html(charCount);
if(charCount > 50) { // Conditional statements start here to change color of text based on character count value
$("#char-count").css("color", "red");
} else {
$("#char-count").css("color", "black");
}
@SMaguina
SMaguina / lesson 3
Last active August 29, 2015 14:18
Lesson 3/javascript, jquery
Javascript: For-loop in jQuery to change CSS properties in the DOM
$(function() {
var rows = $(".my-row");
console.log("row function");
for(var i=0; i<rows.length; ++i) {
if (i%2===0) {
$(rows[i]).css("background-color", "grey");
};
};
@SMaguina
SMaguina / lesson4
Last active August 29, 2015 14:18
Lesson 4/javascript & jQuery
Javascript: 4 boxes of photos with hover-on/out jQuery effect
var myKitties = [ { title: "1st", pic: "https://www.petfinder.com/wp-content/uploads/2012/09/Blog-Kitty-Cam-solo.jpg" }, { title: "2nd", pic: "http://www.animal-photography.com/thumbs/red_tabby_long_hair_kitten_~AP-0UJFTC-TH.jpg" },
{ title: "3rd", pic: "http://www.animal-photography.com/thumbs/silver_tabby_kittens~AP-0JO6Y9-TH.jpg" },
{ title: "4th", pic: "http://www.animal-photography.com/thumbs/silver_tabby_kitten_looking_up~AP-0DLVMB-TH.jpg" }
];
$( document ).ready( function(){
for(var i=0; i<myKitties.length; ++i) {
$("#" + i ).css("background-image", "url(" + myKitties[i].pic + ")" ); //Dot notation occurs here
@SMaguina
SMaguina / lesson 5
Last active August 29, 2015 14:18
lesson 5/jQuery & Javascrpt
HTML Google Maps:
<div class="gmaps">
<iframe
width="275"
height="150"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDjenMNMxYamTc3d9Ol6jOOUa7FlldHIng&q=Space+Needle,Seattle+WA">
</iframe>
</div>
@SMaguina
SMaguina / program.rb
Last active August 29, 2015 14:20
Ruby lesson 1
def greeting
puts "Please enter your name:"
name = gets.chomp
puts "Hello " + "" + name
end
greeting
@SMaguina
SMaguina / program2.rb
Created May 3, 2015 19:43
Ruby Lesson 2 - program2-4.rb
if (5+5==10)
puts "this is true"
else
puts "this is false"
end
@SMaguina
SMaguina / ruby-lesson 3.rb
Created May 14, 2015 03:15
Lesson 3 - Ruby
def fav_foods
food_array = []
3.times do
puts "Name a favorite food."
food_array << gets.chomp
end
puts "Your favorite foods are #{food_array.join(", ")}."
food_array.each do |food|
puts "I like #{food} too!"
end
@SMaguina
SMaguina / cat.rb
Created May 23, 2015 21:28
Ruby lesson 4
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
puts "Mmmm, " + food + "!"
@SMaguina
SMaguina / pet.rb
Created May 24, 2015 00:33
Ruby lesson 5
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
puts "Mmmm, " + food + "!"