Amir Sharif
Engineer.
Weekend hacker.
Self improvement enthusiast.

Adopting Sorbet

Sorbet has been a great addition to the Ruby ecosystem. It helps me write code faster and more correctly. However, it has some gotchas, so I’ll be adding those here along with remediations.

Upgrade ActiveModel::Type::ImmutableString to support Enums

By default, it’s tempting to want to do:

class EventName < T::Enum
  enums do 
    SPECIAL = new
  end 
end

MyModel.where(name: EventName::SPECIAL)
# throws:
# /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.1/lib/active_record/connection_adapters/abstract/quoting.rb:43:in `type_cast': can't cast EventName (TypeError)
# raise TypeError, "can't cast #{value.class.name}"

You can fix it with:

MyModel.where(name: EventName::SPECIAL.serialize)

I found that too easy to forget, and you get no warnings when you forget to do it. Instead, you can add an initializer to allow Rfails to support casting Sorbet enums properly to a string. (h/t to this StackOverflow question).

Add config/initializers/active_record.rb so that if you forget to serialize a value before sending it to the database, it’ll be done automatically.

# typed: true
module TEnumSupport
  def serialize(value)
    case value
    when T::Enum
      value.serialize
    else
      super
    end
  end
end

ActiveModel::Type::ImmutableString.include(TEnumSupport)

Using T::Struct for a JSON database column

If you have a model that has a JSON column and you want that JSON column typed with a struct, try this:

class CustomDataDataType < ActiveRecord::Type::Value
  def cast(value)
    if value.is_a?(BlogPostExtraData)
      value
    elsif value.is_a?(String)
      CustomData.from_hash(JSON.parse(value))
    elsif value.is_a?(Hash)
      CustomData.from_hash(value)
    else
      fail ArgumentError, "Unsupported type for BlogPostExtraData: #{value.class}"
    end
  end

  def serialize(value)
    value.serialize.to_json
  end

  def deserialize(value)
    if value.is_a?(String)
      CustomData.from_hash(JSON.parse(value) || {})
    else
      CustomData.new
    end
  end

  def type
    :my_custom_data
  end
end

ActiveRecord::Type.register(:my_custom_data, CustomData)

You can now get/set the attribute like so:

class MyModel
  # ...
  attribute :extra_data, :blog_post_extra_data
end

my_model.extra_data = blog_post.extra_data.with(other_prop: [])
# OR
my_model.extra_data = { 'other_prop' => [1, 2, 3] }
# OR
my_model.extra_data = { 'other_prop' => [1, 2, 3] }.to_json

my_model.save

# This will not work!
my_model.extra_data.other_prop = [1,2,3]
my_model.save

Using Time

These share the same interface but are different classes. Use Time-ish to solve this to get the autocomplete benefits.

# config/intializer/sorbet.rb
Timeish = T.type_alias { T.any(ActiveSupport::TimeWithZone, DateTime, Time) }

With RSpec and FactoryBot

When using FactoryBot and RSpec you’ll run into issues since FactoryBot adds a bunch of dynamical methods via it’s DSL.

I’ve found disable it like this is the easiest solution because it allows you to still get autocomplete but it does disable the types.

# typed: true
# frozen_string_literal: true

RSpec.describe(Model) do
  T.bind(self, T.untyped)

  it 'can do stuff' do
    instance = create(:model)
  end
end

Draft: Yes

Anti-Goals

I use to be focused on setting the right goals. I’ve found setting anti-goals to feel a lot more liberating.

When I started my business, I had a few anti-goals:

  • I don’t want it to feel like a grind. I will accept certain days where it will be.

Title: Asking Good Questions Teaser: Before asking a question, go through this checklist. Date: Nov 19 2023 Tags: 1 Pager

Asking Good Questions

If you find yourself asking a question, whether to an expert or your team, use this list as a prefilter before you ask it. The cost of a bad question can be high:

  • You won’t get a good answer, or any answer at all.
  • You waste the time of the person who is attemping to answer it for you.

Checklist for Experts

When asking an expert:

  1. Write the question out fully.
  2. Research the answer and include the research in your question.
  • It’s embarassing to ask a question that is answered by 2 minutes of googling around.
  • I’ve looked at X and Y but still had trouble understanding Z…
  1. Pretend to be the person you are answering. In turns out in a lot of cases this ends up answering the question for you. Include it in the question: I figured you might say X, but I was curious about Y”

Checklist for Teams

When asking your team, I use a different checklist heavily inspired from Your Small Imprecise Ask Is a Big Waste of Their Time.

  1. Clarifying the expected time investment:
    1. Be specific about the amount of time needed for the task: Please look into this for me. Do not, DO NOT, spend more than 20 minutes on this. Please come back with whatever you have after 20 minutes.”
    2. Set expectations for time investment: I expect this to take about 2 weeks and not cause major deprioritization of other efforts. If that timeline doesn’t seem accurate after diving in, or if you end up having to prioritize against other things, reach out to me ASAP.”
  2. Prioritizing the task:
    1. Communicate how the task should be prioritized: Be clear about how it should be prioritized: I expect this to take about 2 weeks and not cause major deprioritization of other efforts. If that timeline doesn’t seem accurate after diving in, or if you end up having to prioritize against other things, reach out to me ASAP.’”
    2. Reach out for help if needed: If the task requires a higher priority than initially anticipated, inform your manager immediately.”
  3. Understanding the scope of the task:
    1. Distinguish between whether you’re looking for prior art or new art: Tell me if we have anything on this topic already; if we haven’t even thought about it yet, that’s all I need to know.”
    2. Clarify the specific details of the task: Be clear about what is needed: Please provide a list of potential solutions for X. The list should include at least three options with a detailed explanation of each.’”
  4. Understanding how the information will be used:
    1. Tell people exactly what you’re going to use the information for: Tell people exactly what you’re going to use the information for so that they can calibrate effort levels: I am going to put this into a response to a sales prospect’; I need to know this just in case it comes up during Q&A at our next All Hands’; this is going to be the main topic of our next board meeting.’”
    2. Clarify how the information will be used: If you’re not sure how the information will be used, ask your manager for clarification: Can you provide more details about how this information will be used?’”
  5. Asking for clarification:
    1. Don’t assume that everyone else knows what’s going on: Do not, DO NOT, assume everyone else knows what’s going on.”
    2. Ask questions if you’re unsure: If you’re unsure about something, ask your manager for clarification: Can you provide more details about this task?’ or Are you expecting something super thorough, like multiple hours of effort, or a quick write up?’”
    3. Follow up if needed: If you’re still unclear, follow up with your manager to ensure you understand the task correctly.”

The cost of not doing this:

  1. Increased Employee Burnout and Turnover: Without clear guidance and precise asks, employees may feel overwhelmed and stressed, leading to burnout. They might end up working on tasks that are either unnecessary or overly time-consuming. This not only affects their well-being but can also lead to higher turnover rates as employees seek more structured and clear working environments elsewhere.

  2. Misallocation of Resources and Budget Overruns: When tasks are not clearly defined, teams might allocate resources, including time and money, inefficiently. For instance, a team could spend a significant portion of their budget on a project that was only meant to be a minor task. This misallocation can lead to budget overruns and the need for additional funding, which could have been avoided with precise communication.

  3. Damaged Client Relationships and Reputation: In scenarios where client work is involved, imprecision and lack of clarity can lead to missed deadlines, under-delivered promises, or outputs that do not meet client expectations. This can damage the relationship with the client and, in a broader sense, harm the company’s reputation in the market. Clients who experience poor project management due to unclear instructions may choose to work with competitors in the future.

Draft: Yes

biohacking-research

https://sci-hub.ru/about https://consensus.app/

Title: Biomarkers - from cheap to expensive Teaser: My insights from a book of the same title. Date: Jun 12 2023

Biomarkers

Grip Strength

  • Grip strength isn’t just about how well you can hold onto something—it’s a powerful indicator of your overall health and longevity. Emerging research consistently links grip strength to a range of critical health outcomes, including cardiovascular disease, diabetes, stroke, and even cognitive decline. Studies show that individuals with lower grip strength are at significantly higher risk of developing heart disease and diabetes, as well as experiencing strokes. This makes grip strength a vital metric for assessing your biological age, not just your chronological age.

Blood Pressure Sleep Score

Title: Book Review: Buy Back Your Time Teaser: My insights from a book of the same title. Date: Jun 12 2023

Book Review: Buy Back Your Time

These were the main ideas I tookaway after reading Buy Back Your Time by Dan Martell. I like Dan, he’s got some great content, but I’d give this book a 3/5.

Leadership

  • Transactional leadership is bad and looks like this: tell the person what they do, check that they did it, give them the next ask.
  • Transformational leadership is focused around an outcome. Instead of telling them what to do, you want them to tell you. After providing the outcome, offer a metric to measure progress.

The COACH Framework

If you want to lead, you’ll need to give feedback. Use this framework to structure this feedback without being overly prescriptive or vague:

  1. Co: Core Issue - Describe what the specific problem or area of concern is.
  2. A: Actual Story - Describe an actual instance when that manifested.
  3. Ch: Change - Ask the other person if they can make a commitment to change.

The 1:3:1 Rule

Before a report or colleague asks for your help, they should have a short note that addresses the following points:

  1. Define the one problem that needs to be solved. (Avoid having multiple tangential issues).
  2. Offer three viable solutions.
  3. Make one suggestion from that list of possible solutions.

Playbooks

Dan harps on something I’ve used basically forever but he’s got a good framework for systemizing them. A playbook (sometimes called a Standard Operating Procedure or SOP) is a public document that allows other people to achieve an outcome predictably.

If you’ve spent a lot of time mastering a task (such as hiring new people, opening a new location, or using a particular software library), then you should write up a playbook that can transfer that knowledge to other people so they can do it too and save time.

I personally use Notion but a Google Doc gets the same job done.

Dan has a nice checklist of what a playbook should include:

  1. Camcorder Method: Record a video of yourself doing a task. Put it in the playbook. As soon as you give the playbook to someone else have them record a video of them doing the task to replace the video you made. Record the video up to 3 times, since the task may vary every now and then. Talk through it so people understand your thinking as well. I’ve personally done this when showing people how to use a CRM or an internal tool.
  2. Course: A written version of the video, outlining the steps that you would take to achieve the task.
  3. Cadence: How often the task should get done (monthly, weekly, daily).
  4. Checklist: How to verify that the task was done correctly.

He’s also got a good example in the book that ties it all together. Let’s take the example of hiring someone:

Camcorder Method

  • Record yourself discussing how you’d hire someone. You could even record the interviewing call.

Course

  • Post a job posting.
  • Share on social media.
  • Review resumes.
  • Narrow down list.
  • Schedule onsites job interviews with department managers.
  • Send top choice to CEO.

Cadence

  • Whenever you need more employees!

Checklist

  • Did you receive at least 20 resumes?
  • Are the prospects excited at working here?
  • Did the department manager takes notes on what they liked about the candidate and forward them to the CEO?

Energy Management

Dan spends a good chunk of the book talking about visualization. Focusing on a business is one thing, but most entrepreneurs are focusing on a business as a means to an end to achieve another outcome. It could be leaving behind a legacy, living your ideal lifestyle, or leaving the world a better place than you found it. If you don’t have a vision for the future, you’ll end up wherever the tide sweeps you.

Dan calls this a 10x vision” and breaks it down into 4 parts: Team, Business, Empire and Lifestyle.

Dan hasn’t added much to visualization that I haven’t already covered.

Phase 1: The first step to creating an inspirational 10X Vision is to dream without limitations. Don’t worry about how you’re going to do it, just consider what you would do without any limits. Phase 2: Big dreams eventually need crystal clarity. Once you can describe your future vision with the same specificity and detail with which you can describe your current situation, you’ll have a vision that can motivate you today. Specifically, entrepreneurs need a clear vision that has these four elements: a team, one business, their empire, and their lifestyle.

Hiring

Out of the 6 rules” he highlights, I thought 2 were interesting.

  • Use a personality test. I personally like 16Personalities because it breaks down strengths and weaknesses for each personality, as well as workplace habits. (I’m an Advocate).
  • Require new hires to submit a video that they record answering 5 questions. It’s a nice middle ground between just seeing a resume and having to do a 30 minute call. Here are the questions he asks them to submit in the video:
  1. Why are you interested in this position?
  2. What is your ideal work environment?
  3. What do you know about our company?
  4. What are your strengths?
  5. Where do you see yourself in five years?

On Tasks

In a lot of business contexts I’ll write a TODO only to realize that that thing wasn’t actually done. Dan lays out 3 simple for what done looks like that’s easy to use whenever writing out a task.

  • Facts: What metrics must be accomplished? What should the measurement be?
  • Feelings: How must you and others feel for this task to be complete?
  • Functionality: What does this enable others to do when it’s done?.

He uses another simple framework for prioritization abbreviated by ICE. Each item has a score from 1-10.

  • Impact: If we achieved this item/outcome what problem would that solve?
  • Confidence: How likely are we that investing in this task will lead to the impact? (I like to think of this as a risk coefficient - there are many ideas that are massive in potential impact but have a low probability of risk).
  • Ease: How soon can this be delivered? How many resources will this require (hours worked, financial cost, etc.)?

By splitting out your tasks. Like all rating based systems, you shouldn’t be able to say 7. I’ll publish something on ICE a little later too.

There’s also a nice idea in the book about your Buy Back Rate. You get your hourly rate from a place like this. The rule of thumb is that if you can save 1 hour by paying someone else 1/3 of your rate, then it’s worth it.

Title: The Practice of Groundedness: Cheatsheet Teaser: My insights from a book of the same title Draft: Yes

The Practice of Groundedness

I picked up this book shortly after leaving Facebook and grinding on my business. I didn’t want to burn myself out and knew that there was a way to perform at a very high level without feeling all the anxiety that I use to feel.

I have a love-hate relationship with anxiety, in part because I’m fairly certain it has led to a lot of my outwardly success, but at the cost of never really enjoying the fruits of my labor. It turns out this is fairly common, and there is a relationship between anxiety and productivity that lots of folks are researching.

The scientific conclusion is fairly straightforward: a little bit of anxiety is effective for performance - but too much and it deters from it. In fact, this is known as Yerkes-Dodson law.

The book has a set of tactics set in sea of anecdotes and context but for this cheatsheet I’ll focus on making it as succinct as possible.

One of my anti-goals was to prevent burnout, which can be especially hard when you hold yourself to a high standard. The book starts off with a concept called Heroic Individualism:

an ongoing game of one-upmanship, against both yourself and others, paired with the limiting belief that measurable achievement is the only arbiter of success.

Although I had defined some goals I wantd

When you work on something significant, something significant is working on you.

Transmute Speed -> Thinking -> Presence

Process Mindset:

Stop one rep short

Acceptance Presence Patience Vulnerability Deep Community Movemennt

continually falling short of impossible expectations. I’ve come to call this heroic individualism: an ongoing game of one-upmanship, against both yourself and others, paired with the limiting belief that measurable achievement is the only arbiter of success. Even if you do a good job hiding it on the outside, with heroic individualism you chronically feel like you never quite reach the finish line that is lasting fulfillment.

