Skip to content

Instantly share code, notes, and snippets.

Avatar
🤞

Jurriaan iksi

🤞
View GitHub Profile
View camelCaseToKebabCase.js
export const camelCaseToKebabCase = (string) => {
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
};
View semaphoreci_error_2.txt
Pulling docker images...
Creating network "tmp_default" with the default driver
Creating tmp_main_run ...
Creating tmp_main_run ... done
Starting the docker image...
View semaphoreci_error_1.txt
Pulling docker images...
Creating network "tmp_default" with the default driver
Creating tmp_main_run ...
Creating tmp_main_run ... done
Starting the docker image...
View Image.js
import React from 'react';
import PropTypes from 'prop-types';
const getSrcUrl = (url, width) => `${url}?w=${width}&fm=jpg&auto=format`;
const getSrcSet = (url, widths) => widths
.map((width) => `${getSrcUrl(url, width)} ${width}w`)
.join(', ');
@iksi
iksi / delete_renditions.py
Created Jan 7, 2020
Django management command to delete Wagtail’s image renditions
View delete_renditions.py
import os, shutil
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from wagtail.images.models import Rendition
class Command(BaseCommand):
def handle(self, *args, **options):
renditions = Rendition.objects.all()
if renditions:
@iksi
iksi / path.js
Created Aug 6, 2019
vanilla js functions
View path.js
// Get deep value from object by passing path to it as an array
const path = (pathArray, nestedObject) => pathArray.reduce((object, key) => (
object && object[key] !== 'undefined' ? object[key] : undefined
), nestedObject);
@iksi
iksi / hex-to-hsl.php
Created Apr 18, 2018
convert hex to hsl
View hex-to-hsl.php
<?php
// http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
// convert hex to hsl
$hex = str_split(ltrim('#0099cc', '#'), 2);
// convert the rgb values to the range 0-1
$rgb = array_map(function($part) {
return hexdec($part) / 255;
@iksi
iksi / maintain-ratio-with-svg.html
Last active Feb 8, 2018
maintain ratio with svg (hack)
View maintain-ratio-with-svg.html
<style>
.embed {
position: relative;
}
.embed__ratio {
display: block
}
.embed__content {
@iksi
iksi / negateDecimalPoint.php
Last active Jan 26, 2018
negate possible problematic locale decimal_point for inline styles
View negateDecimalPoint.php
<?php
// negate possible problematic locale decimal_point for inline styles
$paddingTop = (float) number_format(4 / 3 * 100, 2, '.', '');
echo "padding-top:{$paddingTop}%;";
@iksi
iksi / server.php
Created Nov 3, 2017
server.php for kirby
View server.php
<?php
// removes querystrings
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $path)) return false;
// what the .htaccess would normally do
if (preg_match('/^\/panel\/(.*)/', $path)) {
$_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR . 'panel' . DIRECTORY_SEPARATOR . 'index.php';