Skip to content

Instantly share code, notes, and snippets.

View lfalmeida's full-sized avatar

Luis Fernando de Almeida lfalmeida

View GitHub Profile
<?php
/* Dependencias instaladas com composer
{
"require" : {
"knplabs/knp-snappy": "*",
"h4cc/wkhtmltopdf-amd64": "0.12.x",
"h4cc/wkhtmltoimage-amd64": "0.12.x"
}
}
@lfalmeida
lfalmeida / git hook post-receive
Last active August 7, 2016 12:49
git hook post-receive
#!/bin/bash
printMessage () {
if [ $# -eq 0 ]; then
echo "Usage: printMessage MESSAGE [printMessage_CHARACTER]"
return 1
fi
echo ""
echo ""
printf -v _hr "%*s" 80 && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1"
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@lfalmeida
lfalmeida / gist:37a5a8fe84dc9e948527
Created February 25, 2015 12:55
Modal sobre modal mdnb
require(['modules/banners/views/listaView'], function (EmailModal) {
var view = new EmailModal({model: new Backbone.Model()}),
modalOptions = {
removeExtraPannel: true,
showFooter: true,
title: 'Responder e-mail',
modalSize: 'full', // renderiza .modal-lg
onRenderCallback: function () {
console.log('Execuntando o método onRenderCallback');
}
@lfalmeida
lfalmeida / pre-commit
Created March 14, 2015 16:42
Git Hook pre commit
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
CODESNIFER_RUNS=0
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
@lfalmeida
lfalmeida / PDO_Codeigniter
Created March 29, 2015 01:46
Usando PDO com codeigniter
<?php
$pdo = new PDO('mysql:host=localhost;dbname=itlean', $this->db->username, $this->db->password);
$username = 'itlean';
$consulta = $pdo->prepare("SELECT * FROM admin_users WHERE username = :username;");
$consulta->bindParam(':username', $username, PDO::PARAM_STR);
$consulta->execute();
while ($linha = $consulta->fetch(PDO::FETCH_OBJ)) {
@lfalmeida
lfalmeida / inputNumbers.js
Last active August 29, 2015 14:23
inputNumbers.js
(function ($) {
$.fn.onlyNumbers = function () {
return this.each(function () {
$(this).keydown(function (e) {
// backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Ctrl+A, Command+A
@lfalmeida
lfalmeida / git hook post-receive [TAGS]
Last active August 19, 2016 20:28
Hook para deploy utilizando tags
#!/bin/bash
## Print horizontal printMessager with message
printMessage () {
if [ $# -eq 0 ]; then
echo "Usage: printMessage MESSAGE [printMessage_CHARACTER]"
return 1
fi
echo ""
printf -v _hr "%*s" $(tput cols) && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1"
@lfalmeida
lfalmeida / pre-receive
Created August 7, 2016 13:01
Script para hook pre-receive que executa os testes unitários e rejeita em caso de falha
#!/bin/bash
printMessage () {
if [ $# -eq 0 ]; then
echo "Usage: printMessage MESSAGE [printMessage_CHARACTER]"
return 1
fi
echo ""
echo ""
printf -v _hr "%*s" 80 && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1"
<?php
$var = "yes";
var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN));
# A saída do código acima seria:
# bool(true)
?>