The premise of the book is

Most people spend a lot of time and energy showing the world who they are. I’d rather spend that effort showing myself who I can become.

Had an important realization today:

I’ve spent a lot of time and energy trying to show the world who I am.

After quitting my job, I’m on a new path to show myself who I can become.

Draft: Yes

Brain Bullet

Summary

Brain Bullet is a no-nonsense guide to being getting more out of life. We follow the latest books and research on self-improvement to provide our listeners with actionable tips they can apply to their lives.

PRELUDE This 3 minute introduction.

My own journey in self improvement started when I was just a kid and I started playing video games. My parents were strict on my computer time so I wouldn’t have as much time as my friends to play games. Whenever I played with them, they would beat me. That was frustrating because I sensed they were winning simply because they had more time to practice the game. What could I do when I wasn’t on the computer in order to maximize the time I did have? So I took to reading, guides, game manuals, even reverse-engineering the games. I realized that everyone has their own path from Point A to Point B. If I could get to Point B (more success) with less time (the most valuable resource) then I would have an advantage in everything I do. As I began researching the subject, it turns out there is a broad and finite suite of tools that can assist in improving on this process. My documenting it for myself I could use it as a manual for new challenges in my life. By documenting it for others, I could change the world.

You might be wondering how I came up for the name of this podcast.

A bullet is fast. I listen to a lot of podcasts, I read a lot of books. It assumes you don’t care about the research, or the studies because you don’t have the time. You just want someone to tell you what works so you can focus on doing the work not verifying it’s claims. However, if you do want to dig into it, there is an accompanying website where you can find everything you need.

The ultimate goal of learning is not new knowledge. It’s new actions. It’s change. In your life and the lives of those around you.

Hit play on that next episode and enjoy the ride.

You won’t listen to this podcast like other podcasts. You have to listen to it in order, but you should also This podcast is accompanied by many additional resources, things I used to learn and things that motivated me to create it. At first I was going to write about it in my blog, but I realized listening to things can possibly reach more people.

PART ONE: LEARNING FUNDAMENTALS

Alright, so you got to learn a thing. The thing can be something academic like a subject in Science for school, or it can be a skill like guitar, or it can be. At work, if you have to learn how to run a marketing campaign, you want to learn everything you can about that subject is as short amount of time as possible.

Let’s take a birds eye view of what the book Ultralearning can teach us. But before we do that, it always helps to understand the kind of person that wrote this book. It’s written by a guy named Scott Young. He’s a writer, finished the MIT 4 year computer science curriculum in just 1 year.

starting at 4:09

That’s him talking about his challenge in 2012 in a TED talk viewed almost half a million times. Since then, he’s continued to write and research how to learn fast.

He also learned four languages in 1 year later on. This guy basically does a bunch of experiments in learning and his book is a culmination of the research.

Effective practice isolates the skills that are necessary to produce results. Researchers like to distinguish between drills and scrimmages. Drills distort the game so as to work on a specific skill under maximum concentration. Scrimmages mimic the game to get a feel for the cadence and circumstances. Skill transfer is the degree to which working on a skill in one setting translates into another.”

https://www.morganstanley.com/im/publication/insights/articles/article_feedback_us.pdf?1647446179979

Metalearning

The first thing you want to do before learning anything substantial is create a map.

Find online resources such as Google/YouTube that can teach you these things. You can further dig into online learning platforms like Coursera, Skillshare, or Udemy. Then look at books on the subject. You are here only to skim, not to actually dig into each resource. Skimming: If it’s a YouTube video, skip every 2 minutes or so. Check out the channel to see if they have similar content. How many subscribers do they have? Who can help you learn this? These can be people in-person but other times it’s authors of books or people who have the skill you’re trying to learn. They often can point to their own learning journey or other resources. Find them on social media such as Twitter or LinkedIn. In many cases you can reach out and they’ll respond. What should you emphasize? What should you exclude? In many cases if you’re trying to learn something fast you’ll need to prioritize which areas of the project are important for the goal you’re trying to achieve. If you’re going to Paris in 2 weeks, you’ll focus more on french words or phrases that would be used in restaurants or other public spaces. Identify the re-usable skills or concepts. People who learn 1 language are able to learn another related language much faster. How does this apply to your subject?

Break down into Concepts, Facts, and Procedures. Concepts: Ideas that can be manipulated in flexible ways. Needs to be understood, not memorized. Facts: Simple statements that you can recall in the right situation. Procedures: actions to be performed, mechanical instructions, require little thought.

The other part of metalearning is reflecting. This is different than reviewing things you previous learned (that’s important but for another reason). It’s more about reflecting on the process of learning itself. The best way to reflect is to write. Writing is thinking. Get a journal and write in it every day. Use writing prompts to make the process easier:

What is the ideal time to spend on this task? (Programming can take longer to warm up, others not so much).

Spend some time upfront to identify the resources that’ll help you learn the skill or subject. Think of this as coming up with a list of TODOs. Metalearning also means you’re spending some time reflecting on your learning journey. The best way to do this is with a journal. Each day write down what you learned, what was hard to grasp, what seems to be working, what seems to not be working.

Directness

Apply your skills to the ultimate outcome. What exercises can you apply that will help you practice the skill?

Focus

https://fs.blog/2019/10/focused-diffuse-thinking/

Retrieval

Do you spend most of your time on recalling from memory? Do you test your memory?

Feedback

Are you getting feedback/criticism or avoid it? Are you overreacting to noisy data?

Retention

Spacing exposure to retain long term memory. Using mnemonic techniques are useful, but consider: Question and answers should be atomic. 2 small questions can be better than 1 especially for abstract information or concepts. It’s important to make your own cards as that’s half of the process. If you can include a narrative that can be more effective as it has more emotional resonance to stick. (ie. What is the capital of Australia? Canberra - NOT Sydney.) Vary the context: reviewing material in 2 different physical places improves recall. Interleave concepts together to reinforce related concepts. By memorizing smaller pieces of a large concept you can spend more cognitive effort on the conceptual or complicated systems.

Intuition

Do you deeply understand the material or are you just memorizing? Can I explain to someone like they’re five years old? Am I using metaphors and analogies?

Experimentation

Are you exploring outside of your comfort zone? Are you exploring ways to solve problems creatively and do things that others haven’t done before? What system can be put in place to lead to 0-1 innovations such as Roman numerals to Hindu-Arabic numerals?

Sources How can we develop transformative tools for thought?

PART THREE: GREAT POWER, GREAT RESPONSIBILITY

https://blog.samaltman.com/how-to-be-successful

  • Be bold. Hard startups are easier than easy startups.

Ikagi:

What you love to do What you are good at What the world needs What you can be paid for

If you listened to part one and two, you’re now fully equipped to do whatever you want. If someone says jump, you say how high. A much harder question, than only you can answer, is how do you spend your energy on the things that matter. The things that maximize your happiness.

Time is a finite resource. Whether or not you like it, you are spending this resource right now, by listening to me! So let me ask you this: what do you consider time well spent?

Take an account of your time. If you have a mobile phone. I use Qbserve on my computer and the latest OS can display time you spend on your phone. Every time I walked away from social media, . Time

What do you consider time well spent?

Only a small part of the population is going to have the drive and ambition to become the world’s greatest bodybuilder. What can the world give to you? What can you give to the world?

PART TWO: WILLPOWER, MOTIVATION & PROCRASTINATION

Writing/Blog/Optimizing Your Biggest Input- Energy

On Motivation

  • Keep middles short. You’re more likely to quit in the middle than the start or the end of a project.
  • Look back to stay motivated. Looking at how far you’ve come to help you keep going.
    • But what if I haven’t gotten anywhere? Then frame it - is it a lack of commitment or progress? People tend to feel worse about lacking commitment.
  • Give others advice on motivation. By repeating things you’re practicing yourself, you’ll trick yourself to not be cognitively dissonant with your own advice.

WOOP: Wish, Outcome, Obstacle, Plan

  • Accountability Partner
  • Begin Again meditation

Your mind is a suggestion engine. Every thought you have is a suggestion, not an order. Sometimes your mind suggests that you are tired, that you should give up, or that you should take an easier path. But if you pause, you can discover new suggestions. For example, that you will feel good once the work is done or that you have the ability to finish things even when you don’t feel like it. Your thoughts are not orders. Merely suggestions. You have the power to choose which option to follow.”

  • James Clear

Start with Why?

In the previous section on metalearning, we stated some question. One of the most important questions is why you’re doing it. Concentrate and focus on the outcome, ie. what it looks like after you achieve this goal.

Inspiration Read books on the biographies of winners. The secret of success lies in forming habits that allow you to do what failures don’t want to do. If you don’t consciously create good habits then you will unconsciously form bad ones.2

Focus

Time management is pain management. The button gives a painful electrical shock - 60% of people administer. We are so uncomfortable doing nothing that we give ourselves pain. Distraction comes from traction. We don’t do things to avoid pain and pursue pleasure - it’s to avoid discomfort. 10 Minute Rule: I’ll do it in 10 minutes. Surfing the Urge”

From

Willpower

How to beat the marshmallow test? Change the personality or alter the context. Picture the marshmallow as a big puffy cloud”

Chunking

Part One: Focus On Output

Learn Apply Reflect

Learn

https://medium.com/learn-love-code/learnings-from-learning-how-to-learn-19d149920dc4 https://www.coursera.org/learn/learning-how-to-learn

Ultralearning. https://www.scotthyoung.com/blog/about/

Being able to master hard skills quickly is essential to your work and life. This book will show you how.

Reflect

You learned the tools and knowledge to unlock your potential. You’ve figured out how to structure your life to get things done.

In this episode we’re going to talk about how to spend time well.

Sources Time Anxiety The Common Denominator of Success by Albert E.N. Gray https://www.bbc.com/worklife/article/20200121-why-procrastination-is-about-managing-emotions-not-time

Title: Brainwashing Myself To Become Happier and More Productive Draft: Yes

Brainwashing Myself To Become Happier and More Productive

This is a systematic guide on how to brainwash yourself into being happier and more productive. I hope you can appreciate the provocative title.

If you’re a high performer there’s a good chance you’ve learned to burn anxiety as a fuel to becoming more economically productive. The problem is that this same impulse that you have to thank for achieving so much in your life has burnt you out in the process. Occasionally it makes the process of being you” miserable, despite external factors indicating that you’ve got everything under control and you’ve built a life that most people envy.

What if it were possible to maintain that drive and ambition and enjoy the process along the way?

I’ve read a number of books on the subject, some of which I’ve written about, but in this post I’m going to distill it down into a guide.

The basic premise is to recognize that:

  1. You have deeply held beliefs about the world that you view everything through. Those beliefs create emotions, and those emotions trigger the actions you take. Those actions lead to material differences in reality.
  • Beliefs -> Emotions -> Actions
  1. Some percent (say, 80%) of those actions are great (for your bank account, your relationships, your physical fitness) and some percent (say, 20%) of them are not so good. Some of those emotions that arise feel bad.” Feeling bad” over a long enough time causes burn out, depression, and apathy.
  2. Therefore, your downstream reality is a result of your beliefs which are held in your mind.
  3. Your brain is a bidirectional belief factory. Every event that occurs in your reality is interperted by the beliefs your brain holds. New events roll into the belief factory on a conveyer belt. An Organizer puts those beliefs into different lanes. Those areas of the brain become bigger and .
  4. The process of brainwashing yourself is to collect new experiences that affirm new beliefs and discarding old ones.
  5. A thought counts as an experience” but it’s a fairly insignificant one. That’s where confidence comes from - you’ve
  6. When new events occur, your brain . However you brain has 2 bugs: 1 is to confirm itself, and the other is to
  7. You’ve accumulated them over the course of your life and they’re so deeply embedded that you don’t even know that they are working against you.
  8. You’ve already been brainwashed and now we have to do the work to undo that which will take just as long.

Let’s take a practical example of installing a new belief.

Belief: All I do is win, win, win no matter what.

Why? People rarely get tired of winning. Burnout in the workplace occurs more often when you feel like you are losing on some dimensions; if you’re working super hard and feel like your company is not growing despite the grind, that’s a recipe for burnout. How do we find evidence to affirm this new belief? You can start off by setting the conditions for victory. You set the bar so low that you can attain it. Setting the bar too low will not bypass your own filter for what you consider victory. For example, if you want to workout every day to feel like you’re winning, you can do 1 push up each day. It’s likely though that 1 push up won’t make you feel like winning. There are 2 things you can do: change your beliefs (start to believe that 1 push up IS winning), and/or move the bar (do 30, 60, or however many pushups to make you feel proud of yourself).

If you agree and follow along with the above than you’re ready to receive instructions to unroll parts of your old brain and install new beliefs.

You may not have heard about

That’s how I felt. I can’t say that I solved” this problem.

Top performers have harnessed their anxiety into productive

I try to make my home the best it can be. I tidy it up, I buy things to improve it, I invite my friends to make great memories.

I don’t live in my house. I don’t live in my city. I don’t even live in my country.

Useful frames: Don’t make everything so personal. Dose of perspective. Personalization” is what causes stress. Judgement causes stress. Accept reality. Surrender to your greater self?

We try” to make these places livable” but we have the least influence.

You have the power to make living in your mind a hell. The opposite is also true. People spend more time pimping out their homes than they do their mind. We don’t always have full autonomy over our minds. There are times when you want your mind to do something for you, but it doesn’t have the resources to do so. You can’t ask a messy house to clean itself. You can hire a maid. You can buy tools to make the job easier (vacuume, plants, etc.)

There is nobody else LIVING in my head. If someone comes into your house, and you don’t want them there, you ask them to leave. If they don’t listen to you, you call 911.

Some people rent it out from time to time but I should ask them to leave if they’re messing it up.

To the degree that I can, I control my house to be the best. I keep it clean, I buy things to make it more comfortable. I live in mind. The greatest manifestation of myself is in my head. I’m living in there every second of every day and if I’m not pimping that bitch out then I’m losing the game. Everything that manifests in reality starts with the thoughts in my head.

You have the power to make living in your mind a hell. The opposite is also true.

World Views and Happiness

I read a combination of four books successively, and was exposed to a variety of experiences and events that put them all into context. I’ll try to compile my learnings in the last few months in this post.

Idea 1: Perception controls behavior

What you believe shapes what you do. In fact, all of your thought and actions are all motivated by your beliefs. If you didn’t believe that studying in school and working hard would land you with a good job, then you wouldn’t have done it. Yet, we also know that just because you believe something doesn’t mean it’s true.

This is because we don’t operate in reality; we operate on a snapshot of reality. Our brains can only operate on the sensory information that it’s given. A lot of the time the sensory information is different than what we immediately feel.

Idea 2: Your world view is the lens in which you look at the world

I define a world view as a prolonged extension of your experience. It’s the lens in which you perceive all events that are happening to you.

Let’s take an example: when you’re hungry, you experience food differently. However, hunger does not last forever. If you are constantly.

