Skip to content

Instantly share code, notes, and snippets.

@tareko
tareko / Function.php
Created September 28, 2015 19:55
Failure to properly load model inside model as a fixture
public function lastUpdated($id) {
//Set up new Shift model only if not already set (fixes problems with testing)
if(!$this->Shift) {
App::uses('Shift', 'Model');
$this->Shift = new Shift();
}
$calendar = $this->findById($id, array(
'start_date', 'end_date'));
$lastUpdated = $this->Shift->find('all', array(
@tareko
tareko / Test function.php
Created September 15, 2015 16:25
Failure to mock
public function testsendOriginator() {
$this->_TradeRequest = new TradeRequest();
App::uses('CakeEmail', 'Network/Email');
$CakeEmail = $this->getMock('CakeEmail' , array('send'));
$CakeEmail->expects($this->any())
->method('send')
->will($this->returnValue(true));
@tareko
tareko / Trade model.php
Created August 23, 2015 22:30
Trade model saves even when TradesDetail model is absent.
<?php
App::uses('AppModel', 'Model');
/**
* Trade Model
*
* @property Users $Users
* @property Shifts $Shifts
*
* Status legend:
* 0 - Unprocessed
@tareko
tareko / gist:ca6007609aa116513e02
Created November 19, 2014 17:37
New EML footer block
<div style="float: left"><a href="http://www.sjhc.london.on.ca/"><img alt="" src="/sites/emlondon/files/homepage_blocks/xsjhc.png" style="width: 75px; height: 75px;" /><br />
SJHC</a></div>
<div style="float: left"><a href="http://www.lhsc.on.ca/About_Us/Childrens_Hospital/"><img alt="" src="/sites/emlondon/files/homepage_blocks/xchlhsc.png" style="width: 75px; height: 75px;" /><br />
Children's</a></div>
<div style="float: left"><a href="http://www.lhsc.on.ca/"><img alt="" src="/sites/emlondon/files/homepage_blocks/xlhsc.png" style="width: 75px; height: 75px;" /><br />
LHSC</a></div>
<div style="float: left"><a href="http://www.schulich.uwo.ca/"><img alt="" src="/sites/emlondon/files/homepage_blocks/xuwosmd.png" style="width: 75px; height: 75px;" /><br />
@tareko
tareko / AppController.php
Created October 23, 2014 05:09
Can't get boostcake to work..
<?php
class AppController extends Controller {
public $uses = array('User', 'Usergroup', 'Group');
var $components = array('Session',
'Auth' => array(
'loginAction' => array(
'controller' => 'users',
'action' => 'login',
),
@tareko
tareko / Actual query
Last active August 29, 2015 14:07
Very tedious db query
SELECT `Trade`.`status`, `Trade`.`user_id`, `Trade`.`user_status`, `Trade`.`token`, `Trade`.`shift_id`, `Shift`.`date`, `Shift`.`shifts_type_id`, `Shift`.`id`, `Trade`.`id` FROM `kitab`.`trades` AS `Trade` LEFT JOIN `kitab`.`shifts` AS `Shift` ON (`Trade`.`shift_id` = `Shift`.`id`) LEFT JOIN `kitab`.`trades_details` AS `TradesDetail` ON (`Trade`.`id` = `TradesDetail`.`trade_id`) WHERE ((`Trade`.`user_id` = 294) OR (`TradesDetail`.`user_id` = 294)) ORDER BY `Trade`.`status` ASC LIMIT 3
@tareko
tareko / Error message
Last active August 29, 2015 13:58
dovecot won't deliver to the right place
Apr 9 dovecot: lda(vmail): Error: User vmail doesn't have home dir set, disabling duplicate database
Apr 9 postfix/smtpd[9951]: disconnect
@tareko
tareko / main.cf
Created April 9, 2014 15:07
Postfix configuration - still going to local
$ cat main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
@tareko
tareko / configuration.h
Created April 4, 2014 20:15
How can I speed up the prints?
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
// This configuration file contains the basic settings.
// Advanced settings can be found in Configuration_adv.h
// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
//===========================================================================
//============================= DELTA Printer ===============================
//===========================================================================
@tareko
tareko / Error message
Created March 9, 2014 01:45
Can't connect to MySQL socket
$ ls -l /var/run/mysqld/mysqld.sock
srwxrwxrwx 1 mysql mysql 0 Mar 8 20:39 /var/run/mysqld/mysqld.sock
$ sudo rake db:migrate
rake aborted!
Can't connect to local MySQL server through socket 'mysql socket path (/var/run/mysqld/mysqld.sock)' (2)
/var/lib/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/var/lib/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'