Skip to content

Instantly share code, notes, and snippets.

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

Adriano Rosa adrianorsouza

🏠
Working from home
View GitHub Profile
@adrianorsouza
adrianorsouza / gist:5d4a7d210bd659920e8e5b1448b7f343
Created December 2, 2021 23:37 — forked from rmatil/gist:8d21620c11039a442964
Connect MySQL database in Vagrant VM from Host machine

Connecting to Vagrant VM MySQL database from host

This gist shows how to connect to your vagrant MySQL database from the host machine.

Change Address Binding from MySQL

  • Connect to vagrant using vagrant ssh
  • Edit file /etc/mysql/my.cnf:
    • Change parameter bind-address to 0.0.0.0 to allow all incoming connection attempts
@adrianorsouza
adrianorsouza / docker-help.md
Created March 19, 2021 23:43 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@adrianorsouza
adrianorsouza / laravel_path_permissions.sh
Last active November 25, 2023 23:53
Laravel storage path permissions. This script makes storage path writable for both users, the admin and PHP Webserver user
#!/bin/bash
#
# DEFINE PROPER WRITABLE PERMISSIONS FOR LARAVEL PROJECT.
# Run this script in a fresh Laravel install.
#
# @author Adriano Rosa (https://adrianorosa.com)
# @created: 2015-02-15 00:59:19
# @updated: 2021-01-28 14:19:16
# @updated: 2023-11-25 20:53:36
#
@adrianorsouza
adrianorsouza / git.post-update.sample
Last active July 29, 2020 01:29
Laravel production script that run after git post-update hooks
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
echo "--initializing @@SITE_NAME@@ hook--"
git --git-dir @@GIT_DIR@@/.git --work-tree @@GIT_DIR@@ pull @@GIT_REMOTE_NAME@@ @@GIT_BRANCH_NAME@@
@adrianorsouza
adrianorsouza / release.sh
Last active July 24, 2020 22:11
Script that makes it easier to automate the make a release of a project using git and annotated tag
#!/usr/bin/env bash
#
# Script to make a new release of this project.
#
# @author Adriano Rosa <https://adrianorosa.com>
# @date: 2020-07-24 14:47
# @link: https://gist.github.com/adrianorsouza/d970eecefa5c9c5db714d439587d1da6
#
# This bash script is a simple version of the npm package:
# `release-task` https://github.com/adrianorsouza/release-task.
@adrianorsouza
adrianorsouza / MOZJPEG.md
Created June 7, 2020 22:42
BUILDING MOZJPEG ON LINUX

BUILDING MOZJPEG ON LINUX

Link: https://calendar.perfplanet.com/2014/mozjpeg-3-0/

cd /usr/local/src

sudo curl -LO https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.1-release-source.tar.gz
sudo tar -xzvf mozjpeg-3.1-release-source.tar.gz

cd mozjpeg

@adrianorsouza
adrianorsouza / text-overflow-ellipsis.css
Created March 29, 2020 15:17
CSS to make a text overflow collapse with ellipsis
.title {
display: block;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
pointer-events: auto;
overflow: hidden;
}
@adrianorsouza
adrianorsouza / fix-laravel-conn-php7.4-mysql8.md
Last active January 12, 2020 19:30
Fix PHP 7.4 + MySQL 8 errors with server has gone away

Fix PHP 7.4 + MySQL 8 errors with server has gone away

PHP 7.4 is now released, and it comes with support for MySQL 8's new password authentication plugin: caching_sha2_password.

1. Connect to the database as root

Depending on your root username, you will be prompted to enter the password, a hostname, etc. By default, typing mysql in your server terminal should work. If you have trouble logging in, try mysql -p -u root, and entering the root password when asked.

2. Check existing authentication plugin:

Replace USERNAME and YOUR_PASSWORD with your application database username and the password.

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@adrianorsouza
adrianorsouza / indeterminate.js
Last active November 13, 2019 23:29
react checkbox indeterminate
// https://davidwalsh.name/react-indeterminate
// To add the indeterminate property to the checkbox, I needed to take advantage of the ref attribute:
const { value, checked, indeterminate } = this.props
return render(
<input
type="checkbox"
value={value}
checked={checked}