Saturday, October 1, 2011

Wt Configuration and Experimentation - Continued...

This is a continuation of the previous post titled Wt Configuration and Experimentation.

PackRapt.com is a cloud resources search, bundler and mailer. It allows for search and distribution of disparate cloud documents. One stop search and send. In an effort to maximize efficiency while minimizing footprint and resources exploitation I'm moving PackRapt.com to the Wt framework and customizing the search and curation features. These posts document the adventure.


Wt Configuration and Experimentation - Continued...

We left off taking a look at the Wt samples that are applicable to PackRapt.com

Hangman

The Hangman example included in the Wt library offers a look at simple authentication. I've tried to roll my own authentication before. I thought it was easy. That was, until i had a Ruby guy punch so many holes my attempt it resembled the Titanic. We will, however, use the example as a foundation to creating our own. Easy? No. Fun? Yes.

An important part of the Hangman examples lies in the Wt ORM.  We will be getting into the Wt::dbo soon enough. Patience, for goodness sake! I know you're dying to dive into Wt's ORM but show some restraint!

So, here's the scoop. This is an extremely simple example of how the authentication for PackRapt.com will be implemented. 


Easy, huh? Yeah. As you can see from the login function it simply asks if the user exists. If not, it creates a new user and password in the database. Naturally, we must add an abstraction to the data via Salt/crypt. This example, however, shows one point I'd like to highlight. PackRapt.com will offer an either/or authentication. That is, a user's registration will simply exist or be created. Secure? I guess I'll find out.

I'm heading out to a charity event in Bellevue. Being a little short on time we'll keep this brief. As a review, however, I'll say that we've covered a framework for the authentication and uploads. We've still got a ways to go!

Thank you,

Aaron

Wt Configuration and Experimentation

This is a continuation of the previous post titled PackRapt.com - Outline.


PackRapt.com is a cloud resources search, bundler and mailer. It allows for search and distribution of disparate cloud documents. One stop search and send. In an effort to maximize efficiency while minimizing footprint and resources exploitation I'm moving PackRapt.com to the Wt framework and customizing the search and curation features. These posts document the adventure.


Wt Configuration and Experimentation


I hope you all got a chance to mess around with the Wt examples. Most require a bare-bones install of dependencies. For the others the "optional" dependencies include:
  • GraphicsMagick -> sudo port install GraphicsMagick 
  • FCGI Library -> sudo port install fcgi (libfcgi++ inlcuded in FCGI Library)
  • OpenSSL is -> sudo port install openssl
  • Haruhi Free PDF Library -> sudo port install libharu
  • Fastcgi -> sudo port install mode_ fcgid (Apache2 module) 
  • Asciidoc -> sudo port install asciidoc (Not included with Mac OS X Lion)
I should note that while experimenting with the Wt examples I invoked the built-in web server (wthttpd) with minor limitations. As the development progresses, however, it's likely we'll need a web server that can handle multi-threaded requests. I'll cover the multi-threaded stuff in a future post. Frankly, I'm stuck on the mod_fcgid configuration and need a little time for preparation.


We haven't gotten to the cool stuff yet. I could spend all day on configuration, as you know. As such, I'll break it up a bit and get right to the applicable examples.


For our (my) purposes we'll look into the following Wt examples:
  • Widget Gallery - FormWidgets - The FormWidgets examples shows a file upload
  • Hangman - The Hangman example offers a decent authentication example.
  • JavaScript - Wt's JavaScript example shows a very basic use of JavaScript.
  • TreeView-DragDrop - The TreeView-DragDrop example from Wt shows drag/drop and sorting.
Next we'll examine how the above examples are applicable to PackRapt.com. I'll also go over how Wt implements the parts of the examples I'll be using for PackRapt.com and touch on how we'll use them.


Widget Gallery - FormWidgets


FormWidget offers a simple look at uploads. Naturally, the PackRapt application allows for uploads. What good would a cloud document app be without uploads? Wt has a widget called Wt::WFIleUpload that offers a number of members that will be useful to PackRapt.


