Skip to content

Instantly share code, notes, and snippets.

View JakubTesarek's full-sized avatar
🏠
Working from home

Jakub Tesárek JakubTesarek

🏠
Working from home
View GitHub Profile
@JakubTesarek
JakubTesarek / interview.php
Last active March 16, 2018 11:15
Interview question for PHP developers
<?php
/*
Objectives:
- Create PHP script that will translate input data to expected output from example below.
- Calculate time complexity of your script
bonus: Implement solution that will not use pass-by-reference and will not use objects
*/
$input = [
'A' => 1,
@JakubTesarek
JakubTesarek / .bashrc
Last active October 27, 2021 19:59
.bashrc file with useful shortcuts. The file can update itself using `updaterc`. Also contains detection of platform it's running on
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
# Detect platform
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
platform='freebsd'
@datayja
datayja / array_group_by.php
Last active December 16, 2015 09:49
Group by operation implemented in PHP on arrays.
<?php
function array_group_by (array $array, callable $mapping)
{
$buckets = [];
foreach ($array as $item) {
$key = $mapping($item);
if (!isset($buckets[$key])) {
$buckets[$key] = [$item];
} else {
$buckets[$key][] = $item;