Prolonged hunger, say, on a daily basis, affects you in a more permanent way. If you’re constantly hungry, then you That’s not your worldview, because you can satisfy your hunger and the rose-tinted” glasses of hunger disappears.

Your world view is more constant; it’s formed over a much longer period of time: the longer the time, the stronger the worldview.

Purpose, meaning, religion. Example of the gym: pain that has meaning is fine.

Idea 3: You are constantly reaffirming your worldview, whether you like it or not

The whether you like it or not” is important enough to have been included in the headline. I claim that most people do not choose” their worldview, they simply get one” because they don’t give it enough thought.

Confirmation bias. Subjective truth.

Idea 4: You can shape your worldview to work for you.

Worldviews can be changed through persistent thought patterns and physical behaviors.

Intentionally change your worldview to benefit the kind of behavior God is love. Assuming this is true is beneficial.

Just think about the act of hating someone versus loving someone. Isn’t it far more enjoyable to love someone?

Books

  1. Breaking the Habit of Being Yourself: How to Lose Your Mind and Create a New One
  2. The Master Key System
  3. The Untethered Soul: The Journey Beyond Yourself

Title: Breathwork Teaser: You were never taught how to breathe, so you’re probably doing it wrong. Date: Jan 15 2023 Tags: 1 Pager

Breathwork

Forms of Breathing

  • Cyclic Sighing: (source)
    • Daily 5-minute breathwork and mindfulness meditation improve mood and reduce anxiety
    • Breathwork improves mood and physiological arousal more than mindfulness meditation
    • Cyclic sighing is most effective at improving mood and reducing respiratory rate
  • Psychological Sigh: (source)
    • A kill switch for your stress response”
    • Two short inhales through the nose
    • One long exhale through the mouth
    • Repeat one to three times
  • 10 deep breaths during moments of anxiety

Over time, shallow breathing limits the range of our diaphragms and lung capacity. The result is the high-shouldered, chest-out, neck-extended posture and other respiratory problems - Breath: The New Science of a Lost Art

  • Square Breathing
    • 4 Second Inhale, 4 Second Hold, 4 Second Exhale, 4 Second Hold
  • Wim Hoff Method (source)
    • Just watch this 11 minute video and follow along.
    • Inhale fully and exhale partially 30 times.
    • Inhale slowly and hold as long as you can. Exhale slowly.
    • Inhale and hold for 10-15 seconds. Exhale slowly.
    • Repeat 3-5 times.

Other fun facts

  • Exhaling is calming, inhaling activates alertness. Any breath pattern that has more exhaling generally calms you down.
  • Breathing through the left nostril increases the activity in the right side of the brain while breathing through the right nostril stimulates the left side of the brain. (source)

Title: Build vs Buy Date: Mar 12 2023 Teaser: A framework for making a decision with constrained resources. Tags: Startups, 1-Pager Draft: Yes

Build vs Buy

At Halo Science we help connect researchers and startups connect with companies for collaboration opportunities. There are a lot of products we pay for that make our jobs easier, like Hubspot, Google Workspace, Slack, Amplitude, and others. It not a hard decision to use these products instead of building them ourselves because they aren’t a primary feature of our platform for customers.

A simple framework for deciding to build vs buy might look like this:

  1. Can we afford it?
  2. Does it make our lives easier?

If the answer is yes to both, go for it!

Here’s a more complicated framework and trimmed-down versions of how we made the decision for several decisions such as building out SSO, our own outreach platform, and implementing an A/B testing suite.

  1. Is this core to our product?
  • How long will it take to build?
  • How long will it take to buy?

What other shortcuts are we taking if we’re building?

Customization and Flexibility

Technical Expertise

One way to answer this is to ask, has anyone built this before?”

Maintenance & Support

Scalability

But these breakdown when it comes to harder decisions such as choosing to build out SSO, building our own outreach platform, or implementing an A/B testing suite.

I’ll walk through some of the examples

If Hubspot decides to . We also breakdown the

The answer is further complicated by t

I have a tight deadline and won’t be able to make it. I don’t think an inattentive listener is any better than a black screen - do you?

Draft: Yes

building-filters-in-rails

I had a project where I wanted to build filters that a user could combine. [[screenshot 2023-03-07 at ]]

Title: Burnout Playbook Teaser: How to diagnose and treat professional burnout. Date: Jan 5 2023 Draft: Yes

Burnout Playbook

Step 1: Identify the cause

It helps to identify whether or not burnout is being caused by workplace culture or something going on in your personal life.

You can think about the following:

  • Workload: Having too much work to do and not enough time to do it.
  • Lack of control: Feeling like you lack autonomy, access to resources, and a say in decisions that impact your work can contribute to burnout.
  • Insufficient rewards: Feeling undervalued or undercompensated for your work can lead to burnout.
  • Workplace culture: A toxic work environment, lack of support from colleagues or supervisors, and poor communication can contribute to burnout
  • Lack of Learning / Impact: You fail to see a connection from your work to the change you want to have in the worl. You work working on things that are not interesting to you.

You can score each from a score of 1-5 to see if any patterns pop up.

Your personal life plays a big factor as well, but there’s a whole different set of techniques for addressing that. In this post I’ll only focus on workplace related causes.

Step 2: Implement solutions

For each area, here are some potential solutions.

Workload

  • There are only 2 real solutions to this: reduce the workload or increase the output.

Ways to reduce workload

  • Just do less. This is likely not a satisfying answer, but you should start here!
  • The second step is to figure out what you can let go. Do an 80/20 analysis on the tasks that are most important. Implement a strategy for prioritizing new work items.

Ways to increase output

  • Hire more people for the same amount of work.

  • Talk with top performers and learn what resources you can use to improve your output.

    Lack of control

Insufficient rewards

  • Ask for a increase in your salary, a bonus, or equity.

  • Do competitive research and make a case for why you believe you are being underpaid.

    Workplace culture

A toxic work environment, lack of support from colleagues or supervisors, and poor communication can contribute to burnout

Lack of Learning / Impact

  • Ask for projects that prioritize projecst

Title: Career Advice Teaser: Resources to build a great career both inside and outside of the tech industry. Date: Dec 2 2022 Tags: 1 Pager

Career Advice

General Career Advice

Applies to all careers.

Engineering Career Advice

Applies to engineering careers.

  • Don’t Call Yourself A Programmer, And Other Career Advice: If there was one course I could add to every engineering education, it wouldn’t involve compilers or gates or time complexity. It would be Realities Of Your Industry 101, because we don’t teach them and this results in lots of unnecessary pain and suffering. This post aspires to be README.txt for your career as a young engineer.”
  • How To Be A Programmer: To be a good programmer is difficult and noble. The hardest part of making real a collective vision of a software project is dealing with one’s coworkers and customers. Writing computer programs is important and takes great intelligence and skill. But it is really child’s play compared to everything else that a good programmer must do to make a software system that succeeds for both the customer and myriad colleagues for whom she is partially responsible.”
  • Professional Programming: A collection of full-stack resources for programmers.

Interviewing

From Interview advice that got me offers from Google, Microsoft, and Stripe

Algorithms

If you grind NeetCode 150 and Blind 75, you should be in good shape. I have setup a Custom GPT with the following prompt that explains questions to me. This is the prompt:

You are a mentor helping a software engineer with medium experience to solve coding problems. I will provide you with a coding problem, and you will break it down for me. 

Your breakdown should consist of the following sections:

1. Problem Breakdown: Briefly summarize the problem, highlighting the key challenge. Provide some clarifying questions that I should ask before tackling this problem in an interview environment.
2. Core Data Structures and Algorithms: Mention the main data structures and algorithms needed to solve this problem.
3. Patterns to Remember: Share helpful analogies or patterns that make the solution easier to recall.
4. Solution: Write out the solution in Javascript. Use a tab indent size of 2. 
5. Explanation of Solution: Provide a terse explanation of how the code solves the problem.

Format your response such that each section above is its own header.

Every day I take one of the questions from NeetCode 150 and Blind 75 and generate a solution to a problem. I then post them under the Interview Questions tag.

Books

Date: Nov 27 2022 Tags: Health Title: Common Cold Cheatsheet Teaser: Protocols for recovering from a cold ASAP. Draft: No

Common Cold Cheatsheet

I put this together after getting a cold. Take 1 or more of these before or during your sickness.

Ingredients

These are ingredients I found to be effective. You can mix them together (ie. brew a tea), take them as a supplement, or just have them straight.

I found a supplement that contains most of these in 1 pill. I start taking it as soon as I think I’m getting sick.

Routines

  • Drink a warm beverage at least every hour.
  • You can try the Navage Nasal Care to clear your nose… I haven’t tried it, but the reviews are very high.

Date: Nov 29 2023 Tags: 1 Pager Title: Understanding Complex and Complicated Teaser: I’ve found myself relying on this distinction a lot when explaining concepts.

Understanding Complex and Complicated

Lots of people mix up the words complex” and complicated.” They think they mean the same thing, but they’re actually quite different.

Think about a beehive: it’s complex. But making a paper airplane is complicated.

Building a big Lego castle is complicated. Figuring out how to keep our planet healthy is complex.

Writing code for a simple computer game is complicated. Creating a robot that can understand our feelings is complex.

When something is complicated, it means that there are clear steps and rules to follow. If you do things the right way, you can solve the problem. It’s like a puzzle with an answer. Complicated things, like machines, can be controlled, and we can find solutions that last.

But when something is complex, it’s more like a big web of connections. The way things work together can change, and it’s not always easy to predict what will happen. In complex situations, how things relate to each other is more important than just the individual parts.

Title: Concurrency and Parallelism in Ruby on Rails Teaser: Learn how to write faster Ruby code. Date: Apr 25 2023 Tags: Code snippets

Concurrency and Parallelism in Ruby on Rails

Ruby is slow but most tasks are I/O bound (file, network, etc.) To make Ruby faster, split your work across different threads or processes.

Vanilla Threads

  • You can use vanilla Ruby threads for simple tasks.
# Make threads bubble up exceptions. By default, they won't break the main process.
Thread.abort_on_exception = true 

thread =
  Thread.new do
    begin
      # do a thing like a network call
    ensure
      File.delete(LOCKFILE)
    end
  end
# Make ONLY this thread abort if you didn't set the default.
thread.abort_on_exception = true 

Use Parallel for most tasks

Parallel wraps a bunch of concurrent/parallel features in a really nice interface. See below for some common snippets.

results = Parallel.map(['a','b','c'], in_threads: 2) do |one_letter|
  expensive_calculation(one_letter)
end


# After each iteration, it calls the lambda. Keep going until you reach Parallel::Stop.
items = [...]
Parallel.each( -> { items.pop || Parallel::Stop }) { |number| ... }

Parallel.each([], in_processes: 8, progress: "Doing stuff")

# Make sure to use Concurrent structures!
Concurrent::Hash
Concurrent::Set
Concurrent::Array
# Do NOT use += operations on these. Use a.concat(b)

Use Concurrent Ruby

mod = Module.new do
  extend Concurrent::Promises::FactoryMethods
  @thread_pool = Concurrent::FixedThreadPool.new(5)
  def self.default_executor
    @thread_pool
  end
end 
mod.future { 1 }.default_executor        # => :fast
Concurrent::Promises.future { 1 }.default_executor
pool = Concurrent::FixedThreadPool.new(5)
100.times { Concurrent::Promise.execute { sleep(10); puts 'Done' } }
Thread.list.count

500.times { Concurrent::Promise.execute(executor: pool) { puts "Hi" } }
Thread.list.count
# Simple promise
timeout = Concurrent::Promise.new do
  
end

# Returns 0, immediately executes.
Concurrent::Future.execute { 0 }.value!
# Adds a timeout and will return nil.
Concurrent::Future.execute { sleep 5; 0 }.value!(1)

# Immediately executes. Will not throw errors. .value will be nil
r = Concurrent::Promise.execute do
  sleep 2
  fail 'FUCK'
end
r.state # This updates the state. Check if it's :fulfilled
r.value # The final value in the execution. This will BLOCK the main thread until we have a value.

# Common pattern:
(
  first_request = Concurrent::Promise.execute { sleep(rand(5)); 'first' }
  second_request = Concurrent::Promise.execute { sleep(rand(5)); 'second' }
  Concurrent::Promise.zip(first_request, second_request).value! # ['first', 'second']
)

promises = 10.times.map { Concurrent::Promise.execute { sleep 5; Company.first } }
Thread.list.size

ActiveRecord::Base.connection_pool.with_connection do
  Concurrent::Promise.execute do
    Rails.application.executor.wrap do
      Company.first
    end
  end
end

thread_pool = Concurrent::FixedThreadPool.new(4)
executors =
  posts.map do |post|
    Concurrent::Future.execute(executor: thread_pool) do
      SMUtils.fetch_user_from_post(post)
    end
  end

executors.map(&:value!).each_with_index do |user_info, index|
  posts[index]['user'] = user_info
end

futures = []
job.hashtags.each do |hashtag|
  futures << Concurrent::Promises.future do
    Rails.application.executor.wrap do
      InstagramWebClient.search_for_hashtag(hashtag, only_top: true)
    end
  end
end
all_posts = Concurrent::Promises.zip(*futures).value!

executors.map(&:value!)

