Skip to content

Instantly share code, notes, and snippets.

View srgoogleguy's full-sized avatar

Sherif Ramadan srgoogleguy

View GitHub Profile
@srgoogleguy
srgoogleguy / array-visualization.md
Last active April 19, 2023 06:32
Array Visualizations in PHP

Visualizing Array Operations in PHP

It's important to recognize that in PHP an array does not always behave like a traditional array. It's actually more representative of an ordered hashmap. Thus it maintains order, but consists of key/value pairs. A key, in a PHP array, is always unique, but can be either an integer or a string. If the string key can be cast to an integer then PHP will carry out this operation implicitly. Also, array keys do not determine the order of elements in a PHP array.

With this in mind, we can better understand how different operations, like diff, intersect, union, and merge, would be carried out on a native PHP array. Some of these operations rely on the array keys and others on the values in the array.


Table of Contents

@srgoogleguy
srgoogleguy / Classes.md
Last active April 30, 2021 14:52
PHP OOP
@srgoogleguy
srgoogleguy / how-to-learn.md
Created November 23, 2017 16:08
Learning How to Learn In the First Place

Remember that engineering is work, and no document will substitute for your own thinking, learning and experimentation.

How to Learn in the First Place

  1. Play with something.
  2. Read the documentation on it.
  3. Play with it some more.
  4. Read documentation again.
  5. Play with it some more.
@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;
Month, Year Standard deviations from previous month Standard deviation for the year
Jan, 2009 0.85048380530504 758.39186587293
Feb, 2009 0.17141534060412 758.39186587293
Mar, 2009 0.17668965877655 758.39186587293
Apr, 2009 0.088344829388276 758.39186587293
May, 2009 0.28085744268213 758.39186587293
Jun, 2009 0.52347607861411 758.39186587293
Jul, 2009 0.60127227165752 758.39186587293
Aug, 2009 0.2149284655267 758.39186587293
Sep, 2009 0.097574886190036 758.39186587293
@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
#!/usr/local/bin/php
<?php
/**
* Keypad input over STDIN (using non-blocking I/O)
*/
$base = event_base_new();
$input = event_new();
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
---------------------------------------------------------------------------------
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 / 6.php
Created December 1, 2012 06:56
Output from vld
<?php
class C extends B {}
class B extends A {}
class A {}