Skip to content

Instantly share code, notes, and snippets.

View drgomesp's full-sized avatar
🏠
Working from home

Daniel Ribeiro drgomesp

🏠
Working from home
View GitHub Profile
@hectorsanjuan
hectorsanjuan / build.xml
Created September 17, 2011 18:22
Phing build.xml for Symfony2 projects
<?xml version="1.0" encoding="UTF-8"?>
<project name="${projectName}" basedir="." default="build:main">
<!-- Properties -->
<property name="dir.app" value="${project.basedir}/app" />
<property name="dir.src" value="${project.basedir}/src" />
<property name="dir.build" value="${project.basedir}/app/build" />
<property name="dir.docs" value="${dir.build}/docs" />
<property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" />
<property name="dir.docs.docblox" value="${dir.docs}/docblox" />
<property name="dir.reports" value="${dir.build}/logs" />
@Thinkscape
Thinkscape / PSR-0-final-proposal.md
Created September 22, 2011 10:30
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
@sjl
sjl / Menlo-ForPowerline.ttc.zip
Created January 17, 2012 18:09
Patched Menlo for Powerline. This one includes the bold, italic, etc variants.
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@coffeencoke
coffeencoke / jenkins-nginx.conf
Created October 13, 2012 16:58
Nginx conf for redirecting jenkins
server {
listen 80; # Listen on port 80 for IPv4 requests
server_name build.yourdomain.com;
access_log /var/log/nginx/jenkins_access.log;
error_log /var/log/nginx/jenkins_error.log;
location ~ ^/static/[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\/(.*)$ {
#rewrite all static files into requests to the root
@netojoaobatista
netojoaobatista / Example.php
Created November 14, 2012 16:25
To mock or not to mock, that is the question
<?php
class Example {
public function getInsertSQL() {
return 'INSERT INTO `example` (
`email`,
`name`
) VALUES (
:email,
:name
);';
@henriquemoody
henriquemoody / phpunit.bash
Last active May 10, 2023 02:52
PHPUnit Bash Completion. sudo curl -L https://gist.githubusercontent.com/henriquemoody/5014805/raw/phpunit.bash -o /etc/bash_completion.d/phpunit && source /etc/bash_completion.d/phpunit
# Bash-Completion script for PHPUnit
#
# Created by Henrique Moody <henriquemoody@gmail.com>
#
_phpunit()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
@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:

@alganet
alganet / greppy.php
Created March 6, 2013 19:50
Greppy
<?php
// Matches a single char. Equivalent to: /./
Pattern::char()->test('a'); //true
Pattern::char()->replace('a', 'b'); //b
Pattern::char()->match('a'); //array('a') (captures groups)
// Possible "steps":
@alganet
alganet / greppy.php
Last active August 30, 2017 13:38
Greppy
<?php
// Simple empty matching. Explains a lot of how the idea works:
//
// By default, expressions are delimited by a line, which
// implies /^$/. Everything goes inside that. Calling nothing
// else more matches any line.
//
// p() is a function call. Could be Pattern::create(), but I
// believe providing a function is sane. It can be provided