Thursday, October 28, 2010

iPhone - Cocos2D + Lua - Part 1

New Apple licensing finally allows some interpreted code to be executed on the iPhone (http://www.appleoutsider.com/2010/06/10/hello-lua/). For most people this is an indifferent matter of keeping Flash of the iPhone. On the other hand, great projects like Unity and Corona are effectively prevented from delivering awesome solutions to the mobile world, seeing how they both rely on internal interpreters.

Now that we are over that hump I am glad I can finally start integrating Lua in all my games. Lua (http://lua.org) is a fantastic lightweight language, intended to be embedded and cross platform. There is entire Google on the benefits of this combination but in summary game logic can be implemented outside of the graphic engine (Cocos2D - http://www.cocos2d-iphone.org/ being my favorite). I've put together a quick demo of Cocos2D and Lua integration and I'll be working more on it as my game SnowRumble (http://snowrumble.com) rises out of ashes.

This post is a little short because I have to get some work done, but as soon as I get a chance I will write up more and try and explain exactly what's going on.

Git your code here: http://github.com/boriscosic/LuaCocos2D :)

B

Monday, October 25, 2010

OS X + Dovecot + Postfix

Today I pointlessly spent 4 hours figuring out a local mail setup for Snow Leopard. This is all readily available in _every_ variation of Linux and it upset me greatly that I could not just send test email to myself. (NOTE: THIS IS NOT HOW YOU CONFIGURE A MAIL SERVER!!! THIS IS FOR DEV PURPOSES ONLY.)

Problem 1. Lack of imap server.

For that I just downloaded dovecot. Setup is pretty straight forward.
./configure --prefix=/usr/local/dovecot
make && make install
cp /usr/local/dovecot/share/doc/dovecot/example-config/dovecot.conf /usr/local/dovecot/etc/dovecot/

Make sure all the right permissions are there:

sudo dscl . -create /Users/_dovecot
sudo dscl . -create /Users/_dovecot UserShell /usr/bin/false
sudo dscl . -create /Users/_dovecot UniqueID 104
sudo dscl . -create /Users/_dovecot PrimaryGroupID 104
sudo dscl . -create /Users/_dovecot NFSHomeDirectory /var/empty
sudo dscl . -passwd /Users/_dovecot ''

Then I edited dovecot.conf and commented out these lines:
22: #!include conf.d/*.conf

Then added:
protocols = imap
ssl = no
default_login_user = _dovecot
default_internal_user = _dovecot
mail_location = mbox:/var/mail/folders/%u/:INBOX=/var/mail/%u
disable_plaintext_auth = no

passdb {
driver = pam
args = login
}

userdb {
driver = passwd
}

I seriously can't be bothered to setup an SSL for a localhost test mail account only but if you do need one Google is your friend.
Save and start dovecot via /usr/local/sbin/dovecot.
All your issues should be logged in /var/log/mail.log

Problem 2. Postfix.

Since my entry into Linux administration I loathed configuring mail servers. Thankfully you can do everything these days via Google Apps and some quick DNS changes. Dealing with spam, relay blocking, users setups, mail clients and etc was an ongoing pita. But to get started with OSX setup was pretty fast.

Create a file /etc/postfix/virtual if you don't have it.
Add something along these lines. All test emails that go to the domains are forwarded to your user account. It is a quick way of setting up multiple emails for testing and replace 'boris' with your osx username.

@whatever.localhost boris
@me.local boris

Generate a virtual.db via 'postmap virtual'
Save and close and start postfix: 'postfix start'

You can now setup your mail to point to localhost and everything should be working. Open terminal and type:
mail boris (or bee@me.local)
test
.
Don't forget the dot on a new line and change boris to your username. Everything should be delivered to your localhost account.

That should be it and if you have serious trouble http://diymacserver.com/ is an awesome reference.

It is also possible to relay everything to Gmail but you need a valid hostname in your postfix (Gmail rejects localhost). I also do a lot of offline development so I don't always have Gmail there to do my email testing. Local setup + Git is an awesome way to stay off the grid and get some work done.

B