Skip to content

Instantly share code, notes, and snippets.

View ceilidhboy's full-sized avatar

Mike Scott ceilidhboy

View GitHub Profile
ceilidhboy /
Created April 13, 2024 20:10
Add a www redirect to nginx configuration

Add the following block before the existing server block, in the nginx configuration, where is the domain of the website:

server {
        return 301 $scheme://$request_uri;
ceilidhboy /
Created November 10, 2023 10:58
How to define constants safely in Laravel config files

Doing a simple CONST declaration in config files can cause errors when enabling caching in Laravel. The config file appears to be loaded more than once and the second time causes an error because the constant is already defined.

The safe way to do it is to use the old syntax and only try to define the constant if it has not already been defined, as the following example shows:


use Illuminate\Support\Facades\Facade;

How to upload files, e.g. MySQL database export

  • In a terminal, install gdown with pip install gdown
  • Upload the file you want to send to the server to Google drive
  • Copy the "anyone with link" share link for the file
  • Paste it into notepad and copy the file ID from the link
  • cd to the directory you want the file to go (or use the -O <path> option with gdown)
  • Download the file with ~/.local/bin/gdown
ceilidhboy / config
Last active September 22, 2022 20:01
.ssh config file for web servers for connecting to GitHub
ceilidhboy /
Last active August 29, 2022 12:55
cd command on steroids! Place in ~/bin and set execute flag. See file comments for installation and command options.
# Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
# maintains a jump-list of the directories you actually use
# * put something like this in your .bashrc/.zshrc:
# . /path/to/
# * cd around for a while to build up the db
# * PROFIT!!
# * optionally:
ceilidhboy / ClearLaravelLog.php
Last active July 24, 2022 20:06
Laravel Artisan command to clear the laravel.log file. Usage: php artisan log:clear
namespace App\Console\Commands\Log;
use Illuminate\Console\Command;
class ClearLogFile extends Command
protected $signature = 'log:clear';
ceilidhboy / .gitignore
Last active April 6, 2024 12:13
.gitignore file for Laravel projects
# PHP and Laravel stuff
ceilidhboy / add to .gitconfig
Last active September 6, 2022 12:34
Git aliases - add these to the ~/.gitconfig file
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
ceilidhboy / Bowling-kata-specifications.txt
Created July 14, 2022 09:38
Simple instructions for the Bowling Game Code Kata
Requirement: create a class which calculates the score for a complete game of 10 Pin Bowling
The class should have two functions, roll() and score().
roll should be given the number of pins knocked down on that roll: roll(int $pins)
score takes no parameters and simply returns the score for the game: score(): int
Games are made up of 10 frames. Each player gets 2 rolls of the ball per frame
to try to knock down as many pins as possible. The score for each roll is the
number of pins knocked down in that roll.
ceilidhboy / composer.json
Last active July 14, 2022 09:35
Basic Composer file for a coding Kata with PhpUnit. Change the namespaces in lines 7 and 12 to suit.
"require-dev": {
"phpunit/phpunit": "^9"
"autoload": {
"psr-4": {
"Bowling\\": "src"
"autoload-dev": {