Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Livewire\Attributes;
use Attribute;
use Livewire\Features\SupportAttributes\Attribute as LivewireAttribute;
use function Livewire\store;
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
@joetannenbaum
joetannenbaum / WithSpinnerMixin.php
Created February 14, 2023 14:45
A Laravel Artisan macro for showing a spinner in the terminal while you perform a task in the background.
<?php
namespace App\Mixins;
use Spatie\Async\Pool;
class Console
{
public function withSpinner()
{
spotlitt.faces.forEach(face => {
const el = document.getElementById(face.el_id)
// Make sure we're between 0 and 100
const inRange = (val) => {
return Math.min(Math.max(val, 0), 100)
}
const getXPos = (width, height) => {
const imageWidth = (face.width * height) / width
spotlitt.faces = [
{
"el_id": "headshot-bg-3a0GpZdL8q",
"width": 2000,
"height": 1333,
"x": 62,
"y": 39,
},
{
"el_id": "headshot-bg-6OadVLGM92",
<?php
$faces = collect($result->get('FaceDetails') ?: [])->filter(function ($face) {
// We want to be fairly confident that we found a face
return $face['Confidence'] > 95;
});
$box = $faces->first()['BoundingBox'];
// Where the center of the face sits in relation to the entire image
$center_percentage = [
<?php
use Aws\Rekognition\RekognitionClient;
$rekognition = new RekognitionClient([
'version' => 'latest',
'region' => 'AWS_REGION',
]);
$params = [
'Attributes' => ['DEFAULT'],
{
"FaceDetails": [
{
"AgeRange": {
"High": 47,
"Low": 30
},
"Beard": {
"Confidence": 99.16362762451172,
"Value": false
import Hashids from 'hashids'
class HashIds {
evaluate() {
const hasher = new Hashids(this.salt, this.padding)
return hasher.encode(this.id)
}
}
HashIds.identifier = 'shop.sammich.HashIds'
<?php
namespace App\Providers;
use Hashids\Hashids;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
<?php
class UserTransformer extends TransformerAbstract
{
public function transform(User $user)
{
return [
// Make sure to hash any IDs before returning
'id' => Hasher::encode($user->id),
'first_name' => $user->first_name,