Tuesday, December 29, 2020

Anti-Intuitive

 

Image from koloajodo.com

In an ancient kingdom, a wise man provided a king with an herbal remedy that saved the queen’s life. Grateful, the king offered the wise man anything he wished in return. Noticing a chess board beside the king's throne, the wise man asked for a grain of rice to be placed in a corner square, and then for the quantity to be doubled each time it was moved through the succession of squares through the entire board. The courtiers all laughed, thinking that this was the paltry wish of a foolish old man. The king, with a look of regret at having granted the wise man leave to wish for anything, smiled and said, let me give you my crown instead.

.

.

.

.

Why?

.

.

.

.

Because 2 to the 63rd equals 9.22337E+18 or 9,223,370,000,000,000,000 or 9 quintillion. Placed end to end, this amount of rice would stretch for about 30 trillion miles, which is more than the distance between Earth and the closest star beyond our Sun, Alph-Centurai. 

Our minds do not readily intuit this kind of progression. 

-- This is an adaptation of a story first known to have been recorded in 1256 by Ibn Khallikan, but modified to suit my personal tastes


Wednesday, December 23, 2020

Women in the Workplace

A Fortune 500 company sponsored an executive retreat on Hawaii's Big Island. The point was to foster collaboration between executives as they climbed up the slope of the Kilauea Volcano, which had recently erupted in 2018 and was thought to be dormant for the foreseeable future. The executive cadre consisted of 10 male executives and 2 female executives, who endured a lot of snide comments and eye-rolling as they struggled to keep up with the men. At some point the volcano started to rumble, and the guide, seeing that they were too far from the bus at the base to make a run for it, decided to call in a rescue helicopter. However, given that they were on a slope, the helicopter had to hover over the group while they climbed onto a rope ladder, and then they had to simply hold on to the ladder during transport, because there was no way to get into the helicopter during flight. As the pilot struggled to keep the helicopter in the air, he realized that the load was roughly 100lbs over, so he called out to the executives on a loudspeaker: "One of you has to let go, or we are all going down!" This took a little while to sink in, but, even after it sunk in, still, no one volunteered to let go. Finally, one of the women said: "Okay, I will let go. After all, women have been sacrificing themselves for other people for as long as mankind has been around. From child-bearing, to child-rearing, to giving up our careers, to supporting our husbands as they progressed in their careers, to taking care of everyone when they are sick, even as we are sick. Why should this situation be any different?". The men all stared at her in disbelief. With emotional admiration, they all began vigorously applauding with both hands. After the rope ladder was clear, the women gave themselves a knowing glance and warm smile, and then hung on tight for the rest of the ride.

-- Modified from a version I heard on a Tara Brach podcast. She did not recall the source.

Sunday, June 28, 2020

The Roots vs The Flower

I think that the most important issue that we need to grapple with in American today is, what kind of racism continues to exist? In my opinion, claims on either end of the spectrum lack legitimacy, i.e. we are not experiencing a more camouflaged version of Institutional racism but we are not experiencing Incidental racism by a few bad apples either. Rather, we are experiencing a racial bias within the fabric of our society. It is of the same variety that James Baldwin describes in his great debate with William F. Buckley (below). Thus, for example, the notion that the police are, in effect, patrolling the border between black and white communities is not only an inaccurate depiction but also a counter-productive one, as it tilts the frame towards a kind of Institutional racism that does not exist. As well, the notion that policing is uniformly applied across black and white communities, and the disproportionate representation of African Americans in the criminal justice system is as a result of disproportionate criminal activity is an equally inaccurate and counter-productive depiction, as it glosses over a much more militarized and aggressive form of law enforcement that has evolved in high-crime, high-poverty communities, which are typically black communities. The question remains, how do we address a racial bias in the fabric of our society? I do not think it can be addressed by asking white America to take ownership of sins that they have not committed and ask forgiveness for views that they do not hold (as an aside, I would not be considered 'white' by the normal standard, as I am half Indian). This is under the assumption that the vast majority of white Americans are not overt or covert racists, and do not commit racist acts by commission or omission. This may or may not be the case, but, given that it is not a supposition that can be derived from hard data, I think that we would be much better off assuming it is the case. In my view, the only path forward is to re-frame this debate on Individual terms, and adopt measures that benefit all Individuals, even as they will, in fact, benefit African Americans disproportionately. This tracks to the classic answer that Barack Obama gave in a debate, whereby, when asked how he will address the socioeconomic woes of African Americans, he replied that he would address the socioeconomic woes of all Americans, and African Americans would enjoy an incidental, disproportionate benefit by virtue of their more challenging circumstances. To get there, I think that it will be important for everyone to rally around a common cause for preserving Individual life, liberty and the pursuit of happiness, without regard to color, but with full knowledge that, in doing so, they will address the disparities of color within our economy, politics and criminal justice system. This would entail enforcing policies of deescalation and removing criminal liability protections in policing, fixing upside-down voting districts, investing in education and economic enterprise zones, etc, but also enforcing a more uniform code of Individual responsibility and accountability, like eliminating the welfare state and reverse discrimination, such that all Americans that need help can get it, but all Americans are, ultimately, on a level playing field. Rather than burning calories on continually fixating the racist roots of America, let’s focus the measures that will produce a non-racist flower ;-)

