Friday, April 01, 2022

Excel Workbook that Solves an Equation When Any Independent Variable Changed

You get the idea, you have something complicated, like this :


And you want to solve for σ. But, you want to be able to update a, b, G, and lambda on the fly and see the new σ that makes LHS = RHS. How? 😊 Obviously you want one cell to capture LHS - RHS so you can solve for the value that sends this cell to 0.

Start off getting stuff to work using Goal Seek (Data > What if Analysis > Goal Seek.

Now, the cool part is getting that to run on demand through code. What can you do? Use the Macro Recorder obviously. Do that and you have this in your pocket :

Range("F12").GoalSeek Goal:=0, ChangingCell:=Range("C12")

Now, the cool part is getting this to run when the cells in C8-C11 are changed. How? 

In Excel, do ALT-F11 to open the VBA Editor and then, in the Project Explorer, double click the name of the sheet under Microsoft Excel Objects. You now get a new window called filename.xlsm - SheetNamed (Code). In the dropdown on the left, choose "Worksheet" and now, on the right, choose  "Change". This will give you this starting code :

Private Sub Worksheet_Change(ByVal Target As Range)

End Sub

All you have to do is :

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Set rng = Intersect(Target, Range("C8:C11"))
    If Not rng Is Nothing Then
' put your magic code here  - what magic? The stuff that copies the numerical value you calculate use a formula for the initial guess into a cell that you tell Goal Seek to vary of course 😊

Put it all together: 

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Set rng = Intersect(Target, Range("C8:C11"))
    If Not rng Is Nothing Then
    '
    ' solve Macro
    ' run goal seek
    '
        Dim sourceCell As Range
        Dim targetCell As Range
        
        ' Set the source and target cells
        Set sourceCell = Range("D12")
        Set targetCell = Range("C12")
        
        ' Copy the numeric value from the source cell to the target cell
        targetCell.Value = Val(sourceCell.Value)
    
        Range("F12").GoalSeek Goal:=0, ChangingCell:=Range("C12")
    End If
End Sub

And you're done :) Enjoy


Sunday, March 20, 2022

Why it Pays to Get Your Kids Into Coding Early


As Jason Calacanis finds out from uber prodigy Amjad Masad :

Learnt to code in 1993 when he was six years old! (Amjad Masad is from Jordan)

Why learn compilers :

I joined Yahoo! for my first job out of college, who'd just acquired a company in my hometown. As part of the acquisition, we were tasked with moving to the Yahoo! stack, and they were adamant about us using YUI instead of jQuery. The task fell on my lap, which felt like a crushing mountain of repetitive work.

Like any good (read: lazy) programmer, I decided to automate the task. The task was more intricate than simply a massive search and replace because you had to deal with many variations of names, formatting, and patterns. I'd been learning about compilers and ASTs, and I figured this was an excellent time to deploy my newfound skills.

First, I backfilled into YUI some jQuery-like to make the transition easier. Then I wrote a transformer that took in jQuery code and automatically translated the calls into YUI code.

A many-month project turned into a week project. My colleagues were dumbfounded when they saw the volume of patches flying out of my desk. This is the kind of leverage that compiler technology can give you.

______________________________________________

Here is what Carmack thinks an antifragile system might look like:

  1. You are working on a problem and you get an idea and with it the initial idea high
  2. You should instantly try to defeat your idea -- think of all the ways it could not work, test it out, put it under stress
  3. If the idea survive the brutal scrutiny then it has legs for further investigations or implementation
  4. If the idea is implemented and it works then that's great
  5. If the idea fails the scrutiny or implementation you can quickly move on to the next idea without feeling the lows because you haven't obsessed or talked about it i.e. it's not your pet idea.

Sunday, March 13, 2022

For a Change, Some Gems from Farnham Street

Didn't think much of the book, TBH, but, this latest one on Genghis Khan has some good maxims :

As we first succeed, we will find ourselves in new situations, facing new problems. The freshly promoted soldier must learn the art of politics. The salesman, how to manage. The founder, how to delegate. The writer, how to edit others. The comedian, how to act. The chef turned restaurateur, how to run the other side of the house.

It takes a special kind of humility to grasp that you know less, even as you know and grasp more and more. It’s remembering Socrates’ wisdom lay in the fact that he knew that he knew next to nothing.

With accomplishment comes a growing pressure to pretend that we know more than we do. To pretend we already know everything. Scientia infla (knowledge puffs up). That’s the worry and the risk—thinking that we’re set and secure, when in reality understanding and mastery is a fluid, continual process.

Wynton Marsalis : “Humility engenders learning because it beats back the arrogance that puts blinders on. It leaves you open for truths to reveal themselves. You don’t stand in your own way. . . . Do you know how you can tell when someone is truly humble? I believe there’s one simple test: because they consistently observe and listen, the humble improve. They don’t assume, ‘I know the way.’”

No matter what you’ve done up to this point, you better still be a student. If you’re not still learning, you’re already dying.

The solution is as straightforward as it is initially uncomfortable: Pick up a book on a topic you know next to nothing about. Put yourself in rooms where you’re the least knowledgeable person.


Ever been in a meeting where the boss polls people and says we'll wait for more info to decide and sets the date for the next meeting? Consider FS' podcast with Stan the Generale McChrystal :

As a military rookie, Stan asks Dad for peacetime-signs a person is a good commander in combat. "You won't know until you're in combat." OK, what about signs in combat? He said, “Some people keep asking for more information and what they’re trying to do is drive uncertainty to zero so that there’s really not a question on the right course of action because you know everything.” But you can’t do that. It’s not achievable. So they become hesitant. They become tentative, and they become focused on getting more and more information to ratchet the uncertainty out of the situation and they don’t act."

What a gem! Ever read the Colin Powell powerpoint? At what point should you go with your gut? Focus on proximate objectives that are worthwhile - take that hill, secure this building, etc. The battlefield keeps changing. No battle plan survives contact with the enemy.

Monday, February 28, 2022

How Does Chalk Keep Silver from Tarnishing?

By absorbing the moisture, that's how. 

https://www.southernliving.com/home/organization/how-to-prevent-silver-from-tarnishing

And don't forget these lifesavers from the great Schalk Marais who verified each and every one personally :

  1. Put a tea bag in smelly shoes or gym bags to absorb smelly odors.
  2. Mice hate peppermint. Mix some peppermint oil with water and spray it around your house to keep mice away. Works for spiders too.
  3. Throw a denture tablet into your toilet bowl to remove stubborn stains.
  4. Want to know what your breath smells like to others? Lick your wrist and smell it.
  5. Drink ginger tea for headache relief.
  6. Microwaving lemons for 15 seconds can double the juice you get from them

Thursday, February 24, 2022

Beat Employee Boredom with Cybersecurity Training - Ninjio.com

 Some gorgeous animations. Here's one that will make you think twice before you scan that QR code :)



First Principles and Rainy Days

Enjoy : https://physprob.com/ (Problems from the Physics Olympiads of the last 35 years.

Like : 

A 'millisecond pulsar' is a source of radiation in the universe that emits very short pulses with a period of one to several milliseconds. This radiation is in the radio range of wavelengths; and a suitable radio receiver can be used to detect the separate pulses and thereby to measure the period with great accuracy.

These radio pulses originate from the surface of a particular sort of star, the so-called neutron star. These stars are very compact: they have a mass of the same order of magnitude as that of the sun, but their radius is only a few tens of kilometers. They spin very quickly. Because of the fast rotation, a neutron star is slightly flattened (oblate). Assume the axial cross-section of the surface to be an ellipse with almost equal axes. Let r_p be the polar and r_e the equatorial radii; and let us define the flattening factor by:



Consider a neutron star with a mass of 2e+30 kg,

an average radius of 1e+4 m,

and a rotation period of 20 ms. (Yes, rotates 50 times a second!)

a - Calculate the flattening factor, given that the gravitational constant is 6.67e-11 N.m2.kg’2.

In the long run (over many years) the rotation of the star slows down, due to energy loss, and this leads to a decrease in the flattening. The star has however a solid crust that floats on a liquid interior. The solid crust resists a continuous adjustment to equilibrium shape. Instead, starquakes occur with sudden changes in the shape of the crust towards equilibrium. During and after such a star-quake the angular velocity is observed to change according to figure 1.



b - Calculate the average radius of the liquid interior, using the data of Fig. 1. Make the approximation that the densities of the crust and the interior are the same. (Ignore the change in shape of flue interior).

Friday, February 11, 2022

Codecademy Advanced Python


 What you will learn : 

  • How to use logs in Python to help debug and track your software. (Lisa Tagliaferri's masterpiece)
  • How to use functional programming, a coding paradigm that is sometimes used by software engineers in favor of object-oriented programming, to create clean, efficient programs. (realpython tutorial)
  • How to use concurrent programming to implement code more efficiently using the threading, multiprocessing, and asyncio modules. (realpython tutorial)
  • How to do database operations in Python using sqlite3.(David Muller on DigitalOcean DOCN)
  • How to deploy a simple Python script using Flask. (thank you Real Python and Darren Jones! 😊)

Thursday, February 03, 2022

Tim Grover - W1nning

TG came to the US when he was 4 years old and is of Indian origin. His Dad was a doctor, but had a stint disposing off cadavers after the medical students were done. Because they couldn't afford a baby-sitter, young Grover had to watch that, when he was just four!

I give it three stars only because I feel it used up pages unnecessarily. He's had a good life and he's telling us useful stuff. Essentially - don't make excuses - admit that it wasn't a lack of time, it was a lack of focus and failing to set priorities properly. Now, I can't wait to get my hands on his other books.


"The greats know how to put on a different face in certain situations that require it, and take it off when it matters. M] was polite and polished and said the right thing with his sponsors and audiences and interviewers. But put him in his own environment, in the gym, on the court... the real guy came out. No inhibitions, no limitations on what he would say or do to get his message across."

WINNING isn’t heartless, but you’ll use your heart less.

Stop being afraid of what you’ll become. You should be more afraid of not becoming that.

Michael would always answer his questions and help him learn. That’s a major trait of the greats, by the way: They want to pass along their knowledge so the next generation can keep learning. That’s the difference between competing and winning. I hear this all the time from my corporate clients: “We know how to compete. Now we need to learn how to win.” It’s not always the same thing.

Part of MJ’s greatness was that ability to execute; even the smallest details of his movements enabled him to act and react faster than almost anyone else on the court. He could get his shots off quickly because he caught the ball with his knees bent, and his shoulders already squared up to the shot, so he was already in position to shoot. Most players catch the ball, and then get in position to take the shot. MJ was already there; the gun was already locked and loaded. He rarely had to reposition his body or turn his shoulders after the pass; all he had to do was catch and turn his head to see the basket.

I’m often asked about the differences and similarities between the two. I don’t like to compare, because to me they were so different and unique that it’s an injustice to both. But if you want a basic summary, I’ll give you this:
Kobe worked harder. M] worked smarter.
Kobe never stopped. He questioned me about every aspect of our training; he needed to know why and how everything worked. He didn’t always want to be there Wlmt we got 16f}? but he always did the work, and he always came back for more.

I was doing some consulting for a tech company that decided to let go of its top performer because she had a reputation for being “difficult.” She didn’t get along with everyone, they said; she pushed others too hard and often made people uncomfortable by insisting that everyone needed to do better. Someday maybe I’ll understand why that’s a bad thing; I’ll take difficult and effective over easy and incompetent any day. But there were ego and personality issues, probably because the pressure and tension were too high, and management decided it would be better for “morale” to let her go, along with her huge book of business and years of experience.

And within a month of her departure, morale and productivity actually got worse, because those who had the issues with her suddenly had no one to blame for their poor performances, and no one to hold them accountable. And eventually, her former bosses realized that the person who was the “problem” was actually the one holding it all together.

Like being “selfish,” being “alone” is a powerful condition with a bad reputation.

When people talk of Kobe’s greatness, they often say, “He put in the work.” True, but they’re missing the point. Players like M] and Kobe didn’t just work, they constantly and consistently elevated the work, because to get out of hell, you have to elevate everything. They never stayed with what got them there, they were always adding pieces that would take them higher.

My best interns were the guys who’d come in early, stay late, pick up towels, and do things without being asked or told. They came to us without living arrangements, without other obligations, without any motives except a sincere desire to learn and contribute. On the other hand, we had guys who were just impressed. Impressed with themselves, impressed to be around the athletes, impressed by who they knew and how they could use it. They could only stay for a week because they had a vacation planned. They needed us to provide housing (we didn’t). They wanted to negotiate their pay.

I’d ask them a question and they’d answer, “I guess.” You guess? I don’t need you to guess, I can guess on my own. I need you to care enough to find out.

I understand the benefit of creating a certain kind of culture, but let it be a culture that rewards success, not the need for perks. If your people are showing up principally because you have a basketball court and free cookies on Fridays, you have the wrong people around you.

Kobe sprinted through life like no one I’ve ever known. He had no hobbies or distractions. Didn’t play golf, didn’t hang out with buddies, didn’t go to parties. Occasionally, he’d decide to see a movie and would rent out the whole theater so he could take a small group of friends or family to see it privately, usually twice in a row. Otherwise, he trained. He practiced. He studied film. Besides his beautiful family, which was his top nonv basketball priority, his entire focus centered on one obsession: Winning.

A remarkable life, with remarkable achievements. Which led many to ask: How was he able to achieve so much in the time he was given? Kobe’s secret weapon: He had the unfaltering ability to focus on what he was doing, for as long as he needed to, until he got the results he wanted.

Most people worry about how long something will take. Winners just keep gomg until it gets done.

Here’s another way to retrain your mind: Count up to a deadline, not down. Time forces you to count down to the finish: 5... 4... I have so much left to do... 3... hurry up, I’m running out of time... 2... I’m not going to make it... 1. Time’s up. The clock ran out.