> ZeroDivisionError: divided by 0
> from (pry):4:in `/'

def get_all_conversations
  groups_promise = Concurrent::Promise.execute do
    get_groups_list
  end

  channels_promise = Concurrent::Promise.execute do
    get_channels_list
  end

  [groups_promise, channels_promise].map(&:value!). flatten
end

Concurrency in Rails

When doing concurrent tasks in Rails there are additional implications. Read up on Threading & Code Execution in the Rails docs.

Wrap your Parallel work in permit_concurrent_loads

data = [1, 2, 3] 
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
  Parallel.map(data, in_threads: 3) do |item|
    Rails.application.executor.wrap do
      puts "ParallelMapper instance: work_in_threads: #{item}"
      collaborator_one = CollaboratorOne.new(item)
      collaborator_one.perform
    end
  end
end

Deadlocks in Rails

This is a nightmare to debug, but you can visit the locks endpoint.

For a given process you can also print out backtrace for all the threads. This snippet from Thoughtbot.

threads = Thread.list
 
puts
puts "=" * 80
puts "Received USR1 signal; printing all #{threads.count} thread backtraces."

threads.each do |thr|
  description = thr == Thread.main ? "Main thread" : thr.inspect
  puts
  puts "#{description} backtrace: "
  puts thr.backtrace.join("\n")
end

puts "=" * 80

Fibres

More lightweight and memory efficient than threads, but harder to use. You probably won’t need it.

Ractor

True parallelism for Ruby (even over the GIL) without multiple processes. Mostly experimental right now.

Other Resources

Date: Sep 3 2024 Title: Interview Question: Count Subsequences Teaser: Unraveling the mystery of counting subsequences. Tags: Interview Questions

Count Subsequences

This question is part of my Career Advice series.

Original question: https://neetcode.io/problems/count-subsequences

1. Problem Breakdown:

The task is to determine the number of distinct subsequences of string s that are equal to string t. A subsequence is a sequence derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

Clarifying Questions:

  • Can the strings contain any characters other than lowercase English letters? (Given constraints suggest no, but it’s good to confirm).
  • Are there any constraints on the length of s relative to t? (In this problem, s can be longer than t, but if t is longer than s, there are no valid subsequences).
  • Should we consider case sensitivity? (Assuming yes based on standard string manipulation problems).

2. Core Data Structures and Algorithms:

  • Dynamic Programming (DP): We’ll use a 2D DP table where dp[i][j] represents the number of distinct subsequences of s[0...i-1] that equal t[0...j-1].

3. Patterns to Remember:

  • Subsequence Counting: This is a common dynamic programming pattern where you consider both including and excluding the current character in s when matching with t.
  • DP Table Initialization: dp[i][0] should be 1 for all i because an empty string t can always be formed by any string s by deleting all characters.
  • Recursive Subproblem: For each character in s, decide whether to match it with the current character in t or skip it.

4. Solution:

function numDistinct(s, t) {
  const m = s.length;
  const n = t.length;

  // DP table where dp[i][j] means number of subsequences in s[0..i-1] that match t[0..j-1]
  const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));

  // Base case: An empty t can always be matched by any prefix of s by removing all characters
  for (let i = 0; i <= m; i++) {
    dp[i][0] = 1;
  }

  for (let i = 1; i <= m; i++) {
    for (let j = 1; j <= n; j++) {
      if (s[i - 1] === t[j - 1]) {
        // If characters match, count subsequences including and excluding current char
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      } else {
        // Otherwise, carry forward the count without including current char of s
        dp[i][j] = dp[i - 1][j];
      }
    }
  }

  return dp[m][n];
}

5. Explanation of Solution:

  • Initialization: The DP table dp is initialized such that dp[i][0] is 1, indicating that any prefix of s can match an empty t.
  • DP Transition:
    • If the current characters of s and t match (s[i-1] == t[j-1]), then we add the number of subsequences where:
      1. We include the current character from s in our match (dp[i-1][j-1]).
      2. We exclude the current character from s and just carry forward the previous count (dp[i-1][j]).
    • If they don’t match, we carry forward the previous count without including the current character of s.
  • Result: The value at dp[m][n] gives the total number of distinct subsequences of s that match t.

Draft: Yes

Deep Work

Minimize distractions, including meetings.

Draft: Yes

Email Deliverability

Sender Reputation

https://talosintelligence.com/reputation_center/ https://www.barracudacentral.org/lookups/lookup-reputation

Spam

  • Do not use exclamation marks.
  • Do not use all caps.

https://spamcheck.postmarkapp.com/

Authentication

SPF, DKIM, DMARC This is a simple checklist that you should go thorugh

Draft: Yes

Email Verification Cheatsheet

So you want to find emails for anybody? Your options are to choose a paid product such as Hunter.io, Uplead, or something else.

For Ecomm Analyze we need to so I dug into how this can be done and here’s what I found out.

Draft: Yes Teaser: Emotions are hard to quantify.

Emotional Metrics

  • Time To Apologize: When you lose your cool, you usually have a time from when you can disconnect with the rage and apologize. Minimize this.
  • Mental Liquidity: How quickly are you able to change your mind on something.
  • Words Written Per Week: Journaling is good for you, insomuch as you do it. If progress = pain + reflection, then words written per week can be a proxy for reflection.
  • Time In Presence: What percent of your time are you spending being present in the moment vs having thoughts about the past or future.
  • Ego Humbling Interactions: If you have a big ego, you should have anecdotes for when you were humble (and not made humble). This can be number of anecdotes per week.

Date: 2023-12-19 Tags: 1 Pager Title: error-handling Teaser: A brief description goes here. Draft: Yes

Error Handling

A consistent way to handle errors means we

  • Write less code.
  • Have a consiset

Ways that we can show errors in the app:

  • Forms (input validation)
  • Dialogs
  • Redirects (to a login page)
  • Toasts

Types of Errors

  • Invalid data (422)
  • Invalid request (400)
  • Server error (500)
  • Forbidden or Unauthorized

Ways to add error handling

  • The server renders error as a JSON payload.
  • The server renders a JS payload which invokes a toast.
  • On the frontend:
    • onError for React Query
    • catch for Axios.
    • Generic handlers.

When a Request fails

Recently I wanted to revamp the way to

onError: Handle the error yourself. Create some generic handlers that either toast, display a popup, etc.

Do not redirect people. Instead show a screen that allows them to redirect with a message on why. OR, redirect them and show them a pop up.

https://github.com/halocures/halo/pull/3540/files#diff-bbe3877b318d6833ecb6d1deb813590b88e90084a1c1ca9ec409be15223203a6R247-R257

500 Errors: They are unexpected. Show a toast (you encountered an error on this page)

non-200, with JSON: Toast Errors: { error: { message: …, } }

Date: Nov 27 2022 Tags: Health, 1 Pager Title: Everything I’ve Learned About Feedback Teaser: A cheatsheet for giving feedback in a professional (and personal) context. Draft: Yes

Everything I’ve Learned About Feedback

Giving Feedback

The COIN Conversation Model can be used when you want to give feedback to someone in a professional (or personal) setting.

  • Context: This involves setting the stage for the feedback by providing relevant background information and context.
  • Observation: This involves stating specific behaviors or actions that were observed, rather than making judgments or assumptions about the person’s intentions.
  • Impact: This involves describing the effects or consequences of the behaviors or actions on the team, the project, or the individual receiving the feedback.
  • Next Steps: This involves suggesting steps that the individual or group can take to improve or address the issue identified in the feedback.

In Book Review: Buy Back Your Time , you can also use the COACH framework which is similar.

  1. Co: Core Issue - Describe what the specific problem or area of concern is.

  2. A: Actual Story - Describe an actual instance when that manifested.

  3. Ch: Change - Ask the other person if they can make a commitment to change.

    Receiving Feedback

  • Feedback is received from people who care about you. Listen to it without judgment, gather as many of the facts as possible.
  • Always thank the person you gave feedback to.
  • Choose what you’ll address. You’ll receive feedback that you won’t always feel compelled to action on - that being said, you’ll better understand the cost of your behavior and whether or not the tradeoff is worth it.
  • You should always be receiving feedback. If you are not, you are not being bold enough.
  • Many people aren’t sure whether or not to give you feedback: they’ll talk about an action or behavior that they think is too minor” to bring up.

Feedback for High Performers

From Stripe Press — Scaling People

  • People typically stray away from giving feedback to high performers because they’re already so good.
  • Two common problems:
    • They burn others around them out. By having
    • They burn themselves out. If given lots of work, they’ll get it done, but not realize the personal toll it takes on them.
    • They don’t know how to delegate
  • Common solutions:
    • Collect feedback from their peers to ensure that others enjoy working with them.
  • This is bad because high performers need feedback. Claire’s says

Appendix

Date: Nov 3 2022 Tags: Code Title: Performance Cheatsheet for Ruby on Rails Teaser: Tuning performance in various ways to keep your Ruby code fast Draft: Yes

Performance Cheatsheet for Ruby on Rails

Simple Tests

This one liner you can add to your Pry to see how long a single method call takes.

def pmeasure(&block)
  now = Time.now.to_f
  yield
  duration = Time.now.to_f - now
  puts "Finished in #{duration.round(6)}s"
end
# pmeasure { sleep 1 }

Benchmarking

You can use the benchmark library in native Ruby for simple tests.

require 'benchmark'
puts Benchmark.measure {
  evens = []
  arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]
  arrays.each do |array|
    array.each do |num|
     evens << num if num.even?
    end
  end
}

evens = []
arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]
arrays.each do |array|
  array.each do |num|
   evens << num if num.even?
  end
end

arrays.inject([]) do |result, arr|
  result + arr.select { |x| x.even? }
end

arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]

n = 100_000
Benchmark.bmbm do |x|
  x.report("inject") do
    n.times do
      array.inject(0, :+)
    end
  end
  x.report("sum") do
    n.times do 
      array.sum
    end
  end
end

Use benchmark-ips to figure out how many times to run the given function to get interesting data.

require 'benchmark/ips'

Benchmark.ips do |x|
  # Configure the number of seconds used during
  # the warmup phase (default 2) and calculation phase (default 5)
  x.config(:time => 5, :warmup => 2)

  # These parameters can also be configured this way
  x.time = 5
  x.warmup = 2

  # Typical mode, runs the block as many times as it can
  x.report("addition") { 1 + 2 }

  # To reduce overhead, the number of iterations is passed in
  # and the block must run the code the specific number of times.
  # Used for when the workload is very small and any overhead
  # introduces incorrectable errors.
  x.report("addition2") do |times|
    i = 0
    while i < times
      1 + 2
      i += 1
    end
  end

  # To reduce overhead even more, grafts the code given into
  # the loop that performs the iterations internally to reduce
  # overhead. Typically not needed, use the |times| form instead.
  x.report("addition3", "1 + 2")

  # Really long labels should be formatted correctly
  x.report("addition-test-long-label") { 1 + 2 }

  # Compare the iterations per second of the various reports!
  x.compare!
end

Where’s the bottleneck?

Sometimes you want to find out why your logic is slow. You can use rack-mini-profiler for Ruby on Rails apps.

You can add these tags to the end of your URL to instrument any Rails action.

?pp=flamegraph 
?pp=flamegraph 

StackProf works well for Ruby code.

StackProf.run(mode: :cpu, out: 'tmp/stackprof-cpu-myapp.dump', raw: true) do
  # my expensive logic
end
# Open tmp/stackprof-cpu-myapp.dump to see the results.

For identifying the source of long running queries, I like sqlcommenter.

gem "activerecord-sql_commenter", require: "active_record/sql_commenter"

# application.rb
config.active_record.query_log_tags_enabled = true
config.active_record.query_log_tags = [ :application, :controller, :action, :job ]
config.active_record.cache_query_log_tags = true

Title: Flow State Cheatsheet Teaser: How to get more flow states, get in them easier, and stay in them longer. Date: Dec 2 2022 Tags: 1 Pager

The best moments in our lives are not the passive, receptive, relaxing times… The best moments usually occur if a person’s body or mind is stretched to its limits in a voluntary effort to accomplish something difficult and worthwhile

One of the most satisfying feelings I experience in a day is looking at the clock and being surprised to see how fast time flew. If you’re in a rush, this can be quite a bad feelings.

https://contextkeeper.io/blog/the-real-cost-of-an-interruption-and-context-switching/

  • Maintain state as well much as you can. This can involve a session” where you keep your

https://census.dev/blog/an-on-ramp-to-flow

  • Leave things obviously broken or easy to fix.
  • Do NOT leave things at a neat” stopping point or when you’re struggling with something.
  • It should be easy to jump back in and make quick momentum.

The first X minutes of any task sucks. You have to build context and get into the flow. For that reason, multi-tasking means you never get into the flow, and you’re just jumping from the shitty part of each task. Batching for this reason is essential.

From Rian Doris:

Date: Jul 2 2023 Title: Food & Self Control Teaser: Eat like you invest. Tags: Daily Musing

Food & Self Control

If you’re not buying healthy foods, stop buying ones you know are bad for you.

I have little self control: if I see cookies, I eat cookies.

Buying unhealthy food is like investing in a depreciating asset.

Also see…

Title: Getting AI To Write Like Me Teaser: None of that yapping that ChatGPT does today. Date: Oct 27 2024 Tags: AI

Getting AI To Write Like Me

Step 1

Take a large chunk of your writing. Lucky for me, I have all my blog posts. Unfortunately, it’s a ton of code examples as well, so I had to filter that out.

[[../_Images/CleanShot 2024-10-27 at ]]

How do I get all of these *.md and turn them into just prose?

Sorbet has been a great addition to the Ruby ecosystem. It helps me write code faster and more correctly. However, it has some gotchas, so I’ll be adding those here along with remediations.

Upgrade ActiveModel::Type::ImmutableString to support Enums

By default, it’s tempting to want to do:

class EventName < T::Enum
  enums do 
    SPECIAL = new
  end 
end

MyModel.where(name: EventName::SPECIAL)
# throws:
# /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.1/lib/active_record/connection_adapters/abstract/quoting.rb:43:in `type_cast': can't cast EventName (TypeError)
# raise TypeError, "can't cast #{value.class.name}"

You can fix it with:

MyModel.where(name: EventName::SPECIAL.serialize)

I found that too easy to forget, and you get no warnings when you forget to do it. Instead, you can add an initializer to allow Rfails to support casting Sorbet enums properly to a string. (h/t to this StackOverflow question).

Add config/initializers/active_record.rb so that if you forget to serialize a value before sending it to the database, it’ll be done automatically.

# typed: true
module TEnumSupport
  def serialize(value)
    case value
    when T::Enum
      value.serialize
    else
      super
    end
  end
end

ActiveModel::Type::ImmutableString.include(TEnumSupport)

Using T::Struct for a JSON database column

If you have a model that has a JSON column and you want that JSON column typed with a struct, try this:

class CustomDataDataType < ActiveRecord::Type::Value
  def cast(value)
    if value.is_a?(BlogPostExtraData)
      value
    elsif value.is_a?(String)
      CustomData.from_hash(JSON.parse(value))
    elsif value.is_a?(Hash)
      CustomData.from_hash(value)
    else
      fail ArgumentError, "Unsupported type for BlogPostExtraData: #{value.class}"
    end
  end

  def serialize(value)
    value.serialize.to_json
  end

  def deserialize(value)
    if value.is_a?(String)
      CustomData.from_hash(JSON.parse(value) || {})
    else
      CustomData.new
    end
  end

  def type
    :my_custom_data
  end
end

ActiveRecord::Type.register(:my_custom_data, CustomData)

You can now get/set the attribute like so:

class MyModel
  # ...
  attribute :extra_data, :blog_post_extra_data
end

my_model.extra_data = blog_post.extra_data.with(other_prop: [])
# OR
my_model.extra_data = { 'other_prop' => [1, 2, 3] }
# OR
my_model.extra_data = { 'other_prop' => [1, 2, 3] }.to_json

my_model.save

# This will not work!
my_model.extra_data.other_prop = [1,2,3]
my_model.save

Using Time

These share the same interface but are different classes. Use Time-ish to solve this to get the autocomplete benefits.

# config/intializer/sorbet.rb
Timeish = T.type_alias { T.any(ActiveSupport::TimeWithZone, DateTime, Time) }

With RSpec and FactoryBot

When using FactoryBot and RSpec you’ll run into issues since FactoryBot adds a bunch of dynamical methods via it’s DSL.

I’ve found disable it like this is the easiest solution because it allows you to still get autocomplete but it does disable the types.

# typed: true
# frozen_string_literal: true

RSpec.describe(Model) do
  T.bind(self, T.untyped)

  it 'can do stuff' do
    instance = create(:model)
  end
end

Title: Gun Control Teaser: How to get more flow states, get in them easier, and stay in them longer. Date: May 10 2022 Tags: 1 Pager Draft: Yes

Gun Control

  • Switzerland has the third-highest ratio of civilian firearms per 100 residents. The estimates seem to vary widely based on the research publication but Pew estimates around 1/3 Americans own a gun.
  • About 44% of US adults live in a household with a gun, and about one-third own one personally, according to an October 2020 Gallup survey. (source)

