I used to be vehemently against using `reduce` in Javascript. It wasn’t because I thought there was a better way, I actually think the functional programming purists and their aggressive approach to advocacy are what really turned me off. That and those who advocate for using it over a basic for loop as well.
Now, there are instances where I truly believe that filter, map and reduce should not be used. If you’re just wanting to quickly iterate over a collection of values, in many instances. a for..loop will beat all of those aforementioned methods in performance every single time. And if you’re dealing with large collections of items, you will notice.
The controversial Australian government contact tracing application based on the Singapore version has finally been released for Australians. Understandably, a lot of people are concerned about their privacy and whether or not the government messed this up.
I had a spare phone lying around, so I installed the application for the lols. I decided to see if I could find anything nefarious with the app or if it drains my battery like Singaporeans reported their app did.
When it comes to mocking dependencies in Jest, it couldn’t be easier. You can create an actual mock module that gets loaded in place of the dependency in your app or you can do it manually by mocking the implementation or module.
import { SomeClass } from './some-file'; // Mock the uuid module and v4 method jest.mock('uuid', () => ({ v4: () => 'hjhj87878' })); describe('Test Case', () => { let sut; beforeEach(() => { sut = new SomeClass(); }); test('My Test', () => { expect(sut.returnUuid()).toReturn('hjhj87878'); }); }); For reference, our SomeClass implementation looks like this:
As I explained in my HelloFresh review here, we have been trying out at home meal kits because of the shortages of basics in the grocery stores here in Australia such as; mince, flour, eggs and so on.
After trying HelloFresh, we decided to try out Dinnerly which markets itself as, “Australia’s most affordable home dinner kit” it’s actually owned by Marley Spoon, just a cheaper version for those who cannot afford Marley Spoon which is one of the more expensive options.
Recently whilst working on some blockchain specific code, I needed to write a random number generator to simulate generating a range of numbers, except it needed to be predictable. The same input values produce the same output when provided.
In my case, I used values from immutable blockchain data such as the blockchain number, reference block number and transaction ID. I then allow the user to provide a client seed and generate a unique server seed on each roll as well.
Globally, many of us are all in the same unfortunate and unprecedented situation because of the Novel Coronavirus COVID-19. I am fortunate to both work in an industry where I still have a job and for a company mostly unaffected by COVID-19.
Sadly, for many, this is not the case as people find themselves out of work through no fault of their own. For others, they find themselves working remotely; for many, it’s their first time.
This COVID-19/Novel Coronavirus has really changed the world and how we live. Even the basic things we take for granted like being able to go to the shop and buy meat, bread, rice and toilet paper have become difficult tasks.
We have a family of four. Two adults and two children, my son is four years old and my daughter is fourteen months old. Out of frustration of not being able to find basics in the stores like; flour, eggs, rice and mince, we decided to explore home meal kits.
If you have been watching the news of late and let’s be honest, who hasn’t given we are a part of an unprecedented global pandemic? Then you would have heard of the announcement of a contact tracing application you install on your phone which notifies you and others if you’ve been in contact with anyone who tests positive for COVID-19.
On the surface, every day Australians will hear the government say, “If everyone installs this, we can ease restrictions faster and flatten the curve by being able to control the spread” – but for those in tech like myself who are critical of the government’s ability to produce an app that won’t be a privacy nightmare, things are a little more convoluted.
Whilst doing some work in a library I maintain, I needed to add in the ability to calculate the hash of an included file for an integrity check feature I was adding in. The resulting solution is simple and not boast-worthy, but given others might encounter a situation where they need a hash of a file, this might help.
We use the fs module to open up the file we want to calculate the hash for, use the createHash method on the crypto package to then pass in our file buffer from the readFileSync method, and that’s it.
For years the people have been asking for tab groups in Chrome. While extensions do exist, they’re somewhat fickle. Now, tab groups are natively supported in Google Chrome itself. While the feature is rolling out in Google Chrome 81, if you’re like me, you’re running Chrome 81 and the feature isn’t on for you yet.
If you right-click on a tab and can’t see the new tab group options, you need to enable it. To visit the flags screen, open a new tab and visit: chrome://flags/ – in the search input, enter groups.