Skip to content

Instantly share code, notes, and snippets.

View NandoKstroNet's full-sized avatar
🎯
Focusing

Nando Kstro Net NandoKstroNet

🎯
Focusing
View GitHub Profile
@alganet
alganet / 01.http
Last active December 22, 2015 06:19
RESTful HTTP Containers. 01 - A GET on a container. 02 - A specific GET on a container with a filter (defined by the stateless forms in the request before). 03 - A GET on an item (defined by stateless links of the request before). 04 - A POST to create two new items (or any ammount, defined by the forms in requests before). 05 - A POST to update…
GET /products HTTP/1.1
Host: example.com
HTTP/1.1 200 Ok
Content-Type: text/html;charset=utf-8
<!doctype html>
<title>All Products</title>
<h1>Products</h1>
<ul>
<li><a rel="item" href="/products/1">Product 1</a></li>

PHP Prático: Streams

A palavra stream significa corrente. Em geral, qualquer conexão de rede é uma stream, e existem vários tipos de protocolos para streams. Esses protocolos definem como os dados fluem na corrente.

No PHP, vários protocolos são suportados de forma transparente:

<?php
@henriquemoody
henriquemoody / nl_langinfo.php
Last active December 20, 2015 06:59
nl_langinfo() constant values.
<?php
$langinfo = array(
'LC_TIME' => array(
'ABDAY_1' => 'Abbreviated name of fist day of the week',
'ABDAY_2' => 'Abbreviated name of second day of the week',
'ABDAY_3' => 'Abbreviated name of third day of the week',
'ABDAY_4' => 'Abbreviated name of fourth day of the week',
'ABDAY_5' => 'Abbreviated name of fifth day of the week',
'ABDAY_6' => 'Abbreviated name of sixth day of the week',
@alganet
alganet / self_stats.php
Last active December 17, 2015 11:19
PHP Self Stats
<?php
// PHP Self Stats
/*
* get_loaded_extensions() returns all the extension names
* currently loaded.
*
* Using array_intersect(), we can get only the extensions
* we want from those which are really available.
<?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',
@alganet
alganet / tipagem_primitiva.md
Last active August 12, 2019 22:48
PHP Prático: Tipagem Primitiva

PHP Prático: Tipagem Primitiva

A primeira coisa a saber sobre a tipagem do PHP é que ela não é parecida com Java, JavaScript, Python, Ruby, C, C++, C# ou qualquer linguagem que tenha uma tipagem baseada em alguma dessas citadas. A tipagem do PHP é incomparável, e assim como tudo que não pode ser comparado é difícil de ser explicada.

De qualquer forma, a tipagem do PHP é extremamente simples se você apenas confiar na sua intuição. A primeira coisa que você tem que saber sobre a tipagem do PHP é que ela faz malabarismos. É exatamente essa a palavra: malabarismo. E o PHP é um ótimo malabarista, exceto por alguns poucos deslizes fáceis de decorar. O type juggling, traduzido para "malabarismo com tipos" é a habilidade que o PHP tem de tomar decisões intuitivas sobre conversões de tipos. Em termos grosseiros, o PHP decide toda e qualquer tipagem de variáveis em tempo de execução, não compilação (pros pedante aí que tão lendo).

Note bem: tipagem de variáveis. O PHP é multi-paradigma e, ao m

@vitorbritto
vitorbritto / devlist-bookmarks.md
Last active October 10, 2023 13:49
A BADASS list for faster Web Development! Recently, I decided to organize my bookmarks. So, like a good fellow, I am sharing with you. I hope you enjoy!

Dev List Bookmarks

Attention: the list was moved to https://github.com/vitorbritto/dev-list

This page is not maintained anymore, please update your bookmarks.


Recently, I decided to organize my bookmarks. So, like a good fellow, I am sharing with you. I hope you enjoy!

@Ocramius
Ocramius / Foo.php
Last active March 12, 2021 14:14
Self hydrating object proxy in PHP Provides faster hydration by removing the need for reflection.
<?php
class Foo
{
protected $foo;
protected $bar;
protected $baz;
}
@netojoaobatista
netojoaobatista / 1lr-query.php
Last active December 15, 2015 18:39
Obtendo registros aleatórios de uma base sem utilizar ORDER BY RAND()
<?php
$pdo = new PDO('mysql:host=127.0.0.1;dbname=base', 'user', 'pswd');
$stm = $pdo->query('
SET @count = (SELECT COUNT(*) FROM tabela);
SET @query = CONCAT("SELECT * FROM `tabela` LIMIT 4 OFFSET ", 1 + FLOOR(RAND() * @count));
PREPARE stmt FROM @query;
EXECUTE stmt;
');
@alganet
alganet / php_pratico_streams.md
Last active August 15, 2021 20:41
PHP Prático: Streams

PHP Prático: Streams

A palavra stream significa corrente. Em geral, qualquer conexão de rede é uma stream, e existem vários tipos de protocolos para streams. Esses protocolos definem como os dados fluem na corrente.

No PHP, vários protocolos são suportados de forma transparente:

<?php