Skip to content

Instantly share code, notes, and snippets.

View alexjustesen's full-sized avatar

Alex Justesen alexjustesen

View GitHub Profile
@alexjustesen
alexjustesen / app.js
Last active February 20, 2026 21:12
Use the browser's timezone to localize timestamps for visitors using AlpineJS
import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm';
Alpine.magic('dateTime', () => {
return (utcString, options = {}) => {
const defaults = {
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
dateStyle: 'medium',
timeStyle: 'short',
...options
};
from ayx import Alteryx
import requests
import pandas as pd
import json
from pandas import json_normalize
# =============================================================================
# CONFIGURATION
# =============================================================================
SMARTY_API_URL = "https://us-street.api.smarty.com/street-address"
@alexjustesen
alexjustesen / InstallPostgresExtension.php
Created July 9, 2025 14:44
Install Postgres extensions as a Laravel command.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class InstallPostgresExtension extends Command
{
/**
@alexjustesen
alexjustesen / wsl_for_laravel
Created November 23, 2022 13:14
Setup WSL/Ubuntu/Docker for Laravel development
# isntall wsl + ubuntu from the windows app store
# setup ubuntu with a username, password and update existing dependencies
sudo apt update && sudo apt upgrade -y
# install additional ubuntu dependencies
sudo apt install apt-transport-https zip unzip
@alexjustesen
alexjustesen / bash.sh
Created November 21, 2021 15:06
Setup Ubuntu 21.04 on Framework Laptop
# Create an install USB
# Do a regular install
# Update Ubuntu and current packages
# Install some additional packages
sudo apt install git unzip curl ffmpeg
# Disable Apache
# Apache runs by default on port 80, disabled to reduce used ports.
sudo systemctl disable apache2 && sudo systemctl stop apache2
@alexjustesen
alexjustesen / SocialAuthController.php
Created April 21, 2021 14:24
Socialite social auth controller for Laravel SSO
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\SocialAccountService;
use Laravel\Socialite\Facades\Socialite;
class SocialAuthController extends Controller
{
@alexjustesen
alexjustesen / SocialAccountService.php
Created April 21, 2021 14:23
Socialite account service for Laravel SSO
<?php
namespace App;
use App\Models\User;
use Illuminate\Auth\Events\Verified;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite;
@props(['title' => false, 'width' => 'sm:max-w-lg'])
<div x-data="{ open:false }">
<div @click="open = true">
{{ $trigger }}
</div>
<div
x-cloak
x-show="open"
@alexjustesen
alexjustesen / laravel_alpine_tailwind_select_to_location.php
Created February 5, 2021 18:26
On change of the selection, go to the url provided in the value.
/**
* While this example uses Laravel, AlpineJS and Tailwindcss, it can be modified for use with other frameworks.
**/
<div x-data="{ selected: '{{ request()->url() }}' }" class="sm:hidden">
<label for="tabs" class="sr-only">Select a tab</label>
<select x-model="selected" x-on:change="selected && (window.location = selected);" id="tabs" name="tabs" class="block w-full border-gray-300 rounded-md shadow-sm focus:border-gray-400 focus:ring-2 focus:ring-offset-2 focus:ring-gray-200">
<option value="{{ route('model.show', $model) }}" x-bind:selected="this.value === selected">Show</option>
<option value="{{ route('model.edit', $model) }}" x-bind:selected="this.value === selected">Edit</option>
@alexjustesen
alexjustesen / Timezone.php
Created January 30, 2021 14:15
Laravel Timezone model with Sushi
<!-- This model requires https://github.com/calebporzio/sushi: composer require calebporzio/sushi -->
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Timezone extends Model
{