https://www.youtube.com/watch?v=WPz7kTnEWKE&t=975

Wednesday, June 10, 2020

Divided We Fall

Societies are most vulnerable when disparate groups within them are fighting with each other. I do not mean ‘fight’ as in healthy debate and legislative maneuvering, but ‘fight’ as in confrontations in the street, hatred online and the kind of callout culture that has people not wanting to say anything, opting instead to just carry unspoken and, many times, unexamined views in private. This kind of friction may very well be necessary at this juncture, but you can only imagine that the Russians, et al, are delighted at their prospects of fomenting more divisions in advance of the November election. We should give our friends and neighbors the benefit of the doubt when they express controversial views, and we should fact check every news story before we get outraged by the media.

News Blues

A traverse a lot of news stations when I actually watch the news, which is, itself, becoming a rare event these days. My first observation is that there is no truly objective news on TV, and probably elsewhere, which, I am sure, will surprise both CNN and Fox viewers. Both of these particular networks are guilty of sins of omission and commission, as it pertains to the left-right narrative that they are constantly spinning. I cannot stand to watch either one of them, so I watch them both, and like a spectator sitting mid-court at a tennis match, I feel like I am seeing the game much more clearly than if were on either end of the court or either player, for that matter. It is an ugly game. It cannot be won by either ‘side’. It can only be lost by everyone.

Wednesday, June 3, 2020

The American Theme


I think that it is better to refer to this shared experience of ours not as the American Dream but, rather, as the American Theme. A dream might not be realized, even if it is unique to each individual, but a theme can be realized in success or failure, and across a range of circumstances. So what is it? Well, again, it could be unique to each individual, but I contend that unless we have common theme to govern our shared experience, we won't have a shared experience for very long.

I define it this way: Individual liberty and individual accountability; Local government and local accountability; State government as the default, Federal government only as the Constitution allows; Malice towards none [...] Charity for all; and... well... all of those other great, American ideals that characterize American Values, notwithstanding everything that we, as a nation, have done to erode our own values.

At the very base of everything I've just described is the individual's rights. If a society cannot protect the rights of the individual, then there is, in effect, no social contract (Rousseau, 1762). And if a particular group experiences this lack of protection by its individual members, it can be argued that there is no social contract at that level either, but we should all be offended, because a crack in our foundation is not a local concern. It is a threat to every layer that rests upon it. Therefore, we should all be mobilized to protect this most basic right, and be clear-eyed when the mobilization is coopted.

The more polarizing forces in our society would have you confuse rioters with protesters, and, worse, confuse the right to protest with the right to riot. In reality, rioters do more damage to protesters than they do to the owners whose property they destroy, because they pervert the effort to defend the very foundation of our society. It does not mean that protests will not need to be modified to diminish the risk of riots, or that police response should not be pervasive and swift when it comes to rioters, because, after all, if we are marching in protest against the abject disregard for an individual's rights, to the point of murder, then we cannot justify someone else's murder as a side-effect of that march, even if perpetrated by outside parties taking advantage of the situation.

