Skip to content

Instantly share code, notes, and snippets.

View cspray's full-sized avatar

Charles Sprayberry cspray

View GitHub Profile
@loonies
loonies / 1_phpunit-api.md
Last active January 19, 2024 07:34
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this->anything()
@cspray
cspray / cv-ring-description.md
Created January 27, 2012 15:55
A brief description of cv-ring and cv-pls

What is 'cv-ring', 'cv-pls' and 'delv-pls'

In the Stack Overflow PHP chat you may notice the regulars using tags like cv-pls, cv-ring and delv-pls. These tags are used only in the chat room to communicate with other users that a question or answer may need more votes to be closed or deleted. The PHP tag has a lot of inferior quality and duplicative information on Stack Overflow. We feel that inferior quality questions bring down the site and make it harder to find good information, particularly about PHP. By closing and merging these questions as appropriate you'll find the information you need quicker.

  • cv-ring is just a 'funny name' we give to the group of regulars who use the tags
  • cv-pls is an in-chat tag that communicates "Hey, this question may be of inferior quality. Check it out and, if you feel appropriate, cast a close vote."
  • delv-pls is an in-chat tag that communicates "Hey, this question has alr
@btoone
btoone / curl.md
Last active April 2, 2024 20:18
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@PeeHaa
PeeHaa / frameworks-sigh.md
Created May 7, 2012 22:27
Frameworks are bad m'kay

This document will be a reminder why most (/ almost all) frameworks out there just suck monkey balls.

Let's just make a nice list of all the really bad stuff that is happening in the popular frameworks.
And maybe publish it just to give people the shivers.

CodeIgniter

[Are we evaling now][2]?

@cspray
cspray / xdebug_ini_settings.php
Created May 14, 2012 14:04
Xdebug ini settings to show more info on var_dump
<?php
// Displays all array indices and object properties
ini_set('xdebug.var_display_max_children', -1);
// Displays all string data dumped
ini_set('xdebug.var_display_max_data', -1);
// Controls nested level displayed, maximum is 1023
ini_set('xdebug.var_display_max_depth', -1);
@owainlewis
owainlewis / model_to_csv.rb
Created July 2, 2012 17:58
Export Rails model to CSV
# Export Active Record model as a CSV file
#
def self.render_csv active_record_model
CSV.generate do |csv|
csv << active_record_model.column_names
active_record_model.all.each do |m|
values = active_record_model.column_names.map{ |f| m.send f.to_sym }
csv << values
end
end
<!--
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░░░░░░░░░░░░░░░░░░░░░
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░░░░░░░░░░░░░░░░░░░░░
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░░░░░░░░░░░░░░░░░░░░░
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░░░░░░░░░░░░░░░░░░░░░
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█░░░░░░░░░░░░░░░░░░░░
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█░░░░░░░░░░░░░░░░░░░░
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░░░░░░░░░░░░░░░░░░░░░
@morrisonlevi
morrisonlevi / gist:4083664
Created November 16, 2012 03:13
ext/mysql deprecation email

Sirs, Gentlemen and Scholars,

I am appreciative of all of the discussion that has happened on the mysql_deprecation RFC (https://wiki.php.net/rfc/mysql_deprecation). It has helped me understand how we feel collectively about ext/mysql and how to deprecate it. I believe that clarifying what the term 'deprecation' means could help everyone to understand what we are trying to accomplish.

To quote wikipedia on the word 'deprecation':

In the process of authoring computer software, its standards or documentation, or other technical standards, deprecation is a status applied to features, characteristics, or practices to indicate that they should be avoided, typically because they have been superseded.

I think we all agree that ext/mysql should be avoided and that it has been superseded. What I want to point out is that deprecation is a process. The real question is: have we taken the proper steps in that process?

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