Skip to content

Instantly share code, notes, and snippets.

View KrzysztofPrzygoda's full-sized avatar

Krzysztof Przygoda KrzysztofPrzygoda

  • Poland
View GitHub Profile
@KrzysztofPrzygoda
KrzysztofPrzygoda / htpasswd.php
Last active September 19, 2022 07:37
A simple PHP .htpasswd and .htaccess generator
<pre>
<?php
/**
* A simple PHP .htpasswd and .htaccess generator
* If already present, .htpasswd is overwrittern but .htaccess is prepended with Access clousure if not found
*
* @author Krzysztof Przygoda, 2018
* @version 1.0
*/
@KrzysztofPrzygoda
KrzysztofPrzygoda / class.simplexmlelement.php
Last active April 23, 2018 14:15
PHP Filtering XML nodes based on attributes
<?php
class SimpleXMLElementExtended extends SimpleXMLElement
{
/**
* Removes or keeps nodes with given attributes
*
* @param string $attributeName
* @param array $attributeValues
* @param bool $keep TRUE keeps nodes and removes the rest, FALSE removes nodes and keeps the rest
* @return integer Number o affected nodes
@KrzysztofPrzygoda
KrzysztofPrzygoda / class.json.php
Created April 23, 2018 13:48
PHP JSON wrapper with decoding auto corrective actions
<?php
abstract class Json
{
public static function getLastError($asString = FALSE)
{
$lastError = \json_last_error();
if (!$asString) return $lastError;
// Define the errors.
@KrzysztofPrzygoda
KrzysztofPrzygoda / iframes.css
Last active May 17, 2021 04:24
Workaround to iOS WebKit iframe bugs (including Bootstrap Popover) // source https://jsbin.com/mevurem
/*
Embracing iOS WebKit weirdness with iframes
**iOS WebKit iframe bug description**:
https://bugs.webkit.org/show_bug.cgi?id=155198
**My current findings**:
1. iOS WebKit resizes iframes to the full size of their content - it's a bug known since 2016 and still not resolved in iOS 11.
2. To fit iframe contents, its div container must have w/h defined in pixels - any relative measures (like %, vw/vh) doesn't work.
// Based on: http://bonsaiden.github.io/JavaScript-Garden/#types
var types = [
{n: 'Array', c: Array, o: []},
{n: 'new Array', c: Array, o: new Array()},
{n: 'String', c: String, o: ''},
{n: 'new String', c: String, o: new String()},
{n: 'Number', c: Number, o: 0},
{n: 'new Number', c: Number, o: new Number()},
{n: 'Function', c: Function, o: function(){}},
{n: 'new Function', c: Object, o: new function(){}},