There are seven times as many gun crimes (484,800) as there are instances of defensive gun use (70,040) each year, according to the survey.

(source)

Draft: Yes Teaser: A list of things I’ve tried or seen tried in a remote working environment.

Having Fun Remotely

Games

Exercises

Rituals

  • JAMM: A Slack channel where people can post about their weekend.

Services

Draft: Yes

How I Use Alfred

Draft: Yes

how-i-use-iterm2

Draft: Yes

How I Use VS Code

Extensions

You can export extensions with this command. code --list-extensions

Here’s my output:

Teaser: A couple things I’ve learned on asking for help. Date: May 2 2023

How To Ask For Help

Write down a list of specific questions on how you want them to help you.

Put those questions into Google and/or ChatGPT. You’ll likely learn a lot and may no longer need them. If you still need them, you’ll have a list of better questions and you can say things like I’ve seen X, Y, Z, but I’m curious if you would add to this?”

Repeat until you have no more questions or all the questions are very specific.

If you still have questions: Put yourself into their shoes and see what their response is. Include that in your initial outreach to them, ie. I thought you might say something like…”

About 90% of the time after doing this process I no longer need to ask for help.

That being said, if I still want their opinion on something I can ask a hyper-specific question that makes it easy for them to help.

Draft: Yes Teaser: What people who make a living out of it do differently.

How To Listen

Listening to win is, Let me make the problem go away by telling you, you don’t have a problem.’ Listening to learn is getting underneath what’s being said and reflecting back to the person. And listening to fix is, Let me take your problem and solve it for you, or help you solve it.’”

What is it about therapists and life coaches that allow them to be such good listeners?

Most people go day to day having conversations - but the best listeners (who make a living out of it) do it better.

Breaking down what they do differently:

No one ever learned something new by talking. Listening is a super power. Here’s are 6 things to do with your mind, body, and mouth to listen actively.

Mouth

  • Paraphrase what the other person has said.
  • Show interest by asking open-ended questions, avoid yes or no.
    • Can you tell more about that?”
  • Avoid leading questions: don’t you think that’s a little ambitious?”

Body

  • Face the speaker and establish eye contact. You should be relaxed and attentive.

Mind

  • As soon as you indulge in judgmental bemusements, you’ve compromised your effectiveness as a listener.
  • Be patient when you listen. We are capable of listening much faster than others can speak.

Types of Listening

Do you know which you are?

Loud Listening

Quiet Listening

  • Exercise: Try 10 minutes of quiet listening with no interruptions or facial expressions in a meeting.

Appendix

https://www.forbes.com/sites/womensmedia/2012/11/09/10-steps-to-effective-listening/?sh=29c413a13891 https://www.nytimes.com/guides/smarterliving/be-a-better-listener https://hbr.org/2016/07/what-great-listeners-actually-do https://ideas.ted.com/how-to-listen-really-listen-to-someone-you-dont-agree-with/

quiet listening:

  • 10m of quiet listening no interruptions. (facial expressions) in a meeting. creepy or nice.
  • can you tell me a little bit more about that?”
  • state your opinion confidently only of others can confidently shoot you down.
  • the amount of time you spend talking should convey as much information.
  • I’m trying to address this so I’m going to tell you what I think and I look forward to your perspective
  • be aware of your own style. I invite challenge.
  • don’t solve the problem

Draft: Yes

Draft: Yes Teaser: How I approach discussions (even heated ones) at work.

Intellectual Sparring

Productive Arguing for Introverts

Data Wins Arguments

  • To get people to do the thing, you want
  • Align on the goals.

Code Wins Arguments

  • When in doubt, sometimes people just want to see that your idea could work.
  • Often times, an idea explained through visual or written communication doesn’t work as well as actually building the thing. Of course, you don’t want to build the most ad

Emotions Win Arguments

At most Big Tech Companies your work will collide head first with a council” team. A council is a team that was put together so Big Tech Company would stop getting sued or get in some other kind of trouble. It’s harder to get councils to approve your project because they aren’t invested and they rarely have the context on why what you’re doing is important.

Sometimes you may have the data and the code to justify your project - but for reasons outside of your control the council does not want to take the risk.

One way to use emotions in your argument through is storytelling. In his book Build, Tony Fadell through the problem of battery life as iPod devices became smaller (ie. iPod Nano). If you came to a meeting with Steve Jobs saying battery life was reduced by 30% vs the previous generation, he’d throw you out of the meeting. On the other hand, if you came in with a persona, ie. Julie only uses her iPod Nano on her daily commute, so her battery lasts more than a week” you were more likely to convince him.

Date: Mar 24 2024 Tags: 1 Pager Title: Learned Optimism: Cheatsheet Teaser: Read this if you want to be more optimistic.

Learned Optimism: Cheatsheet

Core takeaways from the book, Learned Optimism: How to Change… by Martin E. P. Seligman and how I’ll be changing my behavior.

The book introduces the concepts of explanatory styles” - how people explain the causes of events and setbacks to themselves. Pessimistic explanations tend to be permanent, pervasive and personal, while optimistic ones are temporary, specific and externalized.

To train yourself to be more optimistic, simply take pessimistic thoughts and apply the optimistic lens on them.

Permanent to Temporary

Pervasive to Specific

Personal to Externalized

Here’s an example of a pessimistic explanatory style that is permanent, pervasive and personal, and how it could be reframed in a more optimistic way that is temporary, specific and externalized:

Pessimistic Thought: I failed that job interview. I’m just completely incompetent and will never get hired anywhere. I have no valuable skills.”

This thought displays:

Permanence (the belief that you’ll never get hired) Pervasiveness (the generalization that you have no valuable skills at all) Personalization (the attribution that your supposed failures are due to an inherent flaw within you) A more optimistic way to rephrase it:

The job interview didn’t go as well as I’d hoped, but that’s because I didn’t prepare thoroughly enough for the technical questions they asked. My public speaking skills still need some work. However, I have many other strengths like project management and teamwork that would allow me to excel in the right role. This particular opportunity wasn’t a good fit, but by practicing interviewing and researching companies better, I’ll improve for the next one.”

This optimistic rephrasing has:

Temporary Language (didn’t prepare thoroughly enough”, skills need some work”, implies improvement is possible) Specific Focus (on interview prep and public speaking abilities rather than overgeneralization) External Attribution (about lack of preparation rather than an inherent personal flaw) The key is to avoid global, permanent statements about your abilities or self-worth. Break it down to the specific, temporary, external factors surrounding that one particular situation. This prevents feelings of pervasive helplessness.

Other techniques:

Use Humor: Find ways to laugh at mistakes and setbacks rather than berating yourself. Humor provides perspective.

Dispute Catastrophic Thinking: Whenever you have a pessimistic thought, such as I’ll never get this project done,” question the evidence for that thought and come up with more realistic alternatives.

Use Empowering Language: Instead of saying I’m a failure,” use more specific and temporary language like I didn’t succeed at this particular task.” Avoid labeling yourself negatively.

Practice the ABCDE Model: A - Adversity (Identify the problematic situation) B - Beliefs (Note your negative beliefs about it) C - Consequences (How those beliefs affect your feelings/behavior) D - Disputation (Challenge those negative beliefs) E - Energization (Replace them with more optimistic beliefs)

Keep a Gratitude Journal: Make a daily practice of writing down things you’re grateful for to train your mind to focus on the positive.

Avoid Overgeneralizing: When something bad happens, don’t assume it is permanent or pervasive across all areas of life.

Practice Optimistic Self-Talk: Consciously reframe negative self-statements in a more constructive way.

Socialize with Optimistic People: Spend time with others who tend to see setbacks as temporary and specific rather than permanent and pervasive.

Visualize Success: Take time to vividly imagine achieving your goals to reinforce an optimistic future outlook.

Celebrate Small Wins: Don’t overlook or minimize instances of progress and small victories on the path to larger goals.

Date: Nov 13 2022 Title: Learning Engines Published: true Teaser: Everyone has one - whether they’re intentional about it or not. Here’s mine.

Learning Engines

In a newsletter from Sahil Bloom, I saw the term Learning Engine” defined as:

…all the learning inputs” regularly consumed - books, newsletters, podcasts, videos, etc.”

This article summarizes my Learning Engine, and I encourage others to create one. It often helps to learn what inputs are going into other people’s worldview so you can better understand them.

One reason to be intentional about your learning engine is that you may have sources that are clouding your judgment:

A fool takes in all the lumber of every sort that he comes across, so that the knowledge which might be useful to him gets crowded out, or at best is jumbled up with a lot of other things, so that he has a difficulty in laying his hands upon it. Now the skillful workman is very careful indeed as to what he takes into his brain-attic.”

Books

I keep track of all books I’ve read, want to read, and currently reading on Goodreads.

Newsletters

Podcasts

Last Updated: Jul 24 2021

I use PocketCasts to listen to Podcasts. Here’s my current list of podcasts. This requires a manual export on my end, so it may not be up to date.

https://lists.pocketcasts.com/95e5c539-e3e6-4035-904f-927da13a9e78

Draft: Yes

Life Coaching Yourself

A large portion of the impact of any coach is the accountability.

Title: Mantras Teaser: Here’s a set of words I read that make me feel nice. Date: July 12 2023

Mantras

Here’s a set of things I read that make me feel nice.


For now.

I am happy. For now.

I am miserable. For now.

I am healthy. For now.

I am injured. For now.

For now is a shortcut to emotional moderation.


From Alex Hormozi:

The most important epiphany of my life was realizing I could feel one way and still do an opposing action.

I can feel… Angry & act kind. Impatient & wait. Afraid & move. Insufficient & do enough. Pain & endure. Confidence comes after, not before, we prevail.

Date: Nov 13 2022 Title: Patterns over Advice Published: No Teaser: All advice is bad. Focus on patterns instead. Draft: Yes

Moving Fast

How much time are you spending aiming vs shooting?

Move fast as possible. If you’re not embarassed of your V1, then you’re not moving fast enough.

Aiming vs Shooting

How much of your time is spent aiming at the problem (brainstorming solutions, getting feedback on your ideas, ) vs shooting (actually doing the thinking)?

What would happen if you did the same thing, but you dialed up the intensity?”

Here are a few recent examples I’ve run into:

Our content isn’t reaching enough people. We should focus on SEO, make our formatting nicer and optimize the time of day we send our content out.”

O What if instead of these tweaks, you deliver quality content every single day instead of 1 day a week?

We aren’t reaching enough new prospects. We should revisit who our ideal customer is, create email templates for our team and create a presence on all major social platforms.”

O What if instead, you sent 250 customized 1:1 messages that were individually tailored for each of the people you are trying to reach?

Our customers aren’t having a good experience. We should create a FAQ and put a chatbot in the product for them to help themselves.”

O What if you sat down with each individual customer, listened to their specific problems and understood it in the context of their business?

Title: Notable Companies Using Ruby on Rails Teaser: A list of companies using Ruby on Rails that you can poach talent from Date: Jul 12 2024 Tags: Ruby, Ruby on Rails, CTO

Notable Companies Using Ruby on Rails

While hiring for Halo Science I wanted to reach out to people who were at top tier Ruby on Rails companies. However, it was difficult to find a list of all the companies so I made a list below by aggregating different data sources.

  1. Coinbase
  2. Basecamp
  3. Gitlab
  4. Codepen
  5. Shopify
  6. Calendly
  7. Netlify
  8. Meister
  9. Fiverr
  10. Github
  11. Zendesk
  12. Kickstarter
  13. Soundcloud
  14. Groupon
  15. Hulu
  16. Airbnb
  17. Crunchbase
  18. Ask.fm
  19. Crazyegg
  20. Indiegogo
  21. Pixlr
  22. Scribd
  23. MyFitnessPal
  24. Slideshare
  25. Square
  26. Twitch
  27. Netfli
  28. Cookpad
  29. Helpling
  30. Wayfair
  31. Fool

Title: Opportunity Sizing Date: Dec 5 2023 Draft: Yes

Opportunity Sizing

Look Up: https://www.pretotyping.org/uploads/1/4/0/9/14099067/pretotyping_quick_reference_ms_e_277_2016.pdf

You have so many potential things you could do and you want to figure out what would give you the best ROI. We faced this problem all the time on the Growth team at Facebook Marketplace and one of the most helpful ways to make sense of the chaos was to process each idea through a framework.

Without access to perfect information, the projects/tasks we decide to invest in is a function of:

  • Impact: What will this do for the business? Can be measured in revenue, user growth, etc.
  • Confidence: How likely are we that investing in this task will lead to the impact? (I like to think of this as a risk coefficient - there are many ideas that are massive in potential impact but have a low probability of risk).
  • Ease: How easy is this to realize? How much effort will it take across different business units. Can be measured in days, money, etc.

You can apply a score from 1-10 to each of these when roadmapping. The fun part is figuring out how to score these items. You want to do something a little more than following your intuition.”

Below are some approaches to scoring when you don’t have perfect information.

Impact

  • Find a list of competitors who are in the space and see what they’ve gained from a similar project.
  • Use tools that help you determine trends and give you numbers.
  • Using napkin math on the target audience size and plugging in
    • Ex. Total Population Reached x Conversation Rate x Value To Business
    • Ex.

Confidence

  • Talk to customers. This is a pretty good guide. Don’t want to read it? Here’s 5 simple discovery” questions that you can ask customers.
  1. What’s the problem?
  2. What have you tried? How did it work?
  3. What is that costing you?
  4. How big of a priority is it to fix?
  5. When are you hoping to have it fixed?

Ease

  • Ask team members who would be responsible for the work how long it would take.
  • Look at resources you would need (ie. fixed costs) and their estimated pricing.

Title: Parents & Kids Date: Mar 12 2023 Teaser: If you’ve ever wondering who the oldest mother is… Tags: Random

Parents & Kids

I recently went down a rabbit hole. It started in a conversation when someone mentioned Genghis Khan and how it’s believed approximately 16 million men alive today are directly descended from him.

Why stop there?

According to Guinness, the mother who has given birth to the most children is a peasant from Shuya, Russia. She had 69 children - 16 twins, 7 triplets, and 4 quadruplets. That’s 27 pregnancy events over the course of her life. Assuming ages 18-40, she was pregnant every 0.8 years. Very little down time. Very impressive.

Ismail Ibn Sharif on the other hand is the father believed to have the most kids. He had 868 confirmed children with a harem of over 500 women. He died in 1727.

The youngest mother is Lina Medina, who gave birth when she was 5 years old. Apparently it’s rare but possible to go through puberty at an unusually early age. The youngest father is a boy from China who fathered a child in 1910. Although I couldn’t find any good sources for that, so it’s probably this 11 year old from New Zealand.

The oldest mother is Maria del Carmen, who had twins at the age of 66 through IVF. The oldest father is 94.

Date: Nov 13 2022 Title: Learning Engines Published: No Teaser: All advice is bad. Focus on patterns instead. Draft: Yes

Patterns Over Advice

Lots of dumb advice.

