Skip to content

Instantly share code, notes, and snippets.

Avatar

Artur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / mod_flvx.c
Created Aug 2, 2011
FLV streaming module for Apache2
View mod_flvx.c
/**
* 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 Aug 10, 2011
Very simple performance comparison - arrays vs objects (PHP 5.3.6)
View gist:1136563
# 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 Aug 26, 2011
ZF2 Front Controller Debugger plugin
View Debug.php
<?php
namespace Zend\Controller\Plugin;
use Zend\Controller;
use Zend\Controller\Request;
use Zend\Controller\Plugin\AbstractPlugin;
class Debug extends AbstractPlugin
{
protected $_logger;
View gist:1217290
---------- PROPOSAL 1 --------------------
* directory names in plural form
* assets grouped by purpose
------------------------------------------
/application
/library
/Zend
/OtherVendor
/modules
/Statistics
@Thinkscape
Thinkscape / gist:1217418
Created Sep 14, 2011
ZF2 IRC Meeting 2011-09-14
View gist:1217418
[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 Sep 22, 2011
PSR-0 Final Proposal (PHP Standards Working Group)
View PSR-0-final-proposal.md

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 Dec 1, 2011
Discussion on usage of constants in ZF2 application configuration
View gist:1415354
[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 Feb 8, 2012
Conceptual description of zf2 AssetManager event-driven inter-module workflow
View gist:1772600
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 Mar 3, 2012
A benchmark of several methods for checking if PHP array is associative
View isAssocArrayBench.php
<?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 Mar 27, 2012
SMSTools support for sending UTF-8 SMS messages.
View smstools-utf8-to-ucs2.sh
#!/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