When I write code that works with the Ethereum blockchain, I find myself copy-pasting hex addresses into the etherscan.io search box every five seconds. I was able to speed this up by adding a custom search engine for etherscan to chrome, but I still had to copy paste every address from my terminal into the browser.
Enter iTerm2 Triggers. They let you perform an action when text in your terminal matches a provided regular expression. Our goal is to turn every properly formatted hex address into a hyperlink to the etherscan.io search url.
First, following the instructions on the triggers page, create a new trigger in iTerm2 by opening Preferences > Profiles >…
I love making simple tools, and my favorite tools for making simple tools is HTML + JS. Something I run into every time in these small projects is creating and appending DOM nodes, a problem for which there are 5 trillion solutions. In a big project, one might use React to solve this problem. In a medium project, one might use jQuery to solve this problem. But what about small projects? Like really small projects with no dependencies?
My favorite solution has been to use template strings:
someParentElement.innerHTML = `<p>Lorem to the Ipsum</p>`
Nice. Awesome. Template strings are cool. My text editor even knows how to highlight the stuff in the template string. It even works with nested template…
Often times we need to hide certain parts of our web apps from users who aren’t properly authenticated. The hidden content might be something the user hasn’t paid for, like movies on Netflix, or it might be content that is impossible to display without knowing who the user is, like a profile page. Sometimes we’ll even restrict content because the user is logged in. It wouldn’t make sense to go to the login page if we are already logged in, would it?
In complex applications, we might restrict content based on tiered authorization levels. A basic user shouldn’t have access to the admin panel, but an admin should be able to view everything. In even more complex applications, we could restrict content based on an a set of access permissions. …
I love solving puzzles, I love JavaScript, and I listen to Will Shortz’ Sunday Puzzle almost every week. Oftentimes, I find myself thinking of ways I could solve Will’s puzzles with code. This post, and the ones that follow, are a way for me to combine my passions and hopefully teach a bit of JavaScript and algorithms.
This is the first installment of solving Puzzlemaster Presents puzzles with JavaScript! I’ll try to do the puzzle every week using as much of a code mentality as possible, so stay tuned for more. I’ll try to touch on the benefits and drawbacks of design decisions, but please keep in mind that the code I write here won’t necessarily be optimized for speed. …