Move fast as possible. If you’re not embarassed of your V1, then you’re not moving fast enough.

Date: Nov 13 2022 Title: Perception Of Good & Bad Experiences Teaser: The relationship between negative and positive experiences and time is worth pondering. Draft: Yes

When people look back on their lives, they tend to do so with a positive bias. Our memory tends to polish the past, making it appear brighter.

When people reflect in the present, they tend to do so with a negative bias. We have an uncanny ability to worry about what’s happening now.

In 1 year from now will you worry about what you’re worry about right now?” might be a question to ask yourself to bring the rose-tinted glasses in which you view the past into the present.

Negative experiences fade quickly, but positive experiences seem to do the opposite.

Date: Nov 3 2022 Tags: Code snippets Title: Pimp My Pry Teaser: Making Pry more useful for debugging Ruby on Rails

Upgrade Ctrl-R to search with fzf

Pry is a great alternative to irb. Here’s how I use it.

The default history search for pry is not great. You can override it with more modern tools. (source)

Run gem install rb-readline and add it to your Gemfile in your Rails project.

Modify ~/.pryrc

require 'rb-readline'

def RbReadline.rl_reverse_search_history(sign, key)
  rl_insert_text  `cat <history path> | fzf --tac |  tr '\n' ' '` # see below for modifying this
end

# I added this line to let me know it kicked in.

To see where Pry stores your history, run:

pry(main)> Pry.config.history_file
=> "/Users/amirsharif/.local/share/pry/pry_history"

Voila!

Performance measure any method

def pmeasure(&block)
  now = Time.now.to_f
  yield
  duration = Time.now.to_f - now
  puts "Finished in #{duration.round(6)}s"
end

pmeasure { YourMethod.call } # You'll get a log of how long it took

# [1] pry(main)> pmeasure { sleep 1 }
# Finished in 1.001213s

Copying a variable from the console

Add these methods to your Pry console. (source)

def pbcopy(input)
 str = input.to_s
 IO.popen('pbcopy', 'w') { |f| f << str }
 str
end

def pbpaste
 `pbpaste`
end

Let’s say you have a giant string blob in a local variable like html

In the console you can run:

pbcopy(html) # The string content is now on your clipboard!

You can use this to evaluate quick lines as well. Copy a multiline snippet of code and then type peval in Pry instead of pasting. It will run the code much faster since it won’t have to parse and highlight it inside of the console.

Pry::Commands.block_command 'peval', "Pastes from the clipboard then evals it in the context of Pry" do
  _pry_.input = StringIO.new("(\n#{pbpaste}\n)")
end

Troubleshooting

Often when working with emoji’s I got this error: Encoding::UndefinedConversionError This is because of the rb-readline we added earlier.

You can reproduce this error by just copying and pasting this:

'’ this will break pry!'

I opened this issue on GitHub. https://github.com/ConnorAtherton/rb-readline/issues/163

Date: Nov 3 2022 Tags: Code snippets Title: Rails Polymorphism Cheatsheet Teaser: A collection of scannable learnings working with Rails Polymorphism. Draft: Yes

Rails - Polymorphic Cheatsheet

I got hit by ``

Date: Dec 7 2022 Teaser: Advanced ways to search with Google and social networks

Power Search Moves

Typing keywords into Google is old school. Here’s how I research topics now.

Google Search Operators

Ahrefs has one of the more in-depth articles on this. Below is a raw list of all the operators:

OR
AND
*
()
site:
related:
intitle:
inurl:
allintitle:
allinurl:
allintext:
// Ex: apple AROUND(4) iphone
// The words “apple” and “iphone” must be present in the content and no further than four words apart.
around(x)
inanchor:

For example to find CEOs (or decision makers) of TikTok agencies, you can try this:

site:www.linkedin.com/in tiktok "agency" intitle:("cofounder" OR "ceo" OR "co-founder" OR "principal" OR "owner" OR "president" OR "chief executive officer") ecommerce -intitle:TikTok

Twitter Search Operators

from:twitterhandle
keyword OR otherword
min_faves:250
min_retweets:100
min_replies: 100
filter:links
filter:images
filter:follows
until:YYYY-MM-DD
since:YYYY-MM-DD
near:location within:25mi

Examples:

must be following min_replies:30 -filter:replies tiktok

This tends to find the retweet bait” on Twitter and is a good indicator of what people are interested in as it pertains to TikTok.

Title: Productivity One Liners Teaser: Every productivity tip I’ve learned over a decade of reading articles on productivity. Updated regularly. Date: Aug 22 2024

Productivity One Liners

  • The rule of thumb is that it takes approximately 25 minutes of focus without distraction to reach a state of flow. If you’re checking your Twitter notifications every 20 minutes, which seems harmless, you prevent your brain from reaching that state and therefore prolong the time required to complete your task.
  • No more good intentions” - we need habit and ritual.
  • Practice != deliberate practice - the engagement factor is very important.
  • Dangerous trap: feeling you’re getting better but actually just reinforcing current habits
  • Aim to have your brain in a period of Flow for at least 3-4 hours every day. One of those hours should be on the upper end of what makes your brain comfortable. You’ll know it’s uncomfortable if you’re feeling frustrated.

From https://recurse.henrystanley.com/post/better/

  • Pick nodes on the knowledge graph which are highly-connected to things you do routinely.
  • Identify the common mistakes - too much social media time? What’s taking too long?

From https://jamesclear.com/beginners-guide-deliberate-practice

  • Implement a feedback loop
  • Implement a coach

From https://dcgross.com/accomplish-dread-tasks

  • Our brains model the future value of the task and how we feel about it. If you think about starting a task you don’t do, the brain will make it even harder next time to do it.
  • Make the task incredibly small and simple. Only focus on doing that tiny portion of the task. Catch yourself having negative thoughts and relabel it.
  • Visualization of the task at hand similar to athletes when they perform.
  • Willpower boosters such as caffeine or a music playlist.

From https://well.blogs.nytimes.com/2014/10/06/better-ways-to-learn/

  • A change in scenery allows new assocations to be made. The brain wants change.
  • Telling others about it (self-testing, writing down information)
  • Sleep is the finisher on learning

From this image

  • To stay motivated, focus on Decrease Impulsiveness, Increase Expectancy, Increase Value.
  • Expectancy refers to the perceived odds of getting a reward and whether we expect success or failure.
  • Value refers to the pleasantness of doing a task, and the size of its reward.
  • Impulsiveness refers to the tendency to get distracted or lose focus on a task.
  • Delay refers to the time between the present and a task’s reward or completion.

From http://tools-for-thought.com/2008/03/03/distributed-cognition/

  • Distributed Cognition: Collect your thoughts and then organize them later.
  • If we do not write down the ideas when we have them we tend to discard the ones that require reflection
  • For productivity, all thoughts should be written down and organized later

From How To Triage Your Busy Life

  • Make as few decisions as possible. Whenever possible, automate. Use scheduling and reminders.
  • Colocate: remove the barrier to doing the task. (ie. setting out your gym clothes the night before)
  • Triage: every new task must go through a triage loop that you define - typically people will react to all inputs with the same response which doubles stress levels.
  • Get out of your own head: exercise compassion. Actively put your focus on someone else.

From this paper

Process goals had the largest effect on performance (d = 1.36) compared to performance goals (d = 0.44) and outcome goals (d = 0.09).

  • Focus on process goals over outcome goals. In other words, inputs over outputs which are totally in your control.

From Software Pathfinding

  • Start working on a feature at the beginning of the day. If you don’t finish by the end of the day, write down the groundwork, infrastructure, or refactoring would need to be done to enable it. Use this method to implement that, then come back to the feature.
  • Implement Gun To Your Head: If a process takes 4 weeks, ask the question, how would you finish it in 24 hours if you were held at gunpoint? (Basically this)

Title: Productivity Stack Draft: Yes Teaser: Read this and you’ll be more productive.d

Productivity Stack

Alfred

  1. Use a Mental Cache. This is a custom Alfred workflow, but the idea” behind it can probably be replicated in other places.
  1. Use Snippets for anything you have to write more than once. I use it for common Ruby console commands, pleasantries, and credentials like my passport ID.
  • In this example, 'ufb turns into (u = User.find_by(email: '{clipboard}'))

Title: Questions Teaser: A list of my favorite questions. Date: June 26 2024

Questions

Questions are useful prompts for the brain. Tim Ferris got me thinking about questions when he shared 10 questions that changed his life (he’s since released 17 more). There are entire sites dedicated to collections of questions. Below are some of the questions that I’ve saved” and I review them time to time.

On Business

The following are from Extreme brainstorming questions to trigger new, better ideas

  1. If you were forced to increase your prices by 10x, what would you have to do to justify it?
  2. If all our customers vanished, and we had to earn our growth and brand from scratch, what would we do?
  3. If you were never allowed to provide tech support, in any form, what would have to change?
  4. What would be the most fun thing to build?
  5. If our biggest competitor copied every feature we have, how would we still win?
  6. What if we are forced to ship a full, completed (at least MVP) new feature, in just two weeks, that would delight and surprise some fraction of our customers.
  7. What if you were forced to charge customers in a completely different manner?
  8. If you were not allowed to have a website, how would you still grow your business?
  9. What if you made your most introverted teammates’ dreams come true: No more synchronous meetings, ever again?
  10. If we could never talk to our customers again, how would we figure out what to build?
  11. What if it didn’t matter how unprofitable you were?
  12. What if you could change anything, regardless of what anyone thinks or feels?
  13. What externality has the potential to kill the entire company?
  14. What if our only goal were to create the most good in the world, personally for our customers?
  15. What if you could only ship one thing this year?

Questions to ask your mentors, from Dickie Bush

  1. What is something most people think is important that I can skip entirely?
  2. What’s something important to your daily routine you wish you started sooner?
  3. What channels led to the building of your highest-quality relationships?
  4. What is something you did differently than your peers 5 years ago that led to pushback, but served you in the long run?
  5. What can I expect to struggle with along the way?
  6. What is something you believed 5 years ago you had to unlearn” to take the next step?
  7. What’s something you didn’t pay enough attention to early on, then had to learn the hard way?

What’s something you’re good at unrelated to business or soft skills?

Did I fulfill my potential with time I was given today?

What did I discover this week?

Where do you get your dopamine?

What is working?

What isn’t working?

What is giving me energy?

What have you said no to? Better question: what were good ideas that you said no to?

What is draining my energy?

What relationships give me genuine pleasure?

What relationships are toxic?

What is surprising me about the present?

Are my current habits aligned with my goals?

Am I happy doing what I am doing right now?

On a scale of 1-10 how happy are you and you can’t use 7. (You can’t use 7 because it’s too easy to be wishy washy and say things are ok.” In my world, it’s either a f*ck yes or a no.)

What would I do if no one was watching and success was inevitable in it?

What would I NOT do if I knew for sure it would fail?

What would I do EVEN if I knew it was going to fail.

What am I doing right now because I think I SHOULD do it?

Looking back at last week, how much of my day was spent doing things I actively enjoyed? How’d that compare to the week before?

How’s the weather in your brain?

How am I being complicit in the behaviors that I’m complaining about?

What are your biggest problems right now?

What’s the most impressive thing you’ve done?

What’s the worst hour of your day and why?

If I keep doing what I am about to do today for the next five years, will I end up with more of what I want or less of what I want?

What would I do if my current time available is slashed by 90%? (source)

What activity if you stopped doing now would you start craving?

How can I improve myself? Root for others but compete with yourself.

Am I working on the right level? Do I need to zoom in or zoom out?

What’s the One Thing I can do such that by doing it, everything else will be easier or unnecessary?

Who am I becoming?

What did I change my mind on this week?

What gave me energy?

What drained my energy?

What did I learn this week?

From I Owe My Success As A Creative Entrepreneur To These 8 Questions I Ask Every Month:

  • Is this actually working?
  • If you had to stop doing 10% of what you’re doing, what would you abandon?
  • What would you do if you had to launch/finish X in Y days?
  • What work did you most enjoy doing recently?
  • What work did you least enjoy doing recently?
  • What have you learned to do well in the past year?
  • What would happen if you raised your prices?
  • What would it look like if it were easy?

When did you have to make a decision to quit or keep going?

A common piece of advice is to focus and concentrate on something before you move on to something else. Describes this as chasing the shiny object of the day.

In the exact same way you can spend too much time on something.

Knowing when to switch seems to be something that everyone has a different opinion on and is context specific. By learning from other people specific stories, it may help with your own scenario.

Draft: Yes Teaser: How I approach discussions (even heated ones) at work.

Record and Search Everything Locally

Everything I do on my computer is recorded. Everything I hear through my headphones, everything I speak in my mic, and my screen. This is powered by Backtrack.

One thing I wanted though is the ability to OCR and transcribe everything locally as well.

Prerequisites

  1. Use Whisper to transcribe audio.
  2. Follow the instructions in whisper.cpp to set it up.
  3. Make sure you install ffmpeg
  4. Add a Hazel rule so when you add -transcribed to a file name it will spit out the transcription of that audio file. The file will be the same thing except end in .txt.

This is the Hazel rule I used:

ffmpeg -i '/Users/amirsharif/Downloads/2023.05.16 09.39 Backtrack.mp4' -ar 16000 -ac 1 -c:a pcm_s16le output-audio.wave

Title: Relationship Advice Teaser: What I learned from reading Hold Me Tight by Sue Johnson. Date: July 7 2019

Relationship Advice

Hold Me Tight is a practical guide to Emotional Focused Therapy (EFT). It’s written by Sue Johnson who has lots of accolades in the domain of couple’s therapy. The book combines psychology studies with anonymized conversations with her clients in her couple’s counseling practice.

Motivation

I picked up the book shortly after I got married. I was surprised to learn that 50% of marriages end in divorce within 8 years. What goes wrong in so many of these cases?

A recent survey1 which asked divorced couples the same question showed the following.

Reason Percentage
Lack of commitment 73%
Argue too much 56%
Infidelity 55%
Married too young 46%
Unrealistic expectations 45%
Lack of equality in the relationship 44%
Lack of preparation for marriage 41%
Domestic Violence or Abuse 25%

(Many partners list more than one, so these numbers don’t add up to 100%)

There’s a lot more nuance in the numbers as well. Age, religion, location, previous marriages, education, sexual history, and your habits can all significantly impact the chances of divorce. Other interesting factors I learned:

  • An annual income of over $50,000 can decrease the risk of divorce by as much as 30% versus those with an income of under $25k.2
  • Wives are 2x more likely to file for divorce than husbands.
  • Those with below average” IQs are 50 percent more likely to be divorced than those with above average” IQs
  • The risk of divorce is 50% higher when one spouse comes from a divorced home and 200% higher when both partners do.

While the average” number is 50%, controlling for the variables in my situation would predict a much smaller number. Even so, the whole question is fallacious. A more interesting one: What makes the most loving marriages so successful?

I knew that perserving and enriching my marriage would be one of the most important things in my life. I was especially motivated by what the Harvard class of 1963 had to say when reflecting on marriage and family.

Why Emotional Focused Therapy?

