Skip to content

Instantly share code, notes, and snippets.

View iksi's full-sized avatar
🤞

Jurriaan iksi

🤞
View GitHub Profile
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color

Keybase proof

I hereby claim:

  • I am iksi on github.
  • I am iksi (https://keybase.io/iksi) on keybase.
  • I have a public key ASBD9jM2bNQypuCqFuG4tw_rR6MMQoOYtw4cQ5WhS-PfNAo

To claim this, I am signing this object:

@iksi
iksi / copydir.php
Last active September 12, 2017 20:23
copy a directory and it's files recursively
<?php
function copyDirectory($sourceDirectory, $destinationDirectory) {
// determine the files that need to be copied
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($sourceDirectory, FilesystemIterator::SKIP_DOTS)
);
foreach ($files as $file) {
$sourcePath = $file->getPathname();
$destinationPath = $destinationDirectory . DS . $sourcePath;
// put this inside a function to check the time it takes to complete
var start = performance.now()
// do stuff
var duration = performance.now() - start
console.log(duration)
@iksi
iksi / server.php
Last active October 18, 2017 07:39
Let all other requests than file get passed to the script on duty. Use with `php -S localhost:8888 server.php`.
<?php
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'])) return false;
$_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR . 'index.php';
require_once $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'];
@iksi
iksi / server.php
Created November 3, 2017 10:52
server.php for kirby
<?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';
@iksi
iksi / server.php
Created November 3, 2017 10:52
server.php for kirby
<?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';
@iksi
iksi / negateDecimalPoint.php
Last active January 26, 2018 11:04
negate possible problematic locale decimal_point for inline styles
<?php
// negate possible problematic locale decimal_point for inline styles
$paddingTop = (float) number_format(4 / 3 * 100, 2, '.', '');
echo "padding-top:{$paddingTop}%;";
@iksi
iksi / maintain-ratio-with-svg.html
Last active February 8, 2018 12:01
maintain ratio with svg (hack)
<style>
.embed {
position: relative;
}
.embed__ratio {
display: block
}
.embed__content {
@iksi
iksi / hex-to-hsl.php
Created April 18, 2018 10:44
convert hex to hsl
<?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;