blogging

Cypress.io where have you been all my web dev life?

Probably, the better title would be: where have I been all of Cypress.io‘s life? Now on version 5.1.0 as of this writing with more than 200 releases showing on GitHub, it’s projects like Cypress that make me wonder what rock I’ve been living under when it comes to exploring website dev testing platforms.

I had it installed and running tests on my simple resume website in about 10 minutes. Obviously, a comprehensive web app would take longer and, of course, require more comprehensive testing than a 10 minute run through. Still, Cypress provides an easy to implement testing platform that’s a great fit for a broad spectrum of web development. There are shortcomings, but the majority of web development (especially SPA) isn’t going to fall into those categories.

Setup in a project, is super simple:

npm I cypress --save-dev
node_modules/.bin/cypress open

The above gets you started with a solid set of example scripts. Cypress has a boatload more examples to play around with.

For my example, I have concurrently installed and just added the following script:

"dev-cy": "concurrently \"next\" \"node_modules/.bin/cypress open\""

I made some basic tests on a resume website that I built for myself and ran through a series of viewports. Then, with a viewport selected, you can actually run through each of the tests and see the test elements on the specific viewport. Here it is in action…

blogging

AWS CloudWatch Lambda Functions No Log For You! (solved)

Edited with solution at the bottom…

I had a lambda function on AWS that I wanted to check the logs on. I had it setup with CloudWatch permissions, and I was able to see the summary metrics on the Monitoring tab. So, I was a bit surprised when I saw the following:

Other Lambda functions were logging fine. Just not this one. I tried switching the role under permissions, and even tried deleting it and adding it again (it was a dev only function) and no luck with the CloudWatch logs. I’m just going to chalk this up as luck of the draw for getting logs that are viewable in CloudWatch…

If you happen to encounter this same issue, just know you are not alone 🙂

If you happen to have a solution, feel free to add a generous comment.

Solution

I created a new IAM policy that has the same CloudWatch permissions as the AWSLambdaBasicExecutionRole. I then attached that policy to the role assigned to my Lambda function. I executed a test of my Lambda function and then went to CloudWatch. Sure enough, there was my group and my test call had logged properly!

I then switched the permissions back to the original, and executed another test of my Lambda function. The new test logged correctly. This issue kinda reminds me of the SignatureDoesNotMatch issue I encountered back in March.

blogging, cool stuff

Getting Started with Strapi and Cloudinary + new npm package

The first time I looked into Strapi was 2019. It looked like a project going in an interesting direction, but I didn’t play with it much. With time to spare on my hands over the last few months, I figured I’d look at Strapi again. It’s come a long way!

There are plenty of great resources online about Strapi, so I’ll try to avoid being redundant. There’s a great post on the Strapi blog about a building a starter blog that even has a one click deploy to Heroku! I figured that would be a great starting point to learning the basics, and it saved me the hassle of doing my own deployment. More importantly, it got me looking into Cloudinary (I’ll come back to that in a minute).

After playing around with that, I received an email from Strapi about building a corporate website using Next and Strapi. This is a great intro to the Strapi concept of single types as well as components.

The basic idea with this repo being that you have a global set of components for setting your core metadata, favicon, navbar, notification bar, and footer that will be used on all pages. Of course, the metadata component is also placed on the page collection type, allowing you to define the metadata on a page-by-page basis. You then add the components you want (and the Strapi team has built a fair number of common website elements as components) so that you have a fully functional website CMS.

Both of those demo repos use Cloudinary for their media management, so I took a dive into Cloudinary to see what it’s all about. WOW! What a great DAM system! They have an excellent free tier to get your feet wet, and realistically handle any developer prototyping you might come up with. The image transformation features are DEEP, and the best part is they have a ton of documentation and training/tutorials available to get up to speed quickly.

There was one issue though… Strapi was placing everything into the root Cloudinary root. So, I figured it’s time for me to make my first npm package. To be clear, I really just stole the existing strapi-provider-upload-cloudinary package and modified the code to give you the ability to specify a folder structure when you upload an image using Strapi as well as define a default folder.

So, let’s say you are using your Cloudinary account for more than one project (Project A and Project B). For Project A, you make your default_folder project-a, and for Project B, you make your default_folder project-b. Then when you upload the images/videos, they will default into their respective project folders. And if you want to have sub-folders, you just change the name to include the folder structure at time of upload. Further details and images are available on the GitHub page for the package.

Let’s say you have assets that you want to use on Project A and Project B… Well, just upload the resource with a leading / and it will place it into your Cloudinary root (along with any folder structure you provide), and then use it for all your projects!

One import note regarding new Cloudinary accounts and PDF files. By default, Cloudinary blocks the delivery (not upload but delivery) of PDF files for new accounts. According to their support, you can email them to have that restriction lifted. I have yet to confirm that, but based upon how responsive Cloudinary has been on everything so far, it’s likely valid that they’ll lift the PDF delivery blocking if you request it.

All that said… I’m loving Strapi for rapid API prototyping and Cloudinary for an extremely powerful DAM platform!

blogging

AWS S3: SignatureDoesNotMatch (getSignedUrl)

Setup a new S3 Bucket with IAM User, and went to upload the file after making a call to getSignedUrl. I thought I had everything right. Double/triple checked everything. Turns out the initial Access key ID I received from AWS just didn’t work. Created a new one, and magic.

Apparently, I’m not the only one who has encountered this baffling issue and magical solution. Hope this helps anyone else who encounters the error: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method.

blogging

Metro Bundler error: Invalid regular expression | node > 12.9 Windows

TLDR: If you’re doing React Native Expo development on a Windoze machine and have node version > 12.9 Metro Bundler will fail with a regex error:

error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class.

Seems like two fixes for this:

  1. Downgrade your version of node, as stated on this expo-cli GitHub ticket
  2. Update the regex in metro-config/src/defaults/blacklist.js:
    from

    var sharedBlacklist = [
      /node_modules[/\\]react[/\\]dist[/\\].*/,
      /website\/node_modules\/.*/,
      /heapCapture\/bundle\.js/,
      /.*\/__tests__\/.*/

    ];

    to

    var sharedBlacklist = [
      /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
      /website\/node_modules\/.*/,
      /heapCapture\/bundle\.js/,
      /.*\/__tests__\/.*/
    ];
    note the additional escapes in the expr: /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
    the difference is very subtle

Hoping this helps anyone encountering this issue. If you don’t downgrade node (which might not be an option for everyone), then every new project or any time you npm i, you’ll need to perform this regex replacement in the metro-config/src/defaults/blacklist.js file.

blogging

Email field with space in React 16 backspace issue

TLDR: There’s an “issue” with backspace in an input type=email field and React 16 that has a conversation going on here.

While working on a React project, a testing “issue” came up while testing an email input field. I use “air quotes” here because… Well, spaces in email fields aren’t really a thing you’d happen upon in common real-world scenarios. Nonetheless, it’s a legitimate (albeit, non-critical) issue that you may encounter during dev/testing of a React app.

A tester was testing a login form and entered “Here is a test” into the email field to test if the field validation was working. Sure enough, that input was identified as an invalid email address. Okay! Time to go home. Until they tester started backspacing in the email field and found the cursor suddenly jump to the beginning of the field when backspacing over the space. In other words, the cursor jumped from the a to before the H at the very beginning of the email field and did not delete/backspace over the text.

After sleuthing, I found the above mentioned link. Linked here again if anyone encounters the same “issue” while testing backspacing in an input type=email field while developing in React. GitHub poster’s fiddle demonstrating the issue can be found here.

blogging

npm install bcrypt fails on Windoze

Getting started with a fresh windoze dev environment and went to install the npm bcrypt package. Ended up with an error while building… Found many recommendations to just install bcryptjs, which wasn’t an option I was interested in. Found some sage advice of (Powershell with Admin rights):

//Temporarily disable Real-time protection within Windoze Defender
npm install -g node-gyp
npm install -g --production windows-build-tools

went with that instead. npm i bcrypt worked like a charm!

art, blogging, culture, friends, life, photos, travel

Donde está la biblioteca

It’s one of the first phrases you learn in high school Spanish: Donde está la biblioteca

And the running joke is that you will never use that phrase in a real conversation.

Deadpool’s translation is way off. “Donde está la biblioteca” = “Where is the library”, not:

On my latest trip to Cabo with my beautiful wife to help plan her upcoming country music charity festival, the phrase “Donde está la biblioteca” was finally put to good use! We had heard so many great things about the art walk over the last year, and this trip we decided to check it out. We had visited downtown San José del Cabo the Sunday before to explore some of the potential locations for holding a large outdoor gathering, so we were able to familiarize ourselves with the area a bit.

The area around Parroquia San José is a lively place! It’s also at the heart of the art walk we knew we were going to see on Thursday. We spent some time in the square, soaking up the atmosphere and energy.

The experience inside the Parish was invigorating! Perhaps it was the cool inside air, or it was an adventure for my soul. Either way, this is a must for anyone visiting Cabo!

The Wednesday before the art walk, my wife and I were spending some time with the great artists at Blanco Creative at the Koral Center El Merkado. We got onto the topic of conversational Spanish vs. academic Spanish (as well as how growing up in Los Angeles, I learned all the bad words before I knew anything else). Naturally, “Donde está la biblioteca” came up. We all had a great laugh saying “Donde está la biblioteca” in a super formal manner.

“Donde está la biblioteca” is definitely a term one will almost certainly never use in everyday conversation, right?

Fast forward to the next evening with my wife and I back in beautiful downtown San José del Cabo. We were working longer than expected that evening and didn’t head over until a bit later than we anticipated. When we got there, parking was hard to come by. Later on, we found out there is great parking for art walk visitors just south of the Parish, but we ended up parking several blocks away from the bustling art district.

It was pretty easy to find our way to the festivities. We grabbed a couple of nitro coffees at The Breakdown and started perusing the art scene! There was so much to see. I’ll have to write-up another blog just to touch on the art we got to see and experience, and we only got to see the tip of the iceberg on this first visit.

There was one small gallery that was calling my name though. While my wife and I were making a B-line for our coffees, I saw the gallery out of the corner of my eye and said, “I really want to go to that one.” After we got our coffees and looked around at some of the art displays in the small square outside The Breakdown, we headed over to the small gallery.

It’s hard to describe the experience when we stepped inside this small gallery. The visuals and audio are easy to explain: beautiful handmade jewelry with unique, colorful stones; colorful paintings; lively music from The Baja Brewing Company just on the other side of the back wall; and happy artists inside. But there was more to it than just what can be explained with simple words. There was magic!

I was really impressed with the silver work by Oscar Vargas. We chatted for a bit with him about his craft. As a horologist, I have a great appreciation for handcrafted jewelry, and Oscar’s love of his work was evident in his art.

After picking up a couple of pieces of beautiful jewelry from Oscar, my wife and I still felt like something was calling us in the gallery. We looked around at the paintings, all of them beautiful work! As we were about to head out and on to the rest of the art walk, there was one painting that really called to us both. Interestingly enough, it wasn’t listed for sale (oh, and we captured it in our photo with Oscar without even realizing it until I started going through the photos to make this blog).

The painting was made by the wife of the owner of the gallery. We asked if she’d consider selling it because we were both just drawn to this painting. So, Mario (another artist in the gallery) called up the owner and inquired. Next thing you know, we’re trying to figure out how we’re going to get it on the plane back to Los Angeles. We made the purchase and made arrangements to come back for the painting after we had walked around the art walk.

We went about the walk, enjoying every minute; making new friends and even bumping into old friends at the Parish. My wife and I had such a wonderful experience at the Parish last time, we decided to go back and check it out. This time there was an evening service taking place. I waited outside with the two coffees while my wife went inside. As the service ended, out came a dear friend, Carmina, who I met for the first time about 10 years ago while running the Steinhausen watch company.

Cabo Parish at night

We walked around a bit, shared some churros, and talked about life while enjoying some more beautiful artwork. As we were walking along the art displays in the square, I heard someone say “Señor. Señor”. I looked over and someone was trying to get my attention. He succeeded! “You just bought a painting from my gallery,” he said.

Francisco the Finger Painter

It took me a few seconds to put it together that he was the owner of the gallery where my wife and I had just purchased his wife’s painting. I stood in amazement at what a wonderful experience the entire night was as I spoke with Francisco about how much his wife’s painting had captured my heart. He told me he was so glad to hear this because his wife wasn’t sure if she ever wanted to sell it. He told her that if she ever did, the right person would come along at the right time. The painting had been through three hurricanes and was nearly 10 years old, and now we were blessed to have this treasured piece of work coming home with us!

Of course, we would have to find our car and get the painting back to Los Angeles. We said goodnight to my friend Carmina and then went back to pickup the painting. Then the adventure began. We had a good idea where we parked, so we started walking (painting in hand) in that direction. A few wrong turns later, and we quickly realized we had no idea where we had parked! I stood at a corner near the Parish and pulled up a photo I had taken of our car when we parked. I pulled up the GPS location and started to chuckle as I walked passed by wife and said: Donde está la biblioteca?

My wife looked at me puzzled.

Donde está la biblioteca?

“What does that even mean?” She asked. She definitely shouldn’t watch the Deadpool video!

We walked block after block holding hands as I kept saying “Donde está la biblioteca”. A few minutes later, we were back at our car, which was parked where? You guessed it! En la biblioteca!

20190120_212154000_ios

blogging, culture, life, philosophy, Politics, Relationships, technology, thoughts

What a difference a preposition makes

“Behind every great man is a great woman”

We hear that statement (or some variant: “Behind every successful man is a woman”) so often, particularly in politics. It’s so popular that with the rise of successful women in business and politics we hear the gender role reversal: Behind every great woman is a great man. Regardless of the gender roles, the statement has an underlying tone that the spouse of a great/successful person is hidden “behind” the successful person.

Maybe we see the significant other on the stage… Maybe the great wo/man is mentioned in an acceptance speech… Maybe in the memoirs…

The reality is that *Beside* every great wo/man is a great wo/man. It’s just a preposition, but this preposition swap accurately reflects the true spirit of this popular idiom. The spouse of a successful person stands besides them, not behind them. When they walked down the isle, they walked beside each other. No one individual was behind or in front of the other, and it’s the same in success and greatness.

When I achieve success in business or life, my wife is always beside me; not behind me. And I know that the same holds true for her. We’re on this adventure together. One of us certainly takes the lead depending on what obstacle is in front of us, but when we cross that finish line… When we achieve success, it’s beside one another.

blogging

Everything Awesome and Disappointing About the Chevy Volt

The following two pictures represent both what is great about the Chevy Volt and what is disappointing about the Chevy Volt.

Photo Sep 16, 6 26 56 PMPhoto Sep 16, 6 27 06 PM

This comes from starting with a full charge, almost getting to my destination without using any gas, recharging on a Level 2 for four hours and then driving home.

The Good
3.765 mi/kwh is pretty efficient given that this was all freeway driving in North Los Angeles County (that means a fair amount of hills and mostly 60+mph with the occasional slow-and-go). On the flip side, 3 miles on 0.1 gallons is a measly 30mpg. However, the gas wasn’t really used until the end of the first leg of my trip, which went from 768ft above sea level to 1200ft above sea level.

Great thing about the Chevy Volt is that you have that generator to take you the extra miles. Plus, 97 degrees at 6 at night… It was a hot day outside but plenty cool on the inside with the AC set way down.

That 210 lifetime MPG is really nice too!

The Bad
Obviously, 30MPG isn’t great. However, it was going uphill, which is actually really good. However, it was completely unnecessary given the true size of the Chevy Volt battery. After all, the 2014 Volt has 17.1 kwh battery, which is only 3 wkh less than this total trip that included a second charge.

I was fortunate enough to have access to 240 charging during this trip. Had I only had the trickle charger (8 hour recharge) that GM claims is perfectly acceptable, I would have been blowing fumes for the vast majority of the second leg of my trip. I charged for four hours between legs. The Volt’s measly 3.3 charger didn’t give me a full charge before I had to leave. Were GM to offer a 6.6 charger, I would have been recharged completely and used even less gas than I ended up using on this two legged trip.

Of course, if I needed to run errands after I got back home, I’d be blowing fumes out the back of my Volt unless I waited for hours and hours for my trickle charger at home to get me enough juice to go a few extra miles electric.

Chevy Volt fanboys might look at this and see only the great thing about the fact that the generator allowed me to make this trip with minimal gas usage. Sure, that definitely points to a great feature of the Volt. However, it also points to an annoying feature of the Volt: no extended electric setting. Aside from the painfully slow charge rate of the Volt (which I believe will cost GM thousands of customers with the Volt 2.0), the reality is that this trip didn’t require the use of any gasoline.

If the Volt gave you the ability to set an extended EV range (like the Leaf, Tesla, and every other EV) that gives you an extra 1-3 kwh of battery usage, the gas generator would have never been needed on this trip. Even with just an extra 1kwh, I would have gotten the extra 3 miles I needed to stay 100% electric. I have plenty of other trips that I have taken that far exceed this range, so it’s not like I’m expecting every trip I take to be 100% electric. However, when frequent trips are right outside the cusp the Volt’s 60% battery utilization, it’s plain to see that something as simple as an extended EV setting would be a simple software upgrade for the Volt that would make it all that much more appealing and satisfying to Volt owners.

Better in Every Way
Larry Nitz from GM mentioned some interesting stats the other day when talking about the Volt. A few of the numbers are particularly interesting to me because I think GM interpreted them the wrong way:

  • 60% of volt customers only charge on 110v rather than 240v.
    GM seems to think that this is consumers saying that they are okay with 8 hour charge times. That’s not the case. This is consumers not being willing to invested thousands of dollars for 240 charging when they reap little benefit. Most homes don’t have a 240 that you can just plug your ClipperCreek into and call it a day. Would Volt owners like faster charge times if it wasn’t a multi-thousand dollar investment? Of course. The use of 110 at home is merely because the car sits there for more than eight hours at night most days. Take it out to the beach on the weekend and get ICEd at the public chargers, and your Volt if blowing fumes like any other car.
  • 50% of all volts are at home at any one particular time.
    Well, when it takes you 8 hours to recharge, where else is the Volt going to be. This would also indicate that the Volt isn’t a highly used vehicle. Despite the notion that the Volt is a commuter car, this number would indicate that the Volt is more of a run the local errands car or a secondary to an EV family that uses it for road trips.
  • “Volts plug in on average 10 times per week, not 7. That surprised us. We figured a once a day charge but customers charge more”
    How GM hasn’t interpreted this to mean that a 6.6 charger is needed and 8 hour charge times is NOT completely acceptable is beyond me. My guess is that there is someone at GM who really has a thing for 3.3 chargers and is doing everything they can do to interpret the data to mean that 8 hours of charging is acceptable.
    If the Average Volt is charging more than 7x a week that means that there is data that is significantly skewing the data upwards. It would be interesting to actually see what the standard deviation is on number of weekly charges as well as a scatter chart.

While, I don’t actually have the raw data that GM has, I can easily make a guess as to what the data actually looks like. My guess is that Volt fit into three major categories: 1) Garage Space Consumption, (2) Everyday Local Commuter, and (3) The Work Horse.

The Garage Volt is what makes up the majority of that 50% of all volts are at home number. The Everyday Local Commuter are the people that are okay with the 8 hour charge time because they drive 15 miles to work and 15 miles back at 40 mph and have plenty of range to spare for the gym visit and grocery store. The Work Horse Volts are what skew the plug-in numbers to 10 plug-ins/week vs 7 plug-ins. This isn’t going to be as high as a percentage of the Volt customer base as the other two, but I believe these are the customers that GM should really be courting.

GM has missed their 30K Volts/year sales goals by a gap roughly the size of the Grand Canyon. I believe that’s because the Volt caters to the first two groups rather than the Work Horse Group. If GM wants to see the 30K/year sales volume, they need a Volt that provides more range and a more efficient generator for roughly $40K before tax incentives. That’s entirely possible with a slightly larger battery, an 80% battery utilization instead of 60-65% like the Volt has now, and a more efficient generator with smaller gas tank. Of course, if GM made the 80% battery utilization a software upgrade for current Volt owners, then they could retain a lot of Work Horse customers. Instead, it seems that GM is going to double down on the first two segments. This should net GM roughly the same results they have achieved so far: missed sales goals, new to GM customers, and low repeat.