Skip to content

Instantly share code, notes, and snippets.

View srgoogleguy's full-sized avatar

Sherif Ramadan srgoogleguy

View GitHub Profile
@srgoogleguy
srgoogleguy / tailwatch.php
Created December 1, 2012 04:16
tailwatch -- Monitor your Apache httpd log with this PHP shell script in real time for more comprehensive information
#!/usr/local/bin/php
<?php
const TW_VERSION = '0.3.2';
/**
@name tailwatch
@version 0.3.2 BETA
@author Sherif Ramadan
@url http://sheriframadan.com
@description This is a PHP script for monitoring your apache httpd log from the command line.
The script requires libevent and ncurses see (http://pecl.php.net/ncurses http://pecl.php.net/libevent)
@srgoogleguy
srgoogleguy / 6.php
Created December 1, 2012 06:56
Output from vld
<?php
class C extends B {}
class B extends A {}
class A {}
linux-vdso.so.1 => (0x00007fff35fff000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f97695f5000)
libexslt.so.0 => /usr/lib/x86_64-linux-gnu/libexslt.so.0 (0x00007f97693e0000)
libtidy-0.99.so.0 => /usr/lib/libtidy-0.99.so.0 (0x00007f9769183000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f9768f67000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007f9768d25000)
libaspell.so.15 => /usr/lib/libaspell.so.15 (0x00007f9768a57000)
libmcrypt.so.4 => /usr/lib/libmcrypt.so.4 (0x00007f9768824000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9768620000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f976831f000)
@srgoogleguy
srgoogleguy / ref_info.c
Last active September 23, 2016 03:06
Implementation for a PHP function to find out which variables a given variable is currently referencing or referenced by. This function simply compares the zval pointer by iterating the active symbol table as opposed to simply checking the is_ref property of the zval to tell that it's a reference. This means two-way reference detection is possible.
/**
* Find which variables in the current scope reference which other variables.
*
* mixed ref_info ( string $variable_name )
* - Returns an associative array of variable names that are references of the supplied varriable name argument.
* Returns false on failure.
*/
PHP_FUNCTION(ref_info)
{
char *str;
googleguy@googleguy-pc:~/aa/test$ php -dvld.active=1 /tmp/static.php
Finding entry points
Branch analysis from position: 0
Return found
filename: /tmp/static.php
function name: (null)
number of ops: 9
compiled vars: none
line # * op fetch ext return operands
---------------------------------------------------------------------------------
#!/usr/local/bin/php
<?php
/**
* Keypad input over STDIN (using non-blocking I/O)
*/
$base = event_base_new();
$input = event_new();
@srgoogleguy
srgoogleguy / time.php
Last active August 29, 2015 14:04
Time Spec
<?php
/**
* Translate a clock formatted string into a sum of seconds
* e.g. toSec("3:20") == 200
*/
function toSec($clock) {
$eq = array(1, 60, 3600, 86400);
$seconds = 0;
$parts = explode(':', $clock, count($eq));
$parts = array_reverse($parts);
@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 = "";

@srgoogleguy
srgoogleguy / Classes.md
Last active April 30, 2021 14:52
PHP OOP
@srgoogleguy
srgoogleguy / so-questions-tagged-php.csv
Created September 11, 2016 15:49
StackOverflow Questions [tagged php] By Month/Year
Month Year questions
Aug '08 162
Sep '08 492
Oct '08 623
Nov '08 507
Dec '08 481
Jan '09 645
Feb '09 775
Mar '09 909
Apr '09 976