Friday, November 29, 2013

Javascript Adding Arrays

To add a Javascript array to another, use the "concat" method. Note that it doesn't change the original array but instead returns a new one, so you have to assign the return value.

References:

Friday, November 22, 2013

AngularJS Datepicker

The Angular UI team has an implementation based on JQuery UI datepicker. Download and documentation here: https://github.com/angular-ui/ui-date

Note: it is possible to customize the behavior using options (see "Options" section in the link above).

As an alternative, there is a variant based on Bootstrap: http://angular-ui.github.io/bootstrap/

Thursday, November 21, 2013

Monday, November 18, 2013

Thursday, November 14, 2013

Git Diff Tool

It seems after the Mountain Lion update, "git difftool" now no longer has a graphical diff interface.

I had to set it up again using the instructions from here: http://git-scm.com/book/en/Customizing-Git-Git-Configuration

I also had to install kdiff3 separately.

Wednesday, November 13, 2013

Jackson Date Handling

The default is behavior is epoch, but lots of way to customize, as explained here: http://wiki.fasterxml.com/JacksonFAQDateHandling

Servlet "init" Method Called Multiple Times

This can happen if an exception is thrown the last time it was called.

Wednesday, November 6, 2013

AWS Policy Document "Sid" Field

This is a field that is usually generated by the policy generator but what happens when you copy and paste a policy? Is it safe to leave it unchanged? Or should it be changed to another value?

According to this blog post:

"The Sid (statement ID) is an optional identifier you provide for the policy statement. Essentially it is just a sub-ID of the policy document's ID. The Amazon S3 implementation of the access policy language require this element and have uniqueness requirements for it."

In this case, any identifier unique to the document should be sufficient, even "1", "2", "3" etc.

Hosting a Static Website on AWS S3

Step by step guide provided by AWS here: http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html

MongoDB vs MongoLab for Early Stage Live Apps

MongoDB and MongoLab are the 2 main MongoDB hosted service providers who provide their servers within the AWS network and in all regions. For a startup just going live with a new product, volume is initially expected to be low but HA may also be a requirement. Obviously cost is also an issue.

With these in mind the shared instances sound like the way to go, unfortunately with MongoLab this option is not available in all AWS regions. It also comes at a big jump in price from the single server shared plan (i.e. $15 -> $89 for same storage). Bump up the budget to $200 a month and you can get a dedicated instance with much more storage and dedicated RAM. With MongoHQ it gets worse with no cluster / replica-set options available.

So moving on to dedicated instances, MongoLab provides cluster / replica-set options for as little as $200 a month, while MongoHQ doesn't do so until you reach the $1345 a month price plan. For a startup just starting out trying to save costs and not wanting to compromise on HA, seems like MongoLab is the obvious choice purely basing on the packages and price plans.

References:

DynamoDB Hash and Range

Hash doesn't have to be unique if "Hash and Range" PK is selected. In this case, it is used for evenly sharding the data under-the-hood.

However, the Hash and Range combination should be unique (not mentioned specifically but obvious and implied).

More details in the following references:

Handling Complex Objects in DynamoDB

Apparently AWS's Java APIs provide means to handle this.

Link: https://java.awsblog.com/post/Tx1K7U34AOZBLJ2/Using-Custom-Marshallers-to-Store-Complex-Objects-in-Amazon-DynamoDB

Articles With Comparison Between DynamoDB and MongoDB (Part 2)


Tuesday, November 5, 2013

Cocos2D-X: Drawing Rectangle with Border

This needs to be done in 2 draws, one to draw the border and the other to draw a solid rectangle.

Example code:

void MyLayer::draw()
{
CCPoint p1 = ccp(x1,y1);
CCPoint p2 = ccp(x2,y2);

   ccColor4F color;
   color.a = 1.0;
   color.r = 0;
   color.g = 0;
   color.b = 0;
   ccDrawSolidRect(p1,p2, color);
   
   ccDrawColor4B(255, 255, 255, 255);
   ccDrawRect(p1,p2);
}

p1 being the bottom left corner of the rectangle and p2 being the top right.

In order for this to be called, the function needs to be override the "draw" function of the parent.