Skip to content

Instantly share code, notes, and snippets.

@jan-j
jan-j / manifest.json
Last active October 17, 2018 13:58
PWA test
View manifest.json
{
"name": "PWA Full Name 2",
"short_name": "PWA Short name 2",
"display": "standalone",
"background_color": "#3E4EB8",
"theme_color": "#2F3BA2",
"start_url": "https://s.codepen.io/jan-j/debug/ZqrxEO/gaMeYZvWQmzM",
"icons": [
{
"src": "https://pbs.twimg.com/profile_images/837725662886637568/Bhxc7Yow_400x400.jpg",
View test-1.js
const path = require('path');
const fs = require('fs');
const Canvas = require('canvas');
const targetWidth = 6000;
const targetHeight = 50;
const deltaX = 50;
const sourceWidth = deltaX * 20
const sourceHeight = targetHeight * 20;
@jan-j
jan-j / array_flatmap.php
Last active July 17, 2019 21:10
PHP array flatmap - array_flatmap function
View array_flatmap.php
/**
* Applies the callback to the elements of the given arrays, then merge all results to one array
*
* @param callable $callback Callback function to run for each element in each array.
* @param array $array1 An array to run through the callback function.
* @param array $array,... Variable list of array arguments to run through the callback function.
* @return array Returns an array containing all the elements of array1 after
* applying the callback function to each one, casting them to arrays and merging together.
*/
function array_flatmap()
@jan-j
jan-j / gist:ce8a671521c26021e140
Last active August 29, 2015 14:08
array_flatten_keys function
View gist:ce8a671521c26021e140
/**
* @param array $array
* @param string|null $keyPrefix
* @param string $format 'dot'|'form'
* @return array
*/
function array_flatten_keys($array, $keyPrefix = null, $format = 'dot')
{
$newArray = array();
@jan-j
jan-j / Print an associative array as an ASCII table
Last active August 8, 2018 07:53
My solution to the task "Print an associative array as an ASCII table". More info can be found on task author page: http://phpixie.com/blog/test-tasks-for-php-interviews-that-developers-will-enjoy-solving/
View Print an associative array as an ASCII table
<?php
const SPACING_X = 1;
const SPACING_Y = 0;
const JOINT_CHAR = '+';
const LINE_X_CHAR = '-';
const LINE_Y_CHAR = '|';
$table = array(
array(