Members of the Wt::WFileUpload applicable to PackRapt:
  • void setMultiple () - Allows for multiple uploads
  • WString contentDescription () const - Returns the description of the file
  • WProgressBar* progressBar () - Progress bar fot the upload
  • void setProgressBar (WProgressBar *progressBar)
  • void upload () - You guessed it!
  • bool canUpload () const - Checks whether another upload can be uploaded
  • etc.
The FormWidget example from Wt does this in the following way:




You can see here that the WFileUpload object (fu) is created and set to a new WProgressBar. They both belong to the WContainerWidget object (result). The EventDisplayer object (ed_) is called for any of the three options of changing the upload, finishing the upload, and if the file is too large. This is a very simple look at the initialization of the upload and the results. Fantastic, eh?


You'll notice from the example that the upload is attached and then invokes the progress bar for the fu object. Once the file is uploaded the ed_ object calls the showSignal which displays the applicable message. Very simple. This, however offers a general look at our file upload feature.


Next post we will continue with the Hangman example. We look at rolling our own authentication.


Thank you,


Aaron



Sunday, September 18, 2011

PackRapt.com - Outline


This is a continuation of the previous post titled Application/Search Server - C++.

Where we left off...

Configuring the Boost library with CMake can yield some errors. Not to worry. For anyone who has done any coding you'll know that half the battle is with dependencies and configuration. The best option for me was to install Boost 1.47 from MacPorts.

$ sudo port install boost

From my install directory I cloned the Wt git repository.

$ git clone http://www.webtoolkit.eu/git/wt.git

Then, cd into your Wt directory create a build directory and configure with the Boost library.

$ cd wt
$ mkdir build
$ cd build
$ cmake ../

The small miracle of CMake begins and likely ends with a number of errors relating to the optional dependencies. From there you begin to build the Wt library.

$ make

The only errors I received here had to do with some deprecation warnings for the Android/SSL configuration.  From there you can install the library.

$ make install

You might see an error related to write permissions on a directory to be created. For example - file cannot create directory: usr/local/share/cmake-2.4/Modules. Yeah. You can sudo into admin and go at it.

Once you've got that under control the fun begins. Build the examples from Wt.

$ make -C examples

Work your way around the examples. I think you'll find that they offer a glimpse at the a number of important things. For sake of simplicity I'll start with hello.

The following instructions relate to the wthttpd server included in the library. Naturally, you can configure Apache as well.

For wrhttpd -

$ cd ../examples/hello
$ ln -s ../../resources .
$ ../../build/examples/hello/hello.wt --docroot . --http-address 0.0.0.0 -http-port 8080

You'll notice that the resources are linked along with a call to start the web server. You can include those docroot and web server arguments in your build config in your favorite IDE, if you'd like. It will streamline a number of things later in the project.

Once the server gets kicking you'll see:


And, there you go. You now have the Wt C++ Web Toolkit - hello example running. So, enter your name and...


I'd suggest you try a couple of the other examples. I think you'll find they're rich with possibilities.


So, how does this apply to PackRapt.com?

In consolidating the services used by PackRapt I now have the foundation for a C++ app that will be able to handle indexing, searching, authentication, etc. All-in-one. My goal is to make the search fast and decisive. I know, every search implementation says that they want fast and decisive. Without a disparate set of services like I have currently with PackRapt, however, it's much more likely to meet my expectations.

As such, the outline for building the new PackRapt.com will be:

  1. Prologue
    1. Wt Configuration and experimentation
    2. Library integration with Eclipse CDT
    3. Experiment with Wt Examples
      1. Examine the Wt ORM - Wt::dbo
      2. Integrate Wt::dbo locally
      3. Prepare Wt::dbo for deployment
    4. Create public Git repository
    5. Manymoon setup
  2. Getting into it
    1. Search
      1. Creating a local index
      2. Searching local data
    2. Authentication
      1. Local 
      2. Remote 
    3. Integrate with external sources:
      1. Google Apps
      2. Facebook
      3. Dropbox
      4. Box
      5. LinkedIn
      6. Twitter
    4. Access external services for data
      1. Index external data
      2. Search external data
      3. Internal and External Index Migration
      4. Full Search Integration
    5. Decision Engine
      1. Create
      2. Test
      3. Implement
  3. Getting out of it
    1. Style
      1. Layout and Style
    2. JavaScript Implementation
      1. ExtJS
    3. Finalize UX/UI
  4. Deployment
    1. AWS Setup
      1. EC2
      2. Elastic IP
      3. S3
    2. Test
    3. Deploy
  5. Sell! Wishful thinking again, eh?

That is a rough overview of the PackRapt plan. It'll be a ride for sure. 

There are a couple of ways you can follow and contribute to the mess. I've setup a project on Manymoon. If you'd like to follow along with the project let me know and I'll invite you. Please let me know if you're willing to contribute. I'll send you tasks to complete, as such. That would be great. I'll also create a git repository that'll be hosted on GitHub. Soon!

Well, here we go. I'll see you all soon.

Thank you,

Aaron


Wednesday, September 14, 2011

Application/Search Server - C++

I'll be documenting the redesign of my precious PackRapt.com. It will likely range from interesting banter to weepy regret. That said, however, what good is a challenge without little pain?

The redo will include implementation of a C++ Web Framework called WebToolkit.eu. If that doesn't sound painful, I don't know what does. It's quite popular and you can find a number of useful tools related to it on GitHub.

Previously I developed my PackRapt.com on the Rails 3 Framework. There is, as many of you know, a tremendous amount of community support for Rails and a slightly less amiable but ample community of Ruby devs to exploit. I do, however, enjoy a challenge and a Web Framework in C++ seems like the perfect dare.

The why...

My existing implementation of PackRapt.com relies on a disparate model of search, storage, and processing. In a feeble attempt to curb my curiosity about performance I'd like to consolidate the services as much as I can.

This is a very rough look at the existing architecture of the application:


Ideally, what I'd like in its place:


Now, I know that Heroku is hosted on Amazon Web Services and, as such, there is limited latency in the previous architecture. I thought, however, that I could try to do better. What do I know? The real question is whether I can pull it off. The cure for the insatiable curiosity of a novice is not failure, but success.

Well, let's get started with Wt and see how mad I really am. To start, let's talk about installing Wt.

Dependencies

As with any great C++ roll, the dependencies for Wt are near. The ubiquitous C++ boost library is requisite along with the lovely CMake. There are also a few optional dependencies for PDF Support (Haru) and image support (GraphicsMagick). If you've already got the ImageMagick fork installed you'll be fine - I think. I love ImageMagick, however, and I've been using if with RoR for some time. This installer for ImageMagick is mind-boggling in its simplicity. Kudos to Jon Maddox.

After you have your way with these guys the installation is as follows...

Create a build directory into your Wt root and configure the library with cmake.

$ cd wt-x.xx
$ mkdir build
$ cd build

$ cmake ../

It probably won't work. It never does, huh? If that's the case you can refer to the documentation to guide you through the cmake arguments that might suit your specific setup. It might be a bit painful but we all survive.

Now that we have gotten this far let's take a break. Goodness.

I'll chime in later this week or early next week. We'll tackle the Wt example and get into the design/architecture of PackRapt.com. We'll see...

See you in a few days.

Thank you,

Aaron

Wednesday, September 7, 2011

A Little Herb Sutter

I feel a little bit like the celebrity blogger who loves to drop names.

In the world of C++ there's Herb Sutter. His career has been largely spent prognosticating the direction of C++. He served on the ISO standards committee for C++ and has written a number of C++ related books.

Today on his blog he announced a presentation of he gave in Banff, Canada  (C++ and Beyond 2011) ,being posted on Channel9 (MSDN).  I'm diving right in.

According to his blog, "It's a keynote-y talk, not a technical talk." He does, however cruise over some real advantages to C/C++ .

He starts the presentation by discussing three genuine advantages to C/C++. They surround Performance/Dollar. They are:
  • Performance/Watt
  • Performance/Transistor
  • Performance/Cycle
Interestingly, in his description of the most recent history of C++ he mentions that the productivity over performance onset. Naturally, he touches on managed languages. One interesting thing he points to is how Windows Vista was the, "poster-boy" of the limitations of managed languages. Anyway...

The gist of his presentation is fantastic. Native languages have a place in today's development (I know what you're saying...). Ultimately, performance per dollars do matter.

Some other interesting points:

Managed languages sacrificed the efficiency of the system to allow for a more productive environment. Now, however, an emphasis on performance has brought back the native language's allure.

We've all seen Android's (Google's) Native Development Kit (NDK). It allows for the creation of C/C++ apps for Android. iOS, of course, has supported Objective-C, C/C++, for some time now. A move back to native languages is certainly underway. The point is, as we move to the cloud, efficiency from the level of the app to the level of the datacenter is crucial.

A Renaissance of native languages/efficiency?

I have a dear acquaintance that works in venture capital. He was once the CFO of Microsoft. I've discussed hiring talent around the Northwest and a comment of his struck me. He said, "The cloud will be built on C++ and JavaScript. Snatch up any experts in those areas you can." 

This has been clear now for a couple of years. C/C++, and/or native languages offer the performance that .NET and Java sacrifices for productivity.

He finishes with the most important point. C++ lacks the portable libraries to offer it the same productivity advantages of .NET and Java. 

What apps are you working on that require a significant level of performance that overshadows the need for productivity?

Thank you,

Aaron






Saturday, September 3, 2011

EGit for Eclipse - Yummy

I love git.

There are two things that I find an absolute must for a novice coder like myself. The first is StackOverflow. I hear the screams, chuckles, and jeers now. It's true, however. The suffering that has been eased from StackOverflow, simply cannot be overstated. I'm also confident that I'm not alone. I cannot even guess at the number of times I have found myself scouring SO for an answer. While I don't always find everything I need, I often do. The second is version control and repositories. I use git and GitHub for a remote repository. They have, not only, changed my hobby-flow but my perceptions of coding. It was quite encouraging, actually.

Coming from Ruby on Rails and working in Terminal, I found a comfortable flow in branching often. I found that, more times than not, when I broke my app I'd simply move back to Master and start over. For a mediocre hack, who spends more time fixing than writing code, it's a dream. As I fumble around in Eclipse, however, I often thought back to my dreamy hobby-flow and wished for that flexibility and ultimately forgiveness. Well, there's EGit, of course. And, yes, I'm going to talk about getting it up and running in Eclipse.

Now, there are a number of tutorials/walk-throughs that offer the same thing. As such, I'll keep it short. It's likely those other examples are authored by individuals more qualified to discuss such things. As I said before, however, I'm going to talk about whatever I like without much concern for place.

It's quite simple.

(On a Mac with Eclipse 3.7.0 Indigo)

1. With the Eclipse Install New Software window simply paste this url in the Work with: field.
(Help > Install New Software...)

Work with: http://download.eclipse.org/egit/updates

Press Enter

2. Select the updates (I did the Select All option)
The installer will run through a check on dependencies.

Press Finish

3. After Eclipse restarts control-click a project from your Package Explorer. Go to the Team option and select Share Project. In the Share Project window select git and Next. You'll see the Configure Git Repository window. Select Create... then Finish.

4. If you're new to git you'll need to do some configuration on your .gitconfig file. Here's a link. Or you can go to your Eclipse preferences and change the configuration file directly.
(Eclipse > Preferences > Team > Git > Configuration)

5. After your project is configured with a repository you can control-click > Team to see your git options.

That is heaven, my friends.

Easy to please...

Thank you,

Aaron

You've got to start somewhere...

“In order to please others, we loose our hold on our life’s purpose.” - Epictetus (Greek philosopher associated with the Stoics, AD 55-c.135)


Welcome to my blog. Nothing fancy, I know. Perhaps you should keep your expectations under control. Also, it's not likely I'll stick with it but I'll give it a go until I get tired.


The blog will primarily consist of my rants, raves and curiosities about coding. My guess is that I'll be writing mostly about Java, Ruby and C++. There's a chance, however, that I could venture off into any number of languages, frameworks, platforms and/or architectures with little warning. C'est la vie. My hope is that I can express myself in questions and simple contention in order to curb my profound curiosities about Computer Science. Now, my background is Information Systems and I would never claim to have a significant prowess to coding. However, you've got to start somewhere...


Thank you,


Aaron