Tag: TypeScript
-
Resetting a Slate.js editor to an empty state
I’ve been messing with Slate.js and happen to be using it in the context of having a persistent editor on the page that can be used post from. It’s sort of like a chat’s message input, it’s always there, and when you submit it, it resets back to it’s original…
-
Resetting the undo/redo history of a Slate.js editor
Slate.js has some wonderful undo/redo history under the hood, by way of the React hook useMemo. Out of the box is works great, but if you want to reset your editor back to an empty state (in scenarios where the component is persistent on the page), the undo/redo history will…
-
Submit on enter except when shift is pressed in JavaScript
Been working on something recently where I wanted to implement a submit handler when a user hits the enter key in an input. That’s not that big of a deal, sniff out the key being pressed, and if it’s the Enter key, go ahead and execute the submit handler. Since…
-
Complete CI/CD pipeline with GitLab Runners
Automation is one of the best ways to improve productivity. Even as a development team of one, spending a bit of time on DevOps and improving your developer quality of life can pay off immensely. Automated tasks strip away cognitive load. No more forgetting to deploy code because the process…
-
Converting integers to Roman numerals with TypeScript
My buddy Robert has been seeking new opportunities in the software development realm, and recently ran into a coding challenge that I haven’t thought about in a good long time: converting an integer to Roman numeral. Now, I actually hate these kinds of brain teasers in the context of interviewing…
-
Could not find a declaration file for module
I’ve been working with Typescript on a daily basis for the last year. Admittedly, I still feel pretty amateurish with it. Mostly due to the fact that I’ve mostly been working with it on an existing stack at work and minor application of it on my own side projects. With…
-
FizzBuzz in TypeScript 3.0
FizzBuzz, the engineering smoke test that quickly reveals if somebody is drastically under qualified in their development abilities. Even if you’re unfamiliar with the exercise, most are able to make short work of it. It only leverages a small handful of programming concepts that even the most novice developer should…
-
How to Capitalize the First Letter in a String in JavaScript
I’m still kind of spoiled by the built-in functions in PHP (as well as Ruby and Python for this particular task). Something like capitalizing the first letter of a string is a trivial task in most languages: <?php // Capitalize first letter with PHP ucfirst(‘some string that needs the first…