Feed on
Posts
Comments

After learning about UrAI.com from a blog I frequently read: Modeled Behavior, I decided to run my own blog through the system and see what it says.

jackpo.org is probably written by a male somewhere between 66-100 years old. The writing style is academic and happy most of the time.

Now really? I had no idea I was such a cherry person.. and age 66 – 100? WTF…

In general, I have the belief that most ethics courses whether they be medical ethics or business ethics tend to be taught from too theoretical of a standpoint.  Scenarios are often defined to have black and white answers, and thus the students never actually deal with true moral dilemmas until they are actually on the job.  This is especially true for those who spend their lives in consulting and/or academia, with no real understanding of the pressures that actually happen in an operational environment.  Having gone through some particularly stressful board meetings, I was quite excited when I heard about a new PBS production that will attempt to showcase some of the moral complexity involved:

Banner: In Search of the Good Corporate Citizen

Everyday we hear about business people who gamble on ethics to meet business goals. The ongoing stream of scandals begs the question, “Why does this keep happening?” From an Emmy-winning team of producers, “In Search of the Good Corporate Citizen” weaves together expert panel discussions with personal accounts from real-life white-collar criminals and whistleblowers.

Unable to catch the show on the air, I contacted Light On Production to try and get a copy of the DVD. After several phone calls, Denny Swenson, the producer of the show sent me a *free* copy of their first show, “Hitting the Numbers”!

I think the show is quite well done, and the stories that they showed were truly remarkable. The show leveraged a small panel to discuss each story after they were presented.   The panel was moderated by Thomas Donaldson from the Wharton School of Business and was composed of:

  • William W. George, the former chairman and CEO of Medtronic
  • Ben Heineman, General Counsel of General Electric
  • Donna C. Boehme, former chief compliance officer of BP

Given the show was filmed in 2008, one can reasonably assume that Boehme did not lose her job over the oil scandal.  However, just from the body language of the panelists, it was quite obvious that they were quite dismissive of the idea of having a chief compliance officer and frankly I am as well.  Perhaps such a role is indeed necessary in many large institutions, but it was not clear from the panel discussions how a CCO as described by Boehme would have in anyway contributed to ethical behaviors in an organization.  What was truly disappointing with this panel was that they never really acknowledged how much pressure there was in middle management and how sometimes the decisions are actually not that black and white.  Even with Donaldson offering up truly gray and realistic scenarios, the panel always converged on black and white solutions.  I would assume that the panelists themselves were at least somewhat worried about their professional image if they had mention doubts.  Perhaps true ethical discussions involving business executive can never happen in front of a camera?

Once in a while, I catch the startup bug due to people like Sean Burgess.  So this post is based on hours of frustration that I had from setting up multiple osx machines to deploy rails.  Much of this is for my own reference and borrows heavily from these sites and my own attempts on 4 different macs:

  1. http://www.frederico-araujo.com/2010/08/19/installing-rails-enviroment-on-snow-leopard-with-macports-mysql-and-modrails-passenger/
  2. http://2tbsp.com/content/install_apache_2_and_php_5_macports
  3. https://trac.macports.org/wiki/howto/MAMP

1. Preparing System

In general, just easiest to start from scratch if you haven’t used ports in a while (or have never used it). Also make sure that web sharing is OFF under System Preferences as we are going to install the apache version from macports instead.

sudo rm -rf \
    /opt/local \
    /Applications/DarwinPorts \
    /Applications/MacPorts \
    /Library/LaunchDaemons/org.macports.* \
    /Library/Receipts/DarwinPorts*.pkg \
    /Library/Receipts/MacPorts*.pkg \
    /Library/StartupItems/DarwinPortsStartup \
    /Library/Tcl/darwinports1.0 \
    /Library/Tcl/macports1.0 \
    ~/.macports

1.1 Download and Install Xcode & Macports

http://developer.apple.com/technologies/xcode.html

Download Page: http://www.macports.org/install.php

1.3.1 Update macports

sudo port -v selfupdate
port upgrade outdated

2. Apache, php5, mysql & PhpMyAdmin

2.1 Install Apache, php5, PhpMyAdmin and misc

sudo port -v install phpmyadmin php5 php5-mysql apache2 mysql5-server mysql5 memcached libmemcached wget sqlite3 +apache2 +pear