I think that this is the most complicated collaboration between individuals, groups and governments that we can undertake as a society, which can only be resolved by intelligent cooperation. I cannot even begin to offer solutions, outside of recognizing that we need solutions. Sometimes recognition is a good start, and that is my main objective here.

Saturday, May 23, 2020

Division Divided by Division


The debate that rages on about the COVID-19 quarantine suffers from the classic complexity of trade-offs that are non-resolvable. Shutting down saved lives but it also destroyed [socioeconomic] lives. Opening up too soon or too quickly will cost lives, but remaining closed will destroy more lives. Saving lives means delaying herd immunity, but achieving herd immunity means losing lives. The list of trade-offs goes on, and the real socioeconomic costs of quarantine measures can only be justified by estimated benefits of undertaking them, making such measures difficult to defend in concrete terms. In these kinds of situations, no amount of data or science can build adequate consensus, and this is especially true when the data comes into question (e.g. the variance in death rate based on the true infection rate, which we do not know) and the science comes into question (e.g. the general population being unable to grasp that the very basis of the scientific method). The only thing that can build consensus in these types of situations is trust in government, as in: "I know that they do not have all the answers, I know that they might get it wrong from time to time, but I also know that they are taking advantage of the best data and science that the country has to offer and are making the most informed decision they can on my behalf." I need not say why we do not have this level of trust in government today, but I do need to say that the breakdown along party lines is a sad state of affairs. If we had stronger leadership, we would be more unified, especially in troubled times. I think we can all agree on that, but maybe not.

Wednesday, May 20, 2020

Salesforce Einstein Analytics Dataflow to Deduplicate a Dataset

Let's say you have the following data:

Key,Value,Timestamp
K1,V1,2020-05-01
K1,V2,2020-05-02
K1,V3,2020-05-03
K1,V4,2020-05-04
K2,V1,2020-05-04
K2,V2,2020-05-04
K2,V3,2020-05-02
K2,V4,2020-05-01
K3,V4,2020-05-01
K3,V3,2020-05-02
K3,V2,2020-05-03
K3,V1,2020-05-04
K4,V4,2020-05-04
K4,V3,2020-05-03
K4,V2,2020-05-02
K4,V1,2020-05-01
K5,V1,2020-05-01
K5,V2,2020-05-01
K5,V3,2020-05-01
K5,V4,2020-05-01

Further, let's say that you want to remove duplicate rows (based on the Key) and keep the latest row (based on the Timestamp), with the additional complexity of there being duplicate Timestamps.

Your target result would consist of the following, reduced data:

Key,Value,Timestamp
K1,V4,2020-05-04
K2,V2,2020-05-04
K3,V1,2020-05-04
K4,V4,2020-05-04
K5,V4,2020-05-01

To achieve this result, you can generalize the following approach, in reference to the sample dataflow included in its entirety at the bottom of this post.

  1. Get the dataset ;-)
  2. computeRelative (computePartitionCounter)
    • Partition by the Key
    • Order by the Timestamp (ascending)
    • Compute a partitionCounter column (number, default = 1)
      • saqlExpression: previous(partitionCounter) + 1
  3. computeRelative (computeKeepRow)
    • Partition by the Key
    • Order by the partitionCounter (descending)
      • Note that weather you sort by descending timestamp and then ascending partitionCounter, or vice versa (as I have done here) is immaterial
    • Compute a keepRow column (text)
      • saqlExpresion: case when current(partitionCounter) == first(partitionCounter) then "true" else "false" end
        • Note that in the case of K2 and K5, since some or all of the rows have the same Timestamp, keepRow will be "true" for one of them, arbitrarily, more than likely based on any internal ordering with Einstein Analytics. 
  4. Filter by keepRow == "true"
  5. Slice off parititionCounter and keepRow
  6. Register the de-duplicated dataset
In my example, I went from this...

 

...to this...


Cheers! 


Dataflow:

