Skip to content

Instantly share code, notes, and snippets.

View paranoiq's full-sized avatar
🍵
418 I am a teepot

Vlasta Neubauer paranoiq

🍵
418 I am a teepot
View GitHub Profile
-- kontrola uzávorkování bitových operátorů
\s[|&^]\s([a-zA-Z]+::[A-Z_]|[0-9]+)+\s(!?==+|[<>]=?|<>)\s
@paranoiq
paranoiq / sql-replacements.sql
Last active August 29, 2015 14:08
variable lengh string replacements in MySQL without PCRE UDF extension
-- variable lengh replacements without PCRE UDF extension
-- replaces only one different matched string in each pass!
-- replace string of variable length with known beginning and end
SET @start = 'xxx';
SET @finish = 'yyy';
SET @replacement = '';
UPDATE `table` SET
`text` = REPLACE(
@paranoiq
paranoiq / casting.php
Created November 2, 2014 14:16
casting in PHP
<?php
class Abc {
public $a = 1;
protected $b = 2;
private $c = 3;
}
$resource = tmpfile();
@paranoiq
paranoiq / pecl_http-stub.php
Last active August 29, 2015 14:12
Generated stub file for PHP extension `http` v2.1.4
<?php
// extension: http
// version: 2.1.4
namespace {
define('http\Client\Curl\HTTP_VERSION_1_0', 1);
define('http\Client\Curl\HTTP_VERSION_1_1', 2);
define('http\Client\Curl\HTTP_VERSION_ANY', 0);
@paranoiq
paranoiq / Assert.php
Last active August 29, 2015 14:20
Tester\Assert with fixed order of parameters
<?php
namespace Dogma\Tester;
/**
* Tester\Assert with fixed order of parameters
*/
class Assert extends \Tester\Assert
{
<?php // regulární výraz pro tokenizaci českých číslovek v rozsahu 1 až 999.999 v prvním a druhém pádu
$re = "//(?<=\W)(?:(?:(?:(?:(?:(?:(?:(jed)(?:en|na|nu|né|noho|něch)|(dv)(?:a|ě|ou)|(tř)(?:i|í|ech)|(čtyř)(?:i|ech)?|(pět)i?|(šest)i?|(sedm)i?|(osm)i?|(dev)(?:ět|íti))) )?(s)(?:to|tě|ta|et|tov(?:ka|ky|ek)))? ?(?:(?:(?:(?:(?:(?:(jed)(?:en|na|nu|né|noho|něch)|(dv)(?:a|ě|ou)|(tř)(?:i|í|ech)|(čtyř)(?:i|ech)?|(pět)i?|(šest)i?|(sedm)i?|(osm)i?|(dev)(?:ět|íti))a)|(jed)na)(?:(dvacet)i?|(třicet)i?|(čtyřicet)i?|(padesát)i?|(šedesát)i?|(sedmdesát)i?|(osmdesát)i?|(devadesát)i?))|(?:(?:(dvacet)i?|(třicet)i?|(čtyřicet)i?|(padesát)i?|(šedesát)i?|(sedmdesát)i?|(osmdesát)i?|(devadesát)i?)(?: (?:(jed)(?:en|na|nu|né|noho|něch)|(dv)(?:a|ě|ou)|(tř)(?:i|í|ech)|(čtyř)(?:i|ech)?|(pět)i?|(šest)i?|(sedm)i?|(osm)i?|(dev)(?:ět|íti)))?)|(?:(?:(jedenáct)i?|(dvanáct)i?|(třináct)i?|(čtrnáct)i?|(patnáct)i?|(šestnáct)i?|(sedmnáct)i?|(osmnáct)i?|(devatenáct)i?))|(?:(?:(jed)(?:en|na|nu|né|noho|něch)|(dv)(?:a|ě|ou)|(tř)(?:i|í|ech)|(čtyř)(?:i|ec
<?php // regular expression for tokenization of english numerals from 1 to 999.999
$re = "/(?<=\W)(?:(?:(?:(?:(?:(?:(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))) )?(hundred)s?)? ?(?:and )?(?:(?:(?:(?:(twenty)|(thirty)|(forty)|(fifty)|(sixty)|(seventy)|(eighty)|(ninety))(?:[- ]?(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)))?)|(?:(?:(eleven)|(twelve)|(thirteen)|(fourteen)|(fifteen)|(sixteen)|(seventeen)|(eighteen)|(nineteen)))|(?:(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)))|(?:(ten))))?) )?(thousand)s?)? ?(?:(?:(?:(?:(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))) )?(hundred)s?)? ?(?:and )?(?:(?:(?:(?:(twenty)|(thirty)|(forty)|(fifty)|(sixty)|(seventy)|(eighty)|(ninety))(?:[- ]?(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)))?)|(?:(?:(eleven)|(twelve)|(thirteen)|(fourteen)|(fifteen)|(sixteen)|(seventeen)|(eighteen)|(nineteen)))|(?:(?:(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)))|(?:(ten))
DROP FUNCTION IF EXISTS `GENERATE_DELETE_TRIGGER`;;
CREATE DEFINER=`vlasta`@`%` FUNCTION `GENERATE_DELETE_TRIGGER`(`src` varchar(128), `dst` varchar(128)) RETURNS text CHARSET utf8
READS SQL DATA
COMMENT 'generuje kód pro vytvoření zálohovacího triggeru (AD)'
BEGIN
DECLARE src_schema, src_table, dst_schema, dst_table VARCHAR(64);
DECLARE output TEXT DEFAULT '';
DECLARE col_name, x_schema, x_table VARCHAR(64);
DECLARE nullable VARCHAR(3);
DROP FUNCTION IF EXISTS `GENERATE_UPDATE_TRIGGERS`;;
CREATE DEFINER=`vlasta`@`%` FUNCTION `GENERATE_UPDATE_TRIGGERS`(`src` varchar(130)) RETURNS text CHARSET utf8
READS SQL DATA
COMMENT 'generuje kód pro vytvoření update triggerů (BI, BU)'
BEGIN
DECLARE src_schema, src_table VARCHAR(64);
DECLARE output TEXT DEFAULT '';
DECLARE col_name, x_schema, x_table VARCHAR(64);
DECLARE nullable VARCHAR(3);