Skip to content

Instantly share code, notes, and snippets.

View cronfy's full-sized avatar
🎯
Focusing

Олег Петрачев cronfy

🎯
Focusing
  • Санкт-Петербург
View GitHub Profile
@cronfy
cronfy / remove_closing_tags.sh
Last active February 10, 2017 05:31 — forked from lorenzo/remove_closing_tags.sh
Script to remove all closing ?> php tags in a folder
#!/bin/bash
###
echo "Use PHP_CodeSniffer: https://github.com/squizlabs/PHP_CodeSniffer"
echo
echo "Rules:"
echo " * PSR2.Files.ClosingTag"
echo " * PSR2.Files.EndFileNewline"
echo " * Generic.Files.LineEndings"
@cronfy
cronfy / icon-padding.svg
Created February 14, 2017 12:46
SVG icon with padding
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cronfy
cronfy / convertShortOpenTags.sh
Last active September 26, 2017 16:33 — forked from peterjaap/convertShortOpenTags.sh
PHP: Replace short open tag <? with full form <?php
# Uncomment last line if you want to replace <?= with <?php echo
find . -type f -iname '*.php' -print0 |
xargs -0 sed -i \
-e 's/<? /<?php /g' \
-e 's/<?$/<?php/' \
-e 's/<?\/\//<?php \/\//g' \
-e 's/<?\/\*/<?php \/\*/g' \
# -e 's/<?\=/<?php echo /g'
# fast and explore
SERVER=xxx
WWWROOT=/home/bitrix/www
# fast and explore
cd public_html
# первая часть exlude для ускорения на первом этапе, чтобы просто увидеть все, что скачается, и при необходимости
@cronfy
cronfy / yii2-active-record-save-new-as-existing.php
Created March 17, 2019 18:26
yii2 save new record instead of existing in db (replace with new object)
Допустим, есть объект yii2 ActiveRecord, созданный как $model = new Model().
А надо сохранить его в БД вместо существующей записи.
Казалось бы, $model->id = <существующий id> ; $model->save(), но нет.
Надо сделать подготовительную работу:
<?php

Midnight commander portable (mc portable) for Linux x86_64.

If you do not have root on server, and there is no mc, but you need it, just download mc-portable.tar.gz from this gist, extract into user's home ~/ and enjoy.

@cronfy
cronfy / makedevpwd.sh
Last active April 11, 2020 21:55
Make .htaccess and .htpasswd for dev
#!/usr/bin/env bash
# Creates .htaccess and .htpasswd in current directory to protect site with password
# Default login/password are dev/dev
[ -e .htaccess ] && {
echo " !! .htaccess already exists! Exiting." >&2
exit 1
}
@cronfy
cronfy / make-bitrix-cron.sh
Last active June 2, 2020 07:52
Creates lines for crontab for bitrix
#!/usr/bin/env bash
BITRIX_WWW_DIR="$1"
[ -z "$BITRIX_WWW_DIR" ] && BITRIX_WWW_DIR="."
[ ! -d "$BITRIX_WWW_DIR" ] || [ ! -d "$BITRIX_WWW_DIR/bitrix" ] || [ ! -f "$BITRIX_WWW_DIR/index.php" ] || [ ! -d "$BITRIX_WWW_DIR/bitrix/php_interface" ] && {
if [ "$BITRIX_WWW_DIR" = "." ] ; then
echo " !! Bitrix not found in current directory." >&2
else
@cronfy
cronfy / wtf-changing-dom-element.js
Created November 28, 2020 16:23
WTF javascript is changing element in a DOM?
// who is changing element in DOM?
const element = $0
const callback = function () {
console.trace('here is who and how')
}
const observer = new MutationObserver(callback)