Skip to content

Instantly share code, notes, and snippets.

View maxpoletaev's full-sized avatar

Max Poletaev maxpoletaev

  • Belgrade, Serbia
View GitHub Profile
@maxpoletaev
maxpoletaev / import.php
Created November 30, 2012 10:51
Advanced miniShop console import
<?php
// Вывод ошибок
ini_set('display_errors', 1);
ini_set('memory_limit', '512M');
error_reporting(E_ERROR);
// Подключаем
define('MODX_API_MODE', true);
require dirname(dirname(dirname(__FILE__))).'/index.php';
@maxpoletaev
maxpoletaev / xmlrpc.py
Last active December 17, 2015 14:39
CookieTransport for xmlrpclib
import xmlrpclib
def xmlrpc(url):
api = xmlrpclib.Server(url, transport=CookieTransport())
return api
class CookieTransport(xmlrpclib.Transport):
cookies = []
@maxpoletaev
maxpoletaev / getResourceField.php
Last active December 17, 2015 19:39
Snippet for MODx Revolution. Displays the desired field from the resource.
<?php
if (!isset($id) || !isset($field)) return;
$resource = $modx->getObject('modResource', $id);
if (!$resource) return;
$data = $resource->toArray();
if (isset($data[$field])) {
return $data[$field];
@maxpoletaev
maxpoletaev / AutoRedirect.php
Last active December 20, 2015 09:59
Autoredirect to parent resource if resource not exists for MODx Revolution (plugin)
<?php
if ($modx->event->name == 'OnPageNotFound') {
$config = $modx->getConfig();
$uri = explode('/', $_SERVER['REQUEST_URI']);
array_shift($uri);
array_pop($uri);
return $modx->sendRedirect(
/**
* Preloading images.
* @public
*
* @param {Object} images
* @param {Function} callback
*/
function preloadImages(images, callback) {
var callback = callback || null;
@maxpoletaev
maxpoletaev / msVendors.php
Created November 22, 2013 09:17
Snippet for MiniShop2. Get vendors from category.
<?php
$pdo = $modx->getService('pdoTools');
$fieldName = $modx->getOption('fieldName', $scriptProperties, 'vendor');
$fieldClass = $modx->getOption('fieldClass', $scriptProperties, '');
$firstOption = $modx->getOption('firstOption', $scriptProperties, '');
$parent = $modx->getOption('parent', $scriptProperties, 0);
$depth = $modx->getOption('depth', $scriptProperties, 10);
$limit = $modx->getOption('limit', $scriptProperties, 100);
$tplOuter = $modx->getOption('tplOuter', $scriptProperties, '@INLINE <select name="[[+name]]" class="[[+class]]">[[+rows]]</select>');
module.exports = function(bh) {
/**
* @block b-page
*/
bh.match('b-page', function(ctx) {
ctx.tag('body');
var html = {
tag: 'html',
module.exports = function(config) {
config.node('pages/index', function(nodeConfig) {
nodeConfig.addTechs([
[ require('enb/techs/file-provider'), { target: '?.bemdecl.js' } ],
[ require('enb/techs/file-provider'), { target: '?.bemjson.js' } ],
[ require('enb/techs/levels'), { levels: getLevels(config) } ],
require('enb/techs/html-from-bemjson'),
require('enb-stylus/techs/css-stylus-with-autoprefixer'),
@maxpoletaev
maxpoletaev / .jscsrc
Created April 21, 2014 21:31
Configuration for JSRC
{
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"requireLineFeedAtFileEnd": true,
"requireRightStickedOperators": ["!"],
"requireLeftStickedOperators": [","],
"disallowMultipleLineBreaks": true,
"requireRightStickedOperators": ["!"],
"requireLeftStickedOperators": [","],
"disallowImplicitTypeConversion": ["string"],
@maxpoletaev
maxpoletaev / grid.styl
Created April 25, 2014 10:23
Grid generator for stylus
$grid ?= {
gutter: 0
columns: 16
padding: 20px
}
.grid
float: left
box-sizing: border-box
border-left: $grid.gutter solid transparent