Skip to content

Instantly share code, notes, and snippets.

View carlosfilho88's full-sized avatar

Carlos Filho carlosfilho88

  • Teresina, Piauí - Brasil
  • 18:19 (UTC -03:00)
View GitHub Profile
@carlosfilho88
carlosfilho88 / nginx.conf
Created April 3, 2011 15:46
Nginx basic conf file
user www-data;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 8192;
events {
use epoll;
worker_connections 8192;
}
@carlosfilho88
carlosfilho88 / nginx.conf
Last active October 6, 2015 12:48
Zend with nginx
## Force redirect to www address
server {
server_name zf.local;
rewrite ^(.+?)/?$ http://www.zf.local$1 permanent;
}
server {
listen 80;
server_name www.zf.local;
index index.php;
@carlosfilho88
carlosfilho88 / .inputrc
Created January 4, 2013 20:56
bash autocomplete
# do not make noise
set bell-style none
# Don't echo ^C etc (new in bash 4.1)
# Note this only works for the command line itself,
# not if already running a command.
set echo-control-characters off
# Note this must be done before the settings below
# Caveats:
<?php
class Application_Model_MPDF {
public function createPDF($HTML, $filename) {
define('_MPDF_PATH', APPLICATION_PATH.'/../library/MPDF/');
include(_MPDF_PATH.'mpdf.php');
$mpdf = new mPDF('utf-8', 'A4');
$mpdf->SetWatermarkImage('../public/images/logo.png');
$mpdf->showWatermarkImage = true;
$mpdf->WriteHTML($HTML);
@carlosfilho88
carlosfilho88 / Zend_Form
Created August 6, 2014 20:37
Custom validators
$email = new Zend_Form_Element_Text('email');
$email->setLabel('E-mail')
->addFilter('stringTrim')
->setAttribs(array('onDrag' => 'return false', 'onDrop' => 'return false', 'onPaste' => 'return false', 'autocomplete' => 'off', 'class'=>'input-xlarge'))
->setRequired(true)
->addValidators(array(array('EmailAddress'),array('Db_RecordExists', false, array('table' => 'usuarios','field' => 'email'))))
->addErrorMessages(array(Zend_Validate_Db_RecordExists::ERROR_RECORD_FOUND => 'O e-mail informado não está cadastrado.'));
$cpf = new Zend_Form_Element_Text('cpf');
$cpf->setValidators(array(array('StringLength', false, array(14, 14))))
<?php
class Application_Form_Logindropdown extends Zend_Form {
public function init(){
$this->setMethod('post')
->setAction('/login')
->setEnctype('UTF-8');
$email = new Zend_Form_Element_Email('email');
$email->setAttrib('placeholder', 'Digite seu e-mail')
@carlosfilho88
carlosfilho88 / gist:c065910df01813b17105
Created November 12, 2014 17:10
Zend_Form_Element_MultiCheckbox
<?php
$fooTable = new Application_Model_Useroptions;
$options = $fooTable->getUserOptions();
$checkboxes = new Zend_Form_Element_MultiCheckbox('checkboxes');
$checkboxes->setLabel('Options');
$checkboxes->setRegisterInArrayValidator(false);
foreach ($options as $opt)
$checkboxes->addMultiOption($opt->id_option, $opt->title);
@carlosfilho88
carlosfilho88 / gist:d7ec7fad97a08f09dc5f
Created November 12, 2014 17:14
Multiple checkbox jquery + zend form multiple checkbox (ZF1)
var checkboxes = function() {
var items = new Array();
return {
"add": function(val) {
items.push(val);
},
"addUnique": function(val) {
Array.prototype.inArray = function(comparer) {
for(var i = 0; i < this.length; i++) {
if(comparer(this[i])) return true;
@carlosfilho88
carlosfilho88 / ErrorController
Created November 17, 2014 12:37
Handling exceptions with Zend Framework 1
<?php
class ErrorController extends Zend_Controller_Action {
public function init() {
parent::init();
}
public function errorAction() {
$errors = $this->_getParam('error_handler');
$boot = $this->getInvokeArg('bootstrap');
@carlosfilho88
carlosfilho88 / novosga
Last active May 25, 2021 19:49
NovoSGA nginx configs
## nginx 1.8.0
server {
listen 80;
server_name FQND;
root /var/www/novosga/public;
index index.php;
## Enable CORS
#add_header Access-Control-Allow-Origin *;