Skip to content

Instantly share code, notes, and snippets.

View patrickmaciel's full-sized avatar
🙏
Jesus is coming!

Patrick Maciel patrickmaciel

🙏
Jesus is coming!
View GitHub Profile
@patrickmaciel
patrickmaciel / 1README.md
Created December 21, 2018 18:00 — forked from joseluisq/1README.md
Configure PHP Lumen 5 HTTP Exception Handlers with common JSON responses.

Lumen 5 HTTP Exception Handlers with JSON support.

Configure PHP Lumen 5 HTTP Exception Handlers with common JSON responses.

image

Setup

Copy (replace) only the attached files to their respective directories. app/Exceptions/Handler.php and app/Http/Middleware/Authenticate.php

@patrickmaciel
patrickmaciel / .bash_aliases
Last active December 19, 2018 19:57
bash_aliases #macos #bash
alias fgf='cd ~/workspace/fgf/'
alias vi='nvim'
alias vimdiff='nvim -d'
alias gst='git status'
alias gca='git commit -a'
alias gaa='git add --all'
alias valias='nvim ~/.bash_aliases'
alias zalias='source ~/.bash_profile'
alias balias='nvim ~/.bash_profile'
alias zss='nvim ~/.zshrc'
@patrickmaciel
patrickmaciel / index.php
Last active December 20, 2018 11:18
Compare arrays multidimensional #php
<?php
function array_diff_assoc_recursive($array1, $array2) {
$difference=array();
foreach($array1 as $key => $value) {
if( is_array($value) ) {
if( !isset($array2[$key]) || !is_array($array2[$key]) ) {
$difference[$key] = $value;
} else {
$new_diff = array_diff_assoc_recursive($value, $array2[$key]);
@patrickmaciel
patrickmaciel / phpinstall.sh
Last active February 23, 2023 15:57
PHP 7.4 Install Ubuntu 22.04 #php #apt #php #ubuntu
#!/bin/sh
# This command and the ppa and auto apt-get update after that
sudo env LC_ALL=C.UTF-8 add-apt-repository --yes ppa:ondrej/php
# Install PHP 7.2 and the most common extesions
sudo apt-get install php7.4-fpm php7.4-common php7.4-dev php7.4-curl php7.4-gd php7.4-json php7.4-mysql php7.4-odbc php7.4-pgsql php7.4-pspell php7.4-readline php7.4-sqlite3 php7.4-tidy php7.4-xml php7.4-xmlrpc php7.4-bcmath php7.4-bz2 php7.4-intl php7.4-mbstring php7.4-phpdbg php7.4-soap php7.4-zip php-imagick php-redis php-memcached
@patrickmaciel
patrickmaciel / anotacoes.md
Last active December 20, 2018 11:35
Configurando um ambiente PHP no Ubuntu #php #composer

Em andamento

composer global require phpunit/phpunit
composer global require phpunit/dbunit
composer global require phing/phing
composer global require phpdocumentor/phpdocumentor
composer global require sebastian/phpcpd
composer global require phploc/phploc
composer global require phpmd/phpmd
@patrickmaciel
patrickmaciel / utils.php
Last active December 20, 2018 11:34
Data mysql para BR e vice versa #php
<?php
// Se você quer converter uma data vinda do MYSQL para o formato PT-BR use o seguinte comando:
$data = implode("/",array_reverse(explode("-",$data)));
// Assim vai converter a data do mysql para o formato brasileiro.
// Ex: 2010-31-04 para 31/04/2010
// Se você quer converter uma data em formato brasileiro para inserir no mysql use:
@patrickmaciel
patrickmaciel / aliases
Last active December 20, 2018 11:34
Aliases git bash / bash ubuntu windows 10 / cygwin #alias #bash
alias gst="git status"
alias gcm="git commit -m"
alias gca="git commit -a"
alias gaa="git add --all"
alias cc="cd /c"
alias comdo="composer dump-autoload -o"
alias comda="composer dump-autoload"
alias vhosts="vim /c/Windows/System32/drivers/etc/hosts"
alias tinker="php artisan tinker"
alias arti="php artisan"
@patrickmaciel
patrickmaciel / Arquivo.cs
Last active December 20, 2018 11:35
Executando uma function do postgres pelo C# - Entity Framework #csharp #entity #postgres
using (var context = new IABFLUIDAL.Context.IABModel())
{
using (DbContextTransaction tran = context.Database.BeginTransaction(IsolationLevel.ReadCommitted))
{
var conn = context.Database.Connection;
using (var command = conn.CreateCommand())
{
//command.CommandText = "flui.func_test_patrick";
//command.CommandType = CommandType.StoredProcedure;
//command.Parameters.Add(macaddress);
@patrickmaciel
patrickmaciel / post-commit
Last active December 20, 2018 11:36 — forked from LordGaav/post-commit
Git hook that determines the author based on the email address in a SSH key. Doesn't work because Git doesn't check the config between pre-commit and commit. #git #hook
#!/bin/sh
# Retrieve author information as Git sees it while commiting
AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
NAME=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^\(.*\) <.*$/\1/p')
EMAIL=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^.* <\(.*\)> .*$/\1/p')
printf "AUTHORINFO: %s\n" "${AUTHORINFO}"
printf "NAME: %s\n" "${NAME}"
printf "EMAIL: %s\n" "${EMAIL}"
@patrickmaciel
patrickmaciel / git.sh
Last active December 20, 2018 11:37
Alterar nome e senha de todos commits de um e-mail específico #git
git filter-branch --env-filter '
OLD_EMAIL="email-antigo@exemplo.com"
CORRECT_NAME="Seu nome"
CORRECT_EMAIL="seu-email@exemplo.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]