Skip to content

Instantly share code, notes, and snippets.

Working from home

Carlton carltondickson

Working from home
  • Carlton Dickson Development Ltd.
  • London
View GitHub Profile
View gist:b14d72d9d3631f870c48
# Exporting entire database:
mysqldump -u user -p database --opt | gzip > database.sql.gz
# Export table
mysqldump -uroot --opt --databases DB_NAME --tables TABLE_NAME | gzip > /tmp/TABLE_NAME.export.sql.gz
# Importing:
gunzip < database.sql.gz | mysql -u user -p database
# Credit
carltondickson / gist:ad979cc684027b64c0ff95383ae1c18c
Last active May 30, 2022
Laravel Queue mailable via tinker
View gist:ad979cc684027b64c0ff95383ae1c18c
// Create mailable, e.g. MailableTest
php artisan make:mail MailableTest --markdown=emails.mailable-test
// Run horizon or queue worker
// Open tinker
$mailable = (new \App\Mail\MailableTest())->onQueue('queue-name');
carltondickson / gist:28a90ccfed2f6b697aba
Created Mar 12, 2015
Undo commit and push to the wrong branch
View gist:28a90ccfed2f6b697aba
# Credit to
# Ensure you're in the branch that you commited to by accident.
git checkout master
# Reset the branch back one commit.
git reset --soft HEAD^
# Stash the changes
git stash
carltondickson / gist:62977cee8ea32c6ce594eaa60524292b
Created May 17, 2016
Install and Configure Redis on Ubuntu 16.04
View gist:62977cee8ea32c6ce594eaa60524292b
# From
# Use at your own risk
sudo apt-get update
sudo apt-get install build-essential tcl
cd /tmp
curl -O
tar xzvf redis-stable.tar.gz
cd redis-stable
carltondickson /
Last active Feb 8, 2021
Useful Postgres queries

Source: Hans-Jürgen Schönig - PostgreSQL performance in 5 minutes

SELECT substring(query, 1, 5000) AS short_query,
       round(total_time::numeric, 2) AS total_time,
       calls, round(mean_time::numeric, 2) AS mean,
       round((100*total_time/sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_overall
FROM pg_stat_statements ORDER BY total_time DESC LIMIT 20;
carltondickson /
Last active Dec 21, 2020
Access Homestead Redis server from host

For local development only

  • Comment out bind ::1 in nano /etc/redis/redis.conf
  • Set protected-mode no
  • sudo service redis-server restart
  • Access Redis using Redis client, e.q. Redis Deskktop Manager
    • Only need to set address as per Homestead.yaml file, e.g.
    • Port is probably default 6379

Better to enable protected mode and set specific bind addresses if for any sensitive environment

carltondickson /
Last active Sep 16, 2020
Access Homestead Postgres DB from host machine

Check version

SELECT version();

PostgreSQL 12.4 (Ubuntu 12.4-1.pgdg18.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit

sudo nano /etc/postgresql/12/main/pg_hba.conf

Add the following lines

carltondickson /
Last active Aug 18, 2020
Postgres - Enable/Disable query logging

Enable query logging

  • Check version, determine which config file to edit

  • SELECT version();

  • PostgreSQL 12.3 (Ubuntu 12.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit

  • sudo nano /etc/postgresql/12/main/postgresql.conf

  • Find REPORTING AND LOGGING section and change following settings

  • log_statement = 'all'

  • Reload configuration from command line SELECT pg_reload_conf();

View gist:1616ad52717ad93790e1550a845d30ad
carltondickson / TestSession.php
Created Jun 6, 2018
Laravel - Jobs - Sessions
View TestSession.php
# Dispatch the following job from multiple tinker instances will see session never gets updated.
# Using sessions in jobs is bad idea.
# $job = new \App\Jobs\TestSession(1, false);Bus::dispatch($job);
# $job = new \App\Jobs\TestSession(2, false);Bus::dispatch($job);
# @see
namespace App\Jobs;