Open in app
Home
Notifications
Lists
Stories

Write
Paul Yeo
Paul Yeo

Home
About

Jun 6, 2021

Why the golang underscore struct field exists

Chances are if you’ve written some go or delved into a well-maintained go project, you’ve seen structs with an underscore field: type ListTablesInput struct { _ struct{} `type:"structure"` ExclusiveStartTableName *string `min:"3" type:"string" Limit *int64 `min:"1" type:"integer"` } > https://github.com/aws/aws-sdk-go/blob/7e0246814d8eb87bdc6850c44e8f75f020db80eb/service/dynamodb/api.go#L15104-L15115

Golang

1 min read


May 11, 2021

SQL slow query patterns

given a composite index, make sure the order of your index is in line with your access pattern. you do not want the following

Sql

2 min read

SQL slow query patterns
SQL slow query patterns

SQL slow query patterns

  1. given a composite index, make sure the order of your index is in line with your access pattern. you do not want the following

--

--


May 10, 2021

What the hell is PostgreSQL’s Bitmap Heap Scan

If you’ve ever seen something like this and wondered what the hell this means you’re in luck. An SQL index lookup requires (1) the tree traversal (2) following the linked list node chain (3) fetching the table data. In step (1) a query will traverse a B-tree to quickly find…

Postgres

2 min read

What the hell is PostgreSQL’s Bitmap Heap Scan
What the hell is PostgreSQL’s Bitmap Heap Scan

Dec 12, 2020

Solving Sudoku Programmatically

Terminology: Boxes are individual squares Units are complete rows, columns, and 3x3 squares Peers are boxes that belong to the same unit rows = 'ABCDEFGHI' cols = '123456789' def cross(a, b): # output = [] # for s in a: # for t in b: # output.append(s+t) …

Sudoku

3 min read

Solving Sudoku Programmatically
Solving Sudoku Programmatically

Dec 6, 2020

Python3: Given two sequences/iterators create a dictionary

a = "ABC", b = "123" dict(zip(a, b)) # {"A": "1", "B": "2", "C": "3"} zip() returns an iterator of tupes where the i-th tuple contains the i-th element from each of the argument sequences or iterators. dict() constructor builds dictionaries directly from sequences of key-value pairs. Built-in Functions - Python 3.9.1rc1 documentation The Python interpreter has a number of functions and types built into it that are always available. They are listed…docs.python.org

Python

1 min read

Python3: Given two sequences/iterators create a dictionary

a = "ABC", b = "123"
dict(zip(a, b))
# {"A": "1", "B": "2", "C": "3"}

zip() returns an iterator of tupes where the i-th tuple contains the i-th element from each of the argument sequences or iterators.

dict() constructor builds dictionaries directly from sequences of key-value pairs.

Built-in Functions - Python 3.9.1rc1 documentation

The Python interpreter has a number of functions and types built into it that are always available. They are listed…

docs.python.org

5. Data Structures - Python 3.9.1rc1 documentation

This chapter describes some things you've learned about already in more detail, and adds some new things as well. The…

docs.python.org

--

--


Dec 3, 2020

Vim: Jump to definition using Golang

$ brew tap universal-ctags/universal-ctags $ brew install --HEAD universal-ctags $ alias ctags=“`brew —-prefix`/bin/ctags” Using tags is a powerful tool to be able to jump to the definition of a function, variable, or class in Vim. Install universal-ctags and alias it as ctags. This allows adding support for languages that are not supported out of the box by universal-ctags (such as golang). Add the following lines to your .ctags file to support golang:

Vim

1 min read


Nov 20, 2020

go.mod, go.sum 101

Most times when writing software, you use other software or as we call them “dependencies.” In golang, we may call that a collection of go packages. That collection of go packages is outlined in a file called go.mod. module example.com/hello require ( github.com/aws/aws-lambda-go v1.13.3 // indirect github.com/aws/aws-sdk-go v1.25.45 github.com/bitly/go-simplejson v0.5.0…

Golang

2 min read


Nov 19, 2020

Golang Channels, Chinese Finger Traps

func Google(query string) (results []string) { c := make(chan string) go func() { c <- Web(query) }() go func() { c <- Image(query) }() go func() { c <- Video(query) }() timeout := time.After(80 * time.Millisecond) for i := 0; i < 3…

2 min read

Golang Channels, Chinese Finger Traps
Golang Channels, Chinese Finger Traps

Nov 18, 2020

Concurrency in Go: Using a channel to append to slices

type Result struct { Item item Error error } ch := make(chan Result) var wg sync.WaitGroup for _, i:= range items { go func(i Item) { defer wg.Done() res, err := processItem(i) if err != nil { ch <- Result{Item: i, Error: err} return } …

Golang

1 min read

Concurrency in Go: Using a channel to append to slices

type Result struct {
Item item
Error error
}
ch := make(chan Result)var wg sync.WaitGroupfor _, i:= range items { go func(i Item) {
defer wg.Done()

res, err := processItem(i)
if err != nil {
ch <- Result{Item: i, Error: err}
return
}
…

--

--


Aug 29, 2018

How NOT to get f*cked by WeChat Pay as a foreigner

If you’ve been to China or have Chinese friends you know that WeChat is used for just about anything in China. WeChat has an estimated 900 million monthly active users and the vast majority of the country uses WeChat Pay. WeChat Pay allows users to pay virtually anything with the…

China

3 min read

How NOT to get f*cked by WeChat Pay as a foreigner
How NOT to get f*cked by WeChat Pay as a foreigner
Paul Yeo

Paul Yeo

disscepolo della sperientia

Following
  • Netflix Technology Blog

    Netflix Technology Blog

  • Haseeb Qureshi

    Haseeb Qureshi

  • AirbnbEng

    AirbnbEng

  • Kneesovertoesguy

    Kneesovertoesguy

  • Steve Yegge

    Steve Yegge

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable