Skip to content

Instantly share code, notes, and snippets.

View StephanWeinhold's full-sized avatar

Stephan Weinhold StephanWeinhold

View GitHub Profile
@StephanWeinhold
StephanWeinhold / pagination.php
Created June 5, 2018 07:11
Numbered pagination for Datenstrom's Yellow CMS. https://github.com/datenstrom/yellow
<?php list($name, $pages) = $yellow->getSnippetArgs() ?>
<?php if($pages->isPagination()): ?>
<div class="pagination">
<?php if($pages->getPaginationPrevious()): ?>
<a class="previous" href="<?php echo $pages->getPaginationPrevious() ?>"><?php echo $yellow->text->getHtml("paginationPrevious") ?></a>
<?php endif ?>
<?php if($pages->getPaginationCount() > 1): ?>
<?php for($i = 1; $i <= $pages->getPaginationCount(); ++$i): ?>
<a class="pagination-number<?php if ($i == $pages->getPaginationNumber()) echo " active" ?>" href="<?php echo $pages->getPaginationLocation(true, $i) ?>"><?php echo $i ?></a>
<?php endfor ?>
@StephanWeinhold
StephanWeinhold / saveExternalImageToPimcore.php
Created January 11, 2017 15:07
Set an ExternalImage to a pimcore-object.
<?php
$imageObject = new Pimcore\Model\Object\Data\ExternalImage;
$imageObject->setUrl('http://www.url.com/to/your/image.jpg');
$pimcoreObject->setExternalImage($imageObject);
@StephanWeinhold
StephanWeinhold / rgbToHSL.php
Last active September 27, 2016 12:05 — forked from brandonheyer/rgbToHSL.php
PHP snippet to convert RGB to HSL and HSL to RGB.
<?php
function rgbToHsl($r, $g, $b)
{
$r /= 255;
$g /= 255;
$b /= 255;
$max = max($r, $g, $b);
$min = min($r, $g, $b);
/**
* @param string $absolutePathToCsvFile
* @param string $csvFilename
* @return array $data
* @throws Exception $e
*/
private static function readCsvFile($absolutePathToCsvFile, $csvFilename)
{
try {
$data = array_map('str_getcsv', file($absolutePathToCsvFile . '/' . $csvFilename));
@StephanWeinhold
StephanWeinhold / check-for-mobile-device.js
Last active August 29, 2015 14:27
Checks if the user is browsing via a mobile device.
function isMobileDevice {
return (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent))
}
@StephanWeinhold
StephanWeinhold / filter-table.html
Created August 14, 2015 07:38
A simple and slim filter for a HTML-table with plain JS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Filter table</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
tr {
display: none;
@StephanWeinhold
StephanWeinhold / checkIfLocalStorageIsSupported.js
Created July 27, 2015 08:28
Checks if the visitor's browser is supporting local storage.
/**
* return bool
*/
function checkIfLocalStorageIsSupported() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch (e) {
return false;
}
}