Skip to content

Instantly share code, notes, and snippets.

View danizord's full-sized avatar

Danizord danizord

View GitHub Profile
@Ocramius
Ocramius / .gitignore
Last active July 22, 2017 15:20
PissOff: a valid, polite and useful alternative to the `void` return type in PHP
vendor
composer.lock
<?php
$a = 10;
if ($a > 5) {
$b = 5;
} else {
$b = 10;
}
@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>
@Ocramius
Ocramius / SchemaValidityFunctionalTest.php
Created April 22, 2013 11:48
Functional test case for schema validation in Doctrine2 ORM
<?php
namespace Ocramius\CMS\ContentTest;
use Ocramius\CMS\ContentTest\Util\ServiceManagerFactory;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\SchemaValidator;
use PHPUnit_Framework_TestCase;
/**
@nikic
nikic / php-5.5-features.md
Last active August 31, 2020 10:39
List of new features in PHP 5.5
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@augustohp
augustohp / to-apple.md
Last active June 5, 2023 18:49
To: Apple

Apple,

You are a company I learned to love and hate. In that same order.

  • I love the way you try to reach excellence in everything you do
  • I hate the way you try to fuck everyone else who tries to do same

Things I (still) love

  • The MacBook (track pad) is a great piece of hardware, sadly it is not one-of-a-kind anymore. Even more sad is that all other (great) options do not try to hold you on all kind of accessories and stuff, although it still bearable for an old time customer.
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 26, 2024 23:26 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.