Skip to content

Commit 5af87d5

Browse files
committed
you're doing great
1 parent 075eb0d commit 5af87d5

File tree

1,236 files changed

+22135
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,236 files changed

+22135
-66
lines changed
File renamed without changes.

000_temp/02_hello/main.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
x := "Hello, class!"
9+
fmt.Println(x)
10+
}

000_temp/03_christmas/letter.phpasp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
{{range .}}
3+
*************************************
4+
Merry Christmas, {{.}} -
5+
6+
I hope the holiday season finds you well.
7+
8+
Blah blah blah.
9+
10+
Happy New Year, too!
11+
The McLeods
12+
{{end}}

000_temp/03_christmas/main.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"text/template"
7+
)
8+
9+
func main() {
10+
tpl, err := template.ParseFiles("letter.phpasp")
11+
if err != nil {
12+
fmt.Println("There was an error parsing file", err)
13+
}
14+
15+
friends := []string{"Alex", "Conor", "Ken", "Ronnie", "Patick", "Nina", "Jeremy", "Gentry", "Christian"}
16+
17+
err = tpl.Execute(os.Stdout, friends)
18+
if err != nil {
19+
fmt.Println("There was an error executing template", err)
20+
}
21+
}

000_temp/04_tcp-sample/main.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"net"
7+
)
8+
9+
func main() {
10+
conn, err := net.Dial("tcp", "golang.org:80")
11+
if err != nil {
12+
// handle error
13+
}
14+
15+
fmt.Fprintf(conn, "GET / HTTP/1.0\r\n\r\n")
16+
status, err := bufio.NewReader(conn).ReadString('\n')
17+
fmt.Println(status)
18+
}

000_temp/05_tcp-sample/main.go

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"io"
5+
"log"
6+
"net"
7+
)
8+
9+
func main() {
10+
// Listen on TCP port 2000 on all interfaces.
11+
l, err := net.Listen("tcp", ":2000")
12+
if err != nil {
13+
log.Fatal(err)
14+
}
15+
defer l.Close()
16+
for {
17+
// Wait for a connection.
18+
conn, err := l.Accept()
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
// Handle the connection in a new goroutine.
23+
// The loop then returns to accepting, so that
24+
// multiple connections may be served concurrently.
25+
go func(c net.Conn) {
26+
// Echo all incoming data.
27+
io.Copy(c, c)
28+
// Shut down the connection.
29+
c.Close()
30+
}(conn)
31+
}
32+
}
File renamed without changes.
File renamed without changes.

000_temp/08_flexbox/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<link rel="stylesheet" href="main.css">
7+
</head>
8+
<body>
9+
10+
<div class="container">
11+
<p>001</p><p>002</p><p>003</p><p>004</p><p>005</p><p>006</p><p>007</p><p>008</p><p>009</p><p>010</p><p>011</p><p>
12+
012</p><p>013</p><p>014</p><p>015</p><p>016</p><p>017</p><p>018</p><p>019</p><p>020</p>
13+
</div>
14+
15+
</body>
16+
</html>

000_temp/08_flexbox/main.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.container {
2+
display: flex;
3+
flex-flow: row wrap;
4+
}
5+
6+
p {
7+
border: 2px solid hotpink;
8+
}

000_temp/09_child/index.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<link rel="stylesheet" href="main.css">
7+
</head>
8+
<body>
9+
<ul>
10+
<li>01</li>
11+
<li>02</li>
12+
<li>03</li>
13+
<li>04</li>
14+
<li>05</li>
15+
<li>06</li>
16+
<li>07</li>
17+
<li>08</li>
18+
<li>09</li>
19+
<li>10</li>
20+
<li>11</li>
21+
<li>12</li>
22+
<li>13</li>
23+
<li>14</li>
24+
<li>15</li>
25+
<li>16</li>
26+
<li>17</li>
27+
<li>18</li>
28+
<li>19</li>
29+
<li>20</li>
30+
</ul>
31+
</body>
32+
</html>

000_temp/09_child/main.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
li:first-child {
2+
color: red;
3+
}
4+
5+
li:nth-child(2) {
6+
color: yellow;
7+
background-color: blue;
8+
}

000_temp/10_review-tcp/01/main.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"io"
5+
"log"
6+
"net"
7+
)
8+
9+
func main() {
10+
li, err := net.Listen("tcp", ":8080")
11+
if err != nil {
12+
log.Fatalln(err)
13+
}
14+
defer li.Close()
15+
16+
for {
17+
conn, err := li.Accept()
18+
if err != nil {
19+
log.Fatalln(err)
20+
}
21+
io.WriteString(conn, "DID IT WORK?")
22+
conn.Close()
23+
}
24+
}

000_temp/10_review-tcp/02/main.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io"
6+
"io/ioutil"
7+
"log"
8+
"net"
9+
)
10+
11+
func main() {
12+
ln, err := net.Listen("tcp", ":8080")
13+
if err != nil {
14+
log.Fatalln(err)
15+
}
16+
defer ln.Close()
17+
18+
for {
19+
c, err := ln.Accept()
20+
if err != nil {
21+
log.Fatalln(err)
22+
}
23+
24+
bs, err := ioutil.ReadAll(c)
25+
if err != nil {
26+
log.Fatalln(err)
27+
}
28+
fmt.Println(string(bs))
29+
30+
io.WriteString(c, "hello")
31+
c.Close()
32+
}
33+
}

000_temp/10_review-tcp/03/main.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"io"
7+
"log"
8+
"net"
9+
)
10+
11+
func main() {
12+
ln, err := net.Listen("tcp", ":8080")
13+
if err != nil {
14+
log.Fatalln(err)
15+
}
16+
defer ln.Close()
17+
18+
for {
19+
c, err := ln.Accept()
20+
if err != nil {
21+
log.Fatalln(err)
22+
}
23+
24+
scanner := bufio.NewScanner(c)
25+
for scanner.Scan() {
26+
ln := scanner.Text()
27+
fmt.Println(ln)
28+
if ln == "" {
29+
break
30+
}
31+
}
32+
33+
io.WriteString(c, "hello")
34+
c.Close()
35+
}
36+
}

000_temp/10_review-tcp/04/main.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"io"
7+
"log"
8+
"net"
9+
)
10+
11+
func main() {
12+
ln, err := net.Listen("tcp", ":8080")
13+
if err != nil {
14+
log.Fatalln(err)
15+
}
16+
defer ln.Close()
17+
18+
for {
19+
c, err := ln.Accept()
20+
if err != nil {
21+
log.Fatalln(err)
22+
}
23+
serve(c)
24+
c.Close()
25+
}
26+
}
27+
28+
func serve(c net.Conn) {
29+
scanner := bufio.NewScanner(c)
30+
for scanner.Scan() {
31+
ln := scanner.Text()
32+
fmt.Println(ln)
33+
if ln == "" {
34+
break
35+
}
36+
}
37+
io.WriteString(c, "hello")
38+
}

000_temp/10_review-tcp/05/main.go

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"io"
7+
"log"
8+
"net"
9+
"strings"
10+
)
11+
12+
func main() {
13+
ln, err := net.Listen("tcp", ":8080")
14+
if err != nil {
15+
log.Fatalln(err)
16+
}
17+
defer ln.Close()
18+
19+
for {
20+
c, err := ln.Accept()
21+
if err != nil {
22+
log.Fatalln(err)
23+
}
24+
25+
serve(c)
26+
}
27+
}
28+
29+
var counter int
30+
31+
func serve(c net.Conn) {
32+
defer c.Close()
33+
s := bufio.NewScanner(c)
34+
i := 1
35+
for s.Scan() {
36+
ln := s.Text()
37+
// we're in the request line
38+
if i == 1 {
39+
fmt.Println("HERE'S THE REQUEST LINE:", ln)
40+
words := strings.Split(ln, " ")
41+
fmt.Println("HERE'S THE METHOD:", words[0])
42+
fmt.Println("HERE'S THE URI:", words[1])
43+
fmt.Println("HERE'S THE HTTP VERSION:", words[2])
44+
}
45+
i++
46+
//fmt.Println(ln)
47+
//fmt.Fprintln(c, ln)
48+
if ln == "" {
49+
break
50+
}
51+
}
52+
io.WriteString(c, "wassup")
53+
fmt.Fprintln(c, "wassup again")
54+
}

0 commit comments

Comments
 (0)