Skip to content

Instantly share code, notes, and snippets.

@jpcercal
jpcercal / Git Rebase
Created July 17, 2014 21:28
Git Rebase - Caso HWIOAuthBundle - BufferApp
git checkout master && \
git branch -D test2 && \
git checkout -b test2
git ls-files | xargs git update-index --add --chmod=-x
git commit -m "Local mode changed" && \
git checkout -- . && \
git rebase -i HEAD~4
@jpcercal
jpcercal / DefaultController.php
Last active August 29, 2015 14:04
Create date from string
<?php
setlocale(LC_ALL, NULL);
setlocale(LC_ALL, 'pt_BR');
$time = "segunda-feira, 28 de julho de 2014 10h10min07s UTC-3";
$timeParts = explode(',', $time);
$timeParsed = strptime(
@jpcercal
jpcercal / gist:177022261216831b1351
Last active August 29, 2015 14:05
Import database MySQL with Progress Bar
# apt-get install pv
# pv -t -p <your-filename>.sql | mysql -u <your-username> -p -D <your-database-name>
pv -t -p database.sql | mysql -u root -p -D test
@jpcercal
jpcercal / gist:049de2d58a6bceaa539b
Last active August 29, 2015 14:05
Git Filemode
git config core.fileMode false
@jpcercal
jpcercal / gist:e70bc2629a280e7504a0
Created February 20, 2015 21:49
Clear Memcached
echo "flush_all" | nc -q 2 localhost 11211
@jpcercal
jpcercal / Terminal Proxy Setup
Last active August 29, 2015 14:17
Terminal Proxy Setup
# Credentials
export PROXY_SERVER_IP="proxyserver.com"
export PROXY_SERVER_PORT="3128"
export PROXY_USERNAME="your-user"
export PROXY_PASSWORD="your-password@123"
PROXY_CONFIG="http://${PROXY_USERNAME/\@/%40}:${PROXY_PASSWORD/\@/%40}@${PROXY_SERVER_IP}:${PROXY_SERVER_PORT}/"
# System
export {http,HTTP,https,HTTPS}_{proxy,PROXY}=$PROXY_CONFIG
@jpcercal
jpcercal / git-show-content-file-of-a-specific-commit
Created June 1, 2015 13:56
Git Show Content File of a Specific Commit
# git show 0a6cba589532c1b8079e10d9f16511a0d3cd8961:src/filename.ext
git show <treeish>:<file>
# or
git show HEAD~1:src/filename.ext
#!/usr/bin/env bash
DATE_FORMAT="+%Y-%m-%d %H:%M:%S"
echo "["$(date "$DATE_FORMAT")"] Running PHPCSFixer ..."
COMMAND_GIT_DIFF="git diff --cached --name-status --diff-filter=ACM"
COMMAND_PHP_CS_FIXER="./vendor/fabpot/php-cs-fixer/php-cs-fixer fix --dry-run --level=psr2 --verbose"
PHP_FILES_TO_BE_COMMITED=`$COMMAND_GIT_DIFF | grep -E -o '\W+.*?\.php'`
@jpcercal
jpcercal / gist:72007391b4cdc67ad3e4
Created July 6, 2015 12:32
Composer PostInstallCmd
#!/usr/bin/env bash
BASE_PROJECT_DIR=`pwd`
rm $BASE_PROJECT_DIR/.git/hooks/pre-commit 2> /dev/null
ln -s $BASE_PROJECT_DIR/bin/git/hooks/pre-commit $BASE_PROJECT_DIR/.git/hooks/pre-commit
chmod +x $BASE_PROJECT_DIR/.git/hooks/pre-commit
@jpcercal
jpcercal / soapclient.php
Last active June 26, 2016 00:37
An Example of PHP SoapClient
<?php
// Nota: O ideal é que esse script fique em outro arquivo para
// não misturar regras de negócio com o HTML ...
$wsdl = "http://ws.registrocivil.org.br/listarCartoriosReceitaFederal.cfc?wsdl";
try {
$options = array(
'soap_version' => SOAP_1_1,