May 28, 2023

How to clear a map in Go?

You should probably just create a new map. There’s no real reason to bother trying to clear an existing one, unless the same map is being referred to by multiple pieces of code and one piece explicitly needs to clear out the values such that this change is visible to the other pieces of code. […]

May 28, 2023

How to get JSON response from http.Get

The ideal way is not to use ioutil.ReadAll, but rather use a decoder on the reader directly. Here’s a nice function that gets a url and decodes its response onto a target structure. Example use: You should not be using the default *http.Client structure in production as this answer originally demonstrated! (Which is what http.Get/etc call to). The reason is that the default […]

May 28, 2023

Media Queries: How to target desktop, tablet, and mobile?

IMO these are the best breakpoints: Edit: Refined to work better with 960 grids: In practice, many designers convert pixels to ems, largely because ems afford better zooming. At standard zoom 1em === 16px, multiply pixels by 1em/16px to get ems. For example, 320px === 20em. In response to the comment, min-width is standard in “mobile-first” design, wherein you start by designing for your […]