Skip to content

Instantly share code, notes, and snippets.

@condor-bird
condor-bird / test-translit.php
Created January 21, 2019 10:12
test translit
<?php
function rus2translit($string) {
$converter = array(
'а' => 'a', 'б' => 'b', 'в' => 'v',
'г' => 'g', 'д' => 'd', 'е' => 'e',
'ё' => 'e', 'ж' => 'zh', 'з' => 'z',
'и' => 'i', 'й' => 'y', 'к' => 'k',
'л' => 'l', 'м' => 'm', 'н' => 'n',
'о' => 'o', 'п' => 'p', 'р' => 'r',
'с' => 's', 'т' => 't', 'у' => 'u',
CREATE TABLE `offer`(
`_ID` INT NOT NULL,
`_IDoffers` INT NOT NULL,
`available` VARCHAR(255) NOT NULL,
`barcode` VARCHAR(255) NULL,
`categoryId` INT NULL,
`currencyId` INT NULL,
`delivery` INT NULL,
`description` TEXT NULL,
`id` INT NOT NULL,
@condor-bird
condor-bird / slick-example.html
Created June 19, 2018 16:56
Example slick jquery plugins
<div class="slider">
<div class="slide">your content</div>
<div class="slide">your content</div>
<div class="slide">your content</div>
<div>
<h1>ignore me</h1>
</div>
</div>
@condor-bird
condor-bird / php-notes.php
Last active May 12, 2018 16:46
PHP notes
<?php
preg_replace("/http:\/\/.*?\//", "", $string);
preg_replace("@^https?://[^/]+/@", "", $string);
//delete all attribute html
preg_replace("#(</?\w+)(?:\s(?:[^<>/]|/[^<>])*)?(/?>)#ui", '$1$2', $html);
@condor-bird
condor-bird / htmlspecialchars-only-code-tags.php
Created April 22, 2018 11:23
htmlspecialchars only on code tags
<?php
// htmlspecialchars only on <code></code> tags.
// test data
$textToScan = "Hi <code>test12</code><br>
Line 2 <code><br>
Test <b>Bold</b><br></code><br>
";
// the regex pattern (case insensitive & multiline
@condor-bird
condor-bird / regular-expression.php
Last active April 26, 2018 16:25
Regular expression
<?php
//поиск строки, где нет title=
<a (?![^>]*title=".+?").*?\/>
// preg_replace("#(</?\w+)(?:\s(?:[^<>/]|/[^<>])*)?(/?>)#ui", '$1$2', $html);
// \w+(?<!href|title|alt|height|width|src)=".+?"
// <([a-z][a-z0-9]*)(?:[^>]*(\shref=['\"][^'\"]*['\"]))?[^>]*?(\/?)> <$1$2$3>
@condor-bird
condor-bird / react-modal.css
Last active April 22, 2018 11:16
React modal popup example
body {
background-color: #1B2B34;
font-size: 62.5%;
font-family: sans-serif;
color: #00273B;
}
.app-cont {
display: flex;
justify-content: center;
@condor-bird
condor-bird / laravel-validate-extended.php
Created April 13, 2018 17:38
Laravel validate exteded max MB
<?php
Validator::extend('max_mb', function($attribute, $value, $parameters, $validator) {
if ( $value instanceof UploadedFile && ! $value->isValid() ) {
return false;
}
// If call getSize()/1024/1024 on $value here it'll be numeric and not
// get divided by 1024 once in the Validator::getSize() method.
$megabytes = $value->getSize() / 1024 / 1024;
return $megabytes <= $parameters[0];
@condor-bird
condor-bird / laravel-validate-tabs.html
Created April 13, 2018 17:29
Display validation error in tabs using laravel
<li class="error">{ $error }}</li>
@condor-bird
condor-bird / array_diff-json.php
Last active April 13, 2018 17:16
array_diff() with multidimensional arrays
<?php
// Compare all values by a json_encode
$diff = array_diff(array_map('json_encode', $array1), array_map('json_encode', $array2));
// Json decode the result
$diff = array_map('json_decode', $diff);