Skip to content

Instantly share code, notes, and snippets.

@dopsmain
dopsmain / nginx-opencart3
Created May 7, 2021 07:17
nginx config for opencart 3
server {
root /var/www/demo;
index index.php index.html;
server_name www.demo.com demo.com;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/xml+rss text/javascript;
@dopsmain
dopsmain / plugin.mailnotify.php
Created April 17, 2019 12:21 — forked from AgelxNash/plugin.mailnotify.php
Плагин для MODX Evolution отправляющий уведомление на почту указанную в документе при сохранении этого же документа (имеется проверка на заполненность обязательного поля во время сохранения). Помимо этого плагин сохраняет в ТВ параметр статус отправки письма. И если все хорошо, то при повторном редактировании письмо не отправляется. Но для этого…
<?php
/**
* MailNotify
*
* Отправка уведомлений на почту пользователю при публикации документа
*
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
* @author Agel_Nash <[email protected]>
* @version 0.1
*
server {
server_name <домен>;
root <абсолютный путь к директории с движком>;
index index.php;
location / {
root <абсолютный путь к директории с движком>;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
@dopsmain
dopsmain / eloquent-cheatsheet.php
Created October 1, 2017 10:55 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@dopsmain
dopsmain / edit_item.php
Created April 19, 2017 13:58 — forked from nicksheffield/edit_item.php
Edit in place using ajax and contenteditable
<?php
// quit script if you aren't accessing it with ajax
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) == false){
die();
}
// include database class
include('database.class.php');
@dopsmain
dopsmain / localga.js
Created March 14, 2017 09:55 — forked from kirps/localga.js
Replace default ga.js location with local file.
$(document).ready(function(e) {
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
//ga.src = ('https:' == document.location.protocol ? '<a href="https://ssl">https://ssl</a>' : '<a href="http://www">http://www</a>') + '.<a href="http://google-analytics.com/ga.js">google-analytics.com/ga.js</a>';
//replace the google provided src attribute with the local file starting from the www directory
ga.src = 'ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
});
@dopsmain
dopsmain / Slim App
Created February 2, 2017 09:11 — forked from dylanburkey/Slim App
Slim MySQLi Integration
<?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(); $app->get('/', function () use ($app) {
require_once 'lib/mysql.php';
$db = connect_db();
$result = $db->query( 'SELECT id, name, job FROM friends;' );
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ) {
$data[] = $row;
}
@dopsmain
dopsmain / modx-snippets.php
Created September 8, 2016 09:08 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
<?php
/**********************************************************
* Update inventory stock through amazon mws api
*
***********************************************************/
$sku1 = '10101-AM';
$quantity1 = '9';
$leadTimeToShip1 = '7';
<?php
/*
* OnFileManagerUpload.
*/
switch ($modx->event->name) {
case 'OnFileManagerUpload':
$generator = $modx->newObject('modResource');
$bases = $source->getBases($directory);
$fullPath = $bases['pathAbsolute'].ltrim($directory,'/');
$directory = $source->fileHandler->make($fullPath);