Skip to content

Instantly share code, notes, and snippets.

View iksi's full-sized avatar
🤞

Jurriaan iksi

🤞
View GitHub Profile
@iksi
iksi / async-css.js
Last active August 29, 2015 14:10
Load css file without blocking rendering.
(function (s) {
"use strict";
var e,
p;
// Load CSS
e = document.createElement("link");
p = document.getElementsByTagName("head")[0];
e.rel = "stylesheet";
e.href = s;
e.media = "only x";
<?php
/**
* Instructions:
*
* 1. Put this into the document root of your Kirby site
* 2. Make sure to setup the base url for your site correctly
* 3. Run this script with `php statify.php` or open it in your browser
* 4. Upload all files and folders from static to your server
* 5. Test your site
@iksi
iksi / map-array-to-key.php
Last active August 29, 2015 14:11
Map a multidimensional array to a certain key.
<?php
$results = array();
array_walk($array, function ($value, $key, $field) use(&$results) {
$results[$value[$field]] = $value;
}, $field);
@iksi
iksi / price-to-float.php
Created December 23, 2014 12:39
Price to float
// Returns False if no number given, number before decimal is
// missing and when the decimal shorter than two digits
function price_to_float($string)
{
// Remove leading and trailing whitespace
$string = trim($string);
// Check for decimal with comma first
if ( (bool) preg_match('/[+-]?[0-9]\,[0-9]{2}(\w|\b)/D', $string))
{
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@iksi
iksi / detect-svg.js
Created January 5, 2015 16:42
Detect svg support.
document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1');
// using a for loop on an object
for (key in object) {
if (object.hasOwnProperty(key)) {
object[key];
}
}
<style>
rect, line { shape-rendering: crispEdges; }
</style>
/* 16:9 example */
div {
width: 100vw;
height: 56.25vw; /* 100/56.25 = 1.778 */
background: pink;
max-height: 100vh;
max-width: 177.78vh; /* 16/9 = 1.778 */
margin: auto;
}
protected function filter($response, $arguments)
{
$data = json_decode($response);
$dom = new \DOMDocument;
$dom->loadHTML($data->html);
$iframe = $dom->getElementsByTagName('iframe')->item(0);
if ($iframe === null) {