Skip to content

Instantly share code, notes, and snippets.

$(function(){
$("#flashMessage,#authMessage").hide();
// $("#flashMessage").css('left', ( $(window).width()-$("#flashMessage").outerWidth()) /2 );
$("#flashMessage,#authMessage").css('top', 0).css('left',0);
$("#flashMessage,#authMessage").slideDown('fast');
setTimeout(function(){
$("#flashMessage,#authMessage").slideUp('slow')
},10000);
// $(":submit").click(function(){
// $(this).closest("form").submit();
class Article extends ArticlesAppModel {
var $belongsTo = array(
'ArticlesCategory' => array(
'className' => 'Articles.ArticlesCategory',
'foreignKey' => 'articles_category_id'
)
, 'User');
var $hasOne = array('Avatar' => array('className' => 'Image', 'foreignKey' => 'model_id', 'conditions' => array('Avatar.type' => 'hasOne', 'Avatar.model' => 'Article')));
}
<?php
/**
* Copyright 2007-2010, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2007-2010, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<?php
#Put `AppUsersController.php` in `app/Controller`
App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {
public function beforeFilter()
{
SELECT *
FROM `table`
WHERE `TableID` NOT IN (
SELECT `table`.`TableID`
FROM `table` JOIN `reservation_table`
WHERE `reservation_table`.`TableID` = `table`.`TableID`
&& `reservation_table`.`DateTime` > NOW()
&& `reservation_table`.`DateTime` < ( NOW() + INTERVAL 2 HOUR )
)
protected function _getStackTrace(Exception $e) {
$trace = $e->getTrace();
$out = array();
foreach ($trace as $frame) {
if (isset($frame['file']) && isset($frame['line'])) {
if (strpos($frame['file'], 'app') !== false){
$basename = '<span style = "color: green;text-transform:none;font-size:12px">' . basename($frame['file']) . '</span>';
}else{
$basename = basename($frame['file']);
}
@meotimdihia
meotimdihia / gist:5270063
Created March 29, 2013 10:18
Grep the process id and kill all the filtered process
kill $(ps ax | grep 'search' | awk '{print $1}')
ps ax | grep 'search' | awk '{print $1}' | xargs svn add
@meotimdihia
meotimdihia / pre-commit
Last active August 29, 2015 14:05
Check error for php files.
#!/usr/bin/php
<?php
$output = array();
$return = 0;
exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
exec("git diff-index --cached --name-only HEAD", $output);
exec("git diff-index --cached --name-only --diff-filter=D HEAD", $outputDels);
$filename_pattern = '/\.(php|ctp)$/';
@meotimdihia
meotimdihia / config.fish
Created June 26, 2018 10:07 — forked from alyssaq/config.fish
config.fish set environment variables from bash_profile
# Fish shell
egrep "^export " ~/.bash_profile | while read e
set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\1/")
set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\2/")
# remove surrounding quotes if existing
set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/")
if test $var = "PATH"
@meotimdihia
meotimdihia / config.fish
Created June 26, 2018 10:07 — forked from alyssaq/config.fish
config.fish set environment variables from bash_profile
# Fish shell
egrep "^export " ~/.bash_profile | while read e
set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\1/")
set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\2/")
# remove surrounding quotes if existing
set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/")
if test $var = "PATH"