A Full Stack Engineer's Perspectives on Technology, Startups, Software Engineering, and UI Design

Design Patterns: GoF Masterpiece

Posted: January 14th, 2012 | Author: | Filed under: General | No Comments »

So I felt like writing a new blog post rather than using tumblr or any of the billion other micro blogging or knowledge services out there. I still think there’s space for a blog, where blogs function as journals more than as primary communication devices. So I’ll start using it as that (and as tutorials like my other popular posts).

Computer Science Shift

Three months ago I moved from my agency-getting-things-done job to a start up working mainly with comp sci guys from some of the best schools in the world. This change has been full of new and interesting terms from clean code to hadoop. I’ve mainly worked on the client (Flash for our team) and a little bit on the server (PHP/MySQL/CI). Since joining, I’ve thought carefully about what it means to support millions of users and have boiled it down to a few select ways (which I can highlight in another post). Anyways, the change has been immense and I’ve studied very consistently since then. I’ve read a couple of code related books while keeping up with my regular readings. Most recently, I’ve finished a book on design patterns — yes the original GoF one. It’s come up throughout the last two years a number of times so I felt it was pretty important to read now that I’m in full blown comp-sci. Here’s a brief summary and opinion:

Design Patterns: You Shouldn’t Live Without ‘Em

If you are programming, or learning to program, and want to build scalable software, I urge you to read the original design patterns book (or something similar). Within the book, they talk about two dozen or so patterns that help organize common issues in software design. I found it immensely valuable to be able to talk about these design patterns with teammates and other professionals and why we choose certain ones over others. Here’s a list of the design patterns that interest me and what they do:

Creation Patterns 

  • Builder – This pattern helps you create objects a certain way and then change them by using inheritance. You code out how you build a certain object in a class by using methods (build legs, build arms, etc.) and then extend that class and override those specific methods for various implementations. This is the same to me as using a similar pattern called template methods…
  • Factory Method – A pattern that uses a method to create objects. I never embraced this enough until reading this. We use it in our code quite frequently and having something control the creation of your objects is powerful. Combining this with a singleton and other patterns allows you to determine at runtime which class should be used based on which class it’s being used by. Look up the term single dispatch as well (interesting concept), and if you can do double/multi dispatch with this, great.
  • Prototype – An object you “clone” to create other objects with different behavior. Think events in flash; they have clone functions. Clone it, change properties, and send it out again is how I’d use them.
  • Singleton – I heart singletons. Although they can be called “global” variables, they are safer to use than static classes and very necessary in almost every application. When there really should only be one instance, this is your friend. Unfortunately there’s so many ways of faking enforcement of a singleton in flash. I’ll be trying Casalib’s way for my next project. In full-blown OO where constructors can be private (like in Java and PHP), Singleton’s are even cooler.

Structural Patterns

  • Adapter – The concept behind changing an interface of someone else’s library so that you can use your library to “plug” into it.
  • Bridge – Separates implementation from abstraction. I loved the diagram in this book. If you have a multi-OS application, and need to separate how windows are treated, you can use a bridge to communicate between your windows and their implementations where the bridge is used to communicate to device specific implementations. I’d wager that most multi-platform dev kits use something similar.
  • Composite – A base object that can contain other base objects. Think DisplayObject, NSView, whatever — every advanced visual language supports this concept. Parent -> children.
  • Decorator – Adding functionality to something without having to change the original object. Their example was putting a border around a UI element. You can wrap an entire element to manage it as well and still be a decorator (managing many objects = mediator).
  • Facade – I build “facades” to make using larger systems easier. It’s part of making coding intuitive. If something can be made simpler, it can very well be worth while to create a facade to interact with a whole system. I love using tool sets that accomplish certain tasks really well for example. And without having to build an Adapter, I can just create a facade that makes it easier to use it.
  • Proxy – A proxy object is basically something that can 1) be used in place of something else, or 2) an object that communicates between two objects. I like that first point, that it can be used instead of something else. If something hasn’t loaded, you can use a proxy object to keep it’s place for fluid layouts or just to hold data until it’s loaded.