2.2 Make apache, mysql autoload on startup

sudo -u mysql mysql_install_db5
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo port load memcached

2.3 Activating PHP5

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

2.4 Add index.php to the dir_module directive

Open /opt/local/apache2/conf/httpd.conf in your favorite text editor.

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

2.5 Add mod_php and phpmyadmin

Also, at the end of the httpd.conf file, add the following lines so that Apache includes the mod_php and phpmyadmin file

#Include PHP configurations
Include conf/extra/mod_php.conf
# Local access to phpmyadmin installation
Include conf/extra/httpd-phpmyadmin.conf

Set up your PHP configuration files

cd /opt/local/etc/php5
sudo cp php.ini-development php.ini

Setup the MySQL default socket to use the CentOS MySQL socket location by editing php.ini

pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
mysql.default_socket=/var/lib/mysql/mysql.sock

2.6 Building my.cnf and changing the MySQL default socket to conform to CentOS (optional)

Open /opt/local/apache2/conf/httpd.conf in your favorite text editor. Add a new mimetype so that Apache will direct files ending in .php to the PHP module for processing. Add the following within the block. Without this, all you’ll see is the text of your PHP scripts

sudo cp /opt/local/share/mysql5/mysql/my-medium.cnf /etc/my.cnf
sudo mkdir /var/lib/mysql/
sudo chown -R _mysql:_mysql /var/lib/mysql

Change the TWO lines in /etc/my.cnf that says

socket = /opt/local/var/run/mysql5/mysqld.sock

to

socket = /var/lib/mysql/mysql.sock

2.7 Create the phpmyadmin configuration file

create a file /opt/local/apache2/conf/extra/httpd-phpmyadmin.conf containing this text:

AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "/opt/local/www/phpmyadmin$1"

<Directory "/opt/local/www/phpmyadmin">
  Options -Indexes
  AllowOverride None
  Order allow,deny
  Allow from all

  LanguagePriority en de es fr ja ko pt-br ru
  ForceLanguagePriority Prefer Fallback
</Directory>

2.8 Setup aliases to control the two services

sudo  ln -s /opt/local/apache2/bin/apachectl /usr/sbin/apache2
sudo ln -s /opt/local/share/mysql5/mysql/mysql.server /usr/sbin/mysql.server
sudo apache2 restart
sudo mysql.server restart

2.9 Setup the mysql root password

Set the MySQL root password. Where is your new desired root password. You will be prompted for your existing password (“Enter password:”); since it’s empty, just press Return.

mysqladmin5 -u root -p password <new-password>

Then log into the mysql connection and use these commands (replacing your root password of course) to update all the root accoutns

shell> mysql -u root -p
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
    ->     WHERE User = 'root';
mysql> FLUSH PRIVILEGES;

2.10 Test the PHP server

Make an index.php in /opt/local/apache2/htdocs and put the following in it:

<?php
phpinfo();
?>

2.11 Install and Test phpmyadmin

First make these changes in /opt/local/www/phpmyadmin/config.inc.php

$cfg['blowfish_secret'] = WHATEVER YOU WANT THIS TO BE

You should see quite a bit of information regarding your php installation.

3. Ruby, Rubygems, Rails, other gems

3.1 Install Ruby from macports

sudo port -v install ruby
$ ruby -v
ruby 1.8.7 (2010-08-08 patchlevel 302) [x86_64-darwin10]

3.2 download rubygems from http://rubygems.org/pages/download

cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar -xvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb

3.3 Install rails, rake, rspec etc.

sudo gem install rake rails thin tzinfo capistrano ruby-debug rspec mysql sqlite3-ruby

4. ImageMagick, Rmagick and mini_magick (Optional)

lets install ImageMagick with support for JPEG, TIFF, WMF, PDF, and PNG images, and for Postscript and TrueType fonts.

sudo port -v install tiff -macosx imagemagick +q8 +gs +wmf
sudo gem install mini_magick rmagick

Test rmagick

$ irb -rubygems -r RMagick
>> puts Magick::Long_version
This is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) 2009 by Timothy P. Hunter
Built with ImageMagick 6.6.3-0 2010-08-19 Q8 http://www.imagemagick.org
Built for ruby 1.8.7
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=> nil

