Skip to content

Instantly share code, notes, and snippets.

View devLopez's full-sized avatar
🎯
Focusing

Matheus Lopes Santos devLopez

🎯
Focusing
View GitHub Profile
@devLopez
devLopez / laravel.js
Last active December 5, 2017 16:06 — forked from JeffreyWay/laravel.js
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.)To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@devLopez
devLopez / README.md
Created July 20, 2016 02:48
PHP: HTML to PDF conversion using wkhtmltopdf (and Smarty)

Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn't particularly impressed with any of them.

Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which uses WebKit (the same layout engine as Safari and Google Chrome) and therefore is very accurate.

There is a class for PHP integration on the Wiki, but I found it overly complicated and it uses temp files which aren't necessary. This is the code I wrote instead.

I used Smarty for generating the HTML for the PDF, but you can use any template engine, or pure PHP if you prefer.

Note: I originally tried to install wkhtmltopdf from source, but it's much easier to use the static binary instead.

@devLopez
devLopez / NewMessage.php
Created November 21, 2016 18:43 — forked from sebastiaanluca/NewMessage.php
Laravel + Redis + NodeJS + Socket.io pub/sub secure server and client supporting multiple rooms, channels, users, … Add `client.js` to your client app, run `node server.js`, and trigger the Laravel event any way you want to broadcast the data.
<?php
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class NewMessage extends Event implements ShouldBroadcast
{
@devLopez
devLopez / phpstorm-ajuste.sh
Created February 21, 2018 12:38 — forked from cagartner/phpstorm-ajuste.sh
Ajuste para acentos phpstorm
# Adicionar essa linha no arquivo phpstorm.sh da pasta do seu editor
export XMODIFIERS=""

Configuração de subdomínios local (Apache + DNSmasq + Laravel)

Este tutorial tem como objetivo, a configuração do seu apache local para trabalhar com subdominios no laravel.

O que será utilizado:

  • Laravel
  • Servidor Apache
  • Servidor DNS/DHCP
  • Linux
@devLopez
devLopez / README.md
Created July 10, 2018 19:18 — forked from emsifa/README.md
Laravel 5.1 Validation Outside Laravel

Laravel 5.1 Validation Outside Laravel

First you need to install illuminate/validation by typing this composer require illuminate/validation:5.1.*.

Then, you can use laravel validation like this:

$validatorFactory = new ValidatorFactory;
@devLopez
devLopez / php_apache_homebrew.md
Created February 25, 2019 23:59 — forked from DragonBe/php_apache_homebrew.md
Installation of Apache 2.4 and PHP 7.1 with Homebrew

I posted several talks about compiling PHP from source, but everyone was trying to convince me that a package manager like Homebrew was a more convenient way to install.

The purpose of Homebrew is simple: a package manager for macOS that will allow you to set up and install common packages easily and allows you to update frequently using simple commands.

I used a clean installation of macOS Sierra to ensure all steps could be recorded and tested. In most cases you already have done work on your Mac, so chances are you can skip a few steps in this tutorial.

Apache and PHP with homebrew

I’ve made this according to the installation instructions given on GetGrav.

@devLopez
devLopez / osx_uninstall_mysql_install_mariadb_homebrew.md
Created December 7, 2019 15:01 — forked from brandonsimpson/osx_uninstall_mysql_install_mariadb_homebrew.md
OSX How To: Uninstall native MySQL and install MariaDB via Homebrew

OSX How To: Uninstall native MySQL and install MariaDB via Homebrew

This is a short overview on how to completely remove any old mysql server installs in OSX and upgrade to MariaDB without conflicts. Things can get a bit weird when you have various old installs of MySQL server floating around, and utilizing homebrew to install and upgrade MariaDB as a drop in replacement for MySQL has worked well, especially if you're used to managing MySQL installs via yum in linux.

First: Backup Your Data!

Backup all of your current databases with mysqldump

This isn't a tutorial on backups, and there are many ways to do it. You should know how to backup your data anyway. For this example, we'll do a full backup of our InnoDB databases.

@devLopez
devLopez / gist:262e07ef00cadae0d536c224e638ec0d
Created March 27, 2020 21:53 — forked from billsinc/gist:1157544
Remove Firebird DB from MacOS
#!/bin/sh
echo "Clean Services"
echo "Clean User"
dscl localhost -delete /Local/Default/Users/firebird
echo "Clean Group"
dscl localhost -delete /Local/Default/Groups/firebird
if [ -f "/Library/StartupItems/Firebird" ]; then
echo "Remove SuperServer StartupItem"
rm -fr /Library/StartupItems/Firebird
fi
@devLopez
devLopez / mac-setup-redis.md
Created March 26, 2021 00:24 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis