Today, I’m releasing a framework-agnostic, in-browser image cropper. The motivation is that I need this on a regular basis in multiple projects, across multiple frameworks and – while I’m aware of existing tools like Cropper.js and others – quite frankly, to me they seem too complex to setup especially depending on the front-end framework I’m dealing with. I needed this problem reduced to a simple JS call.
Continue readingLatest articles
Dynamic session cookie name in Laravel
Here’s a case that may be useful when authenticating multiple apps from a single Laravel code-base. Recently I’ve built an application API and admin UI in the same Laravel code-base. This made lots of things easier to manage, including DB-related stuff. The API is consumed by a single-page app (ReactJS) and the backend is built with Laravel Orchid. Also, it’s worth noting that the API is using Laravel Sanctum to
Continue readingDynamic custom data via OAuth with Laravel Socialite
If you’ve ever done authentication in a Laravel-based project then you probably had to deal with the Socialite extension, which enables OAuth-based authentication using third-party services (like Google or Facebook). Passing dynamic data to the external OAuth system and getting that data back to your application, using Socialite, is something neither easily done nor well documented and given that I’ve seen a lot of people wasting time on this, I
Continue readingDespre Criptomoneda “Pi”
Am scris acest scurt articol special pentru prietenii și apropiații mei ce vor să înțeleagă în câteva cuvinte despre ce e vorba cu noua criptomonedă numită “Pi“ creată de 3 doctoranzi de la Universitatea Stanford. Aici găsești răspunsuri foarte succinte la 7 întrebări frecvent întâlnite pe acest subiect. 1. Ce este o criptomonedă? O criptomonedă este o valută ca oricare alta (așa cum sunt Euro sau Lirele sterline) însă virtuală,
Continue readingRemember last value in React functional components
Sometimes it can be very useful to save previous values of props (or state) in a React component. Perhaps this is easier to be imagined in a class component, but in a functional component, less so. However, we can use the useRef() React hook to achieve that quite efficiently. Less talk, more code (typescript)… const someFunctionalComponent = (p: {index: number}) => { // Keep the last positive value around. const
Continue readingUsing enum values as strictly typed object keys
In TypeScript, it’s often useful to define interfaces or complex (structured) types whose properties (or keys) may only be values of a previously defined enum type. Here’s a good example: an object declaring a set of buttons for a modal dialog. Instead of this… type DialogButtons = { yes?: boolean, no?: boolean, cancel?: boolean } interface IDialog { buttons: DialogButtons } const dialog: IDialog = { buttons: { yes: true,
Continue readingA CloudFormation recipe for scheduling Lambda functions with 1-minute frequency
Among the plethora of tools which Amazon has given us there’s AWS CloudFormation. IMO, this proves that AWS is (still) in a class of it’s own. It’s the embodiment of the “infrastructure as code” concept. And, it’s battle-tested, it works! So well, in fact, that they ElasticBeanstalk right on-top of it. Automation not supported However, once you gain some experience with this beast, you start realizing that it also has
Continue readingFully dynamic JSON handling in Scala
For some time now I (badly) wanted to be able to work with JSON structures in Scala just as easily as in JavaScript (though even in JS you need some wizardry to be able to to this elegantly). I don’t particularly like Json4s since I feel that it’s overly complex (no, I don’t want to extract data into case classes using for-combinators), documentation is difficult to grasp and use (especially
Continue readingUniversal getter for plain JS objects.
Many times in JavaScript we have to reach deep into objects to access fields that could possibly not be there at all; for example let’s assume I have a JS object called options into which I’ve just read an entire JSON configuration file. Trying to access a field like options.application.cache.enable directly will potentially fail (e.g. when any of the intermediate levels is missing)… if (options.application.cache.enable) { // do stuff }
Continue readingVisualizing Git diffs in Meld.
Here’s a quick way of configuring your (Linux-based) Git installation to use the excellent Meld program by default for displaying/editing the outputs of the git diff and git merge commands (e.g. git diff «filename»). Install Meld …if you haven’t already (note that we assume Git to be present): # on Debian-based distros (ymmv) sudo apt-get install meld Viewing/editing file diffs via Meld Configure Git to use Meld as the default
Continue reading