Skip to content

Instantly share code, notes, and snippets.

View Thinkscape's full-sized avatar

Arthur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / mod_flvx.c
Created August 2, 2011 11:30
FLV streaming module for Apache2
/**
* Copyright 2006 Paul Querna
* (modified by Artur Bodera 2009, see http://tperspective.blogspot.com/2009/02/apache-flv-streaming-done-right.html)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@Thinkscape
Thinkscape / gist:1136563
Created August 10, 2011 11:05
Very simple performance comparison - arrays vs objects (PHP 5.3.6)
# php -v
PHP 5.3.6 (cli) (built: Mar 17 2011 20:58:15)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $s[] = array("name"=>"Adam","age"=>35); }; echo memory_get_peak_usage(); ' | php
655040
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $o = new ArrayObject; $o->name = "Adam"; $o->age = 35; $s[] = $o;} echo memory_get_peak_usage(); ' | php
887984
@Thinkscape
Thinkscape / Debug.php
Created August 26, 2011 05:58
ZF2 Front Controller Debugger plugin
<?php
namespace Zend\Controller\Plugin;
use Zend\Controller;
use Zend\Controller\Request;
use Zend\Controller\Plugin\AbstractPlugin;
class Debug extends AbstractPlugin
{
protected $_logger;
---------- PROPOSAL 1 --------------------
* directory names in plural form
* assets grouped by purpose
------------------------------------------
/application
/library
/Zend
/OtherVendor
/modules
/Statistics
@Thinkscape
Thinkscape / gist:1217418
Created September 14, 2011 18:50
ZF2 IRC Meeting 2011-09-14
[Zend Framework 2.0 IRC Meeting channel. Next meeting: 2011-09-14 17:00 UTC; agenda: http://bit.ly/rimSDJ. Previous meeting minutes: http://bit.ly/oQ60Xm]
[18:55] * Thinkscape : meeting starts in 5 minutes
[18:56] == rdohms [~rdohms@201.23.78.250.dedicated.neoviatelecom.com.br]
[18:56] == realname : Rafael Dohms
[18:56] == channels : #zf2-meeting #zftalk.dev
[18:56] == server : adams.freenode.net [Budapest, HU, EU]
[18:56] == account : rdohms
[18:56] == End of WHOIS
[18:56] <Akrabat> I have dinner in 5 minutes :)
[18:58] <weierophinney> starting in 2 or 3 minutes...
@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.
@Thinkscape
Thinkscape / gist:1415354
Created December 1, 2011 09:35
Discussion on usage of constants in ZF2 application configuration
[19:22] <EvanDotPro> :) no rush
[19:27] <Thinkscape> So ... I feel like in this discussion on using constants inside config files, there are literaly 2 constants we're talking about: APPLICATION_ENV and APPLICATION_PATH. These are most important ones.
[19:28] <Thinkscape> But.... with recent changes in ZF2 core, APPLICATION_ENV is reflected with different config files being loaded --- so it's irrelevant
[19:28] <Thinkscape> APPLICATION_PATH on the other hand does not make any sense, as we do not use application path...
[19:28] <Thinkscape> there is no application/ dir per se, as modules go into modules/, vendor into vendor/ and config into config/
[19:29] <Thinkscape> So by definition --- path definitions should be >RELATIVE<
[19:29] <Thinkscape> For example: modules.somemodulewithsqlite.sqlite.params.file = "data/db.sqlite"
[19:29] <Thinkscape> Which means: ./data/db.sqlite
[19:29] <Thinkscape> Absolute paths should be prepended with a slash:
[19:30] <Thinkscape> modules.somemodulewithsqlite.sqlite.params.fi
@Thinkscape
Thinkscape / gist:1772600
Created February 8, 2012 19:26
Conceptual description of zf2 AssetManager event-driven inter-module workflow
1) AssetManager module init(): register "resources.collectPath" event with Mod.Manager
2) Other modules' init(): attach listener to "resources.collectPath"
3) Application runs...
4) $this->locator->assetManager->injectCSS();
5) AssetManager: $events->trigger("resources.collectPath").
6) listeners in modules do: $r = $event->getTarget(); $r[] = __DIR__ .'/css/main.css"
7) AssetManager: receives a whole collection of paths
8) AssetManager: merge, minify, output
@Thinkscape
Thinkscape / isAssocArrayBench.php
Created March 3, 2012 11:35
A benchmark of several methods for checking if PHP array is associative
<?php
if(!isset($argv[1])){
echo "Usage: ".$argv[0]." (number of iterations)\n";
exit(1);
}
/**
* Arrays to check
*/
$tests = array(
@Thinkscape
Thinkscape / smstools-utf8-to-ucs2.sh
Created March 27, 2012 11:28
SMSTools support for sending UTF-8 SMS messages.
#!/bin/bash
#
# This script converts SMS encoded with UTF-8 to UCS2 format expected by smsd.
# To use it, edit your /etc/smsd.conf and add the following line:
#
# checkhandler = /path/to/smstools-utf8-to-ucs2.sh
#
# When creating a new message in /var/spool/outgoing/, add the following header line:
#
# Alphabet: UTF-8