Skip to content

Instantly share code, notes, and snippets.

@ChrisTaylorDeveloper
ChrisTaylorDeveloper / vagrant_up.out
Created May 7, 2024 18:56
vagrant up output for Homestead issue
Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Importing base box 'laravel/homestead'...
Progress: 10%
Progress: 90%
==> homestead: Matching MAC address for NAT networking...
==> homestead: Checking if box 'laravel/homestead' version '14.0.2' is up to date...
==> homestead: Setting the name of the VM: homestead
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / firewall-linux.md
Last active January 9, 2021 09:11
Network security - running services and open ports

netstat

Discover which services are running locally

sudo netstat -plunt

nmap

The association between ports and services are listed in this file

@ChrisTaylorDeveloper
ChrisTaylorDeveloper / ubuntu-cheatsheet.md
Last active September 2, 2020 18:31
Ubuntu cheatsheet

Ubuntu cheatsheet

reboot

sudo shutdown -r now

shutdown

sudo shutdown -h now
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / sql-identifying-vs-non-identifying.md
Created June 14, 2020 09:49
SQL identifying vs non identifying relationships.

Non-identifying

Consider books and owners. A book can exist without an owner or change owner. The relationship between a book and owner is non-identifying. The primary key of the parent is included in the child but not as part of the child's primary key.

Identifying

Consider books and chapters. A chapter only exists when a book exists. The relationship between a book and its chapters is an identifying relationship. The primary key of the parent is included in the primary key of the child entity.

@ChrisTaylorDeveloper
ChrisTaylorDeveloper / mysqldump-remote-database-with-local-docker-image.md
Created May 11, 2020 07:33
Run mysqldump on remote database using local docker image

When no mysql tools are available locally, use mysqldump from inside a docker container to backup a remote database.

docker run -it --rm -e MYSQL_PWD=<user pass> mysql:5.7 mysqldump -u <user> -h <ip address> -P 3306 database 1> backup.sql

@ChrisTaylorDeveloper
ChrisTaylorDeveloper / convert-csv-to-mysql-table.sh
Created November 27, 2019 20:31
Dynamically create a mysql table to accomodate a csv file and import the csv file.
#!/bin/bash
# Contents of create-table.sql
#
# CREATE TABLE `csv` (
# `id` int(11) NOT NULL AUTO_INCREMENT,
# PRIMARY KEY (`id`)
# );
mysql -u user -ppassword < create-table.sql
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / jquery-autocomplete-testing-with-mink.md
Last active August 1, 2019 09:05
Testing jQuery autocomplete suggestion list with Behat and Mink

The pre-defined step I fill in "field" with "text" removes focus from the input element and does not hold open the suggestion list. The step definition below resolves this issue.

Feature file step

And I fill in "autocomplete-ajax" with "J" maintaining focus

Step definition

/**
 * @Given I fill in :arg1 with :arg2 maintaining focus
 */
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / vs-code-php-debug-docker-xdebug.md
Last active April 7, 2022 05:31
How to configure the PHP-Debug extension for VS Code when serving the PHP project from Docker with xdebug

The Dockerfile

Only add the xdebug.remote_log line if you need to troubleshoot.

FROM php:7.1-apache

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / PostController.php
Created August 26, 2018 16:04
Symfony 4 @ParamConverter annotation Exception when using ajax
<?php
use App\Entity\Post;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/post")
*/
class PostController extends Controller
{
@ChrisTaylorDeveloper
ChrisTaylorDeveloper / index.html
Created August 21, 2018 11:43
Filterable list of bookmarks
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bookmarks</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>