{
  "getDataset": {
    "action": "edgemart",
    "parameters": {
      "alias": "KeyValueTimestamp"
    }
  },
  "computePartitionCounter": {
    "action": "computeRelative",
    "parameters": {
      "source": "getDataset",
      "computedFields": [
        {
          "name": "partitionCounter",
          "label": "partitionCounter",
          "expression": {
            "saqlExpression": "previous(partitionCounter) + 1",
            "type": "Numeric",
            "scale": 2,
            "default": "1"
          }
        }
      ],
      "orderBy": [
        {
          "name": "Timestamp",
          "direction": "asc"
        }
      ],
      "partitionBy": [
        "Key"
      ]
    }
  },
  "computeKeepRow": {
    "action": "computeRelative",
    "parameters": {
      "source": "computePartitionCounter",
      "computedFields": [
        {
          "name": "keepRow",
          "label": "keepRow",
          "expression": {
            "saqlExpression": "case when current(partitionCounter) == first(partitionCounter) then \"true\" else \"false\" end",
            "type": "Text"
          }
        }
      ],
      "orderBy": [
        {
          "name": "partitionCounter",
          "direction": "desc"
        }
      ],
      "partitionBy": [
        "Key"
      ]
    }
  },
  "filterDataset": {
    "action": "filter",
    "parameters": {
      "source": "computeKeepRow",
      "saqlFilter": "keepRow == \"true\""
    }
  },
  "sliceDataset": {
    "action": "sliceDataset",
    "parameters": {
      "mode": "drop",
      "fields": [
        {
          "name": "keepRow"
        },
        {
          "name": "partitionCounter"
        }
      ],
      "source": "filterDataset"
    }
  },
  "registerDataset": {
    "action": "sfdcRegister",
    "parameters": {
      "alias": "KeyValueTimestampDeduplicated",
      "name": "KeyValueTimestampDeduplicated",
      "source": "sliceDataset"
    }
  }
}

Tuesday, May 5, 2020

Conscientious Courtesy


I am seeing a lot of posts about ‘government control’, ‘mask Nazis’, ‘media fear mongers’, etc, as it pertains to the practice of wearing masks in public, on flights, etc. To me, it isn’t about any of those mechanisms or motivators. It is about courtesy. Not just the courtesy of protecting the health of others, but courtesy in kind. For me, this morning was a perfect example. I finally got an appointment at the groomer for Maggie (my dog), who has been shedding balls of wool lately. I had no notion of wearing my mask to drop her off, but when I saw the person receiving dogs wearing a mask, I put mine on as well. This is the new social grace, and, as surely as there is no mind control at play when I respond “good morning” in kind, there is no mind control at play here either. Of course, I would hate to be fined for not saying “good morning”, but the lack of a greeting in kind cannot possibly make someone sick, whereas not wearing a mask presents that risk, however small, so a different level of conscientious courtesy is required. Remember that.

Friday, May 1, 2020

Salesforce OAuth 2.0 Web Server Flow Using cURL

If you are in need of validating a Salesforce API from start to finish using cURL - i.e. from authorization code to access token to a successful API call using the access token - try this:

Create a Connected App in your Salesforce Org:

Check the Salesforce documentation for Create a Connected App with OAuth. Include https://localhost as one of the Callback URLs to follow along with this example, or use whatever URL you like, but just be sure to modify the example below accordingly.

Once you have the Connected App, you can copy-paste the following URL in browser:

Note: If you are attempting to do this in Production, then use 'login' instead of 'test' in the URL.

https://test.salesforce.com/services/oauth2/authorize?client_id=[Consumer Key from Connected App]&response_type=code&scope=api&access_type=offline&redirect_uri=https://localhost

You will be presented with a login screen.

After successfully logging in, your browser will be redirected to https://localhost, which, obviously, will not render a working page, but the authorization code will be available in the URL window:


Copy the value of the code (i.e. code=[authorization_code]) into a text editor, and then URL decode any characters that are URL encoded. In my experience, this is typically two %3D characters at the end of the code, which equates to two equal signs, but I make no claim as to the standard.

Use the Authorization Code to get the Access Token via cURL

Note: If you are attempting to do this in Production, then use 'login' instead of 'test' in the URL.

curl --request POST 'https://test.salesforce.com/services/oauth2/token' --data 'client_id=[Consumer Key from Connected App]' --data 'client_secret=[Consumer Secret from Connected App]' --data 'code=[Authorization Code from Previous Call]' --data 'redirect_uri=https://localhost' --data 'grant_type=authorization_code'

This will return the following response (in non-pretty print format):

