Skip to content

Instantly share code, notes, and snippets.

View netojoaobatista's full-sized avatar
💭
GitHub is not Orkut.

João Batista Neto netojoaobatista

💭
GitHub is not Orkut.
View GitHub Profile
@netojoaobatista
netojoaobatista / person.php
Created October 30, 2012 22:37
Validação e manipulação de XML
<?php
$dom = new DOMDocument();
$dom->load('person.xml');
if (!$dom->schemaValidate('person.xsd')) {
//log: XML inválido
}
<?php
$postos = array(
'A' => 'atendimento.jpg',
'B' => 'banheiros.jpg',
'1' => 'borracharia.jpg',
'2' => 'brindes.jpg',
'C' => 'churrascaria.jpg',
'E' => 'estacionamento.jpg',
'G' => 'gasolina.jpg',
'L' => 'loja.jpg',
@netojoaobatista
netojoaobatista / dica.md
Last active February 25, 2019 14:08
Dica para não programadores aprenderem a pensar em programação

Por estar envolvido diretamente com várias comunidades de desenvolvedores, de diversas linguagens, vejo, com frequência, uma série de dificuldades de entendimento por parte dos mais novos (leia-se iniciantes em programação). Essa dificuldade de entendimento, normalmente, está relacionada com uma confusão em relação ao objetivo real do desenvolvimento de software.

Programar, ao contrário do que os mais novos pensam, não se trata de escrever códigos. De fato, trata-se de percepção com o objetivo puro e simples de se resolver problemas. O código é apenas uma, entre as várias atribuições do programador e, acreditem, não é a mais importante.

Digo que não é a mais importante, pois o código é apenas a aplicação de uma linguagem. Porém, quando se percebe que uma linguagem é apenas uma ferramenta, dentre várias ferramentas que podem ser utilizadas, compreende-se que o código naquela linguagem é equivalente ao serrote utilizado pelo marceneiro.

Alguém aqui definiria um marceneiro como um cara que sabe usar um serrot

@netojoaobatista
netojoaobatista / post-mortem.md
Created July 17, 2018 14:12 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@netojoaobatista
netojoaobatista / sample.php
Created August 8, 2012 15:00
Slug function
<?php
echo slug('João Batista Neto'); //joao-batista-neto
@netojoaobatista
netojoaobatista / Customer.php
Created July 16, 2013 15:47
Fetching entities
<?php
namespace Example;
class Customer
{
private $id;
private $firstName;
private $lastName;
private $email;
private $company;
<?php
$a = 10;
if ($a > 5) {
$b = 5;
} else {
$b = 10;
}
@netojoaobatista
netojoaobatista / gist:3716209
Created September 13, 2012 17:55
histórico do chat do Hangout sobre PHP
esse alganet é uma figura ^^ kkkk
Ruan_Aragao: Jamaicaaa kkkk
DavidRamires: Manual fantastico!
danjesus: netojoaobatista, sem d?vida ? o melhor manual
augustohp: +1
Ruan_Aragao: Demais!
danjesus: e os coment?rios s?o foda
poultwo: total
Denise: Manual PHP, Like, +1
Ruan_Aragao: Ele é muito mais vivo que eu :-S
@netojoaobatista
netojoaobatista / gist:3059996
Created July 6, 2012 12:49
Chat do hangout sobre Web Performance Optimization
Al3xsandro: http://vsarbranchingguide.codeplex.com/downloads/get/101549
Al3xsandro: https://docs.google.com/open?id=0B3TxkJ9ZFyzWUHFuUWE4TEtqTEE
Eduardo: é recente sim, teve um evento de otimização para web com o Steve Souders
Eduardo: aí eles fizeram uma promoção de ebooks dele
Eduardo: e lançaram esse aí
Eduardo: aproveitei e comprei
Eduardo: fica a disposição se alguém quiser
netojoaobatista: http://youtu.be/ZHZemt32SNw
junin: Bora pro youtube!
Miguel_Oliveira: http://www.youtube.com/watch?v=ZHZemt32SNw&feature=youtu.be
@netojoaobatista
netojoaobatista / PSR-2.xml
Created December 19, 2012 14:40
Code formatter for Zend Studio using the FIG-Standards PSR-2 Coding Style Guide. see: https://github.com/netojoaobatista/PSR-2
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles>
<profile name="PSR-2">
<setting id="com.zend.php.core.formatter.insert_new_line_in_function_invoke" value="0"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_force_split" value="true"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_indent_policy" value="2"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_line_wrap_policy" value="1"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_force_split" value="true"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_indent_policy" value="2"/>
<setting id="com.zend.php.formatter.core.formatter.alignment_for_arguments_in_method_invocation_line_wrap_policy" value="1"/>