Feedback Form

Coda: a First Look

July 30, 2007

It’s not every day that I get really excited about a new application. But some weeks ago when Panic released their latest application entitled Coda (www.panic.com/coda/), I was instantly excited as soon as I read a little bit about it. And since it came from Panic, makers of Transmit, one of the best FTP applications for Mac OS X, I was even more interested.

Screen Coda

Four in one
So what is Coda? It’s an attempt by the people at Panic to replace a set of tools and applications that many developers of web sites use. FTP for transferring files, text editor for writing and editing the code, CSS editor, and SSH client. So today you may be using Transmit for FTP, TextMate for text editing, CSSEdit for CSS editing, and Terminal for SSH. Coda replaces all of them in one application. Or at least it attempts to.

The site is the core
To start working with Coda, you set up sites. Each site has it’s own URL, FTP and SSH login details, as well as a local copy of the files you’re working on. Once a site is set up you can double click to connect to it, and Coda will restore the files you had open from when you worked on it before.

Interface
The interface is a bit different from many other applications and for the most part Panic got it right, I think. The main parts are the files, over on the left, which you can switch from local and remote view. Then there are buttons along the top for Sites, Edit, Preview, CSS, Terminal, and Books. What’s a bit confusing is that some of these pertain to individual files (Edit, Preview, and CSS), while Sites is obviously for setting up and connecting to sites, and Books is for reference. Let’s say you’re editing a remote file, and you click on Terminal. Would you expect the Terminal to open as a new tab or “over” the existing tab (which is the remote file)? I would say it would make more sense for the Terminal to be a new tab, but it “replaces” the tab that is already there. Then you have to click Edit to see the remote file again. Little peculiarities like this makes an otherwise excellent user interface a bit lacking.

References
If you’ve done any web development you probably know that you often have to look up something in a book or online. Panic thought of this as well and included easy access to online reference books in HTML, CSS, JavaScript, and PHP.

Share the load
Programming and web development is often a collaborative effort. Panic thought about that and included functionality so you can share a document over a local network via Bonjour (see “What is Bonjour?” in the May issue of shuffle).

What’s lacking
I’ve not used Coda for very long, in fact I’m still within the 15 day trial period, and most things are excellent. It’s a very nice text editor, the CSS editor is not quite up to CSSEdit’s class but it’s close, the Terminal is good for any SSH work, and it’s also a good, overall FTP program (but I won’t get rid of Transmit anytime soon). One thing I would like to see is built in support for version control, like CVS or Subversion. Perhaps a special Coda server version that could be installed on a Mac, that would seamlessly integrate with Coda clients. That way you could collaborate with more people and over the internet, not just on the local network.

Final thought
Coda is a breath of fresh air into a somewhat stagnating segment of applications. The integration of different applications is well executed, and the individual tools are almost good enough to stand on their own. To some Coda, at $89, may seem a bit expensive, but if it can replace four applications, it’s well worth it.

by Magnus Nystedt

MySQL on Mac Part 3

May 29, 2007

We’re continuing the MySQL series on how to operate a MySQL installation on your Mac. In the first part (see the March issue of shuffle), we looked at logging into a MySQL database server running on a Mac, as well as how to see what databases are available, and how to create a database. In the second part (see the April issue of shuffle) we covered how to create tables and fields. Now, in the third and final part we will look at how to get data out of a database.

To get data out of database we use the Select-statement. It’s called putting a together a query which is an appropriate name because you’re essentially asking a question of the database and seeing what the answer will be. With a Select-statement you basically ask for some information from one or more tables in a database and you give some criteria for what information should be returned. For example, if we have a table called customer and we want all records from it, we type:

SELECT * FROM customer;

The star (“*”) means we want all fields (columns) returned. If the table has ten fields, we get all ten fields returned. Instead if we want just one field returned, let’s say the name-field, we type:

SELECT name FROM customer;

And we can also ask for a specific number of fields, like name and email, like this:

SELECT name, email FROM customer;

That’s how we choose which fields to return. Next, let’s look at how to select which records to return. Let’s say we want to find the customer with the id 5. Then we type:

SELECT * FROM customer WHERE id=5;

Or if we want to find any customer in Dubai that is of type hotel, then the query is:

SELECT * FROM customer WHERE city=”Dubai” AND type=”hotel”;

That’s a very quick introduction to Select-statements. There’s certainly much more to learn but all we wanted to accomplish is to give you a start. From here, if you want to learn more, there are plenty of good books, and many helpful web sites. You can of course also post on www.emiratesmac.com and ask for help.

Wrapping Up
That concludes our brief series on how to use MySQL on your Mac. We hope you can now go on and work with MySQL or some other SQL-variant on your Mac, and perhaps create databases for your own personal use. It may even be that with this as a basis you can create some dynamic web sites. Look out for a new series on PHP in future issues of shuffle. PHP paired with MySQL is arguably the most popular technology for developing dynamic web sites used on the internet today.

by Magnus Nystedt

MySQL on Mac Part 1

April 28, 2007

In the November 2006 issue of shuffle we published an article about how to install MySQL in Mac OS X. MySQL is a free, open source, database server product that you can install on pretty much any operating system including Mac OS X. MySQL may be free but it’s also highly reliable and scalable and it’s use by many of the busiest web sites on the internet, and many corporate systems as well.

This article series
In this series of articles we will look at how to do some of the basic things with MySQL, like create tables, enter information, and get information back out of the database. We will do all of this with the command line so get ready to do some typing. In this the first part we will log in to MySQL, and see what you can do with databases. I assume you have MySQL installed on your Mac and that it’s working.

Quick introduction to databases
We’re going to work with a relational database. If you have no experience with building databases there will be much here that is new. You will at least need to know and understand what tables, fields, records, and keys are. A database is a collection of tables. Each table holds information about something in particular, like a student, a vehicle, or an EMUG member. Every time you store some information in a table, you create a record. So to add an EMUG member to a table, you would create a record. Each record has a number of fields in it that describe that record. For example, for one EMUG member the database would need to know name, email address, phone number, etc. One of those fields is a primary key, the thing that makes one record unique from all other records. Each EMUG member has a unique membership number, as an example. Since we’re working with relational databases, each record can be related to another record in a different table. For example, a student in a college is related to all the different courses he or she is taking. In a similar way, each player in a football team is related to the team, and the team is related to at least one coach.

Login
If you haven’t already, open a Terminal window (Applications>Utilities>Terminal). First you have to log in to MySQL. You do this with by typing “mysql -u yourusername -p” at the prompt. This means you want to connect to the MySQL server using username “yourusername” and your password. Replace “yourusername” with your actual MySQL username of course (which you would probably have set when installing MySQL). In the example I connect using the username “root”. When MySQL asks you for the password, enter your MySQL password. See code example 1.

iMac:~ emiratesmac$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 5.0.27-max
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>

List databases
To see what databases that are available to you (which depends on the level of access of the account you’re using), you use the command “show databases;”. Note that you end each command in MySQL with a semi-colon (”;”). See code example 2.

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| test |
+——————–+
3 rows in set (0.00 sec)
mysql>

So on this MySQL server there are three databases, “information_schema”, “mysql”, and “test”.

Use a database
To use a particular database you type the commando “use” followed by the name of the database. See code example 3.

mysql> use test;
Database changed
mysql>

Create a database
To create a new database you type the command “create database” followed by the name of the new database. See code example 4.

mysql> create database emiratesmac;
Query OK, 1 row affected (0.00 sec)
mysql>

If a database with that name already existed you would get an error message. See code example 5.

mysql> create database emiratesmac;
ERROR 1007 (HY000): Can’t create database ‘emiratesmac’; database exists
mysql>

To avoid getting that error message, add “if not exists” to the command. See code example 6.

mysql> create database if not exists emiratesmac;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>

Then MySQL will create the database is it does not already exist. If there is a database with the same name already, no new database will be created.

Wrapping up
This was the first part of our series about MySQL and Mac OS X. We covered some brief database fundamentals, how to log in to MySQL, how to see what databases you have access to, and how to create a new table. In the next issue of shuffle we will look at how to create tables within databases, and how to put fields within tables.

SIDEBAR
The database world is full of theories and concepts that you will have to be able to grasp in order for you to create and work with databases. You will have to know what table, field, relationship, primary key, etc. are. A good place to get started is http://en.wikipedia.org/wiki/Relational_database.

SIDEBAR
Apple has an interesting article about MySQL on Mac OS X at http://developer.apple.com/business/macmarket/mysql.html. There’s also a good article about MySQL on Mac OS X at http://www.macdevcenter.com/pub/a/mac/2005/12/13/mysql.html.

By Magnus Nystedt

MySQL on Mac Part 2

April 28, 2007

We’re continuing the MySQL series with the steps involved in creating tables and fields. In the first part (see the March issue of shuffle), we looked at logging into a MySQL database server running on a Mac, as well as how to see what databases are available, and how to create a database.

Create and Select Database
You learned this in part one of this series, so I’d like you to go ahead and log in to your MySQL server, and create a new database called “emug”, and select it for use.

Tables, Fields and Field types
Each table has a number of fields. Think about a table that should hold information about EMUG members, for example. It should hold information about a member’s membership number, their name, their mobile, and their email address. You also need to decide what type of data would be entered into each field. For example, membership number is a number, so only digits. Their name is obviously characters, etc. Finally you need to decide on a primary key. The primary key is a field that makes one record unique from all other records. In our example, membership number is what makes one member unique from all other members, in the database’s eyes.

Create Table
Our next step is to create our table, “member”, and set what fields goes into the table. When you create a table you also create the fields. You can later add, delete, and edit fields, but it’s a good idea to try to get it as correct as possible from the start. We’re now going to create a new table called “member”, with the fields “membershipnumber”, “name”, “mobile”, and “email” in it.

CREATE TABLE member (membershipnumber INT PRIMARY KEY, name VARCHAR(100), mobile VARCHAR(11), email VARCHAR(50));

This creates a table called member with four fields in it. The “membershipnumber” field can contain just digits (”INT”) and it’s the primary key. The other fields can contain characters and digits of various lengths (”VARCHAR”).

You can now type “SHOW TABLES;” to see that MySQL did indeed create the new table.

Enter Data
So now we have a table, with fields, but we still don’t have any data in the table. And the whole idea of a database is to work with data, so how do we get some data into the table? Try this:

INSERT INTO member (membershipnumber, name, mobile, email) VALUES (1, ‘Michael Jackson’, ‘050-1231234′, ‘michael@jackson.com’);
INSERT INTO member (membershipnumber, name, mobile, email) VALUES (2, ‘John McEnroe’, ‘050-1234321′, ‘john@mcenroe.com’);

This creates two records in the table. Notice how we made the membership numbers different (1 and 2)? That’s because the primary key field has to contain a unique number for each record. Entering the same number for both members would not work.

Wrapping Up
That concludes our second part of the three part MySQL series. We covered how to create a table, set what fields should go into the table, and what data should go into each field. We also entered a little bit of data. In the next issue we will see how we can get some data out of a table. Obviously we don’t just want to put data into the database, we also want to get data out.

SIDEBAR
MySQL AB recently released the 1.0 version of the GUI (Graphical User Interface) tools (dev.mysql.com/downloads/gui-tools/5.0.html). With them you can administer and work with MySQL databases through a point-and-click interface. We will get back to these tools in a future issue of shuffle.

by Magnus Nystedt

Say XAMPP Five Times Fast if You Can

March 27, 2007

by Magnus Nystedt

Have you ever wanted to try out some web application programming? Perhaps writing your own blog engine, or just publish your company’s employee list to a web page?

There are obviously many options for you and your Mac comes with some of them built in. Mac OS X comes ready to go with Apache, PHP, Perl, FTP server, and more. If you want to try these things, and more, but you want something that’s more up to date than the versions that come with Mac OS X and that’s easy to install, try XAMPP. XAMPP is free and it’s an all-in-one-package for development of dynamic, database- driven web applications using open source technologies. he Mac OS X version of XAMPP contains Apache, MySQL, PHP & PEAR, SQLite, Perl, ProFTPD, phpMy- Admin, OpenSSL, GD, Freetype2, libjpeg, libpng, zlib, Ming, Webalizer, mod_perl, eAccelerator, and phpSQLiteAdmin. XAMPP is about 50Mb to download, it’s easy to install, and it comes with a control panel application from which you can control the individual components. For example you can start and stop the MySQL database in XAMPP by one click on a button. XAMPP offers you a simple way to try out some of the more current versions of these applications without going through too much of individual downloads and work with the command line.

If you can figure out how to say XAMPP ive times fast, you can figure out how to develop dynamic web applications. You can download XAMPP for free from http://www.apache-friends.org/en/xampp-macosx. html. A similar package is MAMP which you can get from http://www.mamp.info/en/home/.

Hidden gems among Apple’s Developer Tools

January 2, 2007

You may not be aware, but Apple gives away their Developer Tools for free (developer.apple.com/tools/). All you have to do is register for a free online membership in the Apple Developer Connection (ADC) and then you can download the Developer Tools. Once you have installed the Developer Tools you have one more folder on your hard drive. The folder is called “Developer” and it’s full of different goodies. Obviously the main purpose of everything in Developer Tools is to write code and develop software, but some of it may be interesting in even if you are never going to develop software.

by Magnus Nystedt

XCode
XCode (in Developer > Applications) doesn’t really belong here because it’s not “hidden”, it’s the core of the whole Developer Tools package. If you don’t know what XCode is, it’s what’s called an IDE or Integrated Developer Environment. Basically that means it’s an application which programmers use to write their code, test their code, and compile the code into double-clickable applications or whatever it is they are developing. If you want to develop any kind of software with your Mac, chances are you’ll end up using XCode sooner or later.

Core Image Fun House
Arguably Core Image Fun House (Developer > Applications > Graphics Tools) is the most fun and potentially also useful application out of the ones mentioned here.

Repeat After Me
The manual for Repeat After Me (Developer > Applications > Utilities > Speech) says “Repeat After Me is a tool that is designed to improve the pronunciation of text generated by the Text-To-Speech (TTS) system, by means of editing the pitch and duration of phonemes”. So what does that mean? “EmiratesMac”, for example, turns out to be “_1EHmUXrIXts _m1AEk.”. Not exactly something you can read easily, I would imagine. But that’s how the Mac sees the text that it speaks. You can then edit the phoneme-text and experiment to see how your changes affect the way the Mac speaks the text.

FileMerge
Have you ever had two pieces of text and wondered what exactly is the difference between them? With FileMerge (Developer > Applications > Utilities) you have to wonder no more. The utility takes two text files and displays them side by side, showing you the difference between them. Many text editors have similar functionality built in but even if it doesn’t, FileMerge gives you quite advanced functionality.

Pixie
Pixie (Developer > Applications > Graphics Tools) is a simple magnifying glass application. Run it and it will show you a small part of the screen magnified up to 1200%. This will let you inspect up close one or more pixels somewhere on the screen which could be helpful if you’re working on a web page and something doesn’t align correctly, and other similar situations.

That’s just a small selection of what’s available when you install the Developer Tools. And since it’s all free what do you have to loose more than some space on your hard drive?