{"access_token":"[access_token]","signature":"[signature_redacted]","scope":"api","instance_url":"https://[instance].my.salesforce.com","id":"https://test.salesforce.com/id/[id_redacted]/[id_redacted]","token_type":"Bearer","issued_at":"1588342208615"}

Use the access_token to make API calls:

Note: The following example is highly specific (e.g. POST, json, etc), so adjust accordingly.

curl --request POST '[REST API URI]' --header 'Authorization: Bearer [access_token]' --header 'Content-Type: application/json' --data '{"key_1" : "value_1","key_2" : "value_2"}'

Special Note: The examples worked using Git Bash on Windows, and may need to be modified to work in the Windows Command Window (i.e. you may need to enclose arguments in double quotes and escape double quotes in JSON, etc). Just beware of this nuance.

Sunday, April 19, 2020

The Restoration of Action


During some of the more labored exchanges I have on Facebook, there are times when it would be legitimate for any rational person to wonder: "Why bother? You think your way. Others think their way. So why argue?" This is where knowing a little something about Hannah Arendt (1906-1975) is useful. Arendt divided the human experience into three categories: Labor, Work and Action. Labor includes what we do every day to maintain our biological existence (drinking, eating, sleeping). Work includes what we do to build the world we live in (carpenter, bus driver, doctor or, the ultimate profession, programmer - wink). Action is the interaction between people as equals in a public forum to debate and determine the meaning things in the world they share. In short, it is the realm of the political, but not the post-Enlightenment version as a means to an end for economic systems and legal rights. Arendt is referring to the pre-Enlightenment version, where people engaged with one another to establish their identities, their cultures and a sense of meaning and belonging that does not come from Labor, Work or economic and legal systems that are based on the notion of rational self interest. In today's modern society, we cycle between Labor and Work, and we relegate Action to the margins. It is no wonder that we suffer from a collective identity crisis. Our point of confusion around WHO we are versus WHAT we do is what Arendt dubbed 'Economic Man'. The ancient Greeks had a very different notion of life. For them, Labor and Work were a means to an end for Action as the most important aspect of life, where engaging with their fellow man (woman) to discuss, debate and arrive at the meaning of things, including the meaning of life and their position in it, took precedence. Today's version of this engagement is rooted in polarized media outlets, hash-tag campaigns, political memes and echo chambers, which do not foster real discourse and do not create real meaning. We have ceded our role as political actors responsible for shaping the world around us, to a role of political casualties, just trying to survive through Labor and Work, and arranging ourselves along black and white political lines that serve interests that are not our own. It is little wonder that one of Arendt's most famous books is The Origins of Totalitarianism. Whatever your opinion about the evils of Social Media, up to and including the amplification of all of the evils I just mentioned, one undeniable fact about it is that it has restored a public realm for people to engage in, which has liberated us from the isolated cycle of Labor and Work. There are certain exchanges that I have had with certain people that I would have never had outside of a heated Facebook thread. This form of engagement has re-established vital lines of communication. This is why I bother engaging in those belabored exchanges. I am not trying to achieve some kind of end, I am engaging in the restoration of action to find meaning.

Friday, April 17, 2020

The Brave New World


We will need to begin a phased reopening of the country prior to a coronavirus vaccine being available, if there ever is one, and no matter what phasing and coordination, there will be an uptick in COVID-19 cases. This so-called 'M curve' can only be minimized, not avoided, because we have to live our lives, and there is no such thing as a risk-free life or, in some cases, a risk-free livelihood. This will probably create an awareness in us that we should already have, i.e. clean hands, clean phone, sensitivity to symptoms, self-isolation, proactive medical care, etc. It will also create a minimalist mindset with benefits to society, e.g. minimizing activities that contribute to global warming, and detriments, e.g. minimizing activities that contribute to heart warming :-) I believe that one of the most valuable upsides will be the fact that when someone shakes your hand or gives you a hug or attends your party or eats at your restaurant, they will be conveying to you that you are worth the risk. That is a good thing.

Saturday, April 11, 2020

The Choice

