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 / TheUnexpectedFizzBuzz.php
Last active March 10, 2020 13:54 — forked from gfabrizi/TheUnexpectedFizzBuzz.php
A different (...veeeery different) approach to the good old PHP FizzBuzz test
#!/usr/bin/env php
<?php
if ($argc !== 2 || !ctype_digit($argv[1]))
die('You must specifiy only one parameter: the max number as an integer' . PHP_EOL);
for ($input = (int) $argv[1], $i = 0; $i < $input; ) echo ([
0 => 'FizzBuzz',
3 => 'Fizz', 6 => 'Fizz', 9 => 'Fizz', 12 => 'Fizz',
5 => 'Buzz', 10 => 'Buzz',
@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
@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 / 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 / docblock_parser.php
Created October 4, 2013 08:18
PHP - DocBlock Parser
<?php
/**
* Title
*
* Description
* Description
* Description
*
* @author Fabio
@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 / 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 / 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 / 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 / combos.php
Last active April 22, 2024 05:18 — 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)