Skip to content

Instantly share code, notes, and snippets.

View Michael-Stokoe's full-sized avatar

Michael Stokoe Michael-Stokoe

  • Northumberland, United Kingdom
View GitHub Profile
@Michael-Stokoe
Michael-Stokoe / Laravel .gitignore
Created July 21, 2022 12:40
gitignore for laravel projects
### LARAVEL / HOMESTEAD ###
/public/hot
/public/storage
/public/assets/
/public/fonts
/public/css
/public/js
/public/img
/public/images
/public/icons
@Michael-Stokoe
Michael-Stokoe / HasValidationRules.php
Last active April 6, 2022 08:46
Livewire centralised validation example
<?php
namespace App\Http\Livewire\Validation;
trait HasValidationRules
{
public function getValidationClass()
{
return new $this->validationClass();
}
@Michael-Stokoe
Michael-Stokoe / wordle.md
Created February 2, 2022 15:02 — forked from huytd/wordle.md
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@Michael-Stokoe
Michael-Stokoe / crupdate.php
Last active January 30, 2020 16:05
Create/Update method for Laravel.
<?php
public function crupdate($id = null, Request $request)
{
$fields = $request->only(['field_1', 'field_2']);
$model = Model::updateOrCreate(
[
'id' => $id
],
@Michael-Stokoe
Michael-Stokoe / setphp.sh
Last active August 26, 2021 18:22 — forked from judgej/setphp
bash script to switch between PHP versions in Plesk
# Installation: Add this file to the bottom of your ~/.bashrc
# Or: $ curl https://gist.githubusercontent.com/judgej/318b59b1e57867ffd2968dfa1521421a/raw >> ~/.bashrc
# Usage: $ setphp {version}
# Example: $ setphp 7.4
# It will look for the path to the current PHP version in your PATH and switch to
# the new PHP version.
# If you do not have a path to a php version, then it will add one.
# If the version you specify does not exist, it will list the versions that are available.
# Add these lines to your .bashrc to automatically start MySQL in WSL.
function mysql_startup() {
i=`ps -eaf | grep -i mysql |sed '/^$/d' | wc -l`
if [[ $i > 1 ]]
then
echo "MySQL is already running."
else
sudo service mysql start
# Add these lines to your .bashrc to automatically start Docker in WSL/WSL2.
function docker_startup() {
i=`ps -eaf | grep -i docker |sed '/^$/d' | wc -l`
if [[ $i > 1 ]]
then
echo "Docker is already running."
else
sudo service docker start
# Generated by Powerlevel10k configuration wizard on 2019-10-15 at 09:28 UTC.
# Based on romkatv/powerlevel10k/config/p10k-rainbow.zsh, checksum 20131.
# Wizard options: powerline, rainbow, angled separators, blurred heads, blurred tails,
# 1 line, compact, concise.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with powerline prompt style with colorful background.
# Type `p10k configure` to generate your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
@Michael-Stokoe
Michael-Stokoe / idehelper.sh
Last active September 18, 2019 13:06
idehelper function for .bashrc
# Add this to your ~/.bashrc or ~/.zshrc or similar
function idehelper() {
if [ -f artisan ]; then
echo "Pulling in BarryVDH's Laravel-IDE-Helper..."
composer require --dev barryvdh/laravel-ide-helper
echo "Generating IDE-Helper files..."
php artisan ide-helper:generate
php artisan ide-helper:meta
php artisan ide-helper:models
echo "Finished setting up Laravel-IDE-Helper!"
@Michael-Stokoe
Michael-Stokoe / functions.zsh
Last active April 17, 2019 13:23
Laravel/Homestead New Project Script
# Usage:
# Copy this into your .zshrc or .bashrc, then run `source .zshrc`/`source .bashrc`
# the command 'nps' will be available to you afterwards.
# There are some variables you might need to change starting at line 22, ending at line 28.
function nps () {
# New Project Setup. (MUST be ran from inside project DIR)
# Uses the directory name of the project you're in as the URL for the site
# Copies .env, replaces APP_NAME, APP_URL, DB_HOST, DB_DATABASE and REDIS_HOST