In The Republic (380 BC), Plato wonders if the average citizen of a society is the right person to be making the decisions about who should be making the decisions for a society. And this has been a question we (at the very least, Western Civilizations) have grappled with since then. In Walter Lippmann's 1922 book Public Opinion, he states that, in the face the ever-increasing complexity of the world, especially relative to the democracy that our Founding Fathers created, average citizens navigate the world through stereotypes (about everything, including the government, environment, medicine, etc), which are fed, in large part, by the media. (This is back in 1922!). If you look at the ever increasing polarization of stereotypes fed by the ever-widening gap between media outlets, you can see how perfectly rational people can be led to vastly different conclusions about the world. I think that "our" job is to close that gap. That means that I actually read posts (and shared articles) of people that I do not agree with, and I actually expect them to consider my counterpoints. I am not sure if this expectation is realistic, but what choice do I have?

Friday, March 20, 2020

POTUS-45 vs COVID-19

When things are going well, very few people ask "who is the single person responsible for our success?". But when things are not going well, the common question is often "who is the single person responsible for our failure?" We have a basic psychological need to find someone to blame when things go wrong, but, in reality, complex systems produce both success and failure. POTUS exacerbates this skewed perception, because we often over-attribute good and bad outcomes to the President, probably because the President is such a visible character and is quite over-covered by the media, whether Clinton, Bush, Obama or Trump. Of course, you can give credit for a job well done, and criticism for a job not well done, because POTUS does play a role, but if you give too much credit or criticism, then you neglect the shared accountability of congress, state and local government, non-governmental agencies, industry leaders and, most importantly, ourselves. I - personally - never wrote my congressman to ask them to sponsor a bill to create excess capacity in emergency medical facilities or stockpile urgent medical supplies, nor did I stockpile supplies in my home or plan for long-term sheltering in place. We can certainly criticize POTUS for his dismissive tone as this crisis ramped up, and other moves that delayed testing or delayed the kind of over-response required to stem the tide of a pandemic. However, overall, these can only be called poor reactions, whereas the real problem here is not having a preemptive system in place. This would go far beyond the NSC Pandemic Unit that Trump disbanded in 2018, though it would be nice to have that top-level office at this juncture. Regardless, I hope that 'preparedness' becomes a more tangible topic after the dust settles on COVID-19.

Saturday, February 1, 2020

Deli Contingencies

In life, I like to give myself three chances. This is why, when I take a ticket for the line at the Deli, I take 3 tickets, just in case I miss my number, or someone double clicks to the next person, etc, etc. Today was the first time in - say - 20 years where this ridiculous strategy paid off. I am not sure how, but the fellas behind the counter skipped over my first two numbers. I don't even think they called them out. I sprang into action upon hearing my third number, mainly because I did not want to spend the next 20 years taking 4 tickets ;-)

Sunday, January 26, 2020

TV Sloppiness

Like most people, I really appreciate good movies and TV series, moreso the latter. For example, Tom Clancy's Jack Ryan on Amazon Prime. Season 1 was superb. Season 2 is also good, but it suffers from a bad case of implausible coincidences and outright omissions. One minute Jack is about to be executed by an assassin, the next, the woman that was shot in the foot by said assassin and left incapacitated 100+ KM away shoots him in the back of the head. One scene, Jack gets stabbed in the arm, the next he is wearing short sleeves and wringing his hands without so much as a band-aid. The story line is still excellent, but these little things add up to make the show feel unbuttoned. It is like going to see Tosca at the Met and noticing that Mario Cavaradossi is wearing high top Converse sneakers. If the objective is to create an alternate reality for the viewer to immerse themselves within, then the craft must be at a higher level.

Thursday, January 16, 2020

The Daily Pattern

Every morning when I wake up, my first thought is ending the day, which consists of the sequence of steps that match the pattern I want for myself on a daily basis. I start each step with an eye towards the next one, but no further. It is a very simple plan: coffee > gym > ready > eat > work > study > home > family > bed :-) Breakfast is my one and only meal on most days, so I don't have to deal with the logistics of lunch or dinner, nor do I have to effect any will power for said meals, nor do I have to kill myself in the gym to manage my weight. This particular plan is not for everyone, but the strategy of defining the lifecycle of a day and targeting it as a pattern to live by can, I think, work for everyone, whatever the pattern. Further, taking the guess work out of every day living leaves more room to be creative, because it conserves energy that might otherwise be spent on deciding between a salad or an entire bag of dark chocolate Hershey's kisses for lunch (wink).