Skip to content

Instantly share code, notes, and snippets.

View iksi's full-sized avatar
🤞

Jurriaan iksi

🤞
View GitHub Profile
@iksi
iksi / fluid-typography.css
Created January 14, 2016 11:45
Fluid typography between a min & max font-size and molten leading
/**
* Fluid typography between a min & max font-size and molten leading
* calc(minSize + (maxSize - minSize) * ((100vw - minPort) / (maxPort - minPort)));
*/
:root {
font-size: 100%;
}
body {
font-size: 1em;
@iksi
iksi / npm-boilerplate-package.json
Last active May 24, 2016 09:46
npm boilerplate package for web projects
{
"name": "<project>",
"private": true,
"scripts": {
"css": "postcss --use postcss-import --use postcss-modular-scale-plus --use postcss-custom-properties --use postcss-custom-media --use css-mqpacker --css-mqpacker.sort --use postcss-calc --use autoprefixer --autoprefixer.browsers 'last 2 versions' --use cssnano --cssnano.safe",
"build:css": "npm run css -- --output assets/css/full.min.css assets/css/src/index.css",
"watch:css": "npm run css -- --watch --output assets/css/full.min.css assets/css/src/index.css",
"js": "uglifyjs --no-mangle --quotes=1",
"build:js": "npm run js -- --compress drop_console=true --output assets/js/full.min.js assets/js/src/lib/*.js assets/js/src/*.js",
"watch:js": "watch 'npm run js -- --compress --output assets/js/full.min.js assets/js/src/lib/*.js assets/js/src/*.js' assets/js/src",
@iksi
iksi / spaceless.php
Last active December 15, 2015 12:56
Imitation of Django’s spaceless tag
<?php
/**
* See https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#spaceless
* Removes whitespace between HTML tags. This includes tab characters and newlines.
* Only space between tags is removed – not space between tags and text.
* Single spaces between tags are preserved as they are probably intentional.
*/
function spaceless($string) {
@iksi
iksi / sort-list.js
Created April 6, 2015 08:28
Starting point for a simple script to sort a list
var list = document.getElementById('mylist');
var items = list.childNodes;
var itemsArr = [];
for (var i in items) {
if (items[i].nodeType == 1) { // get rid of the whitespace text nodes
itemsArr.push(items[i]);
}
}
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) {
/* 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;
}
<style>
rect, line { shape-rendering: crispEdges; }
</style>
@iksi
iksi / minify-kirby.php
Last active June 2, 2018 23:40
Minify Kirby’s HTML output
/**
* Uses Alan Moore's regexp:
* http://stackoverflow.com/questions/5312349/minifying-final-html-output-using-regular-expressions-with-codeigniter
*
* Replace `echo $kirby->launch();` in Kirby’s index.php by
* the following code to minify the HTML output
* (it leaves whitespace within `<pre>` and `<textarea>` tags untouched)
*/
echo preg_replace(
'/(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!\/?(?:textarea|pre)\b))*+)
@iksi
iksi / poor-mans-cron.php
Created January 15, 2015 21:48
Poor man’s cron
<?php
/**
* Simple PHP if statement to execute recurring tasks
* by executing those when visited by a bot
*/
if (preg_match('/slurp|googlebot/i', $_SERVER['HTTP_USER_AGENT'])) {
// tasks to execute
}
// using a for loop on an object
for (key in object) {
if (object.hasOwnProperty(key)) {
object[key];
}
}