Home Blog Tags HOWTO
Tags >> HOWTO
Jul 21
2010

Couple of useful OS X Tricks

Posted by: Marko Tomic

Tagged in: OS X , HOWTO

I just stumbled upon 30 Fantastic Geeky Tricks To Get The Most From Your Mac and I thought I'd write down a couple of tricks I found useful.

Recent Items Stack

Type this in terminal window to show a stack of your 'recent applications'.

defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'

Show Hidden Files

The following command will show all hidden files in your Finder.

defaults write com.apple.Finder AppleShowAllFiles YES

Similarly, change the last bit to 'NO' to re-hide the files.

Enable Safari Inspector

I didn't know that Safari had an Inspector that looks like the one in Google Chrome. As a web developer, I can say that this is music to my ears. Enable it in Terminal:

defaults write com.apple.Safari IncludeDebugMenu 1

Better Screen Sharing

When I first saw Screen Sharing on a Mac, I thought it was the best thing since sliced bread. Apparently, there are more nifty Screen Sharing features that are hidden by default.  This includes a number of options for adjusting quality and allowed input on each side of the screen share. To turn them on, type this in your Terminal:

defaults write com.apple.ScreenSharing \
'NSToolbar Configuration ControlToolbar' -dict-add 'TB Item Identifiers' \
'(Scale,Control,Share,Curtain,Capture,FullScreen,GetClipboard,SendClipboard,Quality)'

Jun 16
2010

Removing default icons from Flex Tree control

Posted by: Marko Tomic

Tagged in: HOWTO , Flex , AS3

What's so cool about Flex framework is the fact that it's very extensible, which allows me to do almost anything I want with it.

For example, to remove folder/arrow icons from Flex Tree control, which prevents nodes from collapsing and also creates more space for labels, you can add the following in your stylesheet:

defaultLeafIcon: ClassReference(null); 
folderClosedIcon: ClassReference(null);
folderOpenIcon: ClassReference(null);
disclosureClosedIcon: ClassReference(null);
disclosureOpenIcon: ClassReference(null);

For more information on Flex Tree CSS properties, refer to AS3.0 Reference.

Marko

May 20
2010

Startup Script for Apache Tomcat on Snow Leopard HOWTO

Posted by: Marko Tomic

Tagged in: Tomcat , Railo , OS X , HOWTO , Apache

I have just set up Apache Tomcat startup script on Snow Leopard and I thought I'd blog about it while it's still fresh in my head.  Assuming you have installed Tomcat in /usr/local/tomcat directory, you can do the following to start Tomcat on system startup.

1. Create your startup script:

sudo nano /usr/local/tomcat/bin/tomcat

#!/bin/sh # Tomcat Startup Script
 
CATALINA_HOME=/usr/local/tomcat; export CATALINA_HOME
JAVA_HOME=/Library/Java/Home; export JAVA_HOME
TOMCAT_OWNER=root; export TOMCAT_OWNER
 
start() {
        echo -n "Starting Tomcat:  "
        su $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh
        sleep 2
}
stop() {
        echo -n "Stopping Tomcat: "
        su $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh
}
 
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: tomcat {start|stop|restart}"
        exit
esac

Set your TOMCAT_OWNER correctly.  You should run it as a valid system user.


2. Create a symbolic link in /usr/bin for easier access

sudo ln -s /usr/local/tomcat/bin/tomcat /usr/bin/tomcat


3. Create the startup daemon which will start Tomcat when the system boots up

sudo mkdir /Library/StartupItems/tomcat
sudo nano /Library/StartupItems/tomcat/tomcat

#!/bin/sh
. /etc/rc.common
 
# The start subroutine
StartService() {
    # Insert your start command below.  
    tomcat start
}
 
# The stop subroutine
StopService() {
    # Insert your stop command(s) below.
    tomcat stop
}
 
# The restart subroutine
RestartService() {
    # Insert your start command below.
    tomcat restart
}
 
RunService "$1"


4. Create your startup parameters plist file

sudo nano /Library/StartupItems/tomcat/StartupParameters.plist

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
    <dict>
        <key>Description</key>
        <string>Tomcat web server</string>
        <key>OrderPreference</key>
        <string>Late</string>
        <key>Provides</key>
        <array>
                <string>Local Web Services</string>
        </array>
        <key>Uses</key>
        <array>
                <string>SystemLog</string>
        </array>
    </dict>
</plist>

Restart your Mac and you should be sweet.

For more info on how to install Tomcat, e.g. Railo on Tomcat via Apache see my blog post on Learnosity Website. Also, have a look at Mark's version using Apache mod proxy 
 
Marko

May 19
2010

MySQL startup script on Mac OS X Snow Leopard

Posted by: Marko Tomic

Tagged in: OS X , MySQL , HOWTO

I've had problems starting up MySQL database server on startup on Snow Leopard.  MySQL preference pane seems to be flaky and it often fails to start MySQL server.

I created this startup script myself and it seems to work nicely.

sudo nano /System/Library/LaunchDaemons/org.mysql.mysqld.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true/>
<key>Umask</key>
<integer>7</integer>
<key>UserName</key>
<string>_mysql</string>
<key>Disabled</key>
<false/>
<key>WorkingDirectory</key>
<string>/usr/local/mysql</string>
<key>GroupName</key>
<string>_mysql</string>
<key>KeepAlive</key>
<true/>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld</string>
<key>Label</key>
<string>org.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>--user=_mysql</string>
</array>
</dict>
</plist>

Now make sure file permission is correct and load the daemon.

