• Shortcuts : 'n' next unread feed - 'p' previous unread feed • Styles : 1 2

» Publishers, Monetize your RSS feeds with FeedShow:  More infos  (Show/Hide Ads)


Date: Tuesday, 24 Jul 2012 17:24

Because it’s my bag, I’ve been spending a lot of time these days deep in Ruby code. Nevertheless, from time to time, I do find myself ensconced in Java via the Android platform. Jumping back and forth between various languages like Ruby, Java, and JavaScript can be a lot of fun; what’s more, doing so broadens one’s view on various practices, idioms, and influences conveyed by a particular community.

Something that I found missing in Java’s community, in the form of a concrete easy to use library, is something like Ruby’s Guard. Guard is “a command line tool to easily handle events on file system modifications.” In essence, Guard makes continuous testing possible with a minimum amount of effort.

For example, with Guard, you can create a Guardfile that watches your file system (naturally, you can select which types of files to watch — .rb files, etc); what’s more, when those target files change (i.e. you added some code) a trigger can be invoked, such as running a test suite, invoking a Rake command, etc. Thus, with Guard, you can set up a process that executes a test suite (or an individual test) whenever you change a source file — this alleviates you from having to manually invoke a Rake task or do something else to trigger a test run.

As you can imagine, once you’ve set this up, it becomes highly addictive — why would anyone ever manually invoke Rake test again? It’s always running anyway!

Setting up Guard to invoke Ant, for example, couldn’t be any easier. You first must have Ruby installed, followed by RubyGems and Bundler. Next, in your Gemfile, you need to include guard as follows:

source :rubygems

group :development do
  gem 'guard'
  gem 'growl'
end

Because I’m on a Mac, I’m also using Growl, which is an OS-level notification mechanism (i.e. a popup dialog that informs you that your test suite has passed, failed, etc).

Next, you need to create a Guardfile — in this case, I’m going to create an inline Guardfile as there isn’t a plugin available (yet) to support running something like Ant. My inline Guardfile looks like this:

require 'guard/guard'

module ::Guard
  class Ant< ::Guard::Guard
    def run_all
      invoke_ant
    end

    def run_on_changes(paths)
      invoke_ant
    end
    
    def start
      invoke_ant
    end

    def stop
    end
    
    def invoke_ant
      system 'ant clean test'
    end
    
  end
end

