This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Date.parse with progressive enhancement for ISO-8601 | |
* © 2010 Colin Snover <http://zetafleet.com> | |
* Released under MIT license. | |
*/ | |
(function () { | |
'use strict'; | |
var origParse = Date.parse; | |
Date.parse = function (date) { | |
var timestamp = origParse(date), minutesOffset = 0, struct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# | |
# http://blog.mozmonkey.com/2008/vpc-ie6-ie7-ie8-on-mac-os-x/ | |
# Requires: Q, VirtualBox | |
VERSION="$1" | |
IE_DOWNLOAD="http://download.microsoft.com/download/B/7/2/B72085AE-0F04-4C6F-9182-BF1EE90F5273/IE${VERSION}-XPSP3.exe" | |
WORK_DIR="/tmp/ievm" | |
mkdir $WORK_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function transferTo($via, $from) { | |
extract($from); | |
$path = Media::short($file, $mimeType) . DS; | |
if (is_file($file)) { | |
$checksum = hash_file('adler32', $file); | |
} elseif (is_file($via['file'])) { | |
$checksum = hash_file('adler32', $via['file']); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MoviesController extends AppController { | |
function edit($id = null) { | |
/* For a single upload */ | |
$this->data = array( | |
'Movie' => array( | |
'file' => 'transferable item here' | |
)); | |
$this->Movie->save($this->data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Attachment extends AppModel { | |
// ... | |
function beforeMake($file, $process = array()) { | |
extract($process); | |
if ($this->alias == 'Avatar' && $version != 's') { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Movie extends AppModel { | |
// ... | |
var $hasOne = array( | |
'Attachment' => array( | |
'className' => 'Media.Attachment', | |
'foreignKey' => 'foreign_key', | |
'conditions' => array('Attachment.model' => 'Movie'), | |
'dependent' => true, | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/controllers/movies_controller.php | |
class MoviesController extends AppController { | |
function edit($id = null) { | |
// ... | |
// $this->data = array( | |
// 'Movie' => array('title' => 'Vicky Cristina Barcelona'), | |
// 'Attachment' => array( | |
// 0 => array('file' => transferable item1, 'model' => 'Movie'), | |
// 1 => array('file' => transferable item2, 'model' => 'Movie'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/models/example.php | |
class Example extends AppModel { | |
var $actsAs = array('Media.Transfer'); | |
} | |
// For single uploads | |
// app/controllers/examples_controller.php | |
class ExamplesController extends AppController { | |
function edit($id = null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Example extends MediaAppModel | |
// ... | |
var $validate = array( | |
// ... | |
'extension' => array('rule' => array('checkExtension', // order: deny, allow | |
array('bin', 'class', 'dll', 'dms', 'exe'), // blacklist | |
array('jpg', 'tmp') // whitelist | |
), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CAKE_CORE_INCLUDE_PATH=/usr/local/share/cake-1.2.x.x | |
CAKE_CONSOLE=${CAKE_CORE_INCLUDE_PATH}/cake/console/cake | |
APP="/path/to/your/app" | |
MODELS="example attachments" # Models separated by one space | |
AUTO="-auto" # Enables automatic (destructive) repair! | |
if [ ! -x $CAKE_CONSOLE ] || [ ! -x $APP ]; then | |
exit 1 |