Skip to content

Instantly share code, notes, and snippets.

View humbertodosreis's full-sized avatar

Humberto dos Reis Rodrigues humbertodosreis

View GitHub Profile
/* Listing tables size - MYSQL */
SELECT
TABLE_NAME,
TABLE_ROWS,
ROUND(DATA_LENGTH/1024/1024) AS DATA_MB,
ROUND(INDEX_LENGTH/1024/1024) AS INDEX_MB,
ROUND(DATA_FREE/1024/1024) AS DATA_FREE_MB
FROM
information_schema.TABLES
WHERE
@humbertodosreis
humbertodosreis / gist:362917b6024987fcf28993438e9dd6e5
Created July 4, 2017 22:46 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@humbertodosreis
humbertodosreis / upgrade-windows-wsl.sh
Created July 13, 2017 13:35
Upgrade WSL (Windows Subsystem linux) and install ZSH shell
sudo do-release-upgrade
sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@humbertodosreis
humbertodosreis / brigde-git-wsl-to-phpstorm.bat
Last active July 17, 2017 13:46
Integrate GIT WSL with PHPStorm
@echo off
REM https://stackoverflow.com/questions/43666009/using-git-in-windows-subsystem-for-linux-through-intellij
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\sysnative\bash.exe -c 'git %*'
) Else (
bash.exe -c 'git %*'
)
@humbertodosreis
humbertodosreis / git-export-changes-two-commit.md
Last active July 31, 2017 19:05
Export changes between two commits
git archive --output=changes.zip HEAD $(git diff --name-only SHA1 SHA2 --diff-filter=ACMRTUXB)
phpcs.standard = WordPress
phpcs.tabWidth = 4
phpcs.encoding = utf-8
ftp.host = ftp.example.com
ftp.port = 21
ftp.username = username
ftp.password = password
ftp.project.dir = /subdomains/docs/httpdocs/${project.name.safe}
ftp.dir = ${ftp.project.dir}/${project.version}
@humbertodosreis
humbertodosreis / data.php
Created August 17, 2017 21:35 — forked from sraboy/data.php
An updated server-side processing script for DataTables
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2016 - Steven Lavoie
* Copyright: 2012 - John Becker, Beckersoft, Inc.
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
namespace Common\Utilities;
@humbertodosreis
humbertodosreis / ForcedLogoutListener.php
Created November 29, 2017 19:27 — forked from slavafomin/ForcedLogoutListener.php
Logging user out of Symfony 2 application using kernel event listener
<?php
namespace App\Security;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@humbertodosreis
humbertodosreis / EmFactory.php
Created February 6, 2018 20:04 — forked from samsch/EmFactory.php
Symfony dynamic DB connection
<?php
namespace AppBundle\Services\Factories;
//Inject the EM and Connection for the configured em that needs to be dynamic.
//I think you can actually just inject the EM, and call ->getConnection() it.
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Connection;
//This service gets the dynamic DB creds from the request/user/whatever.
@humbertodosreis
humbertodosreis / remote react bootstrap table example
Created February 6, 2018 20:07 — forked from xabikos/remote react bootstrap table example
An example of a react bootstrap table that fetches the data asynchronously when navigating between pages and when changing the page size
import React, {Component} from 'react';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
import _ from 'lodash';
const dataTable = _.range(1, 60).map(x => ({id: x, name: `Name ${x}`, surname: `Surname ${x}`}));
// Simulates the call to the server to get the data
const fakeDataFetcher = {
fetch(page, size) {
return new Promise((resolve, reject) => {