This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/tensorflow/tfjs-examples | |
$ cd tfjs-examples/mnist | |
$ yarn | |
$ yarn watch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.11; | |
contract SimpleAuction { | |
// Parameters of the auction. Times are either | |
// absolute unix timestamps (seconds since 1970-01-01) | |
// or time periods in seconds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a-scene> | |
<a-assets> | |
<audio id="click-sound" src="audio/click.ogg"></audio> | |
<!-- Images. --> | |
<img id="city" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/city.jpg"> | |
<img id="city-thumb" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-city.jpg"> | |
<img id="cubes" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/cubes.jpg"> | |
<img id="cubes-thumb" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-cubes.jpg"> | |
<img id="sechelt" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/sechelt.jpg"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the name of our package | |
// Everything with this package name can see everything | |
// else inside the same package, regardless of the file they are in | |
package main | |
// These are the libraries we are going to use | |
// Both "fmt" and "net" are part of the Go standard library | |
import ( | |
// "fmt" has methods for formatted I/O operations (like printing to the console) | |
"fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"net/http/httptest" | |
"testing" | |
) | |
func TestHandler(t *testing.T) { | |
//Here, we form a new HTTP request. This is the request that's going to be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/gorilla/mux" | |
) | |
// The new router function creates the router and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestRouter(t *testing.T) { | |
// Instantiate the router using the constructor function that | |
// we defined previously | |
r := newRouter() | |
// Create a new server using the "httptest" libraries `NewServer` method | |
// Documentation : https://golang.org/pkg/net/http/httptest/#NewServer | |
mockServer := httptest.NewServer(r) | |
// The mock server we created runs a server and exposes its location in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestRouterForNonExistentRoute(t *testing.T) { | |
r := newRouter() | |
mockServer := httptest.NewServer(r) | |
// Most of the code is similar. The only difference is that now we make a | |
//request to a route we know we didn't define, like the `POST /hello` route. | |
resp, err := http.Post(mockServer.URL+"/hello", "", nil) | |
if err != nil { | |
t.Fatal(err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func newRouter() *mux.Router { | |
r := mux.NewRouter() | |
r.HandleFunc("/hello", handler).Methods("GET") | |
// Declare the static file directory and point it to the | |
// directory we just made | |
staticFileDirectory := http.Dir("./assets/") | |
// Declare the handler, that routes requests to their respective filename. | |
// The fileserver is wrapped in the `stripPrefix` method, because we want to | |
// remove the "/assets/" prefix when looking for files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestStaticFileServer(t *testing.T) { | |
r := newRouter() | |
mockServer := httptest.NewServer(r) | |
// We want to hit the `GET /assets/` route to get the index.html file response | |
resp, err := http.Get(mockServer.URL + "/assets/") | |
if err != nil { | |
t.Fatal(err) | |
} |
OlderNewer