sudo chown root:wheel /System/Library/LaunchDaemons/org.mysql.mysqld.plist
sudo launchctl load /System/Library/LaunchDaemons/org.mysql.mysqld.plist
sudo launchctl start org.mysql.mysqld

Restart your Mac and your MySQL server should be running.

Marko

Apr 19
2010

Zen Cart Friendly URLs

Posted by: Marko Tomic

Tagged in: Zen Cart , PHP , HOWTO , Apache

I've been exploring Zen Cart shopping cart for a long time and one thing that, I thought, needed improvement was the support for friendly URLs. Ultimate SEO URLs break my site and I needed another solution. I found this little beauty called Simple SEO URL and it works beautifully.  It's a little tricky to set up, but it's worth the effort.  Installation process will take you about 15-20 minutes.

I use Zen Cart 1.3.8a and SSU 3.8.3. If you have different version(s) the following steps may not work.

Download Simple SEO URL


Requirements
1. PHP 5
2. mod_rewrite enabled on your Apache web server

3. Zen Cart Module Manager installed


Installation
1. Unzip and upload your files to web server
2. Go to Admin==>Extras==>SSU Manager
3. Open path_to_store/.htaccess and add:

If your .htaccess file already has stuff in it, do not overwrite it.  Simply append the following

#### BOF SSU
Options +FollowSymLinks
RewriteEngine On
# Change "/zencart/ to the correct setting
# if your site is located at root folder, then you should have RewriteBase /
# Go to your include/configure.php, this value should be the same with the value of DIR_WS_CATALOG
RewriteBase /zencart/

# Deny access from .htaccess
RewriteRule ^.htaccess$ - [F]

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^(.+) index.php/ [E=VAR1:,QSA,L]
#### EOF SSU

Makle sure your "RewriteBase" path is correct.


4. Set path_to_cache_folder/ssu and its subfolders permission to 0777
5. Now go to Admin==>Configuration==>Simple SEO URL to enable and configure your friendly URLs.

That's it.  You can also test your installation http://yoursite/ssu_check.php after which you can remove ssu_check.php from your server.

Marko

Feb 06
2010

HOWTO convert and shrink your DVD into a web-playable format

Posted by: Marko Tomic

Tagged in: HOWTO , HandBrake , DVD , command

HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded video transcoder, available for MacOS X, Linux and Windows.

It is my tool of choice when it comes to backing up my DVDs. It allows me to shrink DVDs to a relatively small size and convert them to a web-playable format, such as mp4.

I use the Command Line version of HandBrake simply because it is more efficient and I love typing geeky commands in my terminal window.  So here it is, the simplest command to convert your DVD into an .mp4 file is this:

HandBrakeCLI -i VIDEO_TS -o myVideo.mp4 -e x264 -b2000 -B 192

That will encode a source video located at the path VIDEO_TS to an output file called myVideo.mp4. It will use x264 with a bitrate of 2000 to encode the video, and encode the audio as 128kb/s AAC.

Nov 12
2009

Generate Self-Signed SSL Certificate - HOWTO

Posted by: Marko Tomic

Tagged in: SSL , HOWTO

This is another one for my reference. I've had to generate a self-signed SSL certificate quite a few times and I'm sure I'll do it again in future. First of all, self-signed SSL certificates provide the same level of security as any other commercial ones, such as Verisign certs. The 2 main differences are:

1. Self-signed certificates are free
2. Self-signed certificates are not recognised by web browsers by default. They need to be installed in browsers manually in order to be accepted by them. This is a 10 second job.

So, if I am setting up a staging web server or a subversion server on a secure domain, a self-signed SSL would be an obvious choice for me. There are a few ways you can generate your SSL certificates, but this is how I like to do it because it works for me on Mac and Linux.

Step 1: cd into my working directory

cd ~/Desktop/KeyGen

Step 2: Generate my key - a Triple-DES encrypted, 1024 bit RSA key

openssl genrsa -des3 -out server.key 1024


You'll be asked to enter in a passphrase.

Step 3: Create a CSR (Certificate Signing Request)

openssl req -new -key server.key -out server.csr

You'll be asked to enter in some basic information about your organisation such as, country, name, state, email etc... Here's a sample output:

Country Name (2 letter code) [AU]: (enter your country code here)
State or Province Name (full name) [Some-State]: (Enter your state here)
Locality Name (eg, city) []: (enter your city here) Organization Name (eg, company) [Internet Widgits Pty Ltd]: (enter something here) Organizational Unit Name (eg, section) []: (enter something here)
Common Name (eg, YOUR name) []: (this is the important one)
Email Address []: (your e-mail address)

Step 4: Remove passphrase from my key. Note: I want to remove it because Apache web server will ask me to enter it in every time I restart the server. If you want to keep the passphrase, skip this step.

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

Step 5: Create a self-signed certificate using the key I just created. Note: "days -365" will make the certificate valid for 1 year. You can easily make it valid for 10 years if you like. I'm sure you can figure out how to do that!

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

That's it. Now all you need to do is make it work with Apache by enabling mod_ssl and adding the following in your virtual host:

SSLEngine On
SSLCertificateFile 'full_path'/server.crt
SSLCertificateKeyFile 'full_path'/server.key

Stalk Me

Facebook: marko.tomic Twitter: mtomic Twitter: SydneyScuba YouTube: migonyourtail Linked In: tomicmarko MySpace: markomedia Google Wave: marko2009 blip.fm: markotomic Flickr: markotomic FeedBurner: markomedia

Site Login

Tag Cloud

Browser Poll

What browser do you use?