Skip to content

Instantly share code, notes, and snippets.

View augustohp's full-sized avatar

Augusto Pascutti augustohp

View GitHub Profile
@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 / 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>
@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 / 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.
@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 / 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
@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
*/
@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.
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@nikic
nikic / password_hashing_api.md
Created September 12, 2012 15:04
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.