Skip to content

Instantly share code, notes, and snippets.

View Ocramius's full-sized avatar
🔬
In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

🔬
In your repositories, watching your code. Always watching.
View GitHub Profile
@Ocramius
Ocramius / .gitignore
Last active January 10, 2023 16:34
`Zend\EventManager` examples
vendor
composer.lock
@Ocramius
Ocramius / .gitignore
Last active December 3, 2021 09:30
`Zend\ServiceManager` examples
vendor
composer.lock
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@krakjoe
krakjoe / pthreads.md
Last active August 30, 2023 18:30
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@texdc
texdc / 1-Notes.md
Last active December 19, 2015 08:59
Notes on refactoring ZF2's "InputFilter"

A few notes from my personal gripes about what InputFilter is and does.

  1. InputFilter is a terrible name as the class mixes sanitation and validation. Rename to something far more appropriate (e.g. InputManager?).
  2. Data should only be processed, not stored - remove setData()

SoC Article

For example, if both raw and sanitized data are required:

@igorw
igorw / php-lazy-seq.php
Last active August 23, 2021 16:47
Lazy sequences using PHP 5.5 generators.
<?php
// thanks to metaultralurker on reddit for inspiration
function map(callable $fn, \Traversable $data) {
foreach ($data as $v) {
yield $fn($v);
}
}
@textarcana
textarcana / mac_xwindows_x11_xvfb_headless_firefox_howto.md
Last active April 19, 2023 01:53
Headless Selenium on CentOS 6.3 (Mac XWindows / X11 / Xvfb / Headless Firefox / Selenium howto)

XWindows for Headless Selenium

X Wing art by Paul Harckham

How to set up a Headless Selenium Testing environment for CentOS 6.3.

On your CentOS 6.3 host

Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.

@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;
}
@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: