I have forgotten more than I'll ever know
Archive for February, 2011
How to fix a Corrupted Time Machine Backup (Snow Leopard)
Feb 27th
Attache to volumte that has sparsebundle for your backup.
Go to that directory. cd \Volumes\mybackup\
hdiutil attach -nomount -readwrite -noautofsck -noverify nameofmybackup.sparsebundle
/dev/disk1 Apple_partition_scheme /dev/disk1s1 Apple_partition_map /dev/disk1s2 Apple_HFSX
The next step was run fsck_hfs on the main volume.
fsck_hfs -rf /dev/disk1s2
If you get "Resource Busy errrors" Do this.
ps -ax |grep fsck
4437 ?? 0:09.33 /System/Library/Filesystems/hfs.fs/Contents/Resources/../../../../../../sbin/fsck_hfs -y /dev/disk1s2
CSS Calendar picker
Feb 25th
Limit results seen by users
Feb 8th
Here are a couple of nifty functions I came across, to limit the results that are returned in a Cake app.
When using the find() function, by default it will return all of the results. These two methods if placed in the appModel will only return results that are associated with a given user.
<?php function findMy($type, $options=array()) { if($this->hasField('user_id') && !empty($_SESSION['Auth']['User']['id'])){ $options['conditions'][$this->alias.'.user_id'] = $_SESSION['Auth']['User']['id']; return parent::find($type, $options); } else{ return parent::find($type, $options); } } function deleteMy($id = null, $cascade = true){ if (!empty($id)) { $this->id = $id; } $id = $this->id; if($this->hasField('user_id') && !empty($_SESSION['Auth']['User']['id'])){ $opt = array( 'conditions' => array( $this->alias.'.user_id' => $_SESSION['Auth']['User']['id'], $this->alias.'.id' => $id, ), ); if($this->find('count', $opt) > 0){ return parent::delete($id, $cascade); } } return false } ?>
Building Safari Extensions using Javascript
Feb 8th
If you know a little bit about HTML, CSS, and JavaScript you’re already well equipped to create a Safari extension. Since Apple’s documentation can seem intimidating, here’s a tutorial to walk you through creating your first extension, using any custom CSS or JavaScript code you write.
http://www.macworld.com/article/156941/2011/02/safariextension.html
Macworld Daily Reader brings the best Apple-related news, tips, and reviews from Macworld right to your iPad. You can read stories, save them for later, see what’s happening right now, and share stories with friends! Learn more at http://www.macworld.com/dailyreader
Accessing user_id in CakePHP
Feb 8th
Add this to the model
class Foo extends AppModel { var $currentUsrId = NULL; }
Then add this to the controller
class FooController extends AppController { function beforeFilter(){ parent::beforeFilter(); $this->Foo->;currentUsrId = $this->;Auth->user('id'); } }