I love learning about other tools developers are using. For 2011, these are the tools I've been using the most on OS X. Most are development related, but some are not. In no particular order...
I think most of these are pretty standard, but hopefully you find a few you didn't know about.
Happy new year!
Adding unit testing to my Cocos2d project took longer than I expected. In hindsight it was because I didn't really understand how targets worked in Xcode. After stumbling around for a while, I figured out how to get this working. Here's the steps I used. If you know a better/faster way, please leave a comment below.
If you already know Xcode well, this post probably isn't for you.
Xcode offers a way to create tests with a new project, but the Cocos2d template does not. The first step is to create the test target.
1) Click on your project name in the left Project
Navigator
2) Click Add Target on the bottom of your
screen
3) Select Cocoa Touch Unit Testing Bundle. Click
Next
4) Name your test whatever you'd like (ex: UnitTests). Click
Finish
Now you've got tests added to your project. You can select your test name in the Scheme drop down menu. In the menu bar, click Product -> Test. You should receive the following error:
error: testExample (UnitTests) failed: Unit tests are not implemented yet in UnitTests
Success! This is what's supposed to happen, because the only test you currently have is:
- (void)testExample { STFail(@"Unit tests are not
implemented yet in UnitTests"); }
Now we want to actually test our code. Add the following to the top of your UnitTest.m file (or whatever you called your test file):
#import "cocos2d.h"
Add this method somewhere below:
- (void)testNode { CCNode *node = [[CCNode alloc] init];
STAssertNotNil(node, @"Node shouldn't be nil"); }
Disclamer: It doesn't really make sense to test this. But since we have an empty project, we're just trying to get the error to appear as an example. Using CCNode will trigger this error. In your project, you'd want to test things like calculations, transformations, etc..
Run Product -> Test to see the build failure:
Undefined symbols for architecture i386: "_OBJC_CLASS_$_CCNode", referenced from: objc-class-ref in UnitTests.o
This is a link error, and is happening because our UnitTest target doesn't know anything about our project. Usually when you create a new Xcode project, you create UnitTests from the beginning. When you add files to your project, you can select which targets the files belong to. Because we're adding our testing after the fact, we have to add these manually.
1) Click on your project name in the left Project
Navigator
2) Click on your project target. This is not your testing target.
It's probably the one above it. Then click Build
Phases
3) Expand the Compile Sources dropdown.
4) Select everything in the list
5) Right click. Click Reveal in Project
Navigator
6) With the items in the Project Navigator still selected, click
your testing target in the left Project
Navigator
7) Click on Build Phases.
8) Drag and drop the selected files in the Project
Navigator to the testing target's compile sources
We're almost done. Now you just have to add the library frameworks.
In your testing target's build phases expand the Link Binary With Libraries dropdown.
You can manually add each framework required here (use your main project target as a reference for what should be here).
A faster way I found, was:
1) Expand the Frameworks folder in your
Project Navigator
2) Select all frameworks in the folder (using Shift-Click or
Command-Click)
3) Drag these frameworks to your test target's Link
Binary With Libraries dropdown
One more step. If you try to run your tests now, you'll get these errors:
"_inflateInit2_", referenced from: inflateMemory in ZipUtils.o
"_inflate", referenced from: inflateMemory in ZipUtils.o
"_inflateEnd", referenced from: inflateMemory in ZipUtils.o
"_gzopen", referenced from: _ccInflateGZipFile in ZipUtils.o
"_gzread", referenced from: _ccInflateGZipFile in ZipUtils.o
"_gzclose", referenced from: _ccInflateGZipFile in ZipUtils.o
"_uncompress", referenced from: _ccInflateCCZFile in ZipUtils.o
We need to add libz.dylib to the frameworks list under the Link Binary With Libraries dropdown section.
1) Click + under Link Binary With
Libraries
2) Add libz.dylib
I'm not sure why this isn't listed with the original project target libraries, but probably has to do with more Xcode underpinnings I don't fully understand.
Whew. Go to Product -> Test to run your tests. It should compile successfully (but still fail because of testExample). You can remove - (void)testExample if you want to see the tests pass.
This part isn't necessary, but is very nice. We can simplify running our tests by adding them to our project scheme.
1) Select the Scheme dropdown menu, then click
Edit Schemes
2) Select your project name in the scheme dropdown on the top of
the dialog. This is not your tests you created
3) Select Test in the left hand view
4) Click the + icon right above Manage
Schemes...*
5) Select your test. Click Add. Click OK.
Now you can go to Product -> Test without switching schemes first. Even better we can press Command+U to test.
Hopefully if you've run into this problem, these steps will solve it for you. This probably already makes sense to experienced Xcode users, but as someone new to the platform, it took me longer than I'd like. Hopefully this saves you some time.
Since mobile apps have taken off, one big question from developers has been:
Do I write my application native or use HTML/JS/CSS for easy cross-platform support?
I recently went through this when I released my first iPhone/iPod app: DomainFinder.
Rather than try to answer this objectively (the answer is it almost always depends on your needs)—I’ll provide my experience and the tradeoffs I encountered.
Pros
- Fast and easy development
- Native looking UI elements
Cons
- Slow UI
- Missing API features
My first impression of jQuery Mobile is it feels slow. It’s still in very early stages (alpha), but for me the tradeoff isn't worth it. I watched a user press a button. Then press it again. Then press it again. In between the 2nd and 3rd press it would finally register.
This left the impression the UI wasn’t responsive and the user wasn't in control.
Another issue was selecting a row in a list view. Every time the user selected a row, the app scrolled to the top of the screen before switching views. Go try the demo to see what I mean. Click a row at the bottom of the list. Notice the jump?
Conclusion
jQuery Mobile is on its way to becoming great. If they can get
these issues ironed out, it will be a perfect solution for a
lot of developers that need relatively simple cross-platform
apps.
Pros
- Faster than jQuery Mobile
- Extremely light (9.4KB)
- Intuitive and easy to use
Cons
- No native controls
- Missing API features
The lack of native controls isn’t really fair. It’s not what XUI is meant to do. But this meant I had to come up with my own buttons, lists, etc… This is fine if this is what you want, but for me I just wanted native looking buttons and list views (like jQuery Mobile).
The upside is XUI + PhoneGap feels really good. The more I look at PhoneGap the more I’m impressed. The only downside I’ve found is you give up some API features.
PhoneGap does a great job of bridging some APIs that are important, like: Accelerometer, Compass, Camera, Geolocation, etc…
But one thing I wanted to experiment with was in-app payments. I wasn’t able to find anyway to do this.
Conclusion
PhoneGap and XUI are a great choice if you don’t need screaming performance, native looking UI or access to all native APIs.
Pros
- Fast
- Access to all APIs
Cons
- Longer development time
I put off going native because of a mental block: I didn’t know Objective-C. I looked at the syntax and convinced myself it was a weird and obscure language. The truth was, once I dove in--Objective-C was beautiful. It has its warts, but overwhelmingly I found it easy to learn and easy to get things done.
The development time took 3x longer, but that included time learning Objective-C, Interface Builder, etc…
In all honesty, it took me far less time than I expected. I got the native feel I was looking for with the speed and functionality I wanted. I ended up not using in-app payments (so XUI+PhoneGap could have worked), but in hindsight I’m glad I went native.
It opens doors that were closed by my mental block, and I’m actually proud of my first application. When people tap on the app’s list view, I don’t cringe because “something doesn’t feel right”. It all feels right. It’s fast and powerful.
Conclusion
After getting the basics, I found developing a simple native
app nearly as fast as HTML/JS/CSS. The big difference: the
HTML/JS/CSS app is ready for Android, Blackberry, Windows
Phone, etc…
If this is important to you, choose accordingly. For me, I wanted my first app to be as good as it could be, with very few sacrifices.
In the future, if I was developing a relatively simple app for a client, PhoneGap seems like a logical choice. But for apps that I care about the excruciating details, native is best.
This isn’t meant to be a perfect analysis of native vs. HTML/JS/CSS. I’m convinced I haven’t hit all of the warts on either side. I’m too new to this to be authoritative.
But hopefully if you’re struggling with these questions like I was, this post will help you decide which tradeoffs are important to you—and help you decide accordingly.
As a closing anecdote, it's been 10 years since I've touched native application development (Win32). Over that time I've gotten so used to web development I've forgotten what other development stacks are like. My initial impression? Damn this is fun. This is a novel feeling that will wear off. But for now, I'll enjoy the ride.
Ask A Question is a Wordpress plugin that allows you to quickly take feedback on your site through an AJAX form. You can see it in action over at Juped.
It's been a while since last updated and needed to be cleaned off for the newest versions of Wordpress.
I had a few hours to work on it and got version 0.2 done. Not many features, but lots of internal stuff is cleaned up. Dropped Scriptalicious in favor of the JQuery bundled with Wordpress. Use new Wordpress internals where applicable. Fix a few bugs that crept out in the last version.
If you'd like to try it out, head over to: http://github.com/bradjasper/wp-ask-a-question.
Please let me know if you have any issues along with any big features you think are missing.
For the past few months I've been trying to find other developers in Iowa. Its difficult, but not impossible. I've managed to find a few here in the Quad Cities, but was able to find many more in other parts of the state.
I was able to meet some people at the recent Iowa Code Camp and am now lucky enough to have found a Python User Group being started in Iowa City.
The first meeting is tomorrow, so if you're in the area and want to find out more, please join the group.
For the past couple of months I've been working on migrating my old website from a Wordpress based setup to a custom site written with Django.
Now that Summer is here, I've had some time to wipe off the dust and get everything launched.
If you notice any bugs, contact me.
Lately everyone seems to be down about the Economy. Recent graduates can't find jobs. People are being laid off in enormous numbers. Everything is very unstable, and no-one knows what's going to happen next.
But I'm hopeful. I'm hopeful because we're on the downside of a curve. The bubble just popped in the Tech world, and all the easy VC money that goes with it is gone. This means people are bootstrapping, and its a wonderful thing. Business plans and first month profits to boot!
This is a good thing because it brings people back to reality and quickly erases the hype of a sustainable freemium model. The Tech world gets so caught up in its own echo chamber its reminiscent of a mini-hollywood filled with its own mini-cewebrities. The recent downturn has let people rediscover the value of business models that aren't based on advertising and "getting really big"--but I digress.
When "big ideas" stop getting VC money, lots of developers either leave the space or kill their ideas. This is a huge opportunity for the rest of us. Suddenly, there's way less competition. But not only that, there is way less VC-funded competition--even better.
Some people say their idea needs VC funding. Maybe. Some ideas need funding. But the reality is, many startups take money because its there. It helps accelerate growth and lets you work on your startup full-time until you become profitable. There are many ways to move into a competitive high-priced market, be creative.
Taking VC money is sexy and all the cool kids are doing it, but there are other ways. There's nothing wrong with working 10 hours a week on a project. Your lack of time will let you focus on what's really important. Cutting out bloat will make you leaner, quicker and better.
Launch early, get feedback, iterate quickly. Fund it with your existing job and work on it in your spare time. Have no doubt, smart developers have their heads down working on their next project. By the time everybody else starts looking for VC money, they'll already be riding the wave.
The Django Admin interface is the best thing since sliced bread. Its flexible enough to handle 80% of everyday needs and built so that handling the other 20% isn't too bad. Generally speaking, its pretty good for entering data.
Little things like setting default fields can dramatically speed up the data entry process. When you repeat a process hundreds of times, a 30 second improvement can be significant.
Which is why it bugged me that I couldn't set default values for my admin.TabularInline field:
The result was an extra minute for every host I was entering in to Hosting Choice.
After speaking with some people in #django on irc.freenote.net I realized Greasemonkey would be the best way to tackle this problem. Apparently, sub-classing the admin.TabularInline class is more trouble than it's worth.
The Greasemonkey solution is a little dirty, but it definitely gets the job done. It could have make the script shorter, but I opted to include jQuery--because I find Javascript without jQuery these days maddening.
The end result is this:
Here's the script in all its mighty. To set your own default values, adjust the defaults dictionary at the top. The keys are jQuery selectors and the values are whatever your default value is.
// ==UserScript== // @name Django Default Admin // @namespace /django_admin // @description Script fot setting default values in the Django Admin // @include http://hosting-choice.com/admin/catalog/host/add/ // ==/UserScript==
// Syntax is {#id, 'default value'} defaults = { '#id_feature_set-0-type': 'Price', '#id_feature_set-0-value': 6.95, '#id_feature_set-1-type': 'Bandwidth', '#id_feature_set-1-value': 0, '#id_feature_set-2-type': 'Space', '#id_feature_set-2-value': 0}
// Attach jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded function GM_wait() { if (typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { $ = unsafeWindow.jQuery; letsJQuery(); } }
GM_wait();
function letsJQuery() { for (id in defaults) { $(id).val(defaults[id]); } }
Well the inevitable has happened. I have the urge to move my site from a Wordpress page to a custom Django site. Unfortunately, this means migrating.
I searched for good Wordpress to Django migration scripts but couldn't find any, so I decided to write one and release it for everyone else to use.
Its in a very early state but it should help you get the job done. I wrote exactly what I needed, which didn't include comments, excerpts or other less used meta data.
It should be fairly easy to expand however, so fork it and give it a shot.
Download at GitHub: http://github.com/bradjasper/django-wordpress-parser/tree/master
Exactly 4 weeks ago classes ended. I knew I wanted to create a small website over Winter break, but I didn't know what. I started with a completely different idea, and switched twice before sticking with Hosting Choice, a hosting review site. Its midnight, the night before classes start--but I'm launching the site on schedule.
The concept was simple, create a hosting review site that was run by the users. It would rely entirely on user ratings to rank hosts. This would allow me to step away from the editorial side and keep the site unbiased.
I took a week and a half vacation during the break and worked lots of overtime at my full-time job, so Hosting Choice was created in the wee hours of the night after a long days work.
But overall I'm satisfied with the result. The best part of the process was deciding which features to not put on the site. By having a firm deadline I was able to cut away a lot of unnecessary features that would have delayed the launch for weeks or months.
If you have some time, please visit Hosting Choice and add reviews for any hosts you've used.
Its time to put the nose to the grindstone again, classes start in 10 hours.