5. Passenger

5.1 Install Passenger gem

sudo gem install passenger

5.2 Check Passenger path

passenger-config --root
 -> /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15

5.3 Build passenger for apache

and don’t worry about the other steps, we will cover them directly in the guide

sudo passenger-install-apache2-module

5.4 Enable Passenger on apache:

create /etc/apache2/extra/httpd-passenger.conf and change wherever necessary for your directories.
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /opt/local/bin/ruby
PassengerMaxPoolSize 6  # maximum global rails servers
PassengerMaxInstancesPerApp 2  # maximum rails servers per application
RailsFrameworkSpawnerIdleTime 1800
RailsAppSpawnerIdleTime 600
PassengerPoolIdleTime 600
PassengerMaxRequests 1000  # after 1000 requests will restart server, to skip memory leak :) 

# Enabling NameBased Virtualhost
NameVirtualHost 127.0.0.1:80

# my rails app virtual host 1
<VirtualHost 127.0.0.1:80>
    ServerName my-rails-app.local
    DocumentRoot "/Users/jackpo/rails/my-rails-app/public" # change this to match your folder
    RailsEnv "development"
   <Directory /Users/jackpo/rails/my-rails-app/public>
        # change this to match your folder
        # MultiViews must be turned off
        Options -MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    # logs are optional, change this to match your folder
    CustomLog  "/Users/jackpo/rails/my-rails-app/log/access_log" combined
    ErrorLog   "/Users/jackpo/rails/my-rails-app/log/error_log"
</VirtualHost>

5.5 Enable Virtual host on apache:

Edit /opt/local/apache2/conf/httpd.conf and add this new line at the bottom:

# Include Passenger ModRails config file
Include conf/extra/httpd-passenger.conf

5.6 Add your .local domain to /etc/hosts/

edit /etc/hosts and Add this line to that file and change to the name of your choosen application

You might add as many as you want, each line for each that ServerName on your VirtualHost blocks

127.0.0.1 my-rails-app.local
127.0.0.1 myapp-xyz.local

5.6 Restart Apache

sudo apache2 restart

6. Final

go to your browser and open the url of your application http://my-rails-app.local

If it works, congratulations. If it didn’t.. uh.. try and google. I maybe able to help, but I don’t have that much time!

Our Salt Intakes

I really don’t have very much time to blog these days, so just quick short entries :)

For half a decade, I have depended on the great open source Gallery2 project to host my photo galleries. Unfortunately, I am finding myself with less and less time to devote to maintaining the installation, and many useful social media features have yet to make it into its code base. So, I finally decided to port my entire gallery into flickr.

Much to my surprise, there are lots of scripts in the gallery database to import photos from flickr, but no functional scripts to export photos out of gallery2 into flickr. Several past attempts have been made, but I can get none of them to work properly. So I did what any good coder would do, I modified the existing scripts until it worked. I am providing the scripts I hacked at the end of this post. There are several caveats with the scripts that I’m including here:

  1. It’s recommended that you run this script (export-gallery.php) using command line php, or else the script might pre-maturely end due to Apache rest times. I also have max_execution_time = 0 set in my php.ini.
  2. It’s recommended that you dramatically increase resource limitations on your mysql server when attempting to run this script. I made no attempt at optimizing mysql calls at all. The script basically makes a new call whenever it wants new data. I have wait_timeout=600 set in my my.cnf.
  3. I offer NO support whatsoever for these scripts. They were created to ease my own personal transitions, and reading them should be fairly easy.
  4. The script utilizes PHPFlickr and is based on mindlesscode.net‘s version of export-gallery. Several major upgrades to the original script have been made, including the ability to export sub-albums.
  5. I recommend only using getToken.php in phpFlickr, as I personally could not get PHPFlickr’s API authentication to work in any reliable fashion.
  6. You should see a line like this in export-gallery.php i.".DATABASE_COLUMN_PREFIX."ownerId=10 AND . This allows you to export galleries on a per-user basis. You can look up the userid information in the gallery2 tables.


So with that said, click here to download the script. You can run it by typing php export-gallery.php on the command line after editing a few variables at the top of export-gallery.php and setting up the API key / token combination from flickr. I used this very useful link from PHPFlickr to get my token after setting up the API key.