Skip to content

Instantly share code, notes, and snippets.

@codemonkey76
codemonkey76 / InboundMailController.php
Created February 10, 2024 02:50
Inbound mail controller
<?php declare(strict_types=1);
namespace App\Http\Controllers;
use Mail;
use Exception;
use Spatie\Regex\Regex;
use App\Models\Customer;
use App\Mail\NewVoicemail;
use App\Models\Voicemailbox;
@codemonkey76
codemonkey76 / main.rs
Created December 12, 2023 05:04
Advent Of Code - 2023 - Day 5 - Optimized Solution in Rust
use std::fs;
use std::collections::HashMap;
use std::time::Instant;
use itertools::Itertools;
fn apply_mapping(current: u32, map: &Mapping) -> u32 {
let mut value: u32 = current;
for entity in &map.mappings {
if value >= entity.src && value < entity.src + entity.range {
import os
import re
import random
import subprocess
def run_command(cmd):
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
return result.stdout.decode('utf-8').strip()
def get_current_bg(output):
@codemonkey76
codemonkey76 / tmux.conf
Created June 7, 2023 01:00
TMUX Configuration
set-option -sa terminal-overrides ",xterm*:Tc"
set -g mouse on
set -g history-limit 10000
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
unbind C-b
@codemonkey76
codemonkey76 / Accordion.php
Last active March 16, 2023 03:19
Using wire:model on nested component
<?php
namespace App\Http\Livewire\Controls;
use Livewire\Component;
class Accordion extends Component
{
protected $listeners = ['refreshAccordion' => '$refresh'];
<div x-cloak x-data="{
hourOptions: [...Array(12+1).keys()].slice(1),
minuteOptions: [...Array(60).keys()],
isHourHighlighted: function(option) { return this.hourHighlighted === option },
isHourSelected: function(option) { return this.hourValue === option },
isMinuteHighlighted: function(option) { return this.minuteHighlighted === option },
isMinuteSelected: function(option) { return this.minuteValue === option },
highlightHourOption: function(option) { this.hourHighlighted = option },
unHighlightHourOption: function(option) { this.hourHighlighted = null },
highlightMinuteOption: function(option) { this.minuteHighlighted = option },
@codemonkey76
codemonkey76 / WithEdits.php
Created December 7, 2022 00:48
WithEdits Trait
<?php
namespace App\Http\Livewire\Traits;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
trait WithEdits
{
@props([
'categories' => null,
'options' => []
])
<div class="relative" x-data="accordianDropdown({
categories: {{ $categories }},
options: {{ $options }}
})" tabindex="0">
<span x-show="selectedItem" class="absolute inset-y-0 left-0 pl-4 flex items-center text-cyan-600" x-html="getSelectedItemIcon()"></span>
<input id="combobox" x-ref="input" type="text" x-model="search" @keydown="startEditing()" class="w-full rounded-md border border-gray-300 bg-white py-2 pl-10 pr-12 shadow-sm focus:border-cyan-500 focus:outline-none focus:ring-1 focus:ring-cyan-500 sm:text-sm" role="combobox" aria-controls="options" aria-expanded="false">
@codemonkey76
codemonkey76 / index.js
Created November 18, 2022 04:47
Alpine Store for Browser calling
export default {
agents: [],
id: null,
ringing: false,
onCall: false,
statusMessage: 'Initialising...',
callTimer: '',
agentStatus: {
Idle: 'Available',
Break: 'Break',
@codemonkey76
codemonkey76 / app.js
Created September 28, 2022 04:47
Searchable select component
import Alpine from 'alpinejs'
import select from './components/select'
window.Alpine = Alpine
Alpine.data('select', select)
Alpine.start()