Posts tagged #open-source

TailwindCSS <details> plugin

· #open-source #tweet #tailwind

I built a nice looking and fully accessible dropdown menu by using the native <details> HTML tag without a drop of JavaScript in the client.

To build it in a utility-first approach, I created a simple plugin for TailwindCSS.

You can find the plugin over at GitHub.

Laravel Blade Helpers

by Liam Hammett · 3 minute read · #open-source #laravel

Laravel’s Blade templating engine offers a ton of convenient directives you can use to make your view files beautiful and abstract anything that may be too complex or verbose to live inside HTML. It even gives a really handy way to add your own custom directives using the Blade::directive(…) method.

However, the callback in custom directives only receives a single parameter - the raw string expression from the view file. It seems to be rare that developers actually parse the contents of the expression itself within the directive, opting instead to pass the entire expression as arguments to a helper function or a method on another class. For example:

BladeHelper::directive('uppercase', function($expression) {
    return "<?php echo strtoupper($expression); ?>";
});

Read more…

Throttle Simultaneous API Requests with Laravel

by Liam Hammett · 2 minute read · #open-source #php #laravel

Laravel comes with a handy ThrottleRequests middleware out-of-the-box that blocks users of an API from being able to send more than a particular amount of requests within a defined amount of time.

This is extremely useful for preventing an API from being abused by spammed requests, but isn’t suitable for every use case.

What about an API call that takes a lot of limited processing power, or performs an action that simply can’t be running twice at the same time?

Read more…

PHP Shareable Social Media Links

by Liam Hammett · 2 minute read · #open-source #php

I recently had the need to generate various “shareable” links to help share a particular URL to different social media platforms. The problem is that every platform requires information in a slightly different way.

Lo and behold, just a few days later, Dennis Smink shared their method of doing so in their article “Laravel Shareable Trait” that covers the few biggest platforms.

Read more…

Cenafy For Bash

by Liam Hammett · 2 minute read · #open-source #bash

Based on the wonderful Chrome extension of the same name that lets you know who the champ is, this is a version for Bash that lets an unsuspecting victim who left their terminal open know about the champ via the magic of ASCII art (and even some killer singing, if they have the say command like on Mac OS).

You can install it as a command with wget:

Read more…

jQuery.scrollup.js Plugin

by Liam Hammett · 1 minute read · #javascipt #jquery #open-source

A jQuery plugin to recreate the commonly used “pull-to-refresh” found in mobile devices, but this time for the desktop browser.

The “pull-to-refresh” pattern and similar variations are commonly used all over mobile devices to perform a variety of functions such as refreshing a web page, checking for new mail and loading old chat messages as you’re scrolling through, but rarely makes its way over to desktop devices for one reason or another.

Read more…