guard 'ant' do
  watch(%r{^src/*/(.+)\.java$}) 
end

As you can see, this Guardfile simply watches any .java file and if any change, run’s ant clean test — the Guard base class is fairly straightforward — there are a series of hook methods you can implement. In this case, start is called the first time you fire up Guard. run_on_changes ideally is used to run a single test as you have access to the incoming file path of what’s changed; however, in this case, I’ve chosen to run the suite again as parameter passing into Ant & invoking a special JUnit task with single tests is somewhat painful (but it could be certainly done). Finally, run_all is called at special points, such as after you fix a failing test, etc. In essence, these are lifecycle methods and you have complete control over what happens when they are invoked.

Continuous testing in Java isn’t new. Yet, it seems that the wealth of tools and thought regarding continuous testing results in a shift towards Continuous Integration or worse, the IDE. For instance, a simple search on continuous testing tools in Java yields Infinitest and JUnit Max — both are great tools (Ben Rady, the original Infinitest guy is one of the sharpest guys I know). These tools, however, are plugins for an IDE, like Eclipse. I abandoned Eclipse some time ago in favor of IntelliJ (and Infinitest certainly supports IntelliJ); thus, these days, I do all Android development using IntelliJ, however, I tend to rely on Ant for building Android artifacts (even though there is a Maven library for Android).

In the end, I want an easy way to continuously run tests — if they can be run anytime I change a file, excellent. So long as I don’t have to manually kick off an Ant/Rake/Cake build, then the better. Can you dig it?

Author: "admin" Tags: "Android, Blog, Java, Ruby, agile, ant, g..."
Comments Send by mail Print  Save  Delicious 
Date: Monday, 09 Jul 2012 17:53

Installing Ruby version 1.9.2 (which as of this writing, is not the most recent version, however, our production stack relies on this version for now) on Ubuntu Precise Pangolin (12.04 LTS) can be a bit tricky due to a nasty OpenSSL incompatibility. Nevertheless, with a sneaky code edit, you can be on your way using 1.9.2 in a matter of minutes.

First and foremost, for Ubuntu instances, I use a handy set of installation scripts, dubbed Ubuntu Equip, which you can find on Github (note, I wrote these scripts). Ubuntu Equip has a Ruby 1.9.2 script — simply type from your Ubuntu instance’s command line:

$> wget --no-check-certificate https://github.com/aglover/ubuntu-equip/raw/master/equip_ruby.sh && bash equip_ruby.sh

This’ll update various system development libraries and ultimately it’ll download, unzip, and attempt to install Ruby 1.9.2; however, if you aren’t careful, you’ll miss a error a few minutes into the install. The error is easy to miss because after attempting to install Ruby, the script will go on to successfully install RubyGems and Bundler. Because Ubuntu 12.04 already has an older version of Ruby, you won’t necessarily notice any issues unless you type ruby -v, which’ll unveil the problem.

To fix the error (which is a compilation issue), you’ll need to first change directories into ruby-1.9.2-p180 and then edit the ossl_ssl.c file, found in ext/openssl. In this file, comment out (or delete) the lines:

OSSL_SSL_METHOD_ENTRY(SSLv2),
OSSL_SSL_METHOD_ENTRY(SSLv2_server),
OSSL_SSL_METHOD_ENTRY(SSLv2_client),

Incidentally, this code occurs on lines 110-112. Now you’ll need to recompile things; thus, type make followed by make install.

Typing ruby -v should now yield an ever so pleasing ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux].

Author: "admin" Tags: "AWS, Blog, Ruby, amazon, aws, ec2, Preci..."
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 16 Feb 2012 15:21

I recently had the pleasure of writing a review of MongoDB for InfoWorld. For those unfamiliar with MongoDB (or Mongo for short), it’s an “open source, schema-free document store written in C++ that boasts support for a wide array of programming languages, a SQL-like query language, and a number of intriguing features related to performance and scalability”; what’s more, it has excellent documentation and a strong community. The buttress of the community is a commercial company, dubbed 10gen, which provides additional tools and services (for a fee, obviously).

Mongo’s document-oriented nature makes a lot of sense for some domains; conversely, there are definitely scenarios where it isn’t a fit. Regardless, there are a number of benefits to Mongo including:

  • Out-of-the-box scalability and availability with sharding and replica sets
  • Support for wide array of programming languages via drivers
  • Excellent documentation, including a number of published books
  • Ad hoc queries similar to SQL
  • Strong community and commercial support

On the flip side, some disadvantages to Mongo are:

  • No ACID transactions
  • Lack of deep security features
  • BI tool integration lagging (although Jaspersoft supports Mongo)
  • Queries don’t support joins between collections

For more details, check out my article dubbed “Flexing NoSQL: MongoDB in review“; moreover, you might find these other resources helpful:

So what are you waiting for? Stop reading this and click a link, baby!

Author: "admin" Tags: "Blog, MongoDB, NoSQL, mongodb, nosql"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 21 Dec 2011 16:47

At App47, our production MongoDB instance is managed by MongoHQ — that is, we use their PaaS to host our data and leave the details of running and maintaining MongoDB instances up to them. It’s a handy service and worth the money at this point in our company’s evolution (eventually we might need more control over our instances and thus might look to take on some of these responsibilities, etc).

Nevertheless, while production data is hosted in the cloud, in many cases, local testing is desired and accordingly, from time to time, we replicate the state of production into local MonogDB instances. This is easily done with MongoDB’s mongorestore command. This utility can take the output of a mongodump (which, MongoHQ uses as part of their backup offering); thus, we download from S3 a backup of a particular MonogDB instance and restore that data locally as follows:

First, unzip the contents of a zipped mongodump:

$>tar xvf instance_name_628640_20111221150030.gtar

where instance_name is the name of your database. This will consequently create a directory (named after your instance, i.e. foo) containing a .bson file for each of your instances collections.

Next, to import that data to a locally running MongoDB instance, run from the root directory where you unzipped the backup from MongoHQ:

$>mongorestore -vvv instance_name

Where instance_name is the directory containing all the datastore’s .bson files. The -vvv enables verbosity, which is handy to see what’s going on, so standby for a lot of text to be printed out. This will create (or append to) an existing datastore instance (i.e. instance_name!) so if you already have an existing instance you might want to add --drop option to the mongorestore.

Author: "admin" Tags: "MongoDB, NoSQL, mongodb, nosql"
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 01 Nov 2011 19:37

MongoDB is a scalable, high-performance, document-oriented schemaless database. This short demo, entitled “An Introduction to MongoDB“, provides a quick tour of its use, and helps you understand where it’s most applicable. You’ll see first hand how to leverage Mongo’s shell and use its JavaScript syntax to CRUD data.

Don’t forget to check out Java development 2.0: MongoDB: A NoSQL datastore with (all the right) RDBMS moves well as a podcast with Eliot Horowitz, the CTO of 10gen, the company behind MongoDB.

Author: "admin" Tags: "Blog, MongoDB, NoSQL, javascript, mongod..."
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 26 Oct 2011 14:36

Amazon Simple Queue Service (SQS) borrows what it needs from message-oriented middleware (MOM) but doesn’t lock you in to any one implementation language or framework. In this article, entitled “Cloud-based messaging with Amazon SQS” learn how to use Amazon SQS to alleviate the burden of installing and maintaining a message-queuing system, while leveraging the pay-as-you-go scalability of AWS.

Author: "admin" Tags: "AWS, Blog, Cloud Computing, Java, Ruby, ..."
Comments Send by mail Print  Save  Delicious 
Date: Sunday, 23 Oct 2011 19:28

Follow along as this demo, entitled “An introduction to Amazon SimpleDB“, guides you through an introduction to SimpleDB, a massively scalable, highly available key/value datastore.

Part of the Amazon Web Services suite, SimpleDB provides a simple web services interface to create and store multiple data sets, query the data, and return the results. By watching, you’ll learn how SimpleDB works, understand its advantages and disadvantages, and see how to create a record, query data, and delete data using the Java SDK provided by AWS.

Author: "admin" Tags: "AWS, Blog, Cloud Computing, Java, NoSQL,..."
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 20 Oct 2011 14:30

Java developers have historically perceived JavaScript as a toy language, both too lightweight for real programming and too clunky to be of use as a scripting alternative. And yet JavaScript is still around, and it’s the basis of exciting web technologies like GWT and Node.js.

This installment of Java development 2.0, entitled “JavaScript for Java developers“, explains why JavaScript is an important tool for the modern Java developer. The article then gets you started with the syntax you need to build first-class applications for today’s web, including JavaScript variables, types, functions, and classes.

Author: "admin" Tags: "Blog, Java, javascript"
Comments Send by mail Print  Save  Delicious 
Date: Sunday, 16 Oct 2011 14:26

Amazon’s Relational Database Service (RDS) offloads the work of maintaining a database to Amazon Web Services, which makes it exceptionally easy to increase or swap out your application’s data storage. This article, entitled “Play-ing with Amazon RDS” revisits a location-based cloud-to-mobile application, swapping the original NoSQL datastore for a traditional RDBMS. It’s a breeze using the Play framework and the AWS console.

Author: "admin" Tags: "AWS, Blog, Cloud Computing, aws, cloud, ..."
Comments Send by mail Print  Save  Delicious 
Date: Friday, 14 Oct 2011 01:30

Considering moving into the cloud are you? Well then, have I got something for you! Not too long ago, I had the opportunity to catch up with Paul Duvall, the CTO of Stelligent and we, indeed, talked about this very lofty subject. In this podcast, Paul details the many considerations and options a company must investigate to migrate its infrastructure smoothly and safely.

Author: "admin" Tags: "Blog, Cloud Computing, cloud, cloud comp..."
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 11 Oct 2011 01:21

I recently caught up with my old friend, Dan Allen, who is a Red Hat principal software engineer and open source evangelist. In this podcast, he explains how Arquillian eases integration testing by providing a test harness to abstract away container life cycle and deployment from test logic.

If you’ve not listened to Dan or read his works (like Seam in Action), you are in for a real treat — Dan is one of the most high-speed, high-energy guys I know. Red Hat was smart to make him an evangelist. So listen up and find out why!

Author: "admin" Tags: "Blog, Java, Arquillian, j2ee, java ee, p..."
Comments Send by mail Print  Save  Delicious 
Date: Monday, 03 Oct 2011 21:41

A few interesting pieces of data:

  • 70% of the world’s population has a mobile phone
  • over a million Android devices are activated weekly
  • 1/2 of all local searches are done on a mobile device
  • over 90% of mobile Internet access is social media related

Clearly, if you aren’t building mobile apps today, you will be soon.

And if you want to build Android apps as fast as people can consume them, then I recommend you check out Ruboto, a framework that leverages the power of JRuby to enable you to quickly build and deploy Android apps. As you’ll see, with the expressiveness of Ruby and the full stack nature of this Rails-like framework, you can go from idea to device in short-order.

Follow along as some hipster (hint, he’s the coolest disco dancer you read about all the time or at least right this instant) demonstrates using the Ruboto framework to rapidly build and deploy Android applications. See how to create an emulator instance, create a Ruboto project using the command line, code your app, and use a location listener for obtaining GPS information.

Author: "admin" Tags: "Android, Blog, Ruby, Java, JRuby, mobile"
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 29 Sep 2011 15:26

Not too long ago, I wrote about JavaScript; specifically, I espoused it as a language worthy of a Java developers attention mainly due to the fact that JavaScript, while about as old as Java, is arguably the more popular language. Yes, you’ve read that correctly — JavaScript itself is probably one of the widest leveraged languages ever — scores of developers know it whether they be PHP programmers or Ruby developers or even .NET developers. You see, JavaScript makes much of what you see and do on the web work. It’s the glue of the web and as such it’s platform agnostic.

Early in my career, I spent some time as a server side JavaScript developer. At the time, there was a product on the market called Netscape Application Server and as far as I know now, it was the only product out there touting this nifty scripting language as an engine for websites. I had fun, but alas, that product didn’t last; in fact, shortly thereafter, I found myself back into the world of Java building web applications with Servlets.

So it’s with particular interest that I’ve watched a new incarnation of server side JavaScript take hold in the developer community. Node.js is still young, but undeniably exciting in that it offers a highly scalable, event-driven I/O model for building networked applications. Node.js is built to run on V8, which is an open source JavaScript engine developed by Google that compiles JavaScript into native machine code before execution, resulting in extremely fast runtime performance (something not commonly associated with JavaScript). In plain English, Node enables you to rapidly build apps that are lighting fast and highly concurrent.

As a Java developer, you might be thinking “big deal, you can do this with Java too” and you wouldn’t be wrong. Well, maybe partially. That is, Node.js is effortlessly simple to understand and its JavaScript syntax means you can save on keystrokes big time. So with a little code, you can build a blazingly fast, scalable web app that is capable of handing myriad concurrent connections. You can do that in Java, but it’ll require quite a few more lines of code and a bevy of additional libraries. Did I mention there’s an army of developers out there that already know and use JavaScript on a day-to-day basis?

Node.js will continue to rise in popularity due to its far reaching audience pull, but unlike the Visual Basic analogy that might be popping up into your head, Node.js is now and will continue to be leveraged to build real web apps (rather than little calculators, etc of the VB era). If you aren’t looking at Node.js yet, it’s high time you did.

Author: "admin" Tags: "Blog, Java, JavaScript, Node.js, javascr..."
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 27 Sep 2011 22:39

A few weeks back, I was interviewed by Scott Laningham, Editor & Host of The developerWorks Podcast.

In this podcast, I’m on the other side of the mic and have the opportunity to discusses several topics with Scott, including what’s coming up on my Java technical podcast series on developerWorks, my thoughts on the polyglot cloud application platform Heroku, and Ruboto which allows you to run Ruby scripts on Android devices.

Author: "admin" Tags: "Android, Blog, Cloud Computing, iOS, her..."
Comments Send by mail Print  Save  Delicious 
Date: Saturday, 24 Sep 2011 21:46

I’m a huge fan of git-flow; it’s branching model facilitates a release model, supporting multiple versions and branches, quite nicely. For instance, during a development phase, all commits are made to the develop branch; consequently, when it’s time to push a release into production, a release branch is created, which essentially merges everything in develop into master.

During development, however, its handy to push a snapshot of a Git repository into Heroku; which by default, receives anything from master. That is, if you aren’t careful when pushing to Heroku, you’ll end up pushing the state of master to it rather than your intended branch, which is, in this case, develop.

Accordingly, to push a branch other than master to Heroku (for instance, develop when using git-flow), you push as follows:

Note, in this case, develop is being pushed to the Heroku instance named remote_name (i.e. staging, test, etc).

Author: "admin" Tags: "Blog, Cloud Computing, cloud, cloud comp..."
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 22 Sep 2011 21:55

Gretty is one of a new school of ultra-lightweight frameworks made for building web services. Built on top of the blazingly fast Java NIO APIs, Gretty leverages Groovy as a domain-specific language for web endpoints and Grape’s Maven-style dependency management. In this article, get started with using Gretty to build and deploy Java web service applications.

You’ll see first hand that Gretty is as light as light can be. There is no embedded ORM-framework and no robust view framework either. Gretty is the antithesis of the modern full-stack web framework, precisely because sometimes you don’t need an entire stack, baby.

Author: "admin" Tags: "Blog, Groovy, Java, gretty, groovy, web ..."
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 20 Sep 2011 01:13

I recently had the opportunity to chat with Loggly CTO and co-founder Jon Gifford about the concept of logging as a service and how it allows for easier log management and manipulation. Loggly’s service is amazingly easy to stand-up — in fact, we’re using Loggly heavily at App47. I think you’ll find this podcast quite interesting as you’ll learn the details of how Loggly does what it does, how it’s different from what you’ve used before, and where it’s going in the future. So what are you waiting for? Have a listen!

Author: "admin" Tags: "Blog, Cloud Computing, cloud computing, ..."
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 15 Sep 2011 21:30

EC2 is essentially a virtual computer running the OS of your choice along with various options for memory, CPU speed, and storage. EC2 is an Infrastructure as a service: itʼs bare bones computing power without the need for you to go out and buy a bunch of servers because someone (amazon.com, man) already did that for you! In fact, with EC2, you essentially rent computing resources in a data center managed by someone else.

Follow along as this demonstration gets you started using Amazon EC2, part of the Amazon Web Services suite of on-demand, pay-as-you-go products. Once you pick your OS and AMI, you’ll learn how to create an SSH key pair and define a corresponding security policy, provision an instance, and launch the instance. Nothing, and I mean nothing could be more exciting than that, baby. Can you dig it?

While you’re at it, don’t forget to check out some other hip articles on EC2, including:

Author: "admin" Tags: "AWS, Blog, Cloud Computing, amazon, aws,..."
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 25 May 2011 16:46

When Java came out and I began to spend virtually all my time building Java applications, I naively figured the days of manual memory management were gone (after all, Java has garbage collection!). Fast forward to now. The popularity of the iPhone and iPad have propelled C (really, Objective-C) back into the spotlight. And with Objective-C, the return of manual memory management (along with borderline extreme code verbosity).

Manual memory management isn’t too terribly difficult as it turns out — it just requires you pay attention, especially when you alloc objects. That is, alloc calls, for the most part, should usually be followed somewhere, in scope, with a release call.

Objective-C, however, has quite a few handy factory methods that handle memory aspects like retain counts nicely. Accordingly, you don’t have to explicitly release factory created objects — in fact, if you do, you’ll get nasty errors later when some section of code attempts to use it!

For example, in the code below, I’m creating two objects — an instance of NSMutableArray and NSDictionary — both are alloc‘ed and init‘ed. In the ensuing code, the array instance is added to the NSDictionary and then that dictionary is passed along to NSNotificationCenter (code left out). Consequently, I must remember to release them (and thereby decrement their retain counts) after the handoff to NSNotificationCenter.

NSMutableArray *array = [[NSMutableArray alloc]init];
//...fill the array with objects
NSDictionary *dictionary = [[NSDictionary alloc] init];
[dictionary setObject:array forKey:APP_LIST_ARRAY_KEY];
//....add to NSNotificationCenter
[array release];
[dictionary release];

I can, however, make my life a bit easier by leveraging some of NSDictionary‘s factory methods, such as dictionaryWithObject:forKey, which initializes a new instance of NSDictionary containing one item (there’s a corresponding method to add multiple items too).

NSMutableArray *array = [[NSMutableArray alloc]init];
//...fill the array with objects
NSDictionary * dictionary =
  [NSDictionary dictionaryWithObject:array forKey:APP_LIST_ARRAY_KEY];
//....add to NSNotificationCenter
[array release];

Note in the code above, I’m freed from the responsibility to release my dictionary instance. Many core Objective-C classes have these factory-like methods, such as NSString‘s initWithFormat.

Using these methods can reduce the burden of manually managing memory, but certainly doesn’t obviate it. Can you dig it, man?

Author: "admin" Tags: "Blog, Home, iOS, c, ios, iphone, objecti..."
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 19 May 2011 20:01

Unlike relational database models, MongoDB documents can have fields which have values as arrays. The prototypical example in almost all MongoDB documentation is a document having a tags field, whose value is an array of strings, such as ["NoSQL", "Ruby", "MongoDB"]. If you’re coming from a relational world (which most of us are) then this feature, at first glance, is a bit intimidating.

For instance, most queries, regardless of the underlying data structure (be it a relational table, JSON document, dictionary, etc) target a value and not the key itself. Using the aforementioned document containing a tags field with an array as its value, there isn’t much value in querying on the key tags — queries target a key’s value(s). So in this case, the questions asked are in the form of “what documents contain the tag X”, which is easy enough of conceptualize when the value is singular (i.e. select * from document where tag = X).

Yet, when a key’s value is pluralized as in the case above, I sometimes find myself wondering how to construct a query when I only know a portion of the available values. For example, here’s a simple document with two fields:

{a:"foo", b:[10,20,30]}

In this case, the field b has an array of numbers as values. I’m going to add this document along with a few others to a Mongo collection dubbed foo_test.

> db.foo_test.save({a:"foo", b:[10,20,30]})
> db.foo_test.save({a:"foo", b:[15,25,35]})
> db.foo_test.save({a:"foo", b:[10,40,50]})
> db.foo_test.save({a:"bar", b:[10,60,70]})

With those documents created, the question becomes, how do you find all documents who have a 10 in their b‘s values?

Because it’s Mongo’s bag, baby, it turns out to be effortlessly simple. Just query for the value as if it were singular!

> db.foo_test.find({"b":10})
{ "_id" : ObjectId("4dd56bc747cc1d1360674d73"), "a" : "foo", "b" : [ 10, 20, 30 ] }
{ "_id" : ObjectId("4dd56be347cc1d1360674d75"), "a" : "foo", "b" : [ 10, 40, 50 ] }
{ "_id" : ObjectId("4dd56bee47cc1d1360674d76"), "a" : "bar", "b" : [ 10, 60, 70 ] }

What if you want a bit more finesse, such as finding the distinct values of a where b has the value 10? Just as easy, baby.

> db.foo_test.distinct("a", {"b":10})
[ "bar", "foo" ]

One thing to note: you can, and probably should (if you plan to search on array values a lot and there are going to be a lot of documents) add an index to b. While this might slow down inserts (as the index will need updating each time) it’ll most likely improve reads.

> db.foo_test.ensureIndex({b:1})

Arrays as values in a MongoDB document might look odd when you find yourself thinking of how to query against them. But as it turns out, they aren’t so bad and you can act against them as if they were a single value. Not bad if you ask me.

Author: "admin" Tags: "Blog, Home, MongoDB, mongodb, nosql"
Comments Send by mail Print  Save  Delicious 
Next page
» You can also retrieve older items : Read
» © All content and copyrights belong to their respective authors.«
» © FeedShow - Online RSS Feeds Reader