Skip to content

Instantly share code, notes, and snippets.

Sherif Ramadan srgoogleguy

  • United States
Block or report user

Report or block srgoogleguy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@srgoogleguy
srgoogleguy / how-to-learn.md
Created Nov 23, 2017
Learning How to Learn In the First Place
View how-to-learn.md

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 / array-visualization.md
Last active May 3, 2019
Array Visualizations in PHP
View array-visualization.md

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

View standard-deviations-by-year.csv
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 Sep 11, 2016
StackOverflow Questions [tagged php] By Month/Year
View so-questions-tagged-php.csv
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
View Classes.md
@srgoogleguy
srgoogleguy / http.md
Created Oct 31, 2014
PHP Http Interface Draft
View http.md

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 = "";
View time.php
<?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);
View keypad.php
#!/usr/local/bin/php
<?php
/**
* Keypad input over STDIN (using non-blocking I/O)
*/
$base = event_base_new();
$input = event_new();
View static.php
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
---------------------------------------------------------------------------------
@srgoogleguy
srgoogleguy / ref_info.c
Last active Sep 23, 2016
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.
View ref_info.c
/**
* 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;
You can’t perform that action at this time.