Skip to content

Instantly share code, notes, and snippets.

View fabiocicerchia's full-sized avatar
🏠
Working from home

Fabio Cicerchia fabiocicerchia

🏠
Working from home
View GitHub Profile
@fabiocicerchia
fabiocicerchia / gist:3656780
Created September 6, 2012 14:20
PHP - Convert an object to an array
/**
* Convert an object to an array.
*
* @param object $variable The object to convert.
*
* @return array
*/
function object_to_array($variable) {
// Gets the properties of the given object with get_object_vars.
if (is_object($variable) === true) $variable = get_object_vars($variable);
@fabiocicerchia
fabiocicerchia / combos.php
Last active May 1, 2024 22:02 — forked from farinspace/combos.php
PHP - Generate all the possible combinations among a set of nested arrays.
/**
* Generate all the possible combinations among a set of nested arrays.
*
* @param array $data The entrypoint array container.
* @param array $all The final container (used internally).
* @param array $group The sub container (used internally).
* @param mixed $val The value to append (used internally).
* @param int $i The key index (used internally).
*/
function generate_combinations(array $data, array &$all = array(), array $group = array(), $value = null, $i = 0)
@fabiocicerchia
fabiocicerchia / auto_prepend_file.php
Created June 25, 2013 13:17
PHP - Highlight PHP errors
<?php
function checkErrors()
{
$errorMessage = 'This web page contains errors! Go and check it out in the error_log (' . ini_get('error_log') . ').';
$outputContent = ob_get_clean();
$errors = error_get_last();
// If there is at least one error...
if (!empty($errors)) {
@fabiocicerchia
fabiocicerchia / BlackHole.php
Created October 1, 2013 08:39
PHP - Black Hole Class
<?php
/**
* Black Hole Class.
*
* This class could be used as testing class.
*/
class BlackHole
{
/**
@fabiocicerchia
fabiocicerchia / fingerprint.html
Created October 1, 2013 08:41
JavaScript - Browser Fingerprint
<html>
<head>
<script src="http://www.myersdaily.org/joseph/javascript/md5.js" type="text/javascript"></script>
<script type="text/javascript">
var SEP = '|';
var ua = window.navigator.userAgent.toLowerCase();
var opera = ua.indexOf('opera') >= 0 || ua.indexOf('opr') >= 0;
var ie = ua.indexOf('msie') >= 0 && !opera;
/**
@fabiocicerchia
fabiocicerchia / perf.php
Last active December 24, 2015 09:09
PHP - Performance Benchmark (Skeleton to compare two algorithms)
<?php
function test1() {
}
function test2() {
}
function init() {
}
@fabiocicerchia
fabiocicerchia / docblock_parser.php
Created October 4, 2013 08:18
PHP - DocBlock Parser
<?php
/**
* Title
*
* Description
* Description
* Description
*
* @author Fabio
@fabiocicerchia
fabiocicerchia / events.js
Last active March 19, 2018 16:27
JavaScript - Get events bound to DOM elements
/**
* Event Container Class
*/
var EventContainer = function () {
/**
* The Event Container.
*
* @property container
* @type {Object}
* @default {}
@fabiocicerchia
fabiocicerchia / programmerexcuses.md
Last active January 26, 2016 21:23
programmerexcuses.com

http://programmerexcuses.com/
© Copyright 2012 - 2014 programmingexcuses.com - All Rights Reserved

  • Actually, that's a feature
  • Did you check for a virus on your system?
  • Don't worry, that value is only wrong half of the time
  • Even though it doesn't work, how does it feel?
  • Everything looks fine my end
  • How is that possible?
  • I broke that deliberately to do some testing
@fabiocicerchia
fabiocicerchia / .htaccess
Last active December 27, 2018 10:53
Apache - PUT - 405 Method Not Allowed
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.+$ - [NC,L]
RewriteCond %{REQUEST_METHOD} (PUT|DELETE)
RewriteRule .* put.php