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 | |
$array = json_decode(json_encode(simplexml_load_string(file_get_contents("http://news.yahoo.com/?format=rss"))), 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
<?php | |
function array_multi_unique($array) { | |
$tmp_ComparisonArray = $final_Array = Array(); | |
foreach($array as $key => $value) { | |
if(!in_array($value[0], $tmp_ComparisonArray)) { | |
$tmp_ComparisonArray[] = $value[0]; |
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 | |
function assoc_sort($array, $on, $order = SORT_ASC, $preserve_keys = false) { | |
$new_array = $sortable_array = array(); | |
if(count($array) > 0) { | |
foreach($array as $k => $v) { | |
if(is_array($v)) { |
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
var timestamp = Date.parse("1999-12-31 00:00:00") / 1000; |
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
// Create an object. | |
var obj = { "foo": "bar" }; | |
// Store your object as a string. | |
localStorage["data"] = JSON.stringify(obj); | |
// Retrieve your object using `JSON.parse()` | |
console.log(JSON.parse(localStorage["data"]).foo); |
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($) { | |
$.fn.getRotationDegrees = function() { | |
var angle = 0; | |
var matrix = this.css(("-webkit-" || "-moz-" || "-ms-" || "-o-") + "transform"); | |
if((typeof matrix == 'string' || matrix instanceof String) && matrix != 'none') { | |
var values = matrix.split('(')[1].split(')')[0].split(','); | |
var a = values[0]; | |
var b = values[1]; |
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 stringsArrayToIntegersArray($array) { | |
// Before : array("1", "2", "3"); | |
$array = array_map( | |
create_function('$value', 'return (int)$value;'), | |
$array | |
); | |
// After : array(1, 2, 3); |
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 | |
function exportCSV( | |
iterable $items, | |
array $allowed_columns, | |
?string $sep = ';', | |
?string $filename = 'export.csv', | |
) { | |
$output = 'sep=' . $sep . PHP_EOL; | |
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 | |
/** | |
* TODO: Have to make some verifications on a few extensions. | |
* For instance, xml can be found three times with three differents mime-types. | |
*/ | |
$mime_types_extensions = array( | |
// "application/1d-interleaved-parityfec", | |
// "application/3gpp-ims+xml", | |
// "application/activemessage", | |
"application/andrew-inset" => "ez", |
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
#!/bin/bash | |
set -e | |
PHP_VERSION=7.0.0 | |
# Dependencies | |
apt-get update | |
apt-get install -y \ |
OlderNewer