Skip to content

Instantly share code, notes, and snippets.

View geforester's full-sized avatar
🚀
Focusing

Roman Ilin geforester

🚀
Focusing
View GitHub Profile
// Удаление элемента из массива.
// String value: значение, которое необходимо найти и удалить.
// return: массив без удаленного элемента; false в противном случае.
Array.prototype.remove = function(value) {
var idx = this.indexOf(value);
if (idx != -1) {
// Второй параметр - число элементов, которые необходимо удалить
return this.splice(idx, 1);
}
@geforester
geforester / delete-files.ps1
Created May 10, 2017 20:37
Remove files on PowerShell by mask
Get-ChildItem "*].mp3" -recurse | foreach {$_.delete()}
@geforester
geforester / revo_helper.php
Last active January 31, 2023 00:05 — forked from zhabinka/revo_helper.php
snippets for Fenom MODX
// Получение любого поля ресурса произвольного ресурса
{1 | resource : 'pagetitle'}
// Текущий год
{'' | date : 'Y'}
//Условие IF
{$id == '1' ? '' : $url}
//Получение изображения через переменную с точкой ($_pls)
@geforester
geforester / addplace7.4-http.sh
Last active February 3, 2022 22:41
Script for add non MODX site
#!/bin/bash
# MySQL root password
ROOTPASS='password'
TIMEZONE='Europe/Moscow'
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############
@geforester
geforester / remove-7.4.sh
Last active February 3, 2022 23:02
Ubuntu 10.04 (nginx + php5-fpm): remove site including user & database
#!/bin/bash
ROOTPASS='password'
echo "Enter username to delete:"
read USERNAME
mysql -uroot --password=$ROOTPASS -e "DROP USER $USERNAME@localhost"
mysql -uroot --password=$ROOTPASS -e "DROP DATABASE $USERNAME"
rm -f /etc/nginx/sites-enabled/$USERNAME.conf
@geforester
geforester / addsite-php7.0.sh
Last active February 3, 2022 23:09
Ubuntu 10.04 (nginx + php5-fpm): Install MODX 2.2 including user, virtual host, database
#!/bin/bash
# MySQL root password
ROOTPASS='password'
TIMEZONE='Europe/Moscow'
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############