Ever wondered how a sampled wave gets turned back into an analog wave for your speakers? The answer is not as simple as you may think.
In doing my own research I ran into a lot of maths and explanations that took me some time to fully understand and appreciate. The goal of this article is to explain one method for reconstructing a waveform from samples, presented in a way that should be consumable by someone that doesn’t have a heavy maths or engineering background.
I am not an expert by any means, but I do intend the scientific information…
I’m a big fan of TDD. BDD has always been a bit elusive to me in the sense that I wish I could use it more often. However, I always seem to end up struggling to express the same nuances through BDD that come effortlessly through a standard test case.
Truth be told, I have’t touched BDD in a while. However, this question has been bouncing around my head lately:
Why is it often so difficult to express simple systems through BDD?
Code based tests are really good at describing how we complete a task. BDD is really good at…
Go’s error handling is very explicit. It can also be very verbose compared to other languages. I want to talk about how we can minimize the need for explicit error handling by separating what are expected and unexpected errors.
An expected error is generally something you can test/check/verify ahead of time or that would not have a detrimental effect on the system. Some examples of expected errors are:
Expected errors should…
Go does not have any concept of enums like some other languages. There are arguments for and against this approach which I won’t go into here. However, there are times when you want to check that switch
statements contain all enum values. Especially if you intend to add new enum values in the future and want to catch existing code that now needs to be updated accordingly.
For this, I developed a tool called switch-check
. It’s a zero dependency, zero configuration CLI tool for doing just that. You can try it right now with:
go get -u github.com/elliotchance/switch-check
switch-check
Or…
It’s a common scenario — for me at least — to be building a CLI tool (main
package) that has CLI options (flags
package) that I want to add unit tests to.
Here’s a simple example of a CLI tool that adds or multiplies some input numbers:
Let’s try it:
5 + 7 + 9 = 21
— great… But wait! 3 * 2 * 5 != 0
…I’ve put a deliberate bug in the command. Something that we will catch and fix with a unit test.
Let’s write a unit test that uses the same CLI arguments so…
An ordered map (also called a linked hash map in Java) is a data structure that allows amortized O(1) for access and mutation just like a map, but the elements maintain their order.
For this I created the github.com/elliotchance/orderedmap
package. Here is some basic usage:
m := orderedmap.NewOrderedMap()// Keys and values can be any type.
m.Set("foo", "bar")
m.Set("qux", 1.23)
m.Set(123, true)m.Delete("qux")value, exists := m.Get("qux")
The most important feature of the *OrderedMap
is that the order of the keys is maintained, so that we can iterate them in their creation order:
for _, key := range m.Keys() {…
Go ships with great tools for runtime performance monitoring. However, for one of the projects I am working on I needed tailored metrics around three channels that do the primary communication between the larger components of the processing service.
I wanted to be able to print realtime stats on movement and blocking of these channels only each minute. So I created ChannelPerf
:
https://gist.github.com/elliotchance/7db9eb40a935f5526b62f0bcf77b7d2c
For the most part it is a drop in replacement-ish with how you would normally use a channel:
// ch := make(chan interface{}, 1)
ch := NewChannelPerf(1, "Some name")// ch <- "foo"
ch.Send("foo")// next…
start:
display "Hi, I'm bento."
https://github.com/elliotchance/bento
bento is a forth-generation programming language that is English-based. It is designed to separate orchestration from implementation as to provide a generic, self-documenting DSL that can be managed by non-technical individuals.
Wow, what a mouthful… That’s a bunch of fancy talk that means that the developers/engineers can setup the complex tasks and make them easily implementable by non-technical people through (almost) plain English.
The project is still very young, but it has a primary goal for each half of its intended audience:
For the developer/engineer: Programs can be written in any language (called a…
There are some cases where you need to read enough items from a channel to begin processing. However, you also want to a TTL to expire with a smaller batch if there are not more items for a while.
Here’s an example of streaming a channel of string
into an output channel of []string
that guarantees:
maxItems
.maxTimeout
.
I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com