Skip to content

Instantly share code, notes, and snippets.

View klapuch's full-sized avatar
😊
Exploring world through OOP

Dominik Klapuch klapuch

😊
Exploring world through OOP
  • ČSFD
  • Czech Republic
View GitHub Profile
@klapuch
klapuch / check-date.php
Last active March 19, 2016 18:23
Check if given data is valid DATETIME or not
<?php
function isDateTime($input): bool {
return date('Y-m-d H:i:s', strtotime($input)) === $input;
}
<?php
declare(strict_types = 1);
use Bulletpoint\Core\{
Control,
Filesystem,
Security,
Http,
Reflection,
Text,
UI,
@klapuch
klapuch / dateformatting-intl.php
Created June 15, 2016 14:22 — forked from nyamsprod/dateformatting-intl.php
Formatting Date in PHP
<?php
echo IntlDateFormatter::formatObject(
new DateTime(), //a DateTime object
"eeee dd MMMM yyyy '@' hh:mm:ss", //UCI standard formatted string
'fr_FR' //the locale
);
<?php
$arr = [
['id' => 123, 'name' => 'Joe'],
['id' => 345, 'name' => 'Sally']
];
array_column($arr, null, 'id'); // [ 123 => ['id' => 123, 'name' => 'Joe']
array_column($arr, 'name', 'id'); // [ 123 => 'Joe', 345 => 'Sally']
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]
<?php
$array = [
0 => 'A',
1 => 'B',
2 => 'C',
];
array_combine(range(1, count($array)), $array); // [1 => 'A', 2 => 'B', 3 => 'C']
<?php
echo implode(',', array_fill(0, count([1, 2, 3]), '?')); // ?,?,?
echo rtrim(str_repeat('?,', count([1, 2, 3])), ','); // ?,?,?
browser.urlbar.clickSelectsAll;true
browser.backspace_action;0
network.IDN_show_punycode;true
media.peerconnection.enabled;false
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-minimize-window true
@klapuch
klapuch / php_object_to_array.php
Created August 6, 2016 22:09 — forked from victorbstan/php_object_to_array.php
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);