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.
ActiveModel::Type::ImmutableString
to support EnumsBy 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)
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
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) }
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
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:
Title: Asking Good Questions Teaser: Before asking a question, go through this checklist. Date: Nov 19 2023 Tags: 1 Pager
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:
When asking an expert:
When asking your team, I use a different checklist heavily inspired from Your Small Imprecise Ask Is a Big Waste of Their Time.
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.
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.
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
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
Grip Strength
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
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.
If you want to lead, you’ll need to give feedback. Use this framework to structure this feedback without being overly prescriptive or vague:
Before a report or colleague asks for your help, they should have a short note that addresses the following points:
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:
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
Course
Cadence
Checklist
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.
Out of the 6 “rules” he highlights, I thought 2 were interesting.
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.
He uses another simple framework for prioritization abbreviated by ICE. Each item has a score from 1-10.
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
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
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.
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?
https://blog.samaltman.com/how-to-be-successful
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?
Writing/Blog/Optimizing Your Biggest Input- Energy
WOOP: Wish, Outcome, Obstacle, Plan
“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
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:
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.
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.
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.
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.
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.
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
Title: Breathwork Teaser: You were never taught how to breathe, so you’re probably doing it wrong. Date: Jan 15 2023 Tags: 1 Pager
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
Other fun facts
Title: Build vs Buy Date: Mar 12 2023 Teaser: A framework for making a decision with constrained resources. Tags: Startups, 1-Pager Draft: Yes
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:
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.
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
I had a project where I wanted to build filters that a user could combine. [[screenshot 2023-03-07 at 20.48.15@2x.png]]
Title: Burnout Playbook Teaser: How to diagnose and treat professional burnout. Date: Jan 5 2023 Draft: Yes
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:
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.
For each area, here are some potential solutions.
Ways to reduce workload
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.
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.
A toxic work environment, lack of support from colleagues or supervisors, and poor communication can contribute to burnout
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
Applies to all careers.
Applies to engineering careers.
From Interview advice that got me offers from Google, Microsoft, and Stripe
Use recruiters to your advantage
Go to real interviews for practice
Be open to learning during the interview.
Keep your skills sharp even when you’re not job hunting.
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.
Date: Nov 27 2022 Tags: Health Title: Common Cold Cheatsheet Teaser: Protocols for recovering from a cold ASAP. Draft: No
I put this together after getting a cold. Take 1 or more of these before or during your sickness.
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.
Ginger root contains a very high level (3.85 mmol/100 g) of total antioxidants, surpassed only by pomegranate and some types of berries
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.
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.
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
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.
# 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
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)
Concurrent::Ruby
Concurrent::Promises::FactoryMethods::Configuration
— Concurrent Ruby uses :io
by default.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
Concurrent::CachedThreadPool
or Concurrent::FixedThreadPool
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
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
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
More lightweight and memory efficient than threads, but harder to use. You probably won’t need it.
True parallelism for Ruby (even over the GIL) without multiple processes. Mostly experimental right now.
Date: Sep 3 2024 Title: Interview Question: Count Subsequences Teaser: Unraveling the mystery of counting subsequences. Tags: Interview Questions
This question is part of my Career Advice series.
Original question: https://neetcode.io/problems/count-subsequences
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:
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).dp[i][j]
represents the number of distinct subsequences of s[0...i-1]
that equal t[0...j-1]
.s
when matching with t
.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.s
, decide whether to match it with the current character in t
or skip it.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];
}
dp
is initialized such that dp[i][0]
is 1, indicating that any prefix of s
can match an empty t
.s
and t
match (s[i-1] == t[j-1]
), then we add the number of subsequences where:
s
in our match (dp[i-1][j-1]
).s
and just carry forward the previous count (dp[i-1][j]
).s
.dp[m][n]
gives the total number of distinct subsequences of s
that match t
.Draft: Yes
Minimize distractions, including meetings.
Draft: Yes
https://talosintelligence.com/reputation_center/ https://www.barracudacentral.org/lookups/lookup-reputation
https://spamcheck.postmarkapp.com/
SPF, DKIM, DMARC This is a simple checklist that you should go thorugh
Draft: Yes
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.
Date: 2023-12-19 Tags: 1 Pager Title: error-handling Teaser: A brief description goes here. Draft: Yes
A consistent way to handle errors means we
Ways that we can show errors in the app:
Types of Errors
Ways to add error handling
error
as a JSON payload.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.
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
The COIN Conversation Model can be used when you want to give feedback to someone in a professional (or personal) setting.
In Book Review: Buy Back Your Time , you can also use the COACH framework which is similar.
Co: Core Issue - Describe what the specific problem or area of concern is.
A: Actual Story - Describe an actual instance when that manifested.
Ch: Change - Ask the other person if they can make a commitment to change.
From Stripe Press — Scaling People
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
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 }
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
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/
https://census.dev/blog/an-on-ramp-to-flow
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
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
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 12.00.36@2x.png]]
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.
ActiveModel::Type::ImmutableString
to support EnumsBy 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)
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
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) }
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
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.
Draft: Yes
Draft: Yes
Draft: Yes
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
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.
“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
Body
Mind
Do you know which you are?
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:
Draft: Yes
Draft: Yes Teaser: How I approach discussions (even heated ones) at work.
Data Wins Arguments
Code Wins Arguments
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.
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.
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.”
I keep track of all books I’ve read, want to read, and currently reading on Goodreads.
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
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
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
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.
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
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.
Title: Opportunity Sizing Date: Dec 5 2023 Draft: Yes
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:
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.
Title: Parents & Kids Date: Mar 12 2023 Teaser: If you’ve ever wondering who the oldest mother is… Tags: Random
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
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
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!
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
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
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
I got hit by ``
Date: Dec 7 2022 Teaser: Advanced ways to search with Google and social networks
Typing keywords into Google is old school. Here’s how I research topics now.
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
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
From https://recurse.henrystanley.com/post/better/
From https://jamesclear.com/beginners-guide-deliberate-practice
From https://dcgross.com/accomplish-dread-tasks
From https://well.blogs.nytimes.com/2014/10/06/better-ways-to-learn/
From this image
From http://tools-for-thought.com/2008/03/03/distributed-cognition/
From How To Triage Your Busy Life
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).
From Software Pathfinding
Title: Productivity Stack Draft: Yes Teaser: Read this and you’ll be more productive.d
'ufb
turns into (u = User.find_by(email: '{clipboard}'))
Title: Questions Teaser: A list of my favorite questions. Date: June 26 2024
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.
The following are from Extreme brainstorming questions to trigger new, better ideas
Questions to ask your mentors, from Dickie Bush
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:
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.
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.
.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
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.
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:
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.
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:
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.
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.
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
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.
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.
ffmpeg -i <path> -vn -acodec copy output-audio.aac
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
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
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 }
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
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
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.
Problem: You found an awesome email campaign that you want to quickly download as screenshots.
Solution
You will need:
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 runwkhtmltoimage "{}" "{}.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
Findable // pSEO Head Term Generator
You need backlinks. How to get them:
Title: Self Talk Teaser: What you can say to yourself when you’re failing Date: July 12 2023
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 Hormozi’s 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:
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.
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.
Here’s how I setup my new Macbook.
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.
Visit the Settings
Enable Show month in Icon
h:mm a
use this format for time.
Drag it in the menu bar to the far right.
System Preference > Control Center > Clock Options -> Show date = Never.
Change to Analog instead of Digital.
While you’re here:
Add new Keyboard shortcuts:
Cmd+Shift+[
keys to Alt+[
(and equivalent) so it requires less use of the pinky finger.Install the fonts I like to use.
You’ll probably want to setup GitHub.
git clone
git config --global core.editor "code --wait"
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.
Habits you should start to form around sleep.
I have a stack of supplements that I occasionally use to aid with sleep.
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.
[[../_Images/Default_An_illustration_of_a_man_is_severely_hunched_over_and_1_b43924ec-079e-4cf0-8a5a-31cc0995b2db_0.jpg]]
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 11.03.07@2x.png]]
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.
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 11.06.39@2x.png]]
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.
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
If I’m cycling these, I’ll take them on a regular basis.
Omega-3s seem to be some of the most studied supplements with varying health benefits.
“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)
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.
These are the supplements I’ll take based on the situation.
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.
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 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)
Draft: Yes
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.
Focus on
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
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
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">
Title: Water Teaser: Not all water is created equally. Draft: Yes Tags: Life hacks
Hydrogen Water
Ozonated Water
Tap Water Depending on where you’re located it’s probably safe.
I haven’t personally felt better drin
Andrew Huberman
Title: Write To Think Teaser: Writing is a super power. Here’s how to build a writing habit. Date: Jan 5 2023
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.
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.
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:
Once a year, I’ll do a Year In Review. There are lots of templates you can use:
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.
“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