I love this post!
At its core,
requestAnimationFramedoesn’t do much: it’s basically just a method that executes a callback. In fact, there are very few differences between doing
doSomething(). So, what’s so special about it? I’m glad you asked! In short:
requestAnimationFrameschedules the callback call on the next repaint
requestAnimationFramepasses the callback the current time
There are a few other distinctions, but these are the main benefits. Now,
requestAnimationFramedoesn’t create an animation on its own, it’s the sequence of successive callbacks that will make things move on the screen.
My favorite part: since a large part of animating with
requestAnimationFrame consists of composing small mathematical expressions, you can apply all sorts of functional programming tricks to your code.
Learn all about it on Benjamin De Cock’s blog.
I'm building a multi-tenant Laravel application. One of the requirements of the project is that every client can have their own theme based on their corporate guidelines. By default a few css adjustments will suffice, but some clients request a completely different template.
Conditionally loading a different stylesheet per client is pretty trivial, but in order to use a completely different view per theme you quickly end up typing the same thing over and over across various parts of your application.
We just open sourced our company guidelines site! We previously kept the contents in a private wiki on GitHub, but I'm glad we finally put the time in giving the contents a real home.
As for why we decided to open source it all…
This site contains a set of guidelines we use to bring our projects to a good end. We decided to document our workflow because consistency is one of the most valuable traits of maintainable software.
The contents of this site exist for ourselves—more importantly, our future selves—and for giving future collegues a reference to our way of doing things and their quirks. The guidelines cover workflow, code style, and other little things we consider worth documenting.
The guidelines are available on guidelines.spatie.be.
Headless Chrome to the rescue! Chrome can run as a cli tool, and print a pdf file from a url. All I had to do was make some layout tweaks to make everything printer-friendly.
Today I was writing a form component that needed an optional back button. Since the form component is generic, the back button could point to anything.
Ah-ha moments are beautiful and rare in programming. Every so often, we’re fortunate enough to discover some trick or facet of a system that forever changes how we think of it. For me, that’s what snapshot testing is.
In a recent Twitter thread, Sebastian McKenzie (Yarn and Babel author) shared his thoughts on the current state of open source. This tweet stood out for me (and he later ironically dubbed it his “most thoughtleader tweet ever”):
Revel in fragmentation and duplication because without it there's stagnation and it stifles innovation.
When someone shares their latest pet project library, it's often met with responses like “What a waste of time, you can already do this with library X!".
There's no need for justification here. Maybe the author wants something that fully matches their use case instead of the 80% that library X does, maybe they want a different internal architecture. Maybe they have bigger future plans in mind, or most importantly, maybe they just want to experiment, learn, and have fun.
Read the entire thread on @sebmck's Twitter.
Quick Vue tip for package authors! If you publish a package that exposes multiple Vue components, you can write a small plugin to install them all at once.