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
@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 / 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(
-- kontrola uzávorkování bitových operátorů
\s[|&^]\s([a-zA-Z]+::[A-Z_]|[0-9]+)+\s(!?==+|[<>]=?|<>)\s
@paranoiq
paranoiq / check_foreign_keys.sql
Last active December 25, 2015 16:29
vygeneruje SQL pro kontrolu integrity celé databáze, pokud někdo vypnul cizí klíče a rozbil data
SELECT
/*fk.CONSTRAINT_SCHEMA,
fk.CONSTRAINT_NAME,
fk.TABLE_NAME,
col.COLUMN_NAME,
fk.REFERENCED_TABLE_NAME,
col.REFERENCED_COLUMN_NAME,*/
CONCAT('SELECT * FROM `', fk.TABLE_NAME, '` WHERE `', col.COLUMN_NAME, '` NOT IN (SELECT `', col.REFERENCED_COLUMN_NAME, '` FROM `', fk.REFERENCED_TABLE_NAME, '`);') AS query
FROM `REFERENTIAL_CONSTRAINTS` fk
JOIN KEY_COLUMN_USAGE col USING (CONSTRAINT_SCHEMA, CONSTRAINT_NAME)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Blikátko simulátor</title>
</head>
<body>
<style>
html, body { margin: 0; padding: 0; }
</style>
@paranoiq
paranoiq / key.regexp.txt
Last active September 3, 2025 12:01
public RSA key validation regexp
#ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3} ([^@]+@[^@]+)#
// this is the most simple case. see more complete regexps in coments below
// http://generator.my-addr.com/generate_ssh_public_rsa_key-private_rsa_key-ssh_pair_online_tool.php
// https://help.ubuntu.com/community/SSH/OpenSSH/Keys
// http://www.ietf.org/rfc/rfc4716.txt
@paranoiq
paranoiq / Connection.php
Created October 11, 2011 10:29
radostnější řazení paremetrů v Nette\Database\Connection
<?php
namespace Dogma\Database;
/**
* query(), fetch?(), exec():
* New preprocesor makes dibi-like syntax possible.
* Question mark (?) is not required and *not allowed* in alternative syntax.
* eg. $db->exec("UPDATE x SET y = ", $y, "WHERE z = ", $z);
@paranoiq
paranoiq / makeScrollable.js
Created August 24, 2011 16:18
Scrollable table body
/**
* Make table body scrollable, with the table header always visible.
* Table shrinks vertically to fit the browser viewport.
*
* requirements:
* - jQuery framework required (tested with 1.6.2)
* - header must be wrapped in <thead> element
*
* warnings:
* - table <caption> is not supported
@paranoiq
paranoiq / adminer.css
Last active July 17, 2019 10:00
Paranoiqův styl pro Adminer
/**
* Alternative style for Adminer. Zrobeno 7.4.2011
* @author Vlasta Neubauer [@paranoiq]
*/
/* -- fonts ----------------------------------------------------------------- */
body {
font-size: 11pt;
}
body, select, option, optgroup, button {