Monday, May 9, 2011

May, the month of bitching

May month seems to be everyones month of bitching. Spring is not here, it feels like winter, I gotta get my winter tires off, jQuery 1.6 is gonna break my code, oh the Lion is here and it doesn't support Java, evil Apple locking everyone in with the store, iPhone is following me ... and on the list it goes.

The one that hit home is lack of support of Java on the new OSX Lion. Before I get into a rant here is a why I buy a Mac:
1) Quality and support.
2) Solid OS. Windows 7 is not there yet, Photoshop doesn't run on Linux and alternatives make me cry.
3) Buying options make sense. Lenovo and Dell need to read up on Paradox of Choice. I have a degree in Computer Science and I can't make sense out of their laptops.
4) I can run other OSes.

Point 4 is the one I am going to rant on about. Apple provides a great OS to serve as a basis for everything else. Having everything conveniently in one place is nice, but, as Windows has shown with registry, it doesn't take too long before a mix of programs creates a cluster fuck in a happy eco system. This really pisses me off because when I open a computer I want to work on it, not debug, defragmnet or reinstall. Then VMWare Fusion came along. For those not familiar with VMWare it's a way to virtualize any OS in OSX without dual boot. Run Windows, Linux, whatever and it just works in its own designated space. The previous 3 I bitch about, I do use because they serve their purposes for something, but just not that well to be used for everything. Linux is great for my server work, Windows for IE testing (that's about it) and for all my other stuff I have OSX. If I had to lean towards one specific OS it would be Linux and with Lion stripping Java I'll just have to run Eclipse in a VM. But the bottom line is that the Apple hardware plus underlying software combination is still great and solid and allows me to get work done. And if you don't like VM well you should be blaming Apple either way. If they didn't take Java in their own directions and allowed for a community driven project we wouldn't be in a shit hole to beging with. Personally I think this is a good thing for Java because now we can finally get the latest builds and use them how we see fit. That's my rant and 2 cents! :)

B
PS. The prices can be scary but look in the refurbished section.

Wednesday, March 2, 2011

iPhone - Cocos2D + Lua - Part 2

This is a continuation of my Part 1 tutorial.

This is the part 2 of my Lua/Cocos2D integration. Sorry for the delays but I've been busy, then sick, and now still sick and trying to get some work done. Updates are limited and I hope this helps out someone. At this point I've cleaned up the LuaBridge and added a LuaMenu layer. I have an idea for a game I will build using this project and these are good parts to start.

LuaBridge has been reduced to simple declarations:

static const CCNode *ccnode;
static const CCNode *ccmenu;
int lua(const char *, const char *, const luaL_Reg *);

ccnode and ccmenu are my shared variable with which the bridge interacts with active Cocos layer. lua is the main function which takes in the script name, the class name which will define my c function in Lua and a structure to my c functions.

LuaBridge also created a file path for the Lua script being called. When adding additional Lua scripts it's important to add them to the target project. Do this by right clicking on the Lua script, click Get Info, click Targets and check off your project, in my case LuaCocos2D.

When the Cocos2D menu layer is initialized the first thing it does is call the LuaMenu with the script. LuaMenu is a wrapper around Cocos2D menu functions that can be executed with Lua calls. This means that Lua can now begin interactive with the game without recompiling each time.

This by no means wraps the entire menu layer because it's not the useful part. Menu's do not change that often and do not depend on too many parameters. However, it is the easiest way to illustrate the connection and it is much easier to make changes in Lua instead of Code.

Inside the LuaMenu is a structure:

static const luaL_Reg menu_funcs[] = {
{"new", new_menu},
{"add", add_menu},
{"render", render_menu},
{NULL, NULL}
};

This is what gets passed to Lua script and Lua can call the C functions. When the function returns Lua expects it to be of type static int with luaState as the only argument. The arguments are returned on the stack and can be returned via:
const char *title = luaL_checkstring(l, 2);

The 1st argument on the stack is the pointer to the stack table and not needed for this purposes.

With returned values from Lua it's a simple matter of calling the appropriate Cocos2D functions and adding them to they layer.

Till next time! :) Let me know if notice any errors, have correction or better ideas for implementation. I am constantly re factoring the code and looking for better ways to do things.

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

B

Thursday, February 10, 2011

February is awesome

1) Short month.
2) Getting awesome surf in.
3) Got iTorque 2D for $94 bucks (I still have no idea how to use it but that's what vacation is for & surfing).
4) Finally replaced my Daihatsu master window control (myself and it works).
5) Weather is nice.
6) Work galore this month.

Million ideas at million miles a second but gotta stay focussed. There is nothing worse then a developer with a.d.d.

b.out();

Wednesday, February 2, 2011

Bugzilla API Request via PHP

Have you tried to use the Bugzilla API and fell flat on the face unless you are using Python, Perl, C#, Java or anything but PHP (I still like PHP). Sadly I couldn't get any XMLRPC clients to work with the xmlrpc.cgi because prior to 3.6 versions of the API, Bugzilla authenticated via cookies. Zend Framework seems to support this but it also happens to be a lot of work just to create a ticket. Well fear not, I RTFM over and over and found this little note:


You can specify Bugzilla_login and Bugzilla_password as arguments to any WebService method, and you will be logged in as that user if your credentials are correct.

in http://www.bugzilla.org/docs/3.6/en/html/api/Bugzilla/WebService.html

Documented in a very obscure place and 3.6 documentation is not the first to come up on Google. Here is some code via Codeigniter that does the trick but I assume any XMLRPC client will do the job with this concept.

$this->load->library('xmlrpc');
$this->xmlrpc->server('http://bugzilla.yoursite.com/xmlrpc.cgi', 80);
$this->xmlrpc->method('User.login');

$request = array('Bugzilla_login'=>'user@example.com', 'Bugzilla_password'=>'your_password', 'product'=>'Your Product Name', 'component'=>'User Submitted', 'summary'=>'Test', 'version'=>'x.x', 'description'=>'asdas');

$this->xmlrpc->method('Bug.create');
$this->xmlrpc->request(array(array($request, 'struct')),'struct');

if(!$this->xmlrpc->send_request()) {
echo $this->xmlrpc->display_error();
}

// this returns ticket ID
print_r($this->xmlrpc->display_response());

Enjoy this, took me a while to figure it out.
B

Wednesday, January 19, 2011

Extend CKEditor Link Box

Found an awesome post on extending the link box of CKEditor.
http://blog.xoundboy.com/?p=393
Yes this would be for a custom CMS integration I am working on but it's part of a much bigger picture.

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