Mocking Dart HTTP Client When Testing Flutter Widgets

If you’re not familiar with HTTP and Flutter widget tests, testWidgets() mocks the Dart http.Client to always return an HTTP 400 status! Surprising, I know. The idea is that you shouldn’t make real HTTP calls from your widget tests. But I think 99.9% of the time, this is not the response you want. Typically, you could mock the HTTP client with MockClient. This will work if you can provide an HttpClient directly to your widget. [Read More]

A Gun From the Future

I have a gun and it’s from the future. It fires smart bullets which are programmed to hit a specified target miles away. The bullets have built-in navigation and can maneuver around the terrain better than a cruise missile. It can fire an insane number of bullets per minute. And to fire the gun, I don’t even have to hold it or pull the trigger. I just think about my target, the gun locates the target, and fires. [Read More]

Deploy a Flutter web app and API to AWS CloudFront and S3 using Terraform

Over the years, I have used AWS Route 53, CloudFront, and S3 to deploy single-page web apps (SPA). Most of the time the backend API is delivered alongside the web app. This has a lot of advantages: Eliminates CORS issues Provides superfast delivery of the web app via CloudFront’s CDN CloudFront may provide faster access to your API than connecting from the browser/app to an AWS region. This is unintuitive, but if the CloudFront edge node is closer to your browser, there will be less latency. [Read More]

Google Home, Amazon Alexa, and Privacy

I was at my wife’s holiday dinner about a month ago and a conversation came up about Google Home and Amazon “Alexa” (a.k.a “Echo”). Mind you, the rest of the people there are not as technically savvy as my wife and me. Just about everybody had an aversion to these devices. One person at the table said “Dan, they’re always listening right?” I said Google isn’t always listening. The device is listening for the “Okay Google” key phrase inside of the device, then sends what it hears after the key phrase to Google. [Read More]

Food and IP

Here are some movies I think are worth watching about our food supply Strangely, these movies also twist together some of the intellectual property and patent issues I’ve been thinking about recently. Did you know if you grow Monsanto’s patented soybeans, you can’t keep any of the seed you produce? They actually police this. Also, if you’re a non-Monsanto soybean grower next to a Monsanto grower and Monsanto’s plants naturally cross with yours, Monsanto can come and take your crop because of patent infringement? [Read More]

The Light Side of the Moon

I’ve always been greatly inspired by the U.S. mission to the moon. The moon mission drove my passion for electronics, computers, and science; as it did for many others. I’ve read quite a bit on the moon mission and watched quite a few documentaries on it. I recently watched a couple of episodes of “Moon Machines.” This series caused me to connect some thoughts I’ve had lately - none of which have anything to do with actually being on the moon. [Read More]

Bad Smells

We were working on some refactored code today that wasn’t refactored properly. The tests had been changed to make the refactored code pass. My colleague said that I should write-up my “profound” comment on the situation:

If you’re performing a refactoring and you find yourself changing asserts in existing unit tests, something should smell bad. You’ve probably done something more than refactor the code.

I Will Make You Rich, Allow You to Travel the World, and You Don't Have to Do Anything!

A colleague recommended The 4 Hour Work Week by Timothy Ferriss the other day. I bit and bought the book to read on vacation. I got a little more than half way through the book when I had to take Tim’s advice and stop wasting time reading it. I’ll start by being objective. Tim makes a bunch of claims that cannot be backed up. How do we know he makes $40K-$80K a month with BrainQuicken? [Read More]