Skip to content

Commit

Permalink
Adds week 8 exercises, slides, and source code
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRamirezFuentes committed Jul 13, 2021
1 parent 1874174 commit f62cc1d
Show file tree
Hide file tree
Showing 64 changed files with 143,964 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added week_8/slides/lecture8.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions week_8/source-code/api/blink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import requests
import time

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

while True:
requests.put(URL, json={"bri": 254, "on": True})
time.sleep(1)
requests.put(URL, json={"on": False})
time.sleep(1)
13 changes: 13 additions & 0 deletions week_8/source-code/api/blue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import requests

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

body = {
"hue": 46290,
"sat": 254
}

requests.put(URL, json=body)
13 changes: 13 additions & 0 deletions week_8/source-code/api/green.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import requests

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

body = {
"hue": 25500,
"sat": 254
}

requests.put(URL, json=body)
12 changes: 12 additions & 0 deletions week_8/source-code/api/off.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import requests

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

body = {
"on": False
}

requests.put(URL, json=body)
14 changes: 14 additions & 0 deletions week_8/source-code/api/on.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import requests

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

body = {
"bri": 254,
"on": True,
"sat": 0
}

requests.put(URL, json=body)
13 changes: 13 additions & 0 deletions week_8/source-code/api/red.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import requests

USERNAME = os.getenv("USERNAME")
IP = os.getenv("IP")
URL = f"http://{IP}/api/{USERNAME}/lights/1/state"

body = {
"hue": 65535,
"sat": 254
}

requests.put(URL, json=body)
35 changes: 35 additions & 0 deletions week_8/source-code/autocomplete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>

<html lang="en">

<head>
<meta name="viewport" content="initial-scale=1, width=device-width">
<title>autocomplete</title>
</head>

<body>

<input autocomplete="off" autofocus placeholder="Query" type="text">

<ul></ul>

<script src="large.js"></script>
<script>

let input = document.querySelector('input');
input.addEventListener('keyup', function(event) {
let html = '';
if (input.value) {
for (word of WORDS) {
if (word.startsWith(input.value)) {
html += `<li>${word}</li>`;
}
}
}
document.querySelector('ul').innerHTML = html;
});

</script>

</body>
</html>
28 changes: 28 additions & 0 deletions week_8/source-code/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>

<!-- Demonstrates programmatic changes to style -->

<html lang="en">
<head>
<title>background</title>
</head>
<body>
<button id="red">R</button>
<button id="green">G</button>
<button id="blue">B</button>
<script>

let body = document.querySelector('body');
document.querySelector('#red').onclick = function() {
body.style.backgroundColor = 'red';
};
document.querySelector('#green').onclick = function() {
body.style.backgroundColor = 'green';
};
document.querySelector('#blue').onclick = function() {
body.style.backgroundColor = 'blue';
};

</script>
</body>
</html>
30 changes: 30 additions & 0 deletions week_8/source-code/blink.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>

<html lang="en">
<head>
<script>

// Toggles visibility of greeting
function blink()
{
let body = document.querySelector('body');
if (body.style.visibility == 'hidden')
{
body.style.visibility = 'visible';
}
else
{
body.style.visibility = 'hidden';
}
}

// Blink every 500ms
window.setInterval(blink, 500);

</script>
<title>blink</title>
</head>
<body>
hello, world
</body>
</html>
20 changes: 20 additions & 0 deletions week_8/source-code/css0.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>

<!-- Demonstrates inline CSS -->

<html lang="en">
<head>
<title>css</title>
</head>
<body>
<header style="font-size: large; text-align: center;">
John Harvard
</header>
<main style="font-size: medium; text-align: center;">
Welcome to my home page!
</main>
<footer style="font-size: small; text-align: center;">
Copyright &#169; John Harvard
</footer>
</body>
</html>
20 changes: 20 additions & 0 deletions week_8/source-code/css1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>

<!-- Demonstrates inheritance -->

<html lang="en">
<head>
<title>css</title>
</head>
<body style="text-align: center;">
<header style="font-size: large;">
John Harvard
</header>
<main style="font-size: medium;">
Welcome to my home page!
</main>
<footer style="font-size: small;">
Copyright &#169; John Harvard
</footer>
</body>
</html>
41 changes: 41 additions & 0 deletions week_8/source-code/css2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>

<!-- Demonstrates CSS selectors -->

<html lang="en">
<head>
<style>

header
{
font-size: large;
text-align: center;
}

main
{
font-size: medium;
text-align: center;
}

footer
{
font-size: small;
text-align: center;
}

</style>
<title>css</title>
</head>
<body>
<header>
John Harvard
</header>
<main>
Welcome to my home page!
</main>
<footer>
Copyright &#169; John Harvard
</footer>
</body>
</html>
43 changes: 43 additions & 0 deletions week_8/source-code/css3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>

<!-- Demonstrates CSS selectors -->

<html lang="en">
<head>
<style>

body
{
text-align: center;
}

header
{
font-size: large;
}

main
{
font-size: medium;
}

footer
{
font-size: small;
}

</style>
<title>css</title>
</head>
<body>
<header>
John Harvard
</header>
<main>
Welcome to my home page!
</main>
<footer>
Copyright &#169; John Harvard
</footer>
</body>
</html>
43 changes: 43 additions & 0 deletions week_8/source-code/css4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>

<!-- Demonstrates CSS classes -->

<html lang="en">
<head>
<style>

.centered
{
text-align: center;
}

.large
{
font-size: large;
}

.medium
{
font-size: medium;
}

.small
{
font-size: small;
}

</style>
<title>css</title>
</head>
<body class="centered">
<header class="large">
John Harvard
</header>
<main class="medium">
Welcome to my home page!
</main>
<footer class="small">
Copyright &#169; John Harvard
</footer>
</body>
</html>
19 changes: 19 additions & 0 deletions week_8/source-code/css5.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.centered
{
text-align: center;
}

.large
{
font-size: large;
}

.medium
{
font-size: medium;
}

.small
{
font-size: small;
}
21 changes: 21 additions & 0 deletions week_8/source-code/css5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>

<!-- Demonstrates external stylesheets -->

<html lang="en">
<head>
<link href="css5.css" rel="stylesheet">
<title>css</title>
</head>
<body>
<header class="large">
John Harvard
</header>
<main class="medium">
Welcome to my home page!
</main>
<footer class="small">
Copyright &#169; John Harvard
</footer>
</body>
</html>
Loading

0 comments on commit f62cc1d

Please sign in to comment.