Friday, November 14, 2014

Quick solution to the Webworkers local restriction using dropbox public folder

One of the things that Moorsgate Media focuses on is developing code and software projects to support our mission of delivering high quality speculative fiction featuring under represented peoples. As such, from time to time, we come across solutions to coding or development problems while working on those broader goals and we want to share them with you.  

For examples, the Kaizen text analysis app uses a number of software libraries to display infographics about a text selection (like word frequency, adverb usage, and dialog). This analysis uses Google's very capable charting API to produce some of the complex tree diagrams.  Unfortunately, the process of drawing these charts becomes computationally intensive over a certain word limit (roughly 4000 words).
One solution is to use Web workers to speed up some of the regressive processing that is required to look at each word in the text and process it according to our analysis algorithms. 

You might ask, what is a web worker? Well, let HTML5 Rocks inform you:

The Web Workers specification defines an API for spawning background scripts in your web application. Web Workers allow you to do things like fire up long-running scripts to handle computationally intensive tasks, but without blocking the UI or other scripts to handle user interactions.

Web workers are great. Here at Moorsgate, we are using web workers to off-load some of the computationally intensive text processing (looping within looping) to not interrupt the user interface of the  App (unfortunately DOM drawing is still taking awhile). All an all it has shaved about 2 seconds off of the wait time to complete the DOM draw. That is a huge improvement for us. 

However, there is a caveat when developing web-workers.

Again, from HTML5 Rocks:

Restrictions with Local Access

Due to Google Chrome's security restrictions, workers will not run locally (e.g. from file://) in the latest versions of the browser. Instead, they fail silently! To run your app from the file:// scheme, run Chrome with the --allow-file-access-from-files flag set. NOTE: It is not recommended to run your primary browser with this flag set. It should only be used for testing purposes and not regular browsing.
Other browsers do not impose the same restriction

It turns out that our version of Firefox appears to also have this issue. So in-order to get around it, we employed a very simple solution. We developed our webworker code and tested it using the public folder of our Dropbox account. By pushing your test code to the public folder, the files change from local files to remote web accessible files. Presto, no more local access problems. The same thing could be done using your local development server. However, if you don't have a local development server, this is the next best solution.

Now the downside: it can be cumbersome to move your whole app to public folder. For us, it was a good solution since the entire app is client-side and there is no back-end to speak of.  Another issue is,the public folder is, well, public. You might not want to move sensitive tech to the public folder since someone might be scanning your public folder looking for sweet treats.

However, as a solution to our problem, it works and did not require us to change the flag settings in Chrome. That was worth the drawbacks.

Monday, November 3, 2014

Kaizen Update


We are pleased to announce the revised update of our editing and writing analysis software tool: Kaizenmoto. The Kaizen text analysis web-app is up at our mother site, in the code section:  http://www.moorsgatemedia.com/code/kai/index.html It is still a bit slow, but it works well.
 
The goal of the app is to help you in the editing process. See what your average sentence lengths clocks in at. We find that what is needed most in the editing process is a way to quantify styles. Is your dialogue to prose ratio in line with the style you are after (hint, first person ratios are different than third person ones).  Check out your sentence starters, reading complexity, reading time, word count Coleman reading score, and a bunch more metrics. 

Check back often, we are updating and optimizing as we go, but it is publish or perish right. 

[editing software, fiction writing software, word editing, readability software]

Moorsgate Media