Skip to content

Instantly share code, notes, and snippets.

@tolanych
tolanych / backup.sh
Created July 16, 2020 12:06
dev-mysqldump
# бекап из всех таблиц максимум по 100 записей
mysqldump mydatabase --where="true limit 100" | gzip > mydatabase.sql.gz
@tolanych
tolanych / chunk.TicketForm
Created June 2, 2020 06:29
TicketForm CSS preloader
<div class="col-md-6 move-right">
<input type="button" class="btn btn-primary publish" name="publish" value="[[%ticket_publish]]" title="" />
<div class="spinner-border" style="display:none; float: left; width: 2rem; height: 2rem;"></div>
<style>
.form-actions .btn:disabled + .spinner-border {display:block!important}
</style>
<input type="submit" class="btn btn-danger draft" name="draft" value="[[%ticket_draft]]" title="Ctrl + Shift + Enter" />
</div>
@tolanych
tolanych / gist:8e9ec6bf26085bd835d2f7f06260ab08
Created January 29, 2020 09:27
MYSQL dump get tablenames
sed -n 's/CREATE TABLE IF NOT EXISTS //p' sqldump.sql
@tolanych
tolanych / resetAction.php
Created January 27, 2020 19:55
сброс обратного счетчика с 2 дней до 5
<?php
$date = $modx->getOption("date_endless_action");
if ($date) {
$dt = strtotime($date);
$now = time();
if ($now + 172840 >= $dt) {
$new = date(DATE_ISO8601, $dt + 259200);
$modx->setOption("date_endless_action",$new);
$response = $modx->runProcessor('system/settings/update', array(
'key' => 'date_endless_action',
@tolanych
tolanych / MODX clear resources cache
Created January 11, 2020 08:31
Почистить кэш MODX Revo через консоль/скрипт
<?php
$resources = $modx->getCollection('modResource');
foreach ($resources as $find_order) {
$cacheKey = $find_order->getCacheKey();
$modx->cacheManager->refresh(array(
'resource' => array('key' => $cacheKey),
));
}
$modx->cacheManager->refresh();
@tolanych
tolanych / main.js
Created December 27, 2019 08:45 — forked from TrywaR/main.js
MODX Revo > Обработка картинок в контенте
/*_____________________ VeryLazy ______________________*/
// - Подгрузка изображений в блоках при их показе на экране
block_selector = '.home ._block'; // Селектор блоков
function VeryLazy(){
if ($('html').hasClass('webp')) {
$(document).find(block_selector).each(function(index, element){
if ($(document).scrollTop() > $(this).offset().top - $(window).height()){
$(this).addClass('active').find('img[data-src],img[data-webp]').each(function() {
if ($(this).data().webp)
@tolanych
tolanych / TicketGetAuthorSubs
Last active October 15, 2020 18:50
MODX Revo Ticket - get subscribers on author
snippet TicketGetSubs
if ($profile = $modx->getObject('TicketAuthor', array('id' => $scriptProperties['userId']))) {
$properties = $profile->get('properties');
$subscribers = $properties['subscribers'];
$modx->setPlaceholder('AuthorSubs_total',count($subscribers));
}
if (empty($subscribers))
return '';
@tolanych
tolanych / php
Created January 30, 2019 12:50
modx route
<?php
switch ($modx->event->name) {
case 'OnHandleRequest':
$q = trim(@$_REQUEST[$modx->context->getOption('request_param_alias', 'q')]);
$matches = explode('/', rtrim($q, '/'));
if (count($matches) < 2 && $matches[0] != 'item') {
return;
}
$board_uri = array_pop($matches);
$board_uri = preg_split('/-/', $board_uri, 2);