Skip to content

Instantly share code, notes, and snippets.

View dgoguerra's full-sized avatar

Diego Guerra dgoguerra

View GitHub Profile
@dgoguerra
dgoguerra / stringifyIntoArray.js
Created January 18, 2018 15:01
Stringify an object stream into an array
var through = require('through2');
function stringifyIntoArray() {
var isFirstElem = true;
return through.obj(function(data, enc, next) {
if (isFirstElem) {
this.push('[');
isFirstElem = false;
} else {
@dgoguerra
dgoguerra / auto-deploying.md
Created February 14, 2018 14:16 — forked from nickbclifford/auto-deploying.md
How to automatically deploy code to a server using Travis CI

Auto-Deploying via Travis CI

Because Travis CI can automatically execute scripts after successfully (or unsuccessfully!) executing tests, it is an obvious choice for a deployment tool. In order to deploy to a Git repository on a remote server, the process generally is as follows:

  • Set up SSH keys
  • Add the server's copy of the repository as a Git remote
  • Push to the remote
  • SSH into the server and execute any installation/compilation/miscellaneous commands

Before even touching .travis.yml...

Users

@dgoguerra
dgoguerra / mails-tools.md
Created February 16, 2018 11:46
Some notes about tools to test emails and domains configuration

Tools to test specific emails

  • Test the score of your emails: https://www.mail-tester.com/.

Testing a domain's mail configuration

  • General domain health report: https://mxtoolbox.com/domain/.

  • SPF records lookup: https://mxtoolbox.com/spf.aspx.

@dgoguerra
dgoguerra / create-swapfile.md
Last active June 30, 2023 01:02
create swapfile in ubuntu

Taken from a DigitalOcean tutorial.

Create and enable swapfile:

# create a 2GB file only accessible by root
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile

# mark the file as a swap space
@dgoguerra
dgoguerra / install-sentry.md
Last active July 24, 2019 23:16
Install Sentry on-premise in Ubuntu 16.04 with Docker CE (Community Edition)

Install Docker

See: https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-from-a-package

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
@dgoguerra
dgoguerra / Laravel-Container.md
Created April 3, 2018 15:17
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@dgoguerra
dgoguerra / slack-deploy-webhook.sh
Last active April 19, 2018 14:52
slack deploy info webhook
SITE=domain.com
GITHUB_REPO=owner/repo
BRANCH=$(git symbolic-ref --short HEAD)
COMMIT_SHA=$(git log --pretty="%h" -n1 HEAD)
COMMIT_URL=https://github.com/$GITHUB_REPO/commit/$SHA
COMMIT_MSG=$(git log --format=%B -n 1)
COMMIT_TITLE=$(git log --format='Commit %h by %an %ar' -n 1)
GITHUB_REPO_URL=https://github.com/$GITHUB_REPO
GITHUB_COMMIT_URL=https://github.com/$GITHUB_REPO/commits/$COMMIT_SHA
@dgoguerra
dgoguerra / fpm-nginx-max-upload.md
Created April 12, 2018 16:57
php-fpm + nginx config to increase max upload size

Server’s PHP FPM configuration (through Forge):

upload_max_filesize = 20M
post_max_size = 20M

Site’s Nginx configuration (through Forge):

@dgoguerra
dgoguerra / forge-db.sh
Last active April 24, 2018 16:04
Dump a Laravel Forge site's DB through SSH using the .env's credentials
#!/usr/bin/env bash
SERVER="$1"
SITE="$2"
# script to run in the remote host
REMOTE_CMD="
# ensure the site exists in the user's home
if [ ! -d $SITE ]; then
echo '$SITE' not found, aborting
@dgoguerra
dgoguerra / homebrew-dynamodb-local.md
Last active November 5, 2023 11:15
Install dynamodb-local through Homebrew (custom formula)

Install dynamodb-local through Homebrew

An official formula for dynamodb-local existed, but was removed since dynamodb-local is not open source and stopped having versions.

Now its available either through a Cask, or by installing it as a formula from an unofficial tap (third party repo).

When installed as a cask dynamodb-local cannot be exposed as a service, so here we are installing it as a formula. It has been forked from rjcoelho/homebrew-boneyard and updated to be a head-only formula, to avoid checksum erros on new versions. It is available at dgoguerra/homebrew-boneyard.

# dynamodb-local depends on Java 6+