EFT is recognized by the American Psychological Association as an empirically proven form of therapy. Over 15 years, numerous studies have concluded that over 75% of couples that go through EFT recover from distress and are happy in their relationships.

The basis of EFT is on attachment theory. Human beings need emotional care. This point is further emphasized with studies and surveys done on various populations. Here are a few that stood out to me:

  • People have fewer close friends than before, and there’s a growing number of peope who don’t have any.
  • When people are asked what they want out of life, a loving relationship outranks financial success. This is a stark contrast to 30-40 years ago.
  • In one experiment they separated monkeys from their mothers at birth. The infant could choose between a mother” made out of wire or one made out of squashy rags that looked more monkey” like. The monkeys chose to spend most of their time with the soft-cloth mother without food.

In Cleveland, researchers at Case Western Reserve University asked men with a history of angina and high blood pressure, Does your wife show her love?” Those who answered No” suffered almost twice as many angina episodes during the next five years as did those who replied Yes.”

Psychologist Jim Coan of the University of Virginia told women patients having an MRI brain scan that when a little red light on the machine came on, they might receive a small electrical shock on their feet — or they might not. This information lit up the stress centers in patients’ brains. But when partners held their hands, the patients registered less stress.

When they were shocked, they experienced less pain. This effect was noticeably stronger in the happiest relationships, the ones where partners scored high on measures of satisfaction and that the researchers called the Supercouples. Contact with a loving partner literally acts as a buffer against shock, stress, and pain.

Therapy In A Nutshell

Often people will account their unhappy relationship to concrete actions (see above), but in reality it has more to do with a growing absence of responsive intimate interactions.

Johnson identifies what she calls Demon Dialogues.” They are patterns of interaction that come equipped with a ticking time bomb. If you don’t get out of them soon, you’re doomed. The more intense or frequent, the higher your chance of marriage failure.

  1. Protest Polka3: One partner attempts to get an emotional response, the other tries to deny it.
  2. Find The Bad Guy: Partner’s antagonize the other (the blame game).
  3. Freeze and Flea: Avoiding engagement, numbing down emotions to shut down”

There are several steps you can do to avoid and resolve the above. What you don’t want to do is be helpless for navigating your way out of them.

Steps For Resolution

  • Simply identifying the pattern in a conversation can go a long way: This conversation is starting to look like ____.” Work out a mitigation plan” with your partner to catch the warning signs earlier.
  • Remind yourself that stressed conversations are never about the facts (who did what) - they’re about the the strength and security of your emotional bond with your partner. The research suggests people crave emotional confirmation and caring from their partners, as opposed to advice.
  • Create an emotional safety net: allow your partner to share their insecurities and the emotions their feeling. Overcome blame with curiosity (why are they feeling this way?)

Confirming that you have heard your partner’s message, that you appreciate that he or she is sharing with you, and that you want to be responsive is a positive first step.

The overriding lesson is you have to take your partner’s hurt seriously and hang in and ask questions until the meaning of an incident becomes clear, even if to you the event seems trivial or the hurt exaggerated.

Sometimes we don’t know what is so painful to us in a particular event until we can really explore it with our partner.

We know that part of healing from trauma is being able to grasp a cataclysmic event and shape it into a coherent story, one that makes sense out of chaos and creates a vision of renewed control. When one partner puts a negative spin on incidents, the other moves in to comfort and show the larger picture.

While there were other takeaways, for me, the main takeaways are summarized above. The other points of the book were fairly obvious. Things that could be summed up with: have good sex,” (the trick is communication and curiosity!), make time for each other,” and communicate productively.”

While the steps above are sparse on details, they serve as good reminders for me. I’d suggest picking up the book and complementing it with Mark Manson’s Relationship Advice.

One final takeaway from the book was creating a five year love story” for your relationship. The kind of story that you’d want to share with your grandkids one day.


Title: Using ffmpeg to reduce background noise Date: May 2 2023 Tags: Code blocks Teaser: A simple way to remove background noise from recorded videos.

Using ffmpeg to reduce background noise

Scenario:

I have a file I recorded. It has background noise I want to remove (fans, clicking, etc.) Works good for fans but a little less well for clicking.

  1. Extract the audio file from the video
ffmpeg -i <path> -vn -acodec copy output-audio.aac
  1. Pipe it through a rnn model.
ffmpeg -i <audiopath> -af arnndn=<path to model>

For path to model I just downloaded the std model from https://github.com/GregorR/rnnoise-models

  1. Recombine the new audio with the video
ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 new.mp4

Date: Nov 3 2022 Tags: Code Title: Performance Cheatsheet for Ruby on Rails Teaser: Tuning performance in various ways to keep your Ruby code fast

Performance Cheatsheet for Ruby on Rails

Simple Tests

This one liner you can add to your Pry to see how long a single method call takes.

def pmeasure(&block)
  now = Time.now.to_f
  yield
  duration = Time.now.to_f - now
  puts "Finished in #{duration.round(6)}s"
end
# pmeasure { sleep 1 }

Benchmarking

You can use the benchmark library in native Ruby for simple tests.

require 'benchmark'
puts Benchmark.measure {
  evens = []
  arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]
  arrays.each do |array|
    array.each do |num|
     evens << num if num.even?
    end
  end
}

evens = []
arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]
arrays.each do |array|
  array.each do |num|
   evens << num if num.even?
  end
end

arrays.inject([]) do |result, arr|
  result + arr.select { |x| x.even? }
end

arrays = [[1,2,3], [4,2,1], [3,4,2], [1,2,1]]

n = 100_000
Benchmark.bmbm do |x|
  x.report("inject") do
    n.times do
      array.inject(0, :+)
    end
  end
  x.report("sum") do
    n.times do 
      array.sum
    end
  end
end

Use benchmark-ips to figure out how many times to run the given function to get interesting data.

require 'benchmark/ips'

Benchmark.ips do |x|
  # Configure the number of seconds used during
  # the warmup phase (default 2) and calculation phase (default 5)
  x.config(:time => 5, :warmup => 2)

  # These parameters can also be configured this way
  x.time = 5
  x.warmup = 2

  # Typical mode, runs the block as many times as it can
  x.report("addition") { 1 + 2 }

  # To reduce overhead, the number of iterations is passed in
  # and the block must run the code the specific number of times.
  # Used for when the workload is very small and any overhead
  # introduces incorrectable errors.
  x.report("addition2") do |times|
    i = 0
    while i < times
      1 + 2
      i += 1
    end
  end

  # To reduce overhead even more, grafts the code given into
  # the loop that performs the iterations internally to reduce
  # overhead. Typically not needed, use the |times| form instead.
  x.report("addition3", "1 + 2")

  # Really long labels should be formatted correctly
  x.report("addition-test-long-label") { 1 + 2 }

  # Compare the iterations per second of the various reports!
  x.compare!
end

Where’s the bottleneck?

Sometimes you want to find out why your logic is slow. You can use rack-mini-profiler for Ruby on Rails apps.

You can add these tags to the end of your URL to instrument any Rails action.

?pp=flamegraph
?pp=profile-memory

StackProf works well for Ruby code.

StackProf.run(mode: :cpu, out: 'tmp/stackprof-cpu-myapp.dump', raw: true) do
  # my expensive logic
end
# Open tmp/stackprof-cpu-myapp.dump to see the results.

An alternative is Vernier. It tracks multiple threads, GVL activity, GC pauses, idle time, and more.

Vernier.profile(out: "time_profile.json") do
  some_slow_method
end

Vernier.start_profile(out: "time_profile.json")
some_slow_method

# some other file
some_other_slow_method
Vernier.stop_profile

For identifying the source of long running queries, I like sqlcommenter.

gem "activerecord-sql_commenter", require: "active_record/sql_commenter"

# application.rb
config.active_record.query_log_tags_enabled = true
config.active_record.query_log_tags = [ :application, :controller, :action, :job ]
config.active_record.cache_query_log_tags = true

Memory

Use Memory Profiler.

# scratch.rb contains your code.
ruby-memory-profiler run rails r scratch.rb

# as a conveniance method
report = MemoryProfiler.report do
  # run your code here
end

Date: Nov 13 2022 Tags: Coding Title: Save Multiple Emails as Images from Gmail Teaser: Gmail doesn’t make it easy to export emails as PDFs. Here’s how to do it.

Save Multiple Emails As Images

Problem: You found an awesome email campaign that you want to quickly download as screenshots.

Solution

You will need:

  • A Gmail account and a Gmail Script project to export the emails.
    • You’ll need to add Drive and Gmail and in the Services dialog.
  • wkhtmltoimage to convert the emails to image

In this case, I wanted to screenshot all Mercari emails. Here’s the script I used:

function exportEmails() {
  var response = Gmail.Users.Messages.list('me', { q: 'from:no-reply@contact-us.mercariapp.com'}); // You can change this line.
  var allMessageBlobs = [];
  response.messages.forEach(function (message) {
    var message = GmailApp.getMessageById(message.id);
    var subject = message.getSubject();
    var body = message.getBody();
    var blob = Utilities.newBlob(body, 'html', subject + '-' + message.getId() + '.html');
    allMessageBlobs.push(blob);
  });
  var zipBlob = Utilities.zip(allMessageBlobs, 'exported_emails.zip')
  Drive.Files.insert({ title: 'exported_emails' }, zipBlob);
}

Hit the Play button. This will export each email as a HTML file, zip them all together with the email subject as the filename and save it to your Drive. Then visit your Google Drive and download exported_emails.zip”

Now you’ll need to convert these HTML files into images.

find . -name "*.html" | sed 's,\(.*\),"\1",' | xargs -P 4 -I {} -n 1 wkhtmltoimage "{}" "{}.png"

This command will perform the conversion from HTML to PNG. It took me a while to figure out, so let’s take a closer look.

There are 3 commands here that are piped into each other (with the output of each used as an input of the next one)

  • find . -name "*.html" will get the name of all the HTML files in the current directory.
  • sed 's,\(.*\),"\1",' will wrap the text in quotes. I had trouble with xargs using filenames with spaces, so this was necessary.
  • xargs -P 4 -I {} -n 1 wkhtmltoimage "{}" "{}.png"
    • -P 4 will run 4 jobs in parallel. I had about 48 emails and this sped up the execution time.
    • -I {} will replace instances of {} with the input
    • -n 1 will treat each line as a separate command to run
    • Everything after that will just call wkhtmltoimage "{}" "{}.png" which will replace {} with the filenames you’re converting.

Voila, here are the results!

Date: 2023-12-17 Tags: 1 Pager Title: Everything I Know About Search Engine Optimization Teaser: A brief description goes here. Draft: Yes

Search Engine Optimization

Services

Programmatic SEO

Findable // pSEO Head Term Generator

You need backlinks. How to get them:

  • Help a Reporter (HARO): Whenever they post, you can respond and give them a guide. They will reference your site.
  • Use the Products & Services to find competing pages and reach out to those sites. If they sent a backlink to a competitor, they may be interested in giving you a backlink as well.

Title: Self Talk Teaser: What you can say to yourself when you’re failing Date: July 12 2023

Self Talk

David Goggins was asked, What do you say to yourself when you’re in that moment failing?”

He replied: What if…”

He then expanded on this and completed it with a few examples:

What if… I can become someone that no one thinks that I can be.”

What if… I can pull off a miracle.”

That didn’t resonate much with me too much, but I had heard the question posed to Andrew Huberman as well:

His response was…

I was made for this.”

Alex Hormozis was asked a similar question and his answer was…

This is what hard feels like. There is where most people stop and this is why they don’t win.”

These were only the recorded ones I found… so I decided to have fun with it and asked ChatGPT to pretend to be different people (dead, alive, and fictional) and here was the response:

  1. Steve Jobs: This moment of failure is simply a design challenge to innovate my way through.”
  2. Genghis Khan: Each defeat only sharpens my sword, steels my resolve, and maps the path to conquest.”
  3. Khalid ibn al-Walid: The battlefield shifts, and so must I. With faith and strategy, no obstacle can stand.”
  4. Mike Tyson: I’ve been knocked down before, but my will hits harder than any punch.”
  5. Ash Ketchum: Every setback is a chance to learn, grow, and evolve. I won’t stop until I’m a Pokémon Master.”
  6. Arthas aka the Lich King: In the icy grip of defeat, I will forge a new path to power and domination.”
  7. Joe Rogan: Every setback is just another story for the podcast, another lesson to learn and share. Adapt and overcome, that’s the game.”

My personal favorite one (that I took from a book on growth mindset):

I am not where I want to be, but I am capable of getting there.

DALL-E generated images for the characters above.DALL-E generated images for the characters above.

Draft: No Tags: Productivity Date: Oct 26 2022 Teaser: Mostly for myself, but it’s everything I setup to get productive on a new Macbook.

Setting Up A New Macbook

Here’s how I setup my new Macbook.

Installing Applications

  1. Install Dropbox which I try to sync as many things to as possible.
  2. Install Google Chrome. I use Chrome Sync to keep as many settings synced across machines.
  3. Extensions 1. QuickTabs
  4. Install BitWarden and Authy for password management.
  5. Install Alfred. See How I Use Alfred
  6. Install Spotify.
  7. Install VS Code. See How I Use VS Code
  8. Install Obsidian.
  9. Install Qbserve.
  10. Install iTerm2. See How I Use iTerm
  11. Install Notion.
  12. Install GitHub Desktop.
  13. Install Slack.
  14. Install Stretchly.
  15. Install Cleanshot X.
  16. Install USB Overdrive.
  17. Install TablePlus.
  18. Install SwiftBar
  19. Install xbar.
  20. Install Kaleidoscope

Configuring Mac OSX

These settings are a subset of what I found on this blog post.

#1. Disable animations when opening and closing windows.
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
#2. Disable animations when opening a Quick Look window.
defaults write -g QLPanelAnimationDuration -float 0
#3. Accelerated playback when adjusting the window size (Cocoa applications).
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
#4. Disable animation when opening the Info window in Finder (cmd⌘ + i).
defaults write com.apple.finder DisableAllAnimations -bool true
#5. Disable animations when you open an application from the Dock.
defaults write com.apple.dock launchanim -bool false
#6. Make all animations faster that are used by Mission Control.
defaults write com.apple.dock expose-animation-duration -float 0.1
#7. Disable the delay when you hide the Dock
defaults write com.apple.Dock autohide-delay -float 0
#9. Disable the standard delay in rendering a Web page.
defaults write com.apple.Safari WebKitInitialTimedLayoutDelay 0.25
# 10. Show hidden files. Allows editing hidden files too.
defaults write com.apple.finder AppleShowAllFiles -bool YES

Turn off the default Date / Time and replace it with itsycal.

  1. Visit the Settings

  2. Enable Show month in Icon

  3. h:mm a use this format for time.

  4. Drag it in the menu bar to the far right.

  5. System Preference > Control Center > Clock Options -> Show date = Never.

  6. Change to Analog instead of Digital.

While you’re here:

  1. Spotlight > Don’t show in Menu Bar
  2. Bluetooth > Show in Menu Bar