Behavioral Patterns

  • Chain of Responsibility – Passing objects until someone interested does something with it. Think event dispatcher in flash. You pass objects from parent to child or child to parent while anyone along the chain has the option to stop it (stop/prevent propogation in JavaScript and AS3), handles it, or ignores it.
  • Command – The command pattern is a very useful pattern to wrap requests to a server or servers (think p2p). By siphoning all logic directed outside an application through a pattern of objects, you have a very powerful, centralized hub to control communication (think control tower). This pattern is a must have for most applications.
  • Interpreter – This pattern is very interesting in it that it allows you to create your own notation that gets parsed by an “Interpreter” that then opens windows, runs commands, etc.  Think regular expressions on steroids.
  • Mediator – A mediator is a useful UI pattern that can be used to handle communication and states between multiple objects without violating encapsulation (i.e. those objects don’t know each other, only the mediator knows them all).
  • Memento – Wicked name for a simple concept – a pattern that uses objects to store the state of an object so you can return to it later. Use mementos with commands to do undo and redo logic.
  • Observer – A pattern that allows multiple objects (observers) to listen to a specific object for changes. Think binding in flex or the model to view or controllers in mvc, where the view or controller can act as observers. I loved CakePHP for this kind of observer behavior.
  • Strategy – I love the strategy pattern. Consider you have an advanced algorithm and you don’t think it’s the best in all situations. You can wrap it in a strategy style pattern and build out another algorithm in another strategy and decide at run-time which strategy to use. It’s technical term would be separating an algorithm’s context from the algorithm itself so you can create different algorithms for a single context, vice versa, or many-to-many.
  • Template Method – A template method is used when you write a base class with a certain sequence of methods being called in a certain order. The class is designed so that when you inherit from it, you can overwrite certain methods (called template methods) to present different functionality but keep the general structure in order. We use this all the time, everywhere (in good and bad ways).
  • Visitor – Finally, I’ll talk about the visitor pattern. This pattern allows you centralize a certain behavior where you might want to create an object that scans other objects for certain parameters to do a certain thing or compute a certain result. The object is said to be called a visitor where it visits other objects to look for properties of interest.
There were a few that I didn’t write about that I don’t use so much and aren’t interesting for various reasons. Regardless, if you aren’t using design patterns in your small or larger projects (much less likely), get on that ship as it could save you an unforeseeable amount of time down the road (more team members, selling your product, version 2, etc.). Chances are though, you are already using it and you either know it or you don’t. If you don’t, I’d recommend the read. It took me a month and a half of light train reading, but it is well worth it.

 

You are probably using them already

Although I’ve used design patterns before, many of the former unknown design patterns I used instinctively when designing previous applications. This could be due to my experiences with Papervision, Away3D, AS3, CakePHP, CodeIgnitor, Objective-C, Java (each one brings a few patterns to mind). But after reading this book, it all makes a little more sense.
Happy coding.
Ayan

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Blog has a new look

Posted: September 6th, 2011 | Author: | Filed under: General | No Comments »

It’s been awhile since I’ve updated the blog’s look and feel. With WordPress, it’s super easy to do and frankly there’s no reason why I didn’t do it earlier. The new theme, which I will still need to modify slightly, is simpler, cleaner, easier to read, and a lot less busy with less noise and more focus on the text. More importantly, it is ready for mobile and looks beautiful on small and large screens. My objective with this new template is to help you get to the content you are interested in easily with less confusion and to look beautiful on mobile and desktop devices so you can read on the go, on the couch, or on the desktop.

Although lately I haven’t written on my blog, there are some posts I’ve been working on completing. I aim to have a new website out in a few weeks so hopefully around that time I will also post up some new useful content. I’d also like to take this opportunity to thank my current readers who have found many of my posts helpful and have shared there experiences through commenting and emailing me. I will work harder to improve this blog and provide valuable feedback and advice. Thank you.

Stay tuned.

Ayan

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Application Transparency – The Need for Proper Feedback

Posted: April 20th, 2011 | Author: | Filed under: General | No Comments »

I was working on a mobile app today that we were handed from another firm that lacked in a core usability component I consider very important: communication. Like one of my former employer says, communication is paramount. In the mobile space, it is even more important. Users’ hold onto the device and you can expect that they are looking at it. If you lose their focus, they might just close your app and do something else. That’s why it’s critical you let the user know what you are doing at all times. Whether it be hit states for buttons or feedback during potentially long loading times, communication from you (the programmer) to the user (your valued client) is critical.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Define Your Workspace

Posted: September 6th, 2010 | Author: | Filed under: General, Tools | Tags: | No Comments »

I have recently started at a new design agency and have had to become re-accustomed with productivity tools I use to speed up my interaction with the machine. During this time, I reexamined my choice of tools and found others that help me do specific things. I call this defining your workspace — carving out what you want from your environment rather than using the tools that are provided to you by default. I believe this also works universally, whether you’re a fine artist or a chef, you all should start with thinking how you want to work and find that way through various tools available to you. This thinking process, in my opinion, is vital to staying in control and maximizing output.

My Current Workspace

As a new media specialist, I work with new technologies to create compelling design. I work within the whole picture from the back-end server and database design of a website to the animation qualities of a video. I design using Windows and Mac applications for the desktop as well as mobile devices like the iPad, iPhone, and Android-based phones. My point is that my workshop is large and complex and it can be bothersome to manage and stay in control of. Below is a list of things I find useful to make sure I use my machine the way I want to:

1) Launchy

I love launchy. A friend of mine introduced it to me in school and I’ve fell in love ever since. It is the simplest and easiest way to access your machine and do simple yet vital processes like calculations. It’s available for Windows and now OSX, but I’ve heard QuickSilver is better on OSX.  If you haven’t heard about it, it’s basically a 1-box search engine for applications, shortcuts, and folders. It is customizable with themes and can look amazing when you hit the shortcuts that bring the window up. It also gives you quick access to search engines and basically makes it useless to have pinned applications and shortcuts on your desktop. Something like this is a programmers dream as programmers like to use the keyboard as much as possible to speed up how they use the machine.

2) Multi-clipboard

Copying and pasting is a necessity when dealing with data. Sometimes you need to copy and paste two or more things from one place to another. You could open one, copy, paste in other, and repeat. Or you can copy each and paste each using a multi-level clipboard like multi-clipboard. Anyways, I like the multilevel clipboard for programming purposes; it’s almost necessary. This particular application (free) is useful as it has shortcuts to bring it up and you can just click the entries you wish to enter to paste it. It also has a history of 25 and keeps images etc. in this array. If you do a lot of image data copying, it can slow your system down so be cautious too. I have the shortcut set to Alt + Ctrl + C :) .

3) WAMPServer

If you don’t have a personal server on your computer, you should consider getting one. It is great for showing teammates, sharing files, publishing internally to your intranet, writing scripts for local use, and testing your website, applications, or whatever before pushing to the web.  WAMPServer is what I use on my Windows machine but there are numerous choices for everyone no matter what their setup is.

4) Notepad++

OK, this list is becoming more and more Windows specific. If you were on Mac, I’d say use TextMate. Otherwise, get Notepad++. Normal notepad is too archaic and unusable. I am still appalled that it has only one level of undo even in 7. I guess they just have it there as a quick alternative to Wordpad. Anyways, get Notepad++. It has plug-ins and can read files in different ways (I.e. code formatting). It loads quick and can integrate into your right click with “Open with Notepad++”. It has diff, reads multiple file formats, and supports various file encoding. It is a great text editor.

5) Customization

We all like stuff that looks cool. If we didn’t, we wouldn’t keep striving for polished design. The desktop is no different. Pick a background you like. Customize it to your delight. Use something like Window Blinds if you want a more customized experience. I personally stick with a nice background and a nice screen saver (I’m a fan of polar clock). This customization I think allows you to become more comfortable in your space (and applies to all other trades as well).

6) Space Sniffer

This is an interesting application that shows you visually how much space is being used on your hard disk. If you ever find yourself close to running out of space, this kind of application can be crucial in helping to resolve that problem.

7) Gmail Greasemonkey Scripts

Everyone is on email these days and how we use it can take up a lot of time during the day. For a better experience, I use various GMail Greasemonkey scripts. Here are a few that interest me:

  • Gmail Air Skin
  • Gmail Conversation Preview Mod
  • Gmail Macros
  • Gmail Contact List

8) File Renamer Basic

If you have ever worked with many files of similar types and naming, renaming them could be a hassle without a program like this one. I use this on occasion to do just that and it works splendidly.

9) … Suggestions?

Finally, this is by no means complete and thus this post will be an ongoing list of tools I find necessary (aside from the obvious Photoshop, etc.) to improve my interaction with the machine. If you have suggestions, please leave a comment and I’ll add it to the list. Please include a description of what it does too so I can see if it’s something I need too :) .

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Useful Word Building Tool: AyanRay.com Dictionary

Posted: May 14th, 2010 | Author: | Filed under: General, Tools | Tags: , , | No Comments »

Sometimes, when I can’t find something that fits my needs, I build tools for myself to use to fit those needs. Lately, I’ve been trying to build my usable, day-to-day vocabulary. I’ve been reading a lot lately and write down words that are beyond my comprehension. Words like circumspect, scant, and vehement are all words I don’t often use but can describe a particular circumstance quite accurately. And that, the ability to increase my/your vocabulary, is the goal of this tool.

Tool: Dictionary


What is it?

The AyanRay.com Dictionary is a free comprehensive dictionary tool used to help build your vocabulary on a regular and repetitive basis. It offers easy-to-use tools to add any term or word to your dictionary with the ability to have it email you these words regularly for you to review and study. Over a period of time, these words will become second nature to you and will hopefully help build your vocabulary.

Features:

  • Register/Delete your account
  • Add words to your dictionary using an HTML editor (TinyMCE for those interested)
  • Edit/Delete words from your dictionary
  • Alphabetically sorted dictionary page listing all words in your dictionary
  • Categories for organizing and grouping your words into mini-dictionaries (I.e. if you read a new book, you can create a category for words you learn from that book)
  • Category to Word Management – a word can have as many categories as you wish
  • Auto-parse Google “define: word” definitions for easy adding of words to the dictionary
  • Daily, Every other day, Weekly, and Monthly Emails with any number of words from your dictionary randomly emailed to you
  • Comprehensive settings page allowing you to customize email frequency, whether you receive emails at all, and more
  • It’s free :)
  • Coming soon: functionality making it easier to add words :p. I cannot auto-query Google or they will ban my server :( , sorry.

Anyways, this post was more for an introduction to the application. If you find it helpful, have any suggestions, or find any bugs/errors in the application, please let me know. If you need help with it, please post a comment here and I will do my best to answer your questions.

Link: http://www.ayanray.com/tools/dictionary

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Custom PHP Install on Dreamhost Shared Hosting

Posted: April 23rd, 2010 | Author: | Filed under: General | Tags: , , , | 11 Comments »

I like to share what takes some agitation to figure out and doing a custom PHP install on Dreamhost was my most recent tiring endeavor. It’s hardly difficult, but only if you know what you are doing. There’s a plethora of resources out there and unfortunately they all seem outdated (and some are, because I tried them). The ones that are not promise ease and quickness but fail to deliver when it comes down to actually getting it to work or providing the pivotal last hoorah that will accomplish that task.

The PHP Custom Install Script that Works

Source: http://www.bernawebdesign.ch/byteblog/2010/02/17/custom-php-5-3-1-with-apc-and-xdebug-on-dreamhost-shared-hosting/

Note: This script works and the others didn’t for me. I post it up here again for my peers who use Dreamhost in case they need it too. If you require help, you are welcome to post here or post on the original author’s blog.

Note #2: In order for this script and the .htaccess file to work accordingly, you must use a UNIX friendly text editor and save it in UNIX text mode. I use a tool called metapad and you can get it free here: http://liquidninja.com/metapad/. Otherwise, you might get 500 Internal Server Errors and those can sometimes be solved simply with this advice.

#!/bin/sh

# update 16.2.2010
# @author Marco Bernasocchi
# – Added OPENSSL LIBMCRYPT LIBTOOL and a promt for installing XDEBUG
# (still uses XDEBUG 2.05, which has basic PHP 5.3.1 support. 2.1.0 is on its way)
# – removed unsupported php configure switches
# – disabled –with-xsl, if you want to use it you’ll probably need to install
# libxslt (http://xmlsoft.org/XSLT/) version 1.1.0 or greater.
# – sets the ini files into the install directory instead than on cgi-bin
# – to add more domains just copy the cgi binary to the new domain
# cp “$PHP_BIN_DIR/php-cgi” “$NEW_CGI_BIN_DIR/php.cgi” and modifiy the .htaccess

#Script for a minimal PHP 5.3.x install with APC
#
#- Prompts for the domain to build for
#- PHP configure line contains only valid PHP5 options
#- Displays colourful status messages
#- Many build messages, which aren’t helpful to most people, are now suppressed
#- Procedurised, making it cleaner and easier to follow
#
#The only things you may want to change in here are marked with “@todo”s
#
#Derived form the original PHP 5.3 install script at
#http://wiki.dreamhost.com/Installing_PHP5
#
#@author Dan Bettles

#Exit on error
set -e

clear

echo -n “Enter the domain for which you want to build PHP and press [ENTER]: ”
read DOMAIN

echo -n “Enable XDEBUG (y|n): ”
read ENABLEXDEBUG

#==================================================================

#@todo Update versions, if necessary
M4=”m4-1.4.13″
AUTOCONF=”autoconf-2.65″
OPENSSL=”openssl-0.9.8l”
CURL=”curl-7.20.0″
LIBMCRYPT=”libmcrypt-2.5.8″
LIBTOOL=”libtool-2.2.6b”
PHP=”php-5.3.1″
APC=”APC-3.1.3p1″
XDEBUG=”xdebug-2.0.5″

#@todo Update install paths, if necessary
WEB_ROOT=”$HOME/$DOMAIN/web”
CGI_BIN_DIR=”$WEB_ROOT/cgi-bin”
HTACCESS=”$WEB_ROOT/.htaccess”

INSTALL_DIR=”$HOME/mycompiles”
BUILD_DIR=”$INSTALL_DIR/build”
DOWNLOADS_DIR=”$INSTALL_DIR/downloads”
PHP_BASE_DIR=”$INSTALL_DIR/$PHP”
PHP_BIN_DIR=”$PHP_BASE_DIR/bin”
PHP_EXTENSIONS_DIR=”$PHP_BASE_DIR/extensions”
PHP_CONFIG_DIR=”$PHP_BASE_DIR/etc/php5/config”
PHP_INI=”$PHP_CONFIG_DIR/php.ini”

#@todo Alter features, if necessary
PHP_FEATURES=”–prefix=$PHP_BASE_DIR \
–with-config-file-path=$PHP_CONFIG_DIR \
–with-config-file-scan-dir=$PHP_CONFIG_DIR \
–bindir=$PHP_BIN_DIR \
–enable-zip \
–with-xmlrpc \
–with-freetype-dir=/usr \
–with-zlib-dir=/usr \
–with-jpeg-dir=/usr \
–with-png-dir=/usr \
–with-curl=$PHP_BASE_DIR \
–with-gd \
–enable-gd-native-ttf \
–enable-ftp \
–enable-exif \
–enable-sockets \
–enable-wddx \
–enable-sqlite-utf8 \
–enable-calendar \
–enable-mbstring \
–enable-mbregex \
–enable-bcmath \
–with-mysql=/usr \
–with-mysqli \
–without-pear \
–with-gettext \
–with-pdo-mysql \
–with-openssl=$PHP_BASE_DIR \
#–with-xsl=$=$PHP_BASE_DIR \
–with-mcrypt=$PHP_BASE_DIR”

#==================================================================

#@param string $1 Message
function echoL1 () {
echo -e “\n\033[1;37;44m$1\033[0;0;0m\n"
}

#@param string $1 Message
function echoL2 () {
echo -e "\n\033[0;37;44m$1\033[0;0;0m\n"
}

#@param string $1 URL
#@param string $2 Output directory
function downloadTo () {
wget -c $1 --directory-prefix=$2
}

#@param string $1 TAR filename
#@param string $2 Output directory
function untarTo () {
cd $2
tar -xzf $1
cd -
}

#@param string $1 Source directory
#@param string $2 Output directory
#@param string $3 configure arguments
function configureAndMake () {
cd $1
COMMAND="./configure --quiet --prefix=$2 $3"
if [ $1 = "$BUILD_DIR/$OPENSSL" ];then
#special command for OPEN SSL
COMMAND=”./config –prefix=$2 $3″
fi
echo “$COMMAND”
eval $COMMAND
make –quiet
cd -
}

#@param string $1 Source directory
#@param string $2 Output directory
#@param string $3 configure arguments
function makeAndInstall () {
configureAndMake $1 $2 “$3″
cd $1
make install –quiet
cd -
}

#@param string $1 Directory
function mkdirClean () {
rm -rf $1
mkdir -p $1
}

#@param string $1 Message
function echoWarning () {
echo -e “\n\033[1;37;41m$1\033[0;0;0m\n"
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

export PATH="$PATH:$PHP_BIN_DIR"

echoL1 "-> DOWNLOADING..."

mkdirClean $BUILD_DIR

echoL2 "--> Downloading $M4..."
downloadTo "http://ftp.gnu.org/gnu/m4/$M4.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$M4.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $AUTOCONF..."
downloadTo "http://ftp.gnu.org/gnu/autoconf/$AUTOCONF.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$AUTOCONF.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $OPENSSL..."
downloadTo "http://www.openssl.org/source/$OPENSSL.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$OPENSSL.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $CURL..."
downloadTo "http://curl.haxx.se/download/$CURL.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$CURL.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $LIBMCRYPT..."
downloadTo "http://easynews.dl.sourceforge.net/sourceforge/mcrypt/$LIBMCRYPT.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$LIBMCRYPT.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $LIBTOOL..."
downloadTo "http://ftp.gnu.org/gnu/libtool/$LIBTOOL.tar.gz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$LIBTOOL.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $PHP..."
downloadTo "http://www.php.net/get/$PHP.tar.gz/from/this/mirror" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$PHP.tar.gz" $BUILD_DIR

echoL2 "--> Downloading $APC..."
downloadTo "http://pecl.php.net/get/$APC.tgz" $DOWNLOADS_DIR
untarTo "$DOWNLOADS_DIR/$APC.tgz" $BUILD_DIR

if [ $ENABLEXDEBUG = "y" ]; then
echoL2 “–> Downloading $XDEBUG…”
downloadTo “http://xdebug.org/files/$XDEBUG.tgz” $DOWNLOADS_DIR
untarTo “$DOWNLOADS_DIR/$XDEBUG.tgz” $BUILD_DIR
fi

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echoL1 “-> BUILDING…”

mkdir -p $PHP_BASE_DIR

echoL2 “–> Building $M4…”
makeAndInstall “$BUILD_DIR/$M4″ $PHP_BASE_DIR

echoL2 “–> Building $AUTOCONF…”
makeAndInstall “$BUILD_DIR/$AUTOCONF” $PHP_BASE_DIR

echoL2 “–> Building $OPENSSL…”
makeAndInstall “$BUILD_DIR/$OPENSSL” $PHP_BASE_DIR

echoL2 “–> Building $CURL…”
makeAndInstall “$BUILD_DIR/$CURL” $PHP_BASE_DIR “–enable-ipv6 –enable-cookies\
–enable-crypto-auth –with-ssl”

echoL2 “–> Building $LIBMCRYPT…”
makeAndInstall “$BUILD_DIR/$LIBMCRYPT” $PHP_BASE_DIR “–disable-posix-threads”

echoL2 “–> Building $LIBTOOL…”
makeAndInstall “$BUILD_DIR/$LIBTOOL” $PHP_BASE_DIR

echoL2 “–> Building $PHP…”
#Fixes compile error
export EXTRA_LIBS=”-lresolv”
makeAndInstall “$BUILD_DIR/$PHP” $PHP_BASE_DIR “$PHP_FEATURES”

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echoL1 “-> INSTALLING PHP…”

mkdir -p -m 0755 $CGI_BIN_DIR
mkdir -p -m 0755 $PHP_CONFIG_DIR
cp “$PHP_BIN_DIR/php-cgi” “$CGI_BIN_DIR/php.cgi”
cp “$BUILD_DIR/$PHP/php.ini-production” $PHP_INI

mkdir -p $PHP_EXTENSIONS_DIR

echoL2 “–> Building $APC…”
APC_SOURCE_DIR=”$BUILD_DIR/$APC”
cd $APC_SOURCE_DIR
$PHP_BIN_DIR/phpize
configureAndMake $APC_SOURCE_DIR $PHP_BASE_DIR “–enable-apc –enable-apc-mmap\
–with-php-config=$PHP_BIN_DIR/php-config”
cp modules/apc.so $PHP_EXTENSIONS_DIR
echo “extension=$PHP_EXTENSIONS_DIR/apc.so” > $PHP_CONFIG_DIR/apc.ini
cd -

if [ $ENABLEXDEBUG = "y" ]; then
echoL2 “–> Building $XDEBUG…”
XDEBUG_SOURCE_DIR=”$BUILD_DIR/$XDEBUG”
cd $XDEBUG_SOURCE_DIR
$PHP_BIN_DIR/phpize
configureAndMake $XDEBUG_SOURCE_DIR $PHP_BASE_DIR “–enable-xdebug\
–with-php-config=$PHP_BIN_DIR/php-config”
cp modules/xdebug.so $PHP_EXTENSIONS_DIR
echo “zend_extension=$PHP_EXTENSIONS_DIR/xdebug.so” > $PHP_CONFIG_DIR/xdebug.ini
cd -
fi
#——————————————————————————-

if [ -f $HTACCESS ]; then
HTACCESS_NEW=”$HTACCESS.old”
cp $HTACCESS $HTACCESS_NEW
echoWarning “–> Copied $HTACCESS to $HTACCESS_NEW”
fi

#The backslash prevents a newline being inserted at the start
HTACCESS_CONTENT=”\
Options +ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

#Deny access to the PHP CGI executable and config files

Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS

#Preserve newlines in the content by quoting the variable name
echo “#######ADDED BY installPHP script” >> $HTACCESS
echo “$HTACCESS_CONTENT” >> $HTACCESS

echoL2 “–> Created $PHP_INI”

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rm -rf $BUILD_DIR

echo -n “Delete the downloads directory? (y/n): ”
read DELETE_DOWNLOADS_DIR

if [ $DELETE_DOWNLOADS_DIR = "y" ]; then
rm -rf $DOWNLOADS_DIR
fi

echoL1 “DONE”

exit 0

After running this script, it creates a folder in your domain called ‘web’ and within that another folder called ‘cgi-bin’.  I wasn’t able to get anything working within this folder at first so I am guessing it is meant to be off limits? Anyways, I was able to get PHP 5.3 working ultimately with the following within your .htaccess file in the root of the your.com folder. This information came from the Dreamhost Custom PHP Install Wiki itself.

AddHandler phpFive .php
Action phpFive /web/cgi-bin/php.cgi

After getting your custom PHP build installed correctly, you should create a php file with phpinfo(); and check that the PHP version is 5.3 or whatever you might have altered the script to. At that point, you are free to edit your php.ini file located at /home/user/mycompiles/php-5.3 (or whatever it might be)/etc/php5/config/php.ini for further modifications.

Phew, well that took me a few hours to figure out and I hope it saves you some time :p. Trying scripts left and right can really eat up time. Some literally just “stopped” or as Dreamhost might say was “killed”. Others just produced errors during the php build of the operation with no indication of why it failed. Helpful? Not at the very least.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

The Best Way to Render Wireframe in Maya

Posted: January 25th, 2010 | Author: | Filed under: 3D | Tags: , | 61 Comments »

A quick google for render wireframe in Maya will get you some sound results. Unfortunately, I tried them and they didn’t consistently produce the results I needed. So here is the most consistent, and thus in my opinion best way to do wireframe in Maya.

Method 1: “The Best Way” – Mental Ray Contours

Why is it the best?

It does not tessellate your objects. It can be applied to multiple objects without having to do new UV Snapshots. It can render in smooth shaded. It is quick and easy. And it uses the power of mental ray, and can look sweet if you do it right.

Process

  1. Assuming you have something to render, create a new material (can be anything that has a shader group – lambert, blinn, phong, etc.). In this example, I will be creating a lambert.
  2. Call the new material WireFrameMTRL and the shading group WireFrameSG. Who doesn’t like being a little organized ;) ?
    Note: If you clicked somewhere else and can’t get to the shading group easily, you can just go to the Hypershade and find the tab Shading Groups to find it.
  3. Go to the newly created lambert’s shading group WireFrameSG.
  4. Open the mental ray -> Contours tab.
    Note: If it isn’t there, you need to enable mental ray in your plug-ins Manager. Mental ray is called “Mayatomr.dll” so find it and load it.
  5. Click Enable Contour Rendering.
  6. Set the color to something you’d like. I like white.
  7. Set the width to something like 0.2 – 1.0. This setting is the absolute width of the wire frame lines. You can comeback and play with this later.
  8. Apply the material to the object.
  9. Open Render Settings
  10. Select render using Mental Ray (if it’s not there, go see the note for #4).
  11. Find the Contours Tab (it is under the features tab in 2009)
  12. Select Enable Contour Rendering
  13. Open the Draw By Property Difference Tab
  14. Select Around All Poly Faces
  15. Render!

And that is the easiest and most consistent way to get wireframe without the flaws of the other methods.

Here’s a shot of the result from one of my recent projects (with render settings fine tuned):

Rendering Wireframe with Mental Ray

The Worse Ways

For full disclosure, here are some other not so good ways to render wireframe.

Method 2: UV Snapshot

I don’t feel like doing the process for this one. It is somewhat of a pain to explain without pictures and frankly I don’t want to take them since it isn’t a method I’d advise. So here is a pretty decent video that does: http://www.youtube.com/watch?v=ZUFAtkVJdpg&NR=1

Method 3: Maya Vector

Rendering in Maya Vector is fairly painless to test. Unfortunately, Maya needs to tessellate all quads whose vertices do not fall on the same plane.  There is a way to find these planes if you have a few but in my case, almost all my quads are non-planar so there was no point trying to fix them.  So here we go on the process:

Process

  1. Assuming you have objects to render, open up your render settings dialog.
  2. Render using Maya Vector.
  3. Go to the Maya Vector settings.
  4. You can select Fill objects if you’d like. It will fill the object with a color you can select through the settings or leave it fill-less. For the example below, I unchecked fill objects.
  5. Un-check show back faces.
  6. Select Include Edges in the Edge Options Tab
  7. Choose an edge weight. I chose 0.5 for the example below.
  8. Choose Entire Mesh for Edge Style.
    Note: Outlines gives you a pretty cool effect. So try that too :)
  9. Render!

Wireframe render using Maya Vector. Oh boy look at the tessellation.

Method 4: Hardware Buffer

Hardware buffer is another painless way to render out in wire frame. Unfortunately, it doesn’t look nearly as cool as the previous two images. Anyways, here’s the process:

Process

  1. Open up the Hardware Rendering Buffer from Window > Rendering Editors.
  2. In the Hardware Rendering Buffer, open Render > Attributes.
  3. In the Attribute Editor, change the Rendering Mode > Draw Style to Wireframe.
  4. Render!

This one looked terrible so I didn’t capture an image of it. I couldn’t figure out how to do back-face culling so this quickly became the worst of the techniques.

Method 5: Toon Shader

The second best method to render wireframes in maya is to use the toon shader. I personally like the mental ray method better for the control and power of mental ray but this one seems just as good for simplicity’s sake.

http://www.artbycrunk.com/blog/2008/09/rendering-wireframe-using-toonshader/

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Japanese Visemes and Phonemes

Posted: January 20th, 2010 | Author: | Filed under: 3D | No Comments »

I’m currently working on an interesting project that involves Japanese speech lip-syncing of a 3D character. Since it was difficult to find resources on this from an English speaker, I decided to write on it.

Firstly, visemes are the unique facial positions required to produce phonemes, which are basic sounds from a particular language. Each language has multiple phonemes and visemes and each viseme can have multiple phonemes. In the English language, there are about 10 basic phonemes (a-i, e, o, u, c-d-g-k-n-r-s-y-z, f-v,th,l,m-b-p,w-oo-q) with one viseme each totaling 10 visemes.

When I first began looking into Japanese visemes and had luck finding resources, I decided to try to develop my own solution with my understanding of the language. In my view, the Japanese language is composed of some very basic sounds that are construed to make more sounds. Although the phonemes begin to add up, the actual visemes are almost exact. Combinations like じゃ(jya) can be formed accurately by combining their similar visemes  い (i) and あ (a). The following diagram depicts the 5 visemes:

Yours truly making visemes for animation

Again, I believe that with these 5 basic visemes, it will allow you to construct every mouth pose required for Japanese speech. Unfortunately, the character I am using lip-syncing for will most likely never have a tongue. This is important because, in Japanese speech,  the tongue is used more often than other languages (I’m thinking of English, but similar Latin-based languages fall in that category) and requires less movement of the lips to make the language’s basic phonemes.

Finally, near the end of my researching for this particular topic, I found this webpage that explains everything I just did and more: http://www.ordix.com/pfolio/research/

I don’t particular like the visemes for the first two sounds as the character’s teeth stick out far too much for my liking. It is entirely possible that the character is making the correct sound, but when I try the phoneme in her pose, it feels quite strange.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Japan: New Years Celebrations

Posted: January 5th, 2010 | Author: | Filed under: Japan, Travels | Tags: | 2 Comments »

It’s been awhile since I’ve written on Japan. This has been because of mostly the fact I’ve been here before for an extended period of time and simply ran out of things to write about. There are some things that have crossed my mind that could be interesting topics, but I’ll save those for later. This post however is on a new topic that I never got to experience the first time I was here. This time I truly got to experience Japanese life in regards to Christmas and New Years.

Christmas

Christmas isn’t much different in Japan than the North American version. You still get presents for your friends and family and they still get presents for you (or else would it really be Christmas?). Unfortunately for us, and I still don’t know if this is common, we didn’t have a Christmas tree. Instead, we used some makeshift plant as a tree and put presents around it. Hooray. The stores were their usual self playing Christmas music with Christmas decorations galore. It was interesting to see the local KFC with their statue of Colonel Sanders dressed up in a Santa outfit and to see at the local mall not Santa but guess who? Ultraman. Who needs jolly old saint Nick anyway? Why not a super hero sent from space to defend Earth from aliens? Way cooler.

Ultraman @ AEON mall


New Years

The most interesting Japanese holiday traditions involve New Years. I was kind of surprised at how important it is here in Japan after experiencing how similar Christmas was. Firstly, Japanese people support the Chinese astrology and subsequently the animals of the Chinese Zodiac. The new year brings the tiger to replace the cow so likewise, you see images of tigers and stuffed fluffy tigers everywhere. Secondly, New Years brings the most fun and interesting concept to shops: fukubukoro! Fukubukoro is a Japanese New Years tradition at shops where shops include random goods into a sealed container and sell it for one flat price. They tempt you with what could be in the boxes like for example some electronic stores package $500 worth of stuff into a $250 fukubukoro and hide it randomly among other lower valued fukubukoro. I did end up buying one as I’ve looked forward to this all year long. I got a Police fukubukoro for $50 that contained a necklace, bracelet, and a hat. If you know Police, you know that’s a steal. Thank god more people don’t know Police here or that price would go through the roof.

Among other things, Japanese people tend to have a very specific diet on New Years. They generally start eating a prepared meal of raw fish and traditional Japanese foods in the morning. From there, I think it’s up to the family. Specifically, we had sushi for lunch and sukiyaki for dinner, which are both still very traditional Japanese meals. Also during this time, older people are expected to give money to younger people in the amount of generally more than $100. No it’s not an early birthday gift or late Christmas gift; it’s extra.

Another interesting tradition for New Years is one I took part in early New Year’s morning. Not all Japanese do this but many have done it at least once in their lifetime. The tradition is to climb the local highest mountain, visit the mountain’s temple before sunrise, and then view the sunrise with everyone on the summit. As it can be very cold during January and at 5 – 7 am, it’s understandable people don’t do this every year. However, it is a thrilling experience when you climb a mountain in the dark and see the sun break from the clouds in the freezing cold.

Peaceful sunrise on New Years Day

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Getting Things Done: The Personal Wiki

Posted: December 16th, 2009 | Author: | Filed under: General | Tags: | No Comments »

One application of David Allen’s Getting Things Done principles is the personal wiki (google Monkey GTD). Although the book is on my reading list and I have yet to touch it, there’s no reason to start ‘working on it’ early, eh? Well, I’ve been using a personal wiki for a few weeks now and let me tell you it is the best think since peanut butter. A personal wiki allows you to share knowledge with the most important person in your life — you! No, it’s not egotistical, it’s brain centric. Humans are notorious for forgetting things. If we stop, we forget. If we forget, we might lose information or skills that are necessary down the road. A personal wiki is beyond that. It is exactly like any wiki — it is searchable, indexes items, and can be used from any computer and certain mobile devices. If you know you are going to forget something, or want to write something down that could be important or interesting, why not save it in your own wiki? I don’t advocate being dependent on a machine to look up content you forgot or writing everything you read down; I’d rather you remember. However, as it’s impossible to remember everything, it could be a good source of knowledge kept just forgotten. Here’s an example of how I use it. Currently, I use it for is for writing book reviews to myself — at least for now. I remember a lot of details from books I read and yet I still forget a lot of the good stuff. The great stuff sticks, but it’s those one-liners and unique examples that might be peripheral to the solution but could really interest me down the road and allow me to remember complicated discussions and some of the reasons to support theories. Too bad I forget those the most. So, lately, I’ve been writing book reviews and keeping track of valuable information chapter by chapter — in my own words. I write a post to myself, indicating the main points of chapters and in a language I’m comfortable with. I don’t edit it as much as I edit assignments or work projects; it’s for my eyes only so that I can revisit it without having to read the whole book again. I also use it for jargon, definitions within my problem domain, that would otherwise be forgotten in a few hours if not minutes after look up. It’s a useful tool that maybe won’t pay off immediately, but in the long run for sure.

As for recommended personal wikis, I use TiddlyWiki. It is a 1 file HTML page that can be stored locally, on a jump drive, or on a server. It needs write permissions on the local drive to run but that’s certainly worth it considering how valuable it is. There are a ton of plugins for it if you know where to look. Goto this page to find them. All you need to do is download the index.html file and load it up in your personal wiki and it automatically detects the plugins and transfers it over. Neat eh? I was impressed on how powerful that one file is. I would hate to be working on it with a team of developers, but I can’t complain because it fits my needs perfectly. Anyways, I can’t express how useful this will be if you start using it. It might take some time getting used to but it can be like your own private journal — except this has a search function you might need 2 years down the road.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS