Sign in

var foo = {done: true, value: undefined};
var bar = foo;
foo.done = foo = {done: false}; // what is value of foo.done ?

Years ago, when I was cutting my teeth on JS, feeding my curiosity like a glutton on the “You Don’t Know JS” series by Kyle Simpson, more specifically on the book, Scopes and Closures, there was a section called Back and Forth. Much as I hated Kyle’s anthropomorphization of scope, compiler and engine, I plodded on, determinedly through every single word the author had to say.

My patience wore thin on a rather painfully obvious section…


Photo by Ryan Franco on Unsplash

Those Warnings 🤦🏼‍♂️. I messed up. I should not have declared variables that I did not need. I should not have imported that extra Intent from BlueprintJS. Maybe a few default imports from . But that is no reason to inundate me with every small code change during dev and make my cool dark chrome console look like it caught jaundice!
So. To get rid of it: . and commented out

case 'warnings':
// handleWarnings(message.data);
break
;

Err … and and other stuff? Yes I hear you. I have to roll out this feature. Wild West for now.

… TBD


Two weeks into quitting my job and I am panicking.

Photo by Aarón Blanco Tejedor on Unsplash

Not slept in days. No gym. Picked up about a dozen products to work on. From ML to IoT to cloud computing.

Had a nice job. It was demanding, but kept me on top of the game. Yes, in Silicon Valley and yes, my employer is the number one in it’s field and yes, we are into “originals”. Yes, my team mates are proverbial rock star programmers.

Did not really think it through. Met with my manager and kind of zoned out during a meeting and at the end of…


Could not get hold of my AWS expert. And I really need to clone my table.

Stackoverflow: https://stackoverflow.com/questions/12241161/copying-one-table-to-another-in-dynamodb

I guess I could use the code pipeline. Or the backups option. Or … the python script.

Why make things simple? Let’s reinvent the wheel. Dug into the docs at: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property

const aws = require('aws-sdk');
const util = require('util');
const dynamodb = new aws.DynamoDB({
sslEnabled: true,
region: 'us-west-2'
});

const srcTable = 'prod-markup';
const targetTable = 'test-markup';

const
scan = util.promisify(dynamodb.scan.bind(dynamodb));
const putItem = util.promisify(dynamodb.putItem.bind(dynamodb));

const clone = async () => {
const data = await scan({TableName: srcTable});
for (const item of data.Items) {…


Getting HTTP Only and Other cookies

Possible that I am just stupid. Or that I am zapped after 4 cups of coffee. But I need httpOnly cookies. just does not cut it. Hmm …

So, open dev console. for the console on the Mac. On Windows … who cares.


I hate index.js

Sitting innocuously at the root of the src folder. At the root of a node server. Or in a component library. <Inject more examples here>

In the world of well formed files with pedigreed names (generic, specific, domain-based) its insulting presence makes me snap the keyboard into two.

Should I try to guess the intent of the author (deliberately diabolical to innocent ignorance) who decided on such a common term? What is an efficient way to search for the file hiding in a plethora of “index.js”s while debugging? How about refactoring the code involving a simple file name change?

I have henceforth banned the humble index.js from all repos that I lord over. Any and every index.js “required” by systems to operate shall be created by my minions during the build process.

Delete the index.js > Find eternal peace.


Credit card checks are ubiquitous on most non trivial sites. Even if the backend performs proper checks to ensure validity of a credit card details, there is some value in performing checks on the front end to avoid invalid data to the backend. It also provides a more responsive user experience when you do not have to perform a round trip to the server for common credit card entry errors.

Perform common checks like validating the cvv and card number for numeric values only, followed by a Mod10 / Luhn check. Check for expiration date being in the past.

For…

Grokkly

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store