Focus counts up. The numbers are infinite, and the clock never runs out. 1... 2... Here’s what’s ahead to reach the goal... 3... Let’s get started... 4... Stop counting and just do the work.

To me, a sense of urgency is the ultimate distinction between those who win and those who watch others win.

That sense of “gotta have it now” defined Kobe’s spirit. His impatience was legendary; there was always work to be done and he had zero tolerance for those who wouldn’t do it.

Winners have one fear, and it isn’t about losing. They can come back from a loss, they can find another way to win. They fear not having enough time.

Most people accept that they won’t get to do everything in their lifetime. Winners can’t accept that. They need to finish. Everything.

Because ultimately, Winning is immortality. It’s your legacy, the culmination of what you’ve accomplished, what you’ve built, what you contributed.



Talent - Intelligence - Competitiveness - Resilience




Sunday, January 23, 2022

Improving Your Odds of Long-Term Success - Hannah Fry

Hannah Fry and Adam Rutherford: The Complete Guide to Absolutely Everything (Abridged): Adventures in Math and Science

 

The people who have the best chance at long-term success are actually the people who’ve got really low negativity thresholds. They’re the people where if something annoys them, they speak up about it really quickly, immediately and address that situation right there and then. But they do it in a way where the problem is dealt with and then actually you go back to normality. So it’s couples where you’re continually repairing and resolving very, very tiny issues in your relationship. Otherwise, you risk bottling things up and then not saying anything.

Sunday, January 09, 2022

Chris Zaire : Eight Free Sites for Content Creators

They are :

Answerthepublic (Content Ideas) (what to write about - slick as hell!)

Exploding Topics (Trending Topics) (what's hot - who are these geniuses and where have they been my whole life?:)

Headline Studio (Create better headlines)

Facebook Audience Insights (Audience Research) (A good reason FB stays strong while the rest of the market tanks)

Canva (Templates/Graphics) (Ooooh... Must be a reason a $55b co doesn't need IPO money!)

Surfer Seo (SEO Ranking) (Be prepared to spend $50-$100/mo if you want to join the big leagues with your blog:)

Pexels (Images)

Ubersuggest (Keywords) (owned by Neil Patel)