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 strToSeconds(timeStr) { | |
const strParts = timeStr.split(':').reverse(); | |
let time = parseFloat(strParts[0]); | |
time += parseInt(strParts[1]) * 60; | |
if (!!strParts[2]) | |
time += parseInt(strParts[2]) * 3600; | |
return time; | |
} |
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
/* | |
* A method by @tmetler done in ES2015 | |
* Original method source http://www.timetler.com/2013/11/14/location-search-split-one-liner/ | |
*/ | |
/** | |
* Parses location.search string | |
* @return {Obeject} Search parameters | |
*/ | |
function parseSearch() { |
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
fn sum_divisors(number: u32) -> u32 { | |
let mut sum = 0; | |
let limit = if number % 2 == 0 { number / 2 } else { number / 3 }; // speeds up the process | |
for divisor in 1..limit + 1 { | |
if number % divisor == 0 { | |
sum += divisor; | |
} | |
} | |
sum + number |
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
/* | |
* Credits goes to +RichBradshaw, from whom I've learned this technique | |
*/ | |
.container .hidden-container { | |
max-height: 0; | |
overflow: hidden; | |
transition: max-height 0.2s ease; /* reverse transition*/ | |
/* remember not to put any borders, paddings here*/ | |
} | |
.container:hover .hidden-container { |
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
// Timber functions | |
add_filter('get_twig', 'add_to_twig'); | |
function add_to_twig($twig) { | |
$twig->addFilter('translate', new Twig_Filter_Function('getTranslation')); | |
return $twig; | |
} | |
function getTranslation($string){ |
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 | |
if (extension_loaded('zlib')) { | |
ob_start('ob_gzhandler'); | |
} | |
header('content-type: text/css; charset: UTF-8'); | |
header('cache-control: must-revalidate'); | |
$offset = 60 * 60; | |
$expire = 'expires: ' . gmdate('D, d M Y H:i:s', time() + $offset) . ' GMT'; | |
header($expire); |
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 areaToSVGPath($area) { | |
$mapPoints = explode(',', $area); | |
$path = "M" . $mapPoints[0]; | |
$delimiter = " "; | |
for ($i = 1; $i < count($mapPoints); $i++) { | |
$path .= $delimiter . $mapPoints[$i]; | |
$delimiter = ($delimiter === " ") ? " L" : " "; | |
} |
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
/** | |
* Draws a textBox at certain cordinates | |
* | |
* @param {object} raphaelPaper | |
* @param {type} text | |
* @param {type} cordinates | |
* @param {type} options that are additional | |
* @returns {unresolved} | |
*/ | |
function Tooltip(raphaelPaper, text, cordinates) { |