About a year ago I wrote Using Sinon Stubs, if you’re new to Sinon I recommend you read that post first!
It all started when a friend wrote a test but the stub he created wasn’t working: reviewing the test everything seemed to be done properly, yet it was obvious from the test logs that the real method was called instead of the stub.
What was going on? And how can we fix it?
It took a bit of digging to figure out, and the root-cause was not trivial which is why we’re sharing it with you, hoping to save…
I should be ashamed of myself that I found it only now, after a year of working with GH, I know…
Reviewing PRs on GitHub was a bit of a hassle when whitespaces were involved (that is, until now).
For example, whenever the writer decides to wrap a piece of code with try/catch clause, all the lines in-between will be marked as “changed” by default.
BUT, there’s a simple setup change to ignore whitespace changes:
Have fun reviewing PRs, bye-bye now!
It all started one afternoon when I got a call from Yoav Nordmann. He wanted to continue a discussion that we just had at the backend-group in Tikal. The discussion was about good and bad use-cases for using NodeJS. But let me take a few steps back.
I was first introduced to Java in the previous century: the year was 1999 and it was my first year on a CS degree and what can I say: I did not fall in-love…
Now we can see that some words got “scrambled” in the book, looking at a few example we can see that they all have the same characteristic:
Only on character was replaced!
This is great news, it means that we’re looking for words that are not in the dictionary file with Levenshtein distance of 1 from a word that is in the dictionary.
Coding it is not difficult (written in nodejs):
Metrics can be divided into two categories: infrastructure-metrics and business-metrics.
Infrastructure-metrics include signals about the system/os such as: memory, disk, CPU etc. Google defines a 4 golden HTTP metrics: traffic, error rate, latency and throughput/saturation — which may be considered as Infrastructure-metrics.
Business-metrics provide visibility into the business/application.
A few examples:
In order to be able to publish business-metrics we have to provide our engineers an easy-to-use mechanism…
Recently I declined two suggested changes to a library I’m maintaining. Both PRs had one thing in common: they introduced a change that required running a regex match in order to do something.
While I love using regexes for small/non-prod scripts, I think it is a bad idea, in general, to use them in production. From over 15 years of experience as a backend-developer, I can hardly remember one instance where I thought that the use of regex in production code was justified.
After having to explain my reasoning to two engineers, I decided that the next one who’ll ask…
Someone asked me how can we use a lambda in order to run a certain logic every time that a certain endpoint gets hit with a HTTP request.
I thought it’s pretty simple but after starting to go through the steps I realized that AWS interface is not that straightforward and could be confusing.
The following is a simple step-by-step guide that explains how to create such a lambda.
1. Go to lambda tab
2. Implement your logic
A few days ago I wanted to test a JS function, part of the test was to verify that another function gets called, and gets called correctly (with the correct parameters). I ended up using Sinon for the task, and now looking at it — it’s pretty easy and straightforward. Thing is, when I was trying to write my tests I didn’t find good examples and there was a little struggle until I figured it out, which is the motivation for this post (why not share and make someone’s else life easier, right?).
So let’s get down to business!
Declarative & Imperative code paradigms, are common buzz-words in the tech industry. In this post we’ll discuss these programming paradigms, what’s so good/bad about them and most important: a simple practical suggestion that can turn imperative code into declarative. Ready?
Let’s start with the more intuitive paradigm: Imperative. Imagine you want to get from point A to point B, like most of us, you’ll turn your phone’s GPS on, and ask for directions.
The list of directions may looks something like the following:
* drive straight for 0.5 miles
* turn right into street X
* continue for another 0.3 miles
* turn right…