This file contains hidden or 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 add(x, y int) int { | |
| return x + y | |
| } |
This file contains hidden or 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 TestAddingExample(t *testing.T) { | |
| result := add(3, 2) | |
| if result != 5 { | |
| t.Error("3 plus 2 is 5 but i got", result) | |
| } | |
| } |
This file contains hidden or 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
| type LatLong struct{ | |
| Lat float64 | |
| Long float64 | |
| } | |
| func (l LatLong) Generate(rand *rand.Rand, size int) reflect.Value{ | |
| randomLatLong := LatLong{ | |
| Lat: rand.Float64(), | |
| Long: rand.Float64(), | |
| } |
This file contains hidden or 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" | |
| "fmt" | |
| ) | |
| type MessageGetter interface { | |
| GetMessage() string | |
| } |
This file contains hidden or 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
| address_book = { | |
| "Chris" => "chris@james.com", | |
| "Ruth" => "ruth@baker.com", | |
| "Pepper" => "pepper@pot.com" | |
| } | |
| givers = address_book.keys.shuffle | |
| receivers = givers.rotate(1) | |
| givers_receivers = givers.zip(receivers) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>Chris James, London - Software Engineer</title> | |
| <meta charset="UTF-8"/> | |
| <meta name="description" content="Chris James, London - Software Engineer" lang="en"/> | |
| <meta name="viewport" content="width=device-width, minimumscale= | |
| 1.0, maximum-scale=1.0" /> | |
| <link rel="stylesheet" type="text/css" href="{{.CSSPath}}"> | |
| <link rel="alternate" type="application/rss+xml" title="RSS feed" href="/rss" /> |
This file contains hidden or 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
| # frozen_string_literal: true | |
| require_relative './setup_test_database' | |
| ENV['RACK_ENV'] = 'test' | |
| ENV['ENVIRONMENT'] = 'test' | |
| # Bring in the contents of the `app.rb` file | |
| require File.join(File.dirname(__FILE__), '..', 'app.rb') |
This file contains hidden or 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 Stitcher(w http.ResponseWriter, r *http.Request) { | |
| urls := r.URL.Query()["url"] | |
| if len(urls) == 0 { | |
| http.Error(w, "please provide a url querystring value", http.StatusBadRequest) | |
| return | |
| } | |
| for _, url := range urls { | |
| res, _ := http.Get(url) |
This file contains hidden or 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 Stitcher(w http.ResponseWriter, r *http.Request) { | |
| urls := r.URL.Query()["url"] | |
| if len(urls) == 0 { | |
| http.Error(w, "please provide a url querystring value", http.StatusBadRequest) | |
| return | |
| } | |
| bodies := make(chan io.ReadCloser, len(urls)) |
This file contains hidden or 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" | |
| "net/http/httptest" | |
| "strings" | |
| "testing" | |
| ) |