Posts
Sql tips for your everyday world
Ecto → Raw SQL Have you ever wanted to chuck an ecto query into your sql tool of choice? Here’s a handy snippet that will output your ecto query into a state that you can directly copy/paste to sql.
:all |> Ecto.Adapters.SQL.to_sql(Repo, <insert ecto query here>) |> Tuple.to_list() |> Enum.at(0) |> String.replace("\"", "") |> Kernel.<>(";") |> IO.inspect(label: "QUERY HERE") Example output:
QUERY HERE: "SELECT l2.id, d4.geo_point, d4.zip_code FROM ….. WHERE (d4.
Posts
The Capture Operator
If you have written Elixir with me, or have been subjected to one of my pull request reviews, you’ll know that one of my favorite ways to refactor code is by adding the capture operator when an anonymous function is required.
What is the capture operator? Well, you may know it as the ampersand or “&” character, but when writing Elixir it takes on a special meaning.
The capture operator ("&") gives us the ability to create an anonymous function with shorthand syntactic sugar.
Posts
An Ode to Open Source
There are a lot of things that I love about my job. As a software engineer for Cars.com, I get to work on cool problems with great people on an awesome tech stack. One of the best parts of our tech stack is our heavy reliance on open source software. We rely on a myriad of different technologies that leverage software that is written to be shared, free of charge, with the outside world.
Posts
The Reflog is a Dev's Best Friend
Often I have encountered developers who use source control as a part of their daily workflow that are intimidated by git. This seems especially true when a rebase goes south, or really anything occurs that deviates from the normal git behavior.
I recognize this intimidation, because it is one that I myself suffered from. However, one of the greatest gifts I received when I first started working as a software professional was a crash course from a senior developer on the use of the reflog.
Posts
IO.ANSI: A World of Color
Viewing debug text while running a server can be challenging. This holds true while running a Phoenix server. Thankfully there is a fantastic module included with the Elixir standard library.
IO.ANSI provides an easy way to inject colors into your terminal text. As server output text flies across your terminal, being able to color not only debug text, but the background of the text as well is extremely helpful.
You can quickly play with this functionality in iex.
Posts
Vim + Vscode = 😁
I love Elixir. This isn’t a big secret if you talk to me about software for more than a minute. I also love VSCode and I’m not ashamed to say it. I suppose that’s the developer equivalent of saying that starbucks is my favorite coffee. Just like starbucks, VSCode provides me the value of a consistent experience.
When I first started writing software it felt like every senior developer I spoke with would espouse the merits of their personal setup.
Posts
How I Built This Blog
“Building a blog has never been easier”…is a sentence you could probably write at any moment in time and it would be accurate.
But that doesn’t mean it’s any less accurate now.
So you’re probably asking, “Jerry how did you build such a beautiful blog? You must be spending money. Did you use my offer code when you signed up for square space?”
The answer may surprise you.
I am indeed paying money, only to Google Domains for the jeremysearls.
Posts
More branches, more problems
Often I find myself hopping around git branches. Between PR review and having multiple branches in flight, I often forget the name of the branch I was working on. This isn’t helped when branch names are prefixed with JIRA story codes and the team I’m working on.
One of the best git tricks I learned when I first started working as a professional software engineer was the use of -. - is evaluated as the last branch you have checked out.