Skip to content

Instantly share code, notes, and snippets.

View humbertodosreis's full-sized avatar

Humberto dos Reis Rodrigues humbertodosreis

View GitHub Profile
<?php
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
@humbertodosreis
humbertodosreis / Application_Form_Login.php
Last active August 29, 2015 14:04
Exemplos de implementações de formulários com Zend Framework 1.
<?php
/* Formulário utilizando definição de decorators */
class Admin_Form_Login extends Zend_Form {
public function init() {
//action e method
$this->setMethod('post');
$this->setElementDecorators(array(
array('ViewHelper', array('class' => 'form-control')),
array('Errors'),
@humbertodosreis
humbertodosreis / Validation_Filter.php
Last active August 29, 2015 14:04
Exemplo de validação e filtro de dados com ZF1
<?php
class Application_Controller_Login {
public function indexAction() {
$nome = $this->getRequest()->getParam('nome');
$validator = new Zend_Validate();
<?php
class Model_Acl extends Zend_Acl {
public function __construct() {
// define Roles
$this->addRole(new Zend_Acl_Role('guest')); // not authenicated
$this->addRole(new Zend_Acl_Role('member'), 'guest'); // authenticated as member inherit guest privilages
$this->addRole(new Zend_Acl_Role('admin'), 'member'); // authenticated as admin inherit member privilages
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home/example/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name dev.apigility.com;
# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<VirtualHost *:80>
ServerName awesome.dev
## Vhost docroot
DocumentRoot "/var/www/awesome/web"
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home/example/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name dev.apigility.com;
@humbertodosreis
humbertodosreis / SoapClientTimeout.class.php
Created December 16, 2015 02:45 — forked from RobThree/SoapClientTimeout.class.php
PHP SoapClient with timeout
<?php
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout
//Usage: Exactly as PHP's SoapClient class, except that 3 new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
class SoapClientTimeout extends SoapClient
{
private $timeout = 0;
private $connecttimeout = 0;
@humbertodosreis
humbertodosreis / example-pubsub.js
Last active October 24, 2016 20:43
Example pubsub with PubSub lib
// require PubSub.js and jQuery
var Model = (function (pubsub) {
function updatePhone(telefone) {
pubsub.publish("service-started"); // notify observers
$.post('/customer/update-phone', {phone: phone}, function (response) {
if (response.status == true) {
pubsub.publish('phone-updated', {phone: phone}); // notify observers
} else {
@humbertodosreis
humbertodosreis / get_total_lines.php
Created April 3, 2017 18:06
Example to get total of lines in file in PHP
<?php
/**
* @see https://secure.php.net/manual/en/splfileobject.seek.php
* @see https://secure.php.net/manual/en/reserved.constants.php
*/
// open a big file
$fileObject = new SplFileObject('big_file.txt', 'r');
// move to last line