Skip to content

Instantly share code, notes, and snippets.

View julienbourdeau's full-sized avatar
🏠
Working from home

Julien Bourdeau julienbourdeau

🏠
Working from home
View GitHub Profile
<?php
\Illuminate\Support\Str::macro('extremeSnake', function($value, $delimiter = '_') {
$pattern = <<<'REGEXP'
/
(?<!^) # don't match the beginning of a string
(
(?<=[^\p{Lu}])[\p{Lu}\p{M}]+(?=\p{M}?[^\p{Ll}]\p{M}?\p{L}) # string of upper-case (like an abbreviation)
| (?<=\p{Lu}{2})[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # the final upper-case in a sequence
| (?<=[^\p{Lu}])[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # first upper-case in a capitalized sequence
@marcoarment
marcoarment / S3.php
Last active June 25, 2023 19:41
A simple PHP class to perform basic operations against Amazon S3 and compatible services.
<?php
/*
A simple PHP class to perform basic operations against Amazon S3 and compatible
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules.
Copyright 2022 Marco Arment. Released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@viirre
viirre / webpack.mix.js
Last active April 20, 2020 22:24
Using different Tailwind config files (eg. one for admin and one for front) with Laravel Mix (TailwindCSS < 1.0)
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
require('laravel-mix-purgecss');
mix
.js('resources/js/admin/admin.js', 'public/js')
.js('resources/js/front/front.js', 'public/js')
// Admin
.sass(
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@mpociot
mpociot / tinker
Last active March 21, 2024 18:30
Python script to open Tinkerwell from your current working directory - tinkerwell.app
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
RUN_PATH = '/Applications/Tinkerwell.app'
def process_args(argv):
args = []
@JeffreyWay
JeffreyWay / AppServiceProvider.php
Last active November 6, 2021 11:51
Laracasts Widgets Lesson
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
@jeromedalbert
jeromedalbert / .gitattributes
Last active March 3, 2024 12:18
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (now works with Rails 5 and recent versions of Git). The following files should be in your home ~ directory. Inspired by https://tbaggery.com/2010/10/24/reduce-your-rails-schema-conflicts.html
db/schema.rb merge=railsschema
@levelsio
levelsio / windows_keys_like_osx.ahk
Last active November 12, 2019 10:08
Make Bootcamp Windows keys act like OSX
; Make Bootcamp Windows keys act like OSX
; by @levelsio
;
; 2017-11-02
;
; Licensed as GPL
;
; Use autohotkey.com to load this file on Windows
;
; This fixes Cmd+Tab to work like Alt+Tab, also keys like Cmd+C as Ctrl+C etc., Cmd+Q to Alt-F4
@calebporzio
calebporzio / PreviewOfUpcomingPackage.php
Last active April 16, 2024 06:26
A model trait that allows child models to use parent table names and relationship keys.
<?php
namespace App\Abilities;
use Illuminate\Support\Str;
use ReflectionClass;
/**
* Note: This is a preview of an upcoming package from Tighten.
**/
@julienbourdeau
julienbourdeau / GeoSearchable.php
Last active July 13, 2017 19:53
Add geolocalization capability to Laravel Scout (with Algolia engine)
<?php
namespace App\Search;
/**
* This trait must be used next to the Laravel\Scout\Searchable trait
*
*/
trait GeoSearchable
{