Skip to content

Instantly share code, notes, and snippets.

View davialexandre's full-sized avatar

Davi Alexandre davialexandre

View GitHub Profile
@davialexandre
davialexandre / provisioning_webgrind.yml
Last active August 29, 2015 14:20
tasks to install webgrind using Ansible
- name: PHP | Create the webgrind dirs
file: name=/var/www/webgrind/storage state=directory owner=www-data mode=0700
- name: PHP | Download webgrind package
get_url: url=https://github.com/bionoren/webgrind/archive/xdebug23.zip dest=/tmp/webgrind.tar.gz
- name: PHP | Extract the webgrind package
unarchive: src=/tmp/webgrind.tar.gz dest=/var/www/webgrind copy=no creates=/var/www/webgrind/index.php
- name: PHP | Move the webgrind package contents to the webgrind dir
@davialexandre
davialexandre / gist:e6bebdab22546aad1692
Created May 15, 2014 13:57
Bash prompt with divider line
export PS1='$(printf '%.0s-' $(seq 1 $COLUMNS))\n\[\e[0;32m\]\u@\h:\[\e[m\]\[\e[36;40m\]\w\[\e[m\]\[\e[1;32m\]\$\[\e[m\] '
{
_index:"index",
_type:"filme",
_id:"16855",
_version:1,
exists:true,
_source:{
titulo_portugues:"RIO",
titulo_original:"Rio",
ano:"2011",
public class EnumExample {
public static void main(String []args){
testGender(Gender.FEMALE);
testGender(Gender.MALE);
}
public static void testGender(Gender gender) {
switch(gender) {
case FEMALE:
System.out.println("Female");
<div id="login-box">
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
<?php
class AdminLoginForm extends CFormModel
{
public $username;
public $password;
public $rememberMe;
private $_identity;
@davialexandre
davialexandre / AdminModule.php
Created November 5, 2012 17:59
AdminModule::beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
if($this->user->isGuest && !($controller->id == 'default' && $action->id == 'login')) {
$this->user->loginRequired();
}
return true;
}
else
@davialexandre
davialexandre / DefaultController.php
Created November 5, 2012 17:53
Exemplo de um controller dentro de um módulo com Login
<?php
class DefaultController extends CController
{
public $defaultAction = 'login';
public function actionLogin() {
$this->layout = 'login';
$model = new AdminLoginForm;
if(isset($_POST['AdminLoginForm'])) {
@davialexandre
davialexandre / gist:3921652
Created October 20, 2012 01:48
Exemplo de customização de filtros no CGridView
<?php $this->widget('zii.widgets.grid.CGridView', array(
'columns'=>array(
array(
'name' => 'pesquisa',
'value' => '$data->pesquisa',
'header' => 'Termo',
),
array(
'name' => 'data_cadastro',
'value' => 'Yii::app()->dateFormatter->formatDatetime(strtotime($data->data_cadastro), "short", "short")',
@davialexandre
davialexandre / relations.php
Created October 19, 2012 18:01
Relations - exemplos
<?php
class Os extends CActiveRecord {
public function relations() {
return array(
'cliente' => array(self::BELONGS_TO, 'Cliente', 'id_cliente'),
);
}
}