Skip to content

Instantly share code, notes, and snippets.

View enov's full-sized avatar

Samuel Demirdjian enov

View GitHub Profile
@srgoogleguy
srgoogleguy / http.md
Created October 31, 2014 02:46
PHP Http Interface Draft

Http Interface

The Http interface SHOULD define the standardized methods and constants upheld by implementing classes. All classes should be obligated to implement such methods and constants, but MAY NOT be limited to only these methods or constants.

The Interface Definition

abstract class HttpMessage
{
    protected $headers = array();

protected $body = "";

@rjd22
rjd22 / Kohana_3_4.md
Last active March 5, 2018 11:16
Plans for Kohana 3.4 and 4.x

Kohana 3.4

Features

  • Kohana core - isolated autoloader/module loader/filesystem and cache (@zombor already started this iirc)

Fixes

  • Move Request::factory() into Request_Factory

Improvements

  • Database should support Mysqli
  • Namespaces
@birkir
birkir / Result.php
Last active December 29, 2015 15:19
Fix mysql Database driver for hhvm
<?php
class Database_MySQL_HHVM_Result {
protected $_ref;
public function current()
{
if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
return NULL;
@birkir
birkir / multiquery.php
Created November 28, 2013 10:05
Multiquery adapter for MySQLi database driver
<?php
class MySQLi_Database extends Database {
...
public function multiquery($sql)
{
// Make sure the database is connected
@ha1t
ha1t / array_walk_test.php
Created August 11, 2013 06:39
array_walk() to destroy the internal array pointer
<?php
echo phpversion() . PHP_EOL;
$lists = array('hoge');
array_walk($lists, 'trim');
if (current($lists) !== false) {
echo 'o';
} else {
echo 'x';
}
@atannus
atannus / kohana.php
Created July 6, 2013 19:38
Quick hack to allow Kohana to handle memory_limit and max_execution_time violations.
<?php defined('SYSPATH') or die('No direct script access.');
class Kohana extends Kohana_Core {
/**
* Augments the core method for two reasons:
* 1) Reserve an extra 1M memory to allow handling memory_limit violation.
* 2) Reserve more exec time to allow max_execution_time violation.
*
* Note: keep variable creation at a minimum.
@leedavis81
leedavis81 / ShutdownProcess.php
Created October 17, 2012 10:05
PHP Register shutdown handler - allows unregistering
<?php
/**
* Shutdown process handler, allows you to unregister a process (not supported natively in PHP)
* Usage:
* $sd = new System_ShutdownProcess($callable);
* $sd->register() /// $sd->unregister()
* or via factory
* $sd = System_ShutdownProcess::factory($callable)->register()
*/
@mindplay-dk
mindplay-dk / reflection-bench.php
Created August 15, 2012 12:40
A benchmark of reflection API performance in PHP
<?php
/**
* Benchmark: Reflection Performance
*
* Conclusion: there is no performance-gain from caching reflection-objects.
*/
define('NUM_TESTS', 10);
@joni
joni / STRINGDECODE.sql
Created June 19, 2012 19:35
STRINGDECODE: MySQL function to decode unicode escapes to utf8
CREATE FUNCTION STRINGDECODE(str TEXT CHARSET utf8)
RETURNS text CHARSET utf8 DETERMINISTIC
BEGIN
declare pos int;
declare escape char(6) charset utf8;
declare unescape char(3) charset utf8;
set pos = locate('\\u', str);
while pos > 0 do
set escape = substring(str, pos, 6);
set unescape = char(conv(substring(escape,3),16,10) using ucs2);
@kemo
kemo / Cached.php
Created April 27, 2012 21:36
Cache-powered ORM model extension (Kohana 3.3) - [!!] Not tested
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Extend this class if you want your model cached. Example usage:
*
* 1. Model
* class Model_User extends ORM_Cached {}
*
* 2. Usage
*