This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//we use double quotes to avoid having to escape the single quote within the city of L'Aquila | |
//accents are not html encoded: use UTF8 to ensure they will not be transformed to something strange | |
$provinces = array ( | |
'AG' => "Agrigento", | |
'AL' => "Alessandria", | |
'AN' => "Ancona", | |
'AO' => "Aosta", | |
'AR' => "Arezzo", | |
'AP' => "Ascoli Piceno", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//an array of countries indexed by their country code | |
//names do NOT contain special or accented chars | |
$countriesByCountryCode = array ( | |
'AF' => 'Afghanistan', | |
'AX' => 'Aland Islands', | |
'AL' => 'Albania', | |
'DZ' => 'Algeria', | |
'AS' => 'American Samoa', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//make sure the function is not already there ;-) | |
if (!function_exists('ereg')) | |
{ | |
//@see https://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php | |
//@see http://php.net/manual/en/function.ereg.php | |
//@see http://php.net/manual/en/function.preg-match.php | |
function ereg($pattern, $string, $matches = null) | |
{ | |
//quote delimiters, if already present in the pattern (ereg does not have delimiters) | |
$pattern = preg_quote($pattern, '~'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to remove duplicate items, using "key" as comparison (other keys are not considered) | |
*/ | |
function ereUniques(arr, key) { | |
var len = arr.length; | |
var seen = []; | |
var final = []; | |
var finalCounter = 0; | |
var i, innerItem; | |
for (i = 0; i < len; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//to be used when you are not really sure about the outcome of a comparison, or when you get an "unexpected" result | |
$a = array( 'a', 0, '0', false, null, ); | |
$b = $a; | |
foreach($a as $temp) { | |
foreach($b as $meow) { | |
echo var_export($temp, true) . ' == ' . var_export($meow, true) . ' : ' . var_export($temp == $meow, true); | |
echo '<br>'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function takes a random string and returns an hex color in the 6-digits format | |
* | |
* @param string $input | |
* | |
* @return string | |
*/ | |
function meow_str_to_hex_color($input) { | |
//characters that we do not want into an hex color | |
$replace = range('g', 'z'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needed built-in modules | |
import random | |
# Randomic names for "whatever" | |
class MyRandomName: | |
"""Class used to create randomized names based on syllables-ish lists | |
Tested with Python 3.6 | |
See: https://pyfiddle.io/fiddle/ea12ddcc-d989-4d87-9a62-836aa1e4b624/?i=true | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$countries = array ( | |
'AF' => | |
array ( | |
'alpha2' => 'AF', | |
'alpha3' => 'AFG', | |
'full' => 'Afghanistan', | |
), | |
'AL' => | |
array ( | |
'alpha2' => 'AL', |