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 | |
final class FisherYatesShuffle | |
{ | |
/** | |
* Shuffle an input sequence by Fisher-Yates-Shuffle. | |
* | |
* @url https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle | |
* | |
* @param array $input Array to shuffle |
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
const getAbsoluteWidth = (element) => { | |
const style = window.getComputedStyle(element); | |
const attrs = ['width', 'padding-left', 'padding-right', 'margin-left', 'margin-right']; | |
return attrs | |
.map((k) => parseInt(style.getPropertyValue(k), 10)) | |
.reduce((p, c) => p + c); | |
}; |
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
const getAbsoluteHeight = (element) => { | |
const style = window.getComputedStyle(element); | |
const attrs = ['height', 'padding-top', 'padding-bottom', 'margin-top', 'margin-bottom']; | |
return attrs | |
.map((k) => parseInt(style.getPropertyValue(k), 10)) | |
.reduce((p, c) => p + c); | |
}; |
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
public function readCSVWithHeaders($csvString, $delimiter = ';') | |
{ | |
$rows = explode("\n", str_replace("\r", '', $csvString)); | |
$headers = str_getcsv(array_shift($rows), $delimiter); | |
return array_map(function ($row) use ($headers, $delimiter) { | |
return array_combine($headers, str_getcsv($row, $delimiter)); | |
}, array_filter($rows, function($row) { | |
return !empty($row); | |
})); |
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 getUrlHost(url) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
return parser.hostname; | |
} |
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 requireCSS(url) { | |
var cssLink = document.createElement("link"); | |
cssLink.href = url; | |
cssLink.type = "text/css"; | |
cssLink.rel = "stylesheet"; | |
document.getElementsByTagName("head")[0].appendChild(cssLink); | |
} |
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
############################################################################## | |
# INSTALL isolated PHP 5.6 ZTS (Thread-safe) with pthreads on Ubuntu 14.04 ### | |
############################################################################## | |
1) Install necessary bison version | |
wget http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb | |
wget http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb | |
dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb | |
dpkg -i bison_2.7.1.dfsg-1_amd64.deb |