total = $this->time = (float)microtime(true); $this->reset(); } public function clock() { return -$this->time + ($this->time = (microtime(true))); } public function elapsed() { return (microtime(true)) - $this->total; } public function reset() { $this->total=$this->time=(microtime(true)); } } class D { protected static $handle; protected static $growlr; protected static $config = array( 'debug' => true, 'warnings' => true, 'logfile' => 'logs/main.log', 'logmode' => 'w+', 'growl' => array( 'host' => 'localhost', 'password' => '' ) ); protected static $timers; static function initialize($config=array()) { self::$config = array_merge(self::$config, (array)$config); self::$handle = fopen(self::$config['logfile'], self::$config['logmode'], true); if(self::$config['debug']) { //"God Mode" //error_reporting(E_ALL | E_DEPRECATED | E_STRICT); error_reporting(E_ALL | E_DEPRECATED); ini_set('display_errors', 1); } else { error_reporting(0); ini_set('display_errors', 0); } } static function log($var=null, $label=null) { if(self::$config['debug']) { if(!self::$handle) { trigger_error('Failed writing to the log. ' . print_r(self::$config, true), E_USER_WARNING); return $var; } fwrite(self::$handle, self::getLogMessage($var, $label)); } return $var; } static function time($timer, $label='') { if(!isset(self::$timers)) { self::$timers = array(); } if(!isset(self::$timers[$timer])) { self::$timers[$timer] = new Timer(); return D::log(0, $label . ' | ' . $timer . ' Started '); } self::$timers[$timer]->clock(); return $label . ' | ' . self::log(round(self::$timers[$timer]->elapsed(), 4) . 's', $timer . ' | ' . $label); } static function growl($var, $label=null) { if(self::$config['debug']) { if(!isset(self::$growlr)) { try { require_once('growl.php'); self::$growlr = new Growl(self::$config['growl']['host'], self::$config['growl']['password']); self::$growlr->addNotification('log'); self::$growlr->register(); self::log(self::$growlr); } catch (Exception $e) { self::warn($a, 'growl failed'); self::$growlr = false; } } self::log($var, $label); if(self::$growlr) { try { self::$growlr->notify('log', $label, print_r($var, true)); } catch (Exception $e) { self::warn($a, 'growl failed'); self::$growlr = false; } } } return $var; } static function copy($var) { /* if(self::$config['debug']) { if(!is_string($var)) { $copy = var_export($var, true); } else { $copy = $var; } D::growl(exec('whoami')); //exec('env '); //escapeshellarg( //$cmd = 'echo "do shell script' . addslashes('echo \"' . escapeshellarg($copy) . '\" | pbcopy') . '" | osascript'; $copy = 'thing to put on your clipboard'; $apple = 'do shell script "' . addcslashes('echo ' . escapeshellarg($copy) . ' | pbcopy', '"') . '"'; $cmd = 'echo ' . escapeshellarg($apple) . ' | osascript'; echo "\n\n" . $cmd . "\n\n" . $apple . "\n\n"; exec($cmd); //exec("echo 'hmmmmmm' | /usr/bin/pbcopy"); } return self::log($var, 'Copied'); */ } static function show($var, $label='') { if(self::$config['debug']) { echo self::getDisplayMessage($var, $label); } return self::log($var, $label); } static function export($var, $label='') { if(self::$config['debug']) { echo self::getDisplayMessage(var_export($var, true), $label); } return $var; } static function getLogMessage($var, $label=null) { return "\n" . (!empty($label) ? '# ' . $label . ': ' : '') . stripcslashes(print_r($var, true)) . "\n\n -~-"; } static function getDisplayMessage($var, $label=null) { return '
' . "\n" . (!empty($label) ? '

' . $label . "

\n" : '') . '
' . htmlentities(print_r($var, true)) . '
' . "\n
"; } static function report($context, $error) { //$temp = "\n There has been an error. Context: " . $context . "\n " . "Error: " . $error . "\n Back trace:" . print_r(stacktrace(), true); //self::log($temp, 'Fatal and kinda expected error'); throw new Exception($context . ' In… ' . $error); exit($temp); } static function error($error='There has been an error') { throw new Exception($error); //exit(self::log("\n There has been an error. Message: \n" . $error . "\n Back trace:" . print_r(stacktrace(), true), 'Fatal and expected error')); } static function warn($warning='Warning') { //D::show('WHAT'); if(self::$config['warnings']) { if(!extension_loaded('xdebug')) { D::show(D::stack(), $warning); } trigger_error($warning, E_USER_WARNING); } } static function stackTrace() { return self::log(stacktrace(), 'Stack Trace'); } static function stack($label='Label') { return self::log( "\n" . join( "\n", array_reverse(array_map( function($v) { //) return ' ' . $v['function'] . '();' . "\n →" . substr(substr(@$v['file'], strlen(realpath(LOC))), 1, -4) . ' | line:' . @$v['line']; }, debug_backtrace() )) ), $label . ' - Stack Trace' ); } static function debug() { self::log(debug_backtrace()); } static function close() { if(self::$config['debug']) { fclose(self::$handle); } } } D::initialize(); A.J. Cates - Web Designer & Developer includeSnippet('includes'); ?>

Hey!

I'm A.J. Cates and this is my personal website, look around if you will, here are somethings I do:

  • PHP Development
  • CSS Based Design
  • Schematic HTML Markup

More About Me »

Tumblr

Articles

Site Updated To Wolf CMS 0.8.0

Posted by ajcates on Thu, 2 Feb 2012

I've gone ahead and updated my personal website to Wolf CMS version 0.8.0. Also I've included a Tumblr section in my main navigation.

Bowtie, your sweet little iTunes controller

Posted by ajcates on Wed, 13 May 2009

Bowtie Icon ImageBowtie is a stylish application that allows you to control iTunes while displaying album art work. This little iTunes controller boasts theming, Last.fm support, quick search and iTunes shortcuts among it's features. Oh and did I mention it's free.

Depending on the theme you choose to use will vary the functionally of Bowtie. Some themes only show the album artwork while others allow you to fully control iTunes and rate your songs. You can override some of the themes settings in the preference pane such as wether it will show on all spaces or the level at which the controller sits at. Among other settings are automatic updates, starting at login and how the application should display.

General Prefence Pane For Bowtie

Adding themes couldn't be simpler in Bowtie. Just open any ".bowTie" file, that's it. Included with the Bowtie download is one of these theme files. Bowtie's theming is all controlled via xhtml, css and JavaScript. That basically means anybody who knows how to code a website is able to create Bowtie themes. That's a lot of people. On the Bowtie website they offer a theme pack that will get you started. If your looking for even more themes I find searching on DeviantART and MacTHEMES really helpful if you know of any other sources please list them in the comments.

Lastfm LogoLast.fm support is an awesome feature just because I find the official Last.fm client to be a bit of a resource hog when compared to Bowtie. For those of you that don't know, Last.fm is a social music recommendation service that tracks your music listing habits. If you are really into music and aren't using Last.fm currently, I suggest going and signing up.

Keyboard Shortcuts Prefence Pane

Another cool feature that Bowtie is the keyboard shortcuts. I don't use the main ones as I prefer the ones that come built into the newer Mac keyboards. However I do use and love the search keyboard shortcut. It pops up this little window and when you start typing it'll search your iTunes library wicked fast, hit enter and the song will start playing your then switched back to your active application(Think Quicksilver). This is allows me to switch songs in iTunes almost effortlessly. Some of the other keyboard shortcuts include ones for Playback, Volume, Rating, and Showing/Hiding of the controller. They're all easily customizable as well.

More Articles »
includeSnippet('copyright')?>