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 ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"strings" | |
"time" | |
) |
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 (u *User) Store(ctx context.Context) error { | |
... | |
if err := u.Hash.Store(ctx, k, u); err != nil { | |
return err | |
} | |
... | |
} |
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
WORKDIR := /usr/src/mycc | |
mycc: mycc.c | |
@docker run --rm -v ${PWD}:${WORKDIR} -w ${WORKDIR} gcc:8.3 gcc -o mycc mycc.c | |
.PHONY: test | |
test: mycc | |
@docker run --rm -v ${PWD}:${WORKDIR} -w ${WORKDIR} gcc:8.3 ./test.sh | |
.PHONY: clean |
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 webapp | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Error struct { | |
code int | |
} |
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
// Inspired by Go in Action: Chapter 7 – Concurrency patterns | |
// https://www.manning.com/books/go-in-action | |
package main | |
import ( | |
"fmt" | |
"os" | |
"sync" | |
) |
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
# See: https://developers.google.com/sheets/api/quickstart/python | |
import pickle | |
import os.path | |
from googleapiclient.discovery import build | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
from google.auth.transport.requests import Request | |
SCOPES = ['https://www.googleapis.com/auth/spreadsheets'] # read/write access | |
SHEET_ID = '<sheet_id>' |
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
import json # https://docs.python-guide.org/scenarios/json/ | |
import csv # https://docs.python.org/3/library/csv.html | |
json_string = '[\ | |
{"gender": "Male", "Nationality": "JPN", "document_type": "passport"}\ | |
]' | |
parsed_json = json.loads(json_string) | |
with open('out.csv', 'w', newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
for row in parsed_json: |
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 handler(w http.ResponseWriter, r *http.Request) { | |
queries := r.URL.Query() // Values = map[string][]string | |
for key, values := range queries { | |
for _, v := range values { | |
fmt.Fprintf(w, "key: %s, value: %s\n", key, v) | |
} | |
} | |
} |
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 (c *Client) Get(url string) (string, error) { | |
resp, err := c.cli.Get(url) | |
if err != nil { | |
return "", err | |
} | |
b, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
return "", err | |
} |
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 TestHeader(t *testing.T) { | |
cases := []struct { | |
input []string | |
want map[string][]string | |
}{ | |
{ | |
input: []string{"X-Test: test"}, | |
want: map[string][]string{"X-Test": []string{"test"}}, | |
}, | |
{ |
NewerOlder