Skip to content

Instantly share code, notes, and snippets.

View augustohp's full-sized avatar

Augusto Pascutti augustohp

View GitHub Profile
@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.
@lox
lox / simpletest-to-phpunit.php
Created December 3, 2012 19:12
A script for converting a test from SimpleTest to PHPUnit
#!/usr/bin/env php
<?php
/**
* Convert SimpleTest tests to PHPUnit, mocks to Mockery.
*
* Caveats:
* - Assertion + return value can't be combined automatically
*/
@alganet
alganet / relational.md
Last active August 30, 2017 13:34
Respect\Relational Filtered, Mixed and Typed Collections

Basics

<?php

use Respect\Relational\Mapper;
use Respect\Data\Collections\Collection;

//Configuring
@nikic
nikic / objects_arrays.md
Last active May 16, 2025 22:07
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:

@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.
@aras-p
aras-p / preprocessor_fun.h
Last active August 7, 2025 15:36
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@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>
@dashed
dashed / github-pandoc.css
Created September 26, 2013 13:42
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@alganet
alganet / index.php
Created December 12, 2013 03:24
Smallest HATEOAS sample in the world [citation needed]. Work in Progress!
<?php
use Respect\Rest\Router;
$r3 = new Router();
$routes = [];
$routes['singleAuthor'] = $r3->any('/authors/*', 'MySingleAuthorClass');
$routes['singlePost'] = $r3->any('/posts/*', 'MySinglePostClass');
$routes['postsList'] = $r3->any('/posts', 'MyPostsListClass');
@alganet
alganet / scrito
Last active August 29, 2015 13:57
Prototype for Mosai Script Tools 1.0. Works on sh, bash, ksh, zsh, and cmd on Windows and Wine! No dependencies.
#!/usr/bin/env sh
scrito () ( : )
# Static version information
scrito_v () ( scrito_version )
scrito_version () ( echo "Mosai Script Tools 1.0" 1>&2 )
# Short help text
scrito_h () ( scrito_help )