Add new Keyboard shortcuts:

  • I remap Capslock to Control key so it’s more accessible.
  • I remap most Cmd+Shift+[ keys to Alt+[ (and equivalent) so it requires less use of the pinky finger.

Install the fonts I like to use.

  1. JetBrains Mono

Setting up my terminal

  1. Install oh-my-zsh.
  2. Install Homebrew.
  • brew install rbenv
  • brew install zsh-autosuggestions
  • brew install terminal-notifier
  • brew install TomAnthony/brews/itermocil
  • brew install fzf
    • Install the keybindings and autocomplete.
  • brew install jq
  • brew install redis
  • brew install overmind
  • brew install ffmpeg
  • brew install youtube-dl
  1. I back up my iTerm configuration with Dropbox. iTerm configuration to backup
  2. Install Command Line Utils:
  3. diff-so-fancy
  4. itermocil

Setup Git

You’ll probably want to setup GitHub.

  1. Visit https://github.com/settings/tokens to generate a PAS. You’ll need it when you use git clone
  2. Use VS Code for Git edits: git config --global core.editor "code --wait"

Setup Authy

After logging in, I have it integrated with Alfred so I don’t need to chase around my keys. Follow the instructions here.

Date: Oct 26 2022 Tags: Life hacks Title: Sleep Stack Teaser: A guide to improving your sleep based on science.

Sleep Stack

Hygiene

Habits you should start to form around sleep.

  • Make your room super dark. Block out windows, shut off screens, lights off.
  • Consistency. I use a reverse alarm” that reminds me when to go to sleep.
  • Wear blue-light blocking glasses in the evenings. I use Gunnar.
    • I have 2 pairs of Gunnars, one that blocks 98% and the other is 65%.
  • Don’t eat a heavy meal 2-3 hours before bed.
  • Don’t have stimulants or alcohol after 4pm.
  • Drink caffeine 1 hour after waking up (instead of immediately), and ideally get some natural sun first thing.

Supplements

I have a stack of supplements that I occasionally use to aid with sleep.

Tactics

  • Get exposure to natural light first thing in the morning. This kicks off a bunch of physiological processes so you’ll be tired when it’s time to sleep.
  • Stretching for 10-15 minutes before.
    • You can try this video.
    • If you have a partner, stretch with them!
  • Meditation
  • Sleep Audio
    • There’s a variety of sounds you can listen to to help you go to sleep. They fall under the categories of Hyponosis, NSDR, Binaural Beats, Sleep Stories, or even white noise. I collect a bunch of them in this Spotify playlist.

Products

Resources

Date: May 19 2024 Tags: 1 Pager Draft: Yes Title: Stretching and Mobility for Hackers Teaser: If your spend most of your career in front of a screen, read this to prevent body aches and pains.

Stretching and Mobility for Hackers

[[../_Images/Default_An_illustration_of_a_man_is_severely_hunched_over_and_1_b43924ec-079e-4cf0-8a5a-31cc0995b2db_0.jpg]]

Overview

  1. Make your desk ergonomic.
  2. Invest in an alternative workspace.
  3. Comply.
  4. Stretching routines to counteract sitting/standing.

Invest in an alternative workspace

You’ve probably heard that sitting is the new smoking, which comes from research that sitting for more than eight hours is associated with a mortality risk comparable to that caused by obesity and smoking.

But did you know that standing all day isn’t much better?

The evidence suggests that there is no position” that you can remain idle in for an extended period of time that isn’t associated with negative health outcomes, including musculoskeletal disorders, cardiovascular problems, and other effects.

The bottom line is to take breaks and to switch up your position.

My office space has several positions” - I have an adjustable standing desk with a walking treadmill underneath it. I can stand in place, walk, and sit by using Ergo Stool that I put on my treadmill. Between the desk area, I have another coffee table that I can floor sit on and work. There are lots of benefits to sitting on the floor that I won’t go into here.

[[../_Images/CleanShot 2024-05-19 at ]]

While you don’t have to go to those extremes, you should at least be able to swap between sitting and standing, in alternating orders.

Comply

Most people already know they don’t have good posture while at their desk.

The issue is not that they don’t know what to do, it’s that they don’t do it.

The single most helpful thing I found is to use an app like Stretchly which will overlay a giant screen every X minutes to remind you to take a break when you’ve been at your computer for a long time. There are a bunch of apps like this (including mobile ones) but I like Stretchly because it’s free and cross platform. You can also customize how long you want your break to be.

[[../_Images/CleanShot 2024-05-19 at ]]

But won’t this interrupt my flow state?

Yes, most likely. Over time you’ll be able to dip back into a flow state once you get into this routine.

I’ve been doing this for enough time now that I’ve become accustomed to having 5+ breaks” throughout my working day.

It’s been far more impactful than just keeping me pain free. It has also allowed me to get more done and feel less mental fatigue.

  • As soon as I see a reminder” notification (which pops up 30s before the break timer) I brain dump my current state” on paper so I can hop back into flow once my break is over.
  • I briefly write down what could’ve made the last 45 minutes more productive, if I have those ideas. Sometimes stepping away from the work is what makes this really clear.
  • I proceed to doing a couple exercises; to keep things interesting I switch it up. Sometimes I’ll stretch, other times I’ll do a set of push ups. (The push ups can add up. 5 sets of 20 over 5 minutes x 5 days = 500 push ups/week, 2000 push ups/month)
  • I will write a small note of what I want to accomplish for my next focus” time before having to take a break again.

Stretching routines to counteract sitting/standing

Title: Supplement Stack Teaser: Supplements or drugs I take to promote wellness, fitness, or cognition, along with why I take them. Draft: No Tags: Life hacks

Supplement Stack

Daily

If I’m cycling these, I’ll take them on a regular basis.

Omega 3

Omega-3s seem to be some of the most studied supplements with varying health benefits.

Theracurmin

Theracurmin with and without exercise appeared to be effective in reducing the pain and enhancing muscular and balancing function.” (source)

This study suggests that the highly absorbable curcumin could potentially inhibit a rise in oxidized LDL in patients with impaired glucose tolerance or non-insulin-dependent diabetes mellitus. (source)

Daily oral Theracurmin may lead to improved memory and attention in non-demented adults. The FDDNP-PET findings suggest that symptom benefits are associated with decreases in amyloid and tau accumulation in brain regions modulating mood and memory. (source)

Vitamin D3

Creatine

Creatine is among the most well-researched and effective supplements. It can help with exercise performance by rapidly producing energy during intense activity. Creatine may also provide cognitive benefits, but more research is needed in that area.

Occasionally

These are the supplements I’ll take based on the situation.

Paraxanthine

This is a metabolite of caffeine. By taking it in its pure form, you bypass some of the jitters and negative effects of caffeine while boosting the nootropic effects.

L-Tyrosine

Alpha GPC

Nicotine

I find nicotine can be just as good of a cognitive booster (if not better) than coffee. I was previously afraid of using nicotine due to it’s associating with smoking, but when taken as a lozenge you’re bypassing some of the addictive behavior and negative side effects.

Preclinical models and human studies have demonstrated that nicotine has cognitive-enhancing effects, including improvement of fine motor functions, attention, working memory, and episodic memory. (source)

Nicotine is rightly reviled because of its associations with smoking and addiction. But the rogue substance has a wide range of effects on the brain, which may include some healing properties. Researchers are testing nicotine and related compounds as treatments for Alzheimer’s disease, Parkinson’s disease, attention deficit/hyperactivity disorder (ADHD), and other conditions. … Nicotine does have some negative cardiovascular effects, raising blood pressure and causing arteries to constrict, but it’s debatable how significant they are. Nicotine: It may have a good side - Harvard Health

UPDATE (Jul 24 2021): The interactions effects of caffeine and nicotine were measured in this study which showed that 4mg nicotine (I take 2mg) raises blood pressure less than 250mg of caffeine. Taking both will increase blood pressure even more. My takeaway: don’t take them together if you’re concerned about blood pressure.

L-Theanine

L-Theanine is one of the main active ingredients found in green tea, alongside caffeine and green tea catechins. It helps reduce anxiety and promotes relaxation without drowsiness, making it potentially synergistic with caffeine. (source)

  • Product Recommendation: Suntheanine® L-Theanine 200mg
  • When I Take It: To relax or calm down or as a cognitive support when combined with coffee. I like it best in the evenings.

Mushrooms

Electrolytes

  • Ultima
    • Before a workout and sauna session.

Draft: Yes

things-ive-changed-my-mind-about

  1. Boxing: Getting punched in the stomach improves your reaction to getting punch in the stomach.

In some of my initial boxing classes there was drill where we lined up on the wall and every punched the person to their left in the stomach. The was supposed to help with conditioning.” This hurt and I thought it was dumb - your body will always feel pain and damage will be done. After several weeks of this drill I feel less pain (or at least, can tolerate more of it) and to my surprise I don’t feel the consequences as much days after.

  1. Focus on

  2. Recurring meetings: recurring time on the calendar means you’ll be thinking about the meeting prior to it. It’s much easier to cancel a meeting than to find time for a new one. It can get easy in the day to day to lose track of reconnecting with people in your organization.

Title: Industry Unsubscribe Rates via Multiple Sources Teaser: Tallied up from the major newsletter providers. Date: Sep 1 2023 Tags: Artifact

Unsubscribe Rates via Multiple Sources

The major email providers have all put out a blog post on this, so I’m aggregating them here. This is aggregated across every Industry and type. The variance between industries is quite high, anywhere from 0.07% to 0.46%.

Blog Post Unsubscribe Rate
CampaignMonitor 0.17%
Hubspot 0.24%
Mailchimp 0.26%
Benchmark 0.19%

The general recommendation is to keep unsubscribe rates below 0.5%.

You should dig into the benchmarks to get something closer to your Industry and email type.

Title: Using UUID for SQLite in Rails Draft: No Date: February 25 2023 Teaser: Most tutorials online are on how to do this for Postgres. Here’s how to do it with SQLite and Rails 6+ Tags: Code Blocks

Using UUID for SQLite in Rails

Most tutorials online are on how to do this for Postgres. Here’s how to do it with SQLite and Rails 6+

Assume we’re creating a User model.

class CreateUsers < ActiveRecord::Migration[6.1]
  create_table :users, id: false do |t|
    t.string :id, null: false
  end
  add_index :users, :id, unique: true
end

You can use a string or blob type. As a general rule of thumb (YMMV) blob is slightly more performant and uses less disk space but is less easy to work with.

Now we need to make sure a UUID is assigned when you save the model.

class User < ApplicationRecord
  before_create :maybe_assign_id
  
  # ...
  
  def maybe_assign_id
    self.id = SecureRandom.uuid if self.id.blank?
  end
end

Take it for a spin:

2.7.4 :003 > User.create
   (0.7ms)  SELECT sqlite_version(*)
  TRANSACTION (0.1ms)  begin transaction
  User Create (0.5ms)  INSERT INTO "users" ("id", "created_at", "updated_at") VALUES (?, ?, ?)  [["id", "d48ccbbc-ff16-4815-acf5-30522bf4c30f"], ["created_at", "2022-09-16 17:13:26.189529"], ["updated_at", "2022-09-16 17:13:26.189529"]]
  TRANSACTION (1.1ms)  commit transaction
 => #<User id: "d48ccbbc-ff16-4815-acf5-30522bf4c30f", currency_amount: 0, currency_code: "USD", created_at: "2022-09-16 17:13:26.189529000 +0000", updated_at: "2022-09-16 17:13:26.189529000 +0000">

Other resources

  • You can use UUID v6 for time-based UUIDs. See gem uuid_v6.
  • If you want a solution in a gem you can use activeuuid.

Title: Water Teaser: Not all water is created equally. Draft: Yes Tags: Life hacks

Water

Hydrogen Water

Ozonated Water

Tap Water Depending on where you’re located it’s probably safe.

I haven’t personally felt better drin

Resources

Andrew Huberman

Title: Write To Think Teaser: Writing is a super power. Here’s how to build a writing habit. Date: Jan 5 2023

Write To Think

Clear writing gives poor thinking nowhere to hide - Shane Parish

I admit, I stole this title from Andrew Bosworth, who in turn stole it from Steven Sinofsky, who probably stole it from someone else. I will say that Andrew’s post (and some of the ones he posted internally at Facebook while I was there) deeply resonated with me.

If you’re thinking without writing, you only think you’re thinking.” - Leslie Lamport

I hope to add to this post over the years (I have more ideas) but I’m publishing this before it is complete so I can share it to a smaller circle.

Journaling

I started journaling in 2011. Throughout each day I’ll take notes of thoughts or reflections of the day. Once a week, every Sunday, I’ll write an email to myself.

Sending emails to myself is how I startedSending emails to myself is how I started

My original goal was to write 500 words. I wrote on whatever I wanted, but typically I was summarizing what happened that week. Since then, it has evolved and likely will continue to evolve.

Here’s a collection of different ways I’ve journaled:

A red Moleskin gifted to me by my brother in law, January 2023A red Moleskin gifted to me by my brother in law, January 2023

Once a year, I’ll do a Year In Review. There are lots of templates you can use:

  • Hammertime: Bug Hunt: Look at your entire life and figure out what you’d change. This is more akin to a system reset,” but a New Year is as good a time as any to do it.
  • The Ultimate Annual Review is a free actionable blueprint to conduct your own self-paced annual life review. By Steve Schlafman, ex-VC and now executive coach.
  • Farnam Street has a PDF guide on questions you can ask to reflect, gain perspective, and refocus.

Writing Tools

For paper, my preference is to use a ultra-fine 0.38mm black pen. I haven’t found something better than the PILOT G2. I might get the Squire one day.

I use Nota for writing digitally because it’s beautiful and simple. Obsidian is also popular but I find it’s not as elegantly designed.

My digital writing is in a Dropbox folder. My blog is also it’s own Dropbox folder and is powered by blot.im which I’ve come to be a huge fan of.

I use a private Telegram chat with myself when I want to write things that I’ll later expand on. I like Telegram because it’s fast and I can easily access chats from anywhere.

Writing Is Good

Rewriting is the key to improved thinking. It demands a real openmindedness and objectivity. It demands a willingness to cull verbiage so that ideas stand out clearly. And it demands a willingness to meet logical contradictions head on and trace them to the premises that have created them. In short, it forces a writer to get up his courage and expose his thinking process to his own intelligence.”

Clear Writing Means Clear Thinking Means…

How many brilliant ideas have you had and forgotten? How many insights have you failed to take action on? How much useful advice have you slowly forgotten as the years have passed?

We feel a constant pressure to be learning, improving ourselves, and making progress. We spend countless hours every year reading, listening, and watching informational content. And yet, where has all that valuable knowledge gone? Where is it when we need it? Our brain can only store a few thoughts at any one time. Our brain is for having ideas, not storing them.

Building a Second Brain: An Overview - Forte Labs

The Perks of a High-Documentation, Low-Meeting Work Culture


  1. Reasons for Divorce and Recollections of Premarital Intervention: Implications for Improving Relationship Education↩︎

  2. WF Lawyers↩︎

  3. WHY THE PROTEST POLKA DANCE↩︎



Date
January 6, 2024