Skip to content

Instantly share code, notes, and snippets.

Avatar

Luboš Remplík LubosRemplik

View GitHub Profile
View matching.php
public function findClient(Query $query, array $options)
{
$query->matching(
'OfferTypes', function ($q) use ($options) {
return $q->where(['OfferTypes.id' => $options['client']['offer_type_id']]);
}
);
$query->matching('Clients', function ($q) use ($options) {
return $q->where(['Clients.name' => $options['client']['name']]);
});
@LubosRemplik
LubosRemplik / gist:c79fc56571d00a403384785b94ec6e7d
Last active Mar 9, 2018
ServerRequest withAttribute / getParam fail in 3.6
View gist:c79fc56571d00a403384785b94ec6e7d
<?php
namespace Admin\Test\TestCase\View\Cell;
use Admin\View\Cell\MenuCell;
use Cake\TestSuite\TestCase;
/**
* Admin\View\Cell\MenuCell Test Case
*/
class MenuCellTest extends TestCase
View gist:0d82f7cfbb0eabd4751f22ac2a6648c9
public function edit($id)
{
$this->Crud->on('beforeFind', function(\Cake\Event\Event $event) {
$event->getSubject()->query->contain(['Roles']);
});
$this->Crud->execute();
}
@LubosRemplik
LubosRemplik / gist:88b8dcfe0c26a25baa6af2d7c0a1f4b0
Created Feb 14, 2018
Crud many-to-many save issue - edit method + request data
View gist:88b8dcfe0c26a25baa6af2d7c0a1f4b0
/**
* Method: edit
*
* Amend user entity before save
*
* {@inheritDoc}
*/
public function edit($id)
{
if ($this->request->is('put')) {
View gist:07877b83589e638e246ce8f55f918d09
SELECT `ShopProduct`.`id`, `ShopProduct`.`shop_category_id`, `ShopProduct`.`name`, `ShopProduct`.`slug`, `ShopProduct`.`meta_title`, `ShopProduct`.`meta_description`, `ShopProduct`.`meta_keywords`, `ShopProduct`. `heading`, `ShopProduct`.`overview`, `ShopProduct`.`excerpt`, `ShopProduct`.`content`, `ShopProduct`.`sorting`, `ShopProduct`.`upload`, `ShopProduct`.`status`, `ShopProduct`.`created`, `ShopProduct`.`created_by`, `ShopProduct`.`modified`, `ShopProduct`.`modified_by`, `ShopProduct`.`shop_order_item_count`, (`I18n__name`.`content`) AS `ShopProduct__i18n_name`, (`I18n__slug`.`content`) AS `ShopProduct__i18n_slug`, (`I18n__meta_title`.`content`) AS `ShopProduct__i18n_meta_title`, (`I18n__meta_description`.`content`) AS `ShopProduct__i18n_meta_description`, (`I18n__meta_keywords`.`content`) AS `ShopProduct__i18n_meta_keywords`, (`I18n__overview`.`content`) AS `ShopProduct__i18n_overview`, (`I18n__heading`.`content`) AS `ShopProduct__i18n_heading`, (`I18n__excerpt`.`content`) AS
View gist:f53f860d9f9700e0ed006eb4350d49db
$query->leftJoinWith('TicketExecutors');
$query->where(['TicketExecutors.id' => $options['request']['restrictByUserId']]);
$query->leftJoinWith('TicketOwners');
$query->orWhere(['TicketOwners.id' => $options['request']['restrictByUserId']]);
View gist:9738452
2014-03-24 12:11:34 Warning: Warning (2): finfo_open() [<a href='function.finfo-open'>function.finfo-open</a>]: Failed to load magic database at '/usr/share/misc/magic'. in [/var/www/vhosts/photographyresearchcentre.co.uk/httpdocs/02/cake/lib/Cake/Utility/File.php, line 560]
Trace:
finfo_open - [internal], line ??
File::mime() - CORE/Cake/Utility/File.php, line 560
File::info() - CORE/Cake/Utility/File.php, line 316
File::ext() - CORE/Cake/Utility/File.php, line 329
CakeResponse::file() - CORE/Cake/Network/CakeResponse.php, line 1236
MediaView::render() - CORE/Cake/View/MediaView.php, line 93
Controller::render() - CORE/Cake/Controller/Controller.php, line 948
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 194
View gist:7767141
$(window).resize(function() {
$.each($('.blog-posts'), function(key, value) {
var height = 0;
$.each($('.item', value), function(key2, value2) {
if ($(value2).height() > height) {
height = $(value2).height();
}
});
console.log(height);
$.each($('.item', value), function(key2, value2) {
View gist:7599382
# backup all rsync projects, weekly
0 11 * * 5 nice -n 19 livedrive-backup golfmore >> /home/lubos/.livedrive 2>&1
# Daily backups (weekdays)
10 10 * * 1,2,3,4,5 nice -n 19 rsync-16x "-azv --exclude-from=/home/lubos/0rsync/.exclude" vmrates:httpdocs/01/ /home/lubos/0rsync/vmrates/ vmrates >> /home/lubos/0rsync/.log/vmrates`date +\%Y-\%m-\%d`.log 2>&1
# Weekly backups
10 10 * * 1 nice -n 19 rsync-3x "-azv --exclude-from=/home/lubos/0rsync/schillings/.exclude" schillings:httpdocs/ /home/lubos/0rsync/schillings/ schillings >> /home/lubos/0rsync/.log/schillings`date +\%Y-\%m-\%d`.log 2>&1
10 10 * * 3 nice -n 19 rsync-3x "-azv --exclude-from=/home/lubos/0rsync/.exclude" gcha:httpdocs/01/ /home/lubos/0rsync/gcha/ gcha >> /home/lubos/0rsync/.log/gcha`date +\%Y-\%m-\%d`.log 2>&1
10 10 * * 5 nice -n 19 rsync-3x "-azv --exclude-from=/home/lubos/0rsync/.exclude" fitzroviapartnership:httpdocs/02/ /home/lubos/0rsync/fitzrovia/ fitzrovia >> /home/lubos/0rsync/.log/fitzrovia`date +\%Y-\%m-\%d`.log 2>&1
@LubosRemplik
LubosRemplik / gist:7023701
Created Oct 17, 2013
Use of Makefile and make
View gist:7023701
LESS_SOURCE = ./app/webroot/frontpage/css/less/style.less
CSS_TARGET = ./app/webroot/frontpage/css/style.min.css
BOOTSTRAP_SOURCE = ./app/webroot/frontpage/js/bootstrap/
JS_TARGET = ./app/webroot/frontpage/js/app.min.js
build:
@recess --compress --compile ${LESS_SOURCE} > ${CSS_TARGET}
@cat \
./app/webroot/app/js/jquery/jquery-1.10.2.min.js \
./app/webroot/app/js/jquery/jquery.cookie.js \
You can’t perform that action at this time.