Metamorphosis from PHP to JavaScript

The following is account of why I prefer writing programs in JavaScript over PHP. I have well over 10 years of programming experience in PHP. I’ve written everything from a simple one page PHP program, to a complex Zend Framework apps, to you name it, I’ve coded it in PHP (even stuff I know I should have not done in PHP). You Always Play To Your Strengths, if PHP is your strength, that’s going to be your game

MongooseJS and the problem with adding new properties

My setup is easy. Node.js, ExpressJS, MongooseJS. The Problem I was getting a list of objects from the MongoDB. Like this // Find all items where owner in following array Thing.find() .where('owner').in(following) .populate('owner') .populate('comments.userId') .sort('-updatedOn') .limit(20) .exec(callback); In the callback I was assigning the results to res.locals.things for use in another middleware function. In another middleware function I tried this // Extend thing[i] with a new property called newProperty for var i=0; i < res.

Markdown is the new WYSIWYG

If you publish content on the web, get ready, a shift started a while back, but now gaining momentum. I first encountered Markdown a few years ago and had a fancy for it, but never took the time to learn it. I didn’t really have a use for it. Now that I’ve had to use it on StackOverflow, GitHub, and other great sites, I’m convinced it’s time to learn it.

Testing XHR in Appcelerator with SinonJS

Coming soon. Testing XHR with SinonJS. Here are some references. https://github.com/cjohansen/Sinon.JS/issues/135 http://titaniumninja.com/testing-titanium-mobile-applications-with-jasmine-and-sinon-part-i/

Getting Titanium CurrentWindow To Work Under CommonJS

Appcelerator is a moving target, developed and changing pretty fast. The old way was using the **url: ** property of a window to open up a new screen with a javascript screen. Old and Busted var window = Ti.UI.createWindow({ url: 'screen.js' }); Another Old Way Then came the Tweetanium structure, while a solid way to set up, it’s not the route Appcelerator is recommending anymore. See my post for more information on the Tweetanium Setup

Improving my Vim environment with ctags and Tagbar

I love Vim. There is something about it. Most people that “try” Vim, hate and wonder what all the fuss is about. If you force yourself to learn it, customize your environment and start using it, you’ll want to use it for all your text editing needs. Here are few more improvements I’ve installed today.   Tagbar Tagbar allows you to see inspect the current file listing the properties and methods in that file.

Programmers should be lazy, but not at the expense of user experience

Has this every happened to you. A form wants you to enter in your phone number… OK, let’s be honest, there are 20 different ways you can enter in your phone, but as far as a computer is concerned it’s just interested in the numbers. So that means stripping out the non-numeric characters is trivial…. So why do so many sites do like this stupid site…. make you enter in a phone the way THEY want you.

Getting AngularJS and Zend Framework POST to play nice

I was simply posting data to the server using this code $scope.submit = function() { console.log($scope.newTitle + ' is the new title'); $http({ url: '/api/idea/method/add', method: 'POST', data: { title: $scope.newTitle, description: $scope.newDescription }, headers: {'Content-Type': 'application/x-www-form-urlencoded'} }) .success(function(data, status) { }) .error(function(data, status) { }); }; But I was getting a JSON object submitted and therefore using Zend’s _getParam('title') could not pick up the title in the post.

Appcelerator Titanium Twitter Birdhouse Failing because of HTTP

This problem caused me much angst and it’s partly Twitter’s fault (just ask me). I’m using the great Titanium library for Twitter called Birdhouse. It does a great job requesting authorization, storing it, and gives you an API to post tweets. So I was using this code to post tweets using Birdhouse. this.tweet = function(message) { Ti.API.info('Im about to post to twitter:'); Ti.API.info(escape(message)); BH.api('http://api.twitter.com/1/statuses/update.json', 'POST', 'status=' + escape(message), function(resp) { Ti.

MVC for Appcelerator Titanium (understanding Tweetanium)

Tweetianium builds its own namespace that it operates under rather than calling code that looks like the following to open up a new window. Ti.UI.createWindow({url:‘somefile.js’, importantdata: mydata }); This essentially uses different files to open new windows, it’s manageable to point, but I had trouble with not having some sort of global variables I could call on. In walks Tweetanium and Struct These keep the entirety of the code in basically a name spaced object.