November 27, 2009

Remote File Request to NSString in Objective C

A current side project in Obj C that I m working on required a way to fetch a remote HTML file and parse through it to get the url of links and images. The first step required a way to get a remote file and store it as a NSString. The code below is an example of how to so.

NSString *url = @"http://www.google.com";
NSURLRequest *urlrequest = [ [NSURLRequest alloc] initWithURL: [NSURL URLWithString:url] ];
NSData *returnData = [ NSURLConnection sendSynchronousRequest:urlrequest returningResponse: nil error: nil ];
NSString *returnstring = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];

Tested on OS X 10.5+ with GCC 4.2

November 14, 2009

Simple Java XML Parser

To continue my SN Project work I started to convert the simple object to data save format I had been using to save time during the semester into a xml based file system. This way when I update code it will not break saved game file due to class def not found exceptions. However I quickly ran into an issue that Java did not have a "simple" built in class to handle XML parsing and other free libraries where a little more complex then I was looking for, so although I usually try not to reinvent the wheel while programing, this time I wanted to try my hand at writing a simple Java XML parser.

What this basic XML parser does:  It looks for the starting tag < and then starts appending the tag characters to the node tag.  Then it hits > telling that the tag had ended and the data starts finally it looks for < for the next node.  There is also the case that another < is found in the data which indicates that a nested tag was found.  The older node is pushed on a stack and the parser moves up one child node and begins the tag and data read once more. This is repeated until no nodes are left on the stack indicating the root closing tag has been reached.

As a note:  I have removed most of the advanced checking and my custom xml build methods for security reasons, so you are on your own to add try/catch as needed.  Also, as I am not using any attributes in tags, so this parser does not read them.

Overall the code works well for the xml documents I am reading in, though for one class I may still look into a faster c based solution in the future, since I am working with a JNI library anyway.

You can check out the code HERE
As usual the code is free to use, but please give me some credit if it is used in a large project, or leave a comment about what it was used in.

October 31, 2009

Epic Box Pumpkin




Continuing the pattern of holiday themed epic boxes, I introduce the Epic Box Pumpkin.

Happy Halloween Everyone!

October 30, 2009

Haibane Renmei Communicator Costume





For this years halloween costume I decided to go with the Haibane Renmei Communicator, at the suggestion of one (or two I forget exactly) of my friends after watching the series at school last year. I had mentioned that it would be a cool costume, so with that push, this year I actually spent the time to bring it to life.

Below is some basic steps I followed, if you are interested in making a similar costume, as there was very little to no information beyond a few cosplay pictures online. So I hope this helps others out looking for a design.

The mask was made out of two halves of a styrofoam craft ball, then routed into shape and then finished off with a good sanding and eight layers of white acrylic latex paint to smooth it down. The black color is permanent marker as I was so sick of painting and sanding at that point. The pendant is also made from styrofoam and a similar process but a brown marker.

The costume is made from my own designs and a combination of tunic 1 from Simplicity pattern 4795 and the hood from cloak A in Simplicity pattern 5840 which is modified for the longer back strip and a rounded flop at the top. The the striped front was of my own pattern , which could have been longer, but still looks fine non the less.

The belt is a standard leather belt. I was too cheap/lazy to buy some red cord.

The wings where made of foam poster board which I used a wood rasp to round the edges. Then covered with thick acrylic brown paint to get a wood like pattern. I added tassels to the six holes drilled into it. The wings where attached to the striped front via two longer strips at the top. I drilled two extra one inch holes at the top of the wings and used two extra straps that looped through and connected to the longer strips that go over the shoulders.

The stick is also foam, a rounded ball and two wings that I cut out of the leftover foam poster board and then painted. he halo is copper wire. The stick is a old handle from a rake or some other garden tool that broke, which the top part is wrapped in leftover fabric.

- Time Required -
Sewing = ~16 hours
Painting/drying = 1 week

Total cost: $42 (Stupid expensive styrofoam!!!)

I like how I get better and better at sewing each Halloween season. I expect next year will be even better!

October 26, 2009

Halloween costume confusion

With this years halloween costume finished, I was thinking back on the other costumes I have had over the years. However it did not take long for me to realize the trend of people having no clue to what I am going as. Now for a few of the costumes I have to admit that it was expected that my idea was obscure, but some times it was just annoying. For a bit for fun let me give some examples with the reactions I received. Oh and if you do not notice, I have never had a store bought costume.

Green Power Ranger (Back when it was just starting!)
- Had no clue, I was too early as next year there where other kids with commercial ranger costumes.

Red Coat Costume (I liked the hat)
- Thought I was a pirate... sigh learn more history people!

Chinese dragon (of one)
- Had no clue, I thought it was cool, and it even ate the candy.

Kosh-tume V1 (Babylon 5)
- Had no clue, sort of understood when I said an alien.

Custom Dn'i Cloak (Myst)
- Had no clue.

Kosh-tume V2 (Babylon 5)
- Most had no clue, a few B5 fans caught on.

So for this years costume, which I will post in a day or two, I expect the same as usual. It is funny, as I am so used to it if someone I do not expect knows what I am I was be flabbergasted. Still, I am always far happier with a unknown custom costume, it just fits me better.

October 23, 2009

Installing Quicktime 7 in Snow Leopard 10.6

On small annoyance with 10.6 and Quicktime X is the some important older components do not work yet. So in order to use these older components you will need to install an older version of quicktime 7.

1. First off download quicktime 7 from Apples website here.

2. Right click and select view contents of the Installer and view the Contents folder.

3. Expand the Archive.pax.gz and open the resulting Archive folder.

4. In the Archive/Applications folder drag the Quicktime application to your Utilities folder

5. In the Archive/System/Library/PreferencePanes double click the QuickTime.prefPane and have it install for all users.

6. Register Quicktime pro if you have a license key.

There you have it a easy way to use Quicktime 7 in 10.6 with out having to reinstall your OS.

October 20, 2009

Mac OGM to iPOD conversion

This is more of a post for my self because I always forget what the name of software tools, so here is my simple guide to converting OGM files on a Mac.

1. Download D-Vision from http://www.objectifmac.com/

2. Download and install the Xiph quicktime component. from http://www.xiph.org/quicktime/

3. Click tools and use the OGM Demuxer function to split the OGM file into separate parts.

4. Open the AVi video only file in quicktime 7. (Snow Leopard aka 10.6 will need an older version of Quicktime as vr X does not work with the Xiph component yet)

5. Copy the audio track and use the "add to movie" option to insert it over the video track.

6. Finally use the export option in quicktime to export it as iPhone or iPod format.

This works fine under 10.5 and below, however as noted in 10.6 you need to use the older ver of quicktime, see my guide on installing Quicktime 7 on Snow Leopard here.

October 5, 2009

Online IE Testing

I had stumbled across IE Netrenderer a few weeks ago, it is a site that lets you put a url into the form on the page and will return a picture of how that site looks rendered in different versions of Internet Explorer. For me as a mac owner this is awesome as it allows quick page testing in IE. I have been using Crossover to run both IE6 and IE7 and for the most part works quite well, however Crossover has some issues with occasional things like transparency in IE7 and can not run IE8. So for final tests IE Netrenderer is perfect for the job. As an added bonus it also allows you to do an overlay of IE6 vs IE7 for ironing out these few small differences in site layouts. Check it out for you self, if you are a Mac or Linux user I guarantee this is something you will want to bookmark.

September 30, 2009

Tomcat install on OS X 10.4

I had seen Tomcat on job applications before, however this was the first time I had actually played with it. What is it? "Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process." So it allows you to run Servlets and JSP on a server. Now I needed to find out how to install it on my Lazurus server running OS X 10.4.11 with the latest Java update.

1. First download tomcat from HERE (I used 5.5, so not sure about 6)

2. Then rename the unarchived tomcat folder to "Tomcat"

3. Drop the folder into /Library/

4. Fix the UNIX permissions recursively to 777 (BatchMod is a simple way if you do not know chmod, just check all of the boxes)

5. Edit the /Library/Tomcat/conf/tomcat-users.xml file, see below for example.


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat,admin,manager"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>


6. Start tomcat by using the terminal to run "cd /Library/Tomcat/bin" and then "./startup.sh"

7. In a web browser head to http://127.0.0.1:8080/ and you should see the Tomcat start up page.

If you want to read on further I figured out most of my instructions from the Tomcat Wiki, so head there for more info or if you get stuck.

Just in case you where wondering, as I was, put your jsp and servlet files in the /Library/Tomcat/webaps/ folder. The webaps/ROOT folder being the one displayed at the base url address. So for now I am just using that folder for testing.

JSP is quite simple to pickup at a basic level if you already know Java. However there are a few differences do to it being web based, but so far I like not having to compile manually. I had no problem writing a few simple classes with outputs and will later play with post and get. HAHA, tri-fecto of web programing achieved (PHP, ASP, JSP), hm still need to sit down with Perl one of these days.

September 14, 2009

Objective C for the iPhone or iPod

I finally decided to sit down and start working with Objective C, namely to expand my development areas into the iPhone and iPod areas. Not that I have any current grand ideas, however I had been meaning to create my own version of lights out and though it might be a good time to get to work. However, who know it may be worth paying the $99 developer fee in the future, but right now I am looking at jail broken device deployment only.

Objective C is similar and at the same time quite different from regular c/c++. One of the biggest differences is that you can use the dot operator, but also have the option of sending messages instead or a mix of the two. For example you could have class.method(input); or you could do [class method:input]; At first this was a little strange, however after a few hours I started to like it a little as it clearly defines what is processing code and what is message code.

Another change for me was using the Interface Builder in xcode. I had played with it briefly before, however I have never actually sat down and used it. It took me a while and some google searching however once I realized that I needed to add a method reference in the .h file as well as the .m file I could then see the links in interface builder. After that I was golden and quickly linked the button in my first game to UIBUttons that could be referenced in the code as well as a single buttonPressed method. HINT: Copy and paste is much faster then doing it individually. This reminded me a little of working in VBStudio as you could design the interface and then do the code second, however unlike VB, C is a little more demanding and requires hand coding instead of a double click on the UI element adding the code for you. Still, minus the some what steeper learning curve it was actually not too bad, and as a bonus I know now how to use Interface Builder in regular OS X development as well.



After ten hours or so of teaching my self objective c, I can now present BlackOut and simple lights out game. You need to have a jail broken device to install this, as I am not paying Apple $99 to give out a free application. Enjoy.

September 11, 2009

iBook Photo frame Controls

I already had the frame and iBook screen setup and running from my iBook Photo frame project, however it required a keyboard and mouse to really do anything, this is a problem. So I had been planing on trying to add controls at some point, however as usual this was not as easy as I had hoped. The ibook keyboard is connected via a flexible printed circuit, which means that soldering is out of the question and conductive epoxy would cost me money. My next idea was to attach wires under the connectors and use some kind of clamp to keep it connected. So I carefully removed all the keys and extracted the plastic switch membrane but that idea went out the window when upon trying to part the two membrane sides it also ripped a few of the printed circuits... sigh.

So left with a non functioning circuit I finally opted to cut off just the connector ribbon after getting the correct pinout; tracing it reminded me of my ddr pad controller project. Once I had the pinouts I had to think of some way to connect wires to the conductive paint. After a few failed ideas I finally settled on crimping small coper connectors onto the exposed paint. With a magnifying glass and a fine point xacto knife I carefully scrapped off the top layer of thin plastic glued to the thicker back which the circuit wires are printed on. After that I cut a small strip of copper and bent it into a U shape and crimped it on with pliers. I tested the connection with my multimeter after each one. I had to be careful that each connector was only a small strip, as too big and it would not crimp on properly.

Finally I used some extra cat-5 to get the six wires I needed, for the up, down, enter and esc keys to control xbmc, which I had loaded on it after enjoying the xbox version so much. Then I attached the lead wires to slightly larger clips to crimp the smaller ones in. I did not dare solder to the smaller clips because they might melt the plastic, so I figured this would work best. Finally I put it all back together and tested it. Sadly I did not have any buttons to finish up the project with, so I will leave that up for part three in the future. At least now I have a workable way to connect printed circuits to wires, which I bet will come in handy in the future.

September 5, 2009

DADGAME


I had posted the dad at home and work flash movies before as must see items, however to add even more to the series is DADGAME the next episode following dad at work, however this time it is a full game. Yes, you get to play as dad as he goes on a rampage in town while stopping his boss' evil plot! With swords, lazors, nunchucks, guitar and briefcase as playable weapons against guards, football players, robots and a monkey. This is a must play, even if just on easy. I laughed very hard through the whole thing, especially with the crazy animations in rampage mode. sakupen went all out this time.

Play DADGAME Now!