Skip to content

Instantly share code, notes, and snippets.

@edjli
edjli / cat.rb
Created July 9, 2018 18:26
cat.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
@edjli
edjli / cat.rb
Created July 5, 2018 19:49
cat.rb
class Cat
attr_reader :color, :breed, :name
# attr_writer :name
attr_accessor :name
def initialize(color,breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
@edjli
edjli / fav_foods.rb
Created July 5, 2018 01:30
fav_foods.rb
def fav_foods
food_array = Array.new
3.times do
puts "Name a favorite food"
food_array << gets.chomp
end
p food_array
puts "Your favorite foods are #{food_array.join(", ")}."
food_array.each do |food|
@edjli
edjli / program2.rb
Created July 5, 2018 00:37
program2.rb, program3.rb, program4.rb
if (5+5==10)
puts "this is true"
else
puts "this is false"
end
@edjli
edjli / program.rb
Created July 5, 2018 00:12
First ruby
def greeting
puts "Please enter your name:"
name = gets.chomp
puts "Hello" + " " + name
end
greeting
@edjli
edjli / index.html
Created July 4, 2018 19:30
Project 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Edward Li's Website</title>
body {
position: relative;
/* background-color: #999; */
}
.projectName a{
color:white;
}
.container{
padding-top:50px;
}
body {
position: relative;
/* background-color: #999; */
}
.projectName a{
color:white;
}
.container{
padding-top:50px;
}
@edjli
edjli / script.js
Created June 29, 2018 17:47
Map DOM
$(document).ready(function(){
console.log("ready");
//smooth scrolling
var $root = $('html, body');
$('.navbar-nav a').click(function() {
var href = $.attr(this, 'href');
if (href != undefined && href != '#') {
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
@edjli
edjli / work.js
Created June 28, 2018 21:28
Added overlay and mousehover events through JQuery
$(document).ready(function(){
var works = [
{title: "Follow The Lead", url: "https://people.ucsc.edu/~edjli/art101/finalproject/edgame/midterm.html", pic: "img/followthelead.png"},
{title: "#BIGMOOD", url: "https://people.ucsc.edu/~edjli/FINAL/myGame/", pic: "img/bigmood2.png"} ];
for(var i = 0; i < works.length; i++){
$("#work-work").append("\
<div class='col-md-6 col-xs-12'>\
<a href='"+ works[i].url+"' class='work-img'>\
<img class='img-responsive' id ='workImg' src='" + works[i].pic + "'>\