Node
Install Node on the Nagios machine (My Nagios XI VM running CentOS… for other platforms see nodejs.org)
wget http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm sudo yum localinstall --nogpgcheck nodejs-stable-release.noarch.rpm sudo yum install nodejs-compat-symlinks npm rm nodejs-stable-release.noarch.rpm
Install the “commander” package by TJ Holowaychuk for easier option processing.
$ sudo HTTP_PROXY=$HTTP_PROXY npm install -g commander npm http GET https://registry.npmjs.org/commander npm http 200 https://registry.npmjs.org/commander npm http GET https://registry.npmjs.org/commander/-/commander-1.0.4.tgz npm http GET https://registry.npmjs.org/keypress npm http 200 https://registry.npmjs.org/keypress npm http GET https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz commander@1.0.4 /usr/lib/node_modules/commander └── keypress@0.1.0
Install PhantomJS and CasperJS
Again on the NagiosXI VM:
# Get PhantomJS and install it in /opt/ with a symlink in /usr/local/bin/ # http://phantomjs.org/download.html wget http://phantomjs.googlecode.com/files/phantomjs-1.6.1-linux-x86_64-dynamic.tar.bz2 bunzip2 phantomjs-1.6.1-linux-x86_64-dynamic.tar.bz2 tar xf phantomjs-1.6.1-linux-x86_64-dynamic.tar sudo mv phantomjs-1.6.1-linux-x86_64-dynamic /opt/ sudo ln -s /opt/phantomjs-1.6.1-linux-x86_64-dynamic/ /opt/phantomjs sudo ln -s /opt/phantomjs/bin/phantomjs /usr/local/bin/ which phantomjs # should return /usr/local/bin/phantomjs phantomjs --version # should return `1.6.1` with no errors # Check out and install the latest CasperJS with Git # http://casperjs.org/installation.html sudo yum install git -y git clone https://github.com/n1k0/casperjs.git sudo mv casperjs/ /opt/casperjs sudo ln -s /opt/casperjs/bin/casperjs /usr/local/bin/ which casperjs # should return /usr/local/bin/casperjs casperjs --version # should return `1.0.0-RC1`
I want programming computers to be like coloring with crayons and playing with duplo blocks… I just want to make computers suck less.
I never write about Emacs because I’m such a n00b and most of my ELisp “programming” has consisted of pasting random code from the Internet into my ~/.emacs file and hoping it works. But finally today I wrote a lick of it and it worked!
I’ve been using Ethan Schoonover’s obsessively comfortable “Solarized” color scheme for a while now, but I’ve become annoyed how many keys I have to mash to switch from light to dark. So I set a global variable to track the current state and mapped Ctrl-c, d (which I at least wasn’t using) to a function to toggle between the two states.
(when window-system ;; ColorTheme - see http://www.emacswiki.org/cgi-bin/wiki/ColorTheme ;; and see gallery at http://www.cs.cmu.edu/~maverick/GNUEmacsColorThemeTest/ ;; try also M-x color-theme-select (message "loading color-theme") (add-to-list 'load-path "~/.emacs.d/color-theme-6.6.0") (require 'color-theme) ;; Ethan Schoonover's Solarized theme from ;; https://github.com/sellout/emacs-color-theme-solarized (load-file "~/.emacs.d/emacs-colors-solarized/color-theme-solarized.el") ;; Set initial theme to "dark" (setq dark-or-light 'dark) (color-theme-solarized dark-or-light) ;; Shortcut to toggle between light and dark (global-set-key (kbd "C-c d") (lambda () (interactive) (if (eq dark-or-light 'light) (setq dark-or-light 'dark) (setq dark-or-light 'light) ) (color-theme-solarized dark-or-light))) )
And ooh, I just found this awesome crash course on Elisp by Steve Yegge which I will certainly consult next time I have a reason to write my own (i.e., I can’t paste it from some random Internet).
And then after it was all over I finally found some instructions for doing it which would’ve been easy enough to paste. Ah well, I’ve learned something.
Steps to get PHPUnit to run on my XAMPP setup with Cygwin, so I can write and run Symfony2 unit tests.
1. Upgrade PEAR
Download
http://pear.php.net/go-pear.pharto C:\xampp\php\go-pear.pharRun this in cmd.exe (cygwin prompts hosed somehow), taking all defaults
c:\xampp\php>go-pear.bat- Yay.
c:\xampp\php>pear version PEAR Version: 1.9.4 PHP Version: 5.3.5 Zend Engine Version: 2.3.0 Running on: Windows NT FAI1046162 6.1 build 7600 (Unknow Windows version Enterpr ise Edition) i586
2. Install/upgrade PHPUnit
Now we can use the cygwin shell. Not sure all these channels are needed, I did this out of order.
cd /cygdrive/c/xampp/php pear update-channels pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear channel-discover pear.phpunit.de pear install --alldeps phpunit/PHPUnit
3. Use it
XAMPP and/or PHPUnit come with a wrapper called phpunit.bat, which has now been upgraded, but you may need to set your PHPBIN environment var. Also I already have c:\xampp\php in my $PATH.
export PHPBIN=c:/xampp/php/php.exe cd /path/to/mysf2project phpunit.bat -c app
Now PHPUnit works. Make tests and make them work!
Propel 1.6 (and Propel 1.5 before it) is pretty sweet (thank you François!). I had some confusion with my model’s array of related objects though, thinking it was a regular PHP array. Actually it’s a Collection, specifically a PropelObjectCollection, which implements PHP 5′s ArrayObject interface. You can do a lot of cool things with them.
Sorting
Not immediately obvious, however, was how to sort them. This did the trick for my case (I have a Sequence field manually re-calculable through a jQueryUI sortable widget. Also note the cool inline anonymous function syntax available since PHP 5.3. Incidentally, I’m not sure the terms lambda or closure are helpful because they’re not quite like Lisp lambdas or JavaScript closures.
// Re-sort them by Sequence, numerically $this->collSegments->uasort(function($a, $b) { return $a->getSequence() - $b->getSequence(); });
// Re-sort them as strings, case-insensitively. $this->collSegments->uasort(function($a, $b) { return strnatcasecmp($a->__toString(), $b->__toString(); });
Deleting
Thanks to the PropelArrayCollection API Documentation
/* * Remove the provided Segment object. * * @param Segment $s * @return Segment $s that was deleted. */ public function deleteSegment(Segment $s) { $s->delete(); $key = $this->collSegments->search($s); $ret = $this->collSegments->remove($key); return $s; }
So elsewhere,
$this->deleteSegment($s);
Problem
On my Snow Leopard machine this kept happening.
- The “open” indicator (glowing silver ball under the app icon) in the Dock was flaky, only showing for a few apps though more were running.
- The task switcher (which you see when you
option-tab/alt-tab) didn’t show all running apps. That RUINS it for me. I always use option-tab. - I hate rebooting.
Workaround–Restart the Dock process.
Open Terminal† and use one command:
killall -HUP Dock
Don’t be afraid of “killall”. HUP means “Hang Up” and is the normal way of telling something to relaunch.
Thanks to AcmeTech’s old post.
† Terminal is located in the Utilities folder in the Applications folder. Or the quick Spotlight way is command-space, Terminal.
A while back I realized something important:
Monitoring tools are to the sysadmin what testing tools are to the developer.
Recently I realized that there need to be more ways to bring both toolsets together. Here’s one, tying the Nagios monitoring toolset to anything that emits the popular Test Anything Protocol.
I just got this working today. The weirdnesses of Cygwin’s half Unix-half Windows nature had stymied me before, but I’ve prevailed!
I’ve got Gnu Emacs 23.3 for Windows installed in c:/emacs, and a fairly recent install of Cygwin on Windows 7.
Saved this script in ~/cygemacs.sh
#!/usr/bin/bash c:/emacs/bin/emacsclientw.exe -n -a "c:/emacs/bin/runemacs.exe" `cygpath -wa $@`
Then in my ~/.bashrc:
alias ec="~/cygemacs.sh"
Now I can be all like,
$ ec ~/.minttyrcAnd it opens a new frame in my running Emacs (I have (server-start) in my ~/.emacs), or starts Emacs and opens the file if Emacs isn’t running yet.
See also: EmasClient at EmacsWiki.
Bonus tips
Yes I’m still using Subversion but also gitting going with Git.
And courtesy of The Lumber Room, in ~/.bashrc and others:
export SVN_EDITOR='c:/emacs/bin/emacsclientw.exe -a c:/emacs/bin/runemacs.exe '
And silence that annoying “kill client buffer z0mgbbq?!?” warning:
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
Stupid me made the same mistake twice in a row so I’m documenting it for humanity.
I’m updating an old Symfony project to use Symfony 1.3/1.4 and Propel 1.5 through François Zaninotto’s sfPropel15Plugin.
Problem:
I followed the README, right? But…
$ ./symfony propel:build --forms >> schema converting "C:/web/myproject/config/schema.yml" to XML >> schema putting C:/web/myproject/config/generated-schema.xml >> propel Running "om" phing task >> file- C:/web/myproject/config/generated-schema.xml >> autoload Resetting application autoloaders >> autoload Resetting CLI autoloader >> propel generating form classes PHP Warning: call_user_func() expects parameter 1 to be a valid callback, class 'FooPeer' does not have a method 'getUniqueColumnNames' in C:\web\myproject\plugins\sfPropel15Plugin\lib\generator\sfPropelFormGenerator.class.php on line 485 PHP Stack trace: PHP 1. {main}() C:\web\myproject\symfony:0 PHP 2. include() C:\web\myproject\symfony:14 PHP 3. sfSymfonyCommandApplication->run() C:\symfony1.3\lib\command\cli.php:20 PHP 4. sfTask->runFromCLI() C:\symfony1.3\lib\command\sfSymfonyCommandApplication.class.php:76 PHP 5. sfBaseTask->doRun() C:\symfony1.3\lib\task\sfTask.class.php:97 PHP 6. sfPropelBuildTask->execute() C:\symfony1.3\lib\task\sfBaseTask.class.php:68 PHP 7. sfTask->run() C:\web\myproject\plugins\sfPropel15Plugin\lib\task\sfPropelBuildTask.class.php:135 PHP 8. sfBaseTask->doRun() C:\symfony1.3\lib\task\sfTask.class.php:173 PHP 9. sfPropelBuildFormsTask->execute() C:\symfony1.3\lib\task\sfBaseTask.class.php:68 PHP 10. sfGeneratorManager->generate() C:\web\myproject\plugins\sfPropel15Plugin\lib\task\sfPropelBuildFormsTask.class.php:72 PHP 11. sfPropelFormGenerator->generate() C:\symfony1.3\lib\generator\sfGeneratorManager.class.php:126 PHP 12. sfGenerator->evalTemplate() C:\web\myproject\plugins\sfPropel15Plugin\lib\generator\sfPropelFormGenerator.class.php:106 PHP 13. require() C:\symfony1.3\lib\generator\sfGenerator.class.php:84 PHP 14. sfPropelFormGenerator->getUniqueColumnNames() C:\web\myproject\plugins\sfPropel15Plugin\data\generator\sfPropelForm\default\template\sfPropelFormGeneratedTemplate.php:34 PHP 15. call_user_func() C:\web\myproject\plugins\sfPropel15Plugin\lib\generator\sfPropelFormGenerator.class.php:485 ... etc ...
Solution
I removed too much of the default config in propel.ini..
Make sure this original line is still intact in propel.ini, even though you’ve removed/commented out all the propel.behavior lines that point to the old sfPropelPlugin:
propel.behavior.default = symfony,symfony_i18n
