Friday, December 2, 2011

Ski season

Ski season in the Rockies is in full swing and my lack of updates reflect that. I am working on something cool at the moment, to do with interface automation testing, and I will be posting it very soon.

Saturday, August 20, 2011

Git Deployment Magic

I got nothing against [insert your favorite Git host here] but sometimes I find the cost unwarranted for simple projects and their tool set more then unnecessary for laid out waterfall development. So here I am going to demonstrate the following:
- Setup a remote git environment with auto deploy.
- Setup a local environment.
This process involves quite a bit of shell work so if you've never used a shell and your world is all about finding the cleanest GUI I did my best to break down the commands.

Setting up a remote environment
1) Create two directories, src and bin. The src directory will be where the git repository resides and bin where your website is deployed. These can be called anything and don't even have to reside in the same folder.
Make sure to get the path of the src directory by going in there and typing 'pwd'.
2) Initialize your src directory by running: 'git init --bare'
3) Create a post deploy hook via 'cp hooks/post-receive.sample hooks/post-receive'
4) Edit hooks/post-receive and add the following:
cd ../bin && env -i git pull
The env -i is necessary because git will always try and execute the command in the directory specified by GIT_DIR. If your bin directory is somewhere else make sure to specify that in cd (eg. cd /home/test/one/bin). To get full path type 'pwd'. For most people the bin directory will be where the host specifies the HTML/PHP/etc files go.

Setting up the development environment
1) Go to your local directory where the code will live and run: git clone user@ . and user need to be replaced with your remote server location information. I find all this information is much easier to store in .ssh/config and create a private/public key for authentication to skip password entry every time. Refer to google on how to do that.
2) After this your repository should be successfully checked out locally. Add a first few files and try the checkin process via: git push origin master.
This will create your first branch and push it to the server. When the push is done a copy will be automatically checked out to your bin deployment folder. Any errors in the process will show up during push and you have to fix accordingly.
NOTE: After your first push you have to manually clone the src into bin: 'git clone ../src .'

Hopefully this helps someone out and if you notice any errors, issues let me know,


Tuesday, June 7, 2011

OSX 10.7 Lion / Postgres installation issue

Recently I tried to install PostgreSQL on OSX 10.7 Lion and failed with this:

Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.

I looked into /Library/PostgreSQL/8.3 and everything seems to be there except the data directory. So open up System Preferences > Users & Groups and add a user postgres. Then as root:

cd /Library/PostgreSQL/8.3
mkdir data
chmod 700 data
chown postgres data
su postgres
./bin/initdb /Library/PostgreSQL/8.3/data
(Watch it go and then you can start your server via)

./bin/postgres -D /Library/PostgreSQL/8.3/data
./bin/pg_ctl start -D /Library/PostgreSQL/8.3/data/ (for daemon mode, pg_ctl --help has a full list of commands)

Now in a new tab try /Library/PostgreSQL/8.3/bin/psql -U postgres and all should connect.

One word of warning. If you are using just psql without the full path it will load the default Lion psql command and you'll get this error:

dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /usr/bin/psql
Reason: no suitable image found. Did find:
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper
Trace/BPT trap: 5

So make sure when launching psql that you include full path to the installation directory.


Friday, May 13, 2011

CSS3 iPhone Badge

It's amazing how much code is on Google but despite all my looking I could not find a CSS solution to recreate the iPhone badge icon. So here is my own.

a, a:link, a:visited {

background-color: #bc0000;
background: -moz-linear-gradient(100% 59% 90deg, #bc0000, #feb9be);
background: -webkit-gradient(linear, 0% 0%, 0% 78%, from(#feb9be), to(#bc0000));

border-radius: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;

box-shadow: 0px 3px 3px black;
-moz-box-shadow: 0px 3px 3px black;
-webkit-box-shadow: 0px 3px 3px black;

border: 2px solid #fff;
font-family:helvetica, sans-serif;
padding:2px 6px;


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! :)

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},

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: :)


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.


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.


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->xmlrpc->server('', 80);

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

$this->xmlrpc->request(array(array($request, 'struct')),'struct');

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

// this returns ticket ID

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

Wednesday, January 19, 2011

Extend CKEditor Link Box

Found an awesome post on extending the link box of CKEditor.
Yes this would be for a custom CMS integration I am working on but it's part of a much bigger picture.