Coder's Revolution

Do you want a revolution?

My First Experience With DataBoss Dynamic ORM Administrator

ColdBox, ColdFusion, ColdFusion Builder, ORM

With the release of DataBoss 1.3 today, I thought I'd share a quick story about my recent first project diving into DataBoss.  Full disclosure: DataBoss is a commercial product and I work for the company that makes it.  None the less, I thought it was pretty freaking useful so I thought I'd throw out this quick post.

For those of you who don't know what the heck DataBoss is-- it's a Dynamic ORM Administrator.  Basically, it can scaffold out CRUD (Create, Read, Update, Delete) screens for pretty much any database structure and it's all based on ColdFusion ORM.  It runs on Adobe ColdFusion as well as Railo and the minimum to get it running is to create ORM entity CFCs, drop them in your models folder and reload ORM via the interface.  It will pick up your entities, read all the relationships, and create all the screens necessary to manage the data in your database complete with formatting, validation, rich text editors, date dropdowns, etc.

So, the recent project I got assigned was for a company that does development services.  They had a project they had been working on for one of their clients that involved a nicely-normalized database of about 20 tables that supported a multi-lingual ordering and reservation system.  They had the front end system built out with ColdFusion but the problem was the deadline was getting very close and they weren't going to have to time build the backend of the system that allowed all the products, descriptions, and companies to be configured.  They needed to have a backend over to their client in a matter of days to start entering data, but there simply wasn't enough time to build one from scratch.

Enter DataBoss.  I was tasked with setting up a data-entry app they could use to manage their database until they had time to finish the backend.  The database that had already been built was well-structured and contained many examples of one-to-many, many-to-one, and many-to-many relationships.  I was given a backup of the data structure and a diagram that showed all the foreign key relationships.  Using Adobe's CFC Generator for ColdFusion Builder, I selected the tables via the RDS datasource view and stubbed out all the ORM entities in script.  Don't try to use the CF Builder plugin to create relationships.  It's horrible and you'll be sorry.  For just stubbing out the entities and the properties, it's pretty good though and saves a lot of time.

DataBoss is packaged as a portable ColdBox module which means you can drop it into an existing ColdBox app, or just deploy it as a small standalone app.  I chose the latter and dropped my ORM entities in the /model folder.  After adding my datasource name to Application.cfc and changing dbCreate to "none" the app sprang to life and displayed a list of all my entities in a drop down.  There's settings in a JSON file to control pagination as well as the internationalization of the DataBoss app itself.  DataBoss already comes bundled with German translations which was nice since this project was for a German company.  

At this point, I went through and configured all the relationships and added metadata to each entity and property that controlled how it displayed on the screen, what kind of validation it applied, and what form controls to display for each field.  After a bit of tweaking, we had really nice CRUD screens fleshed out that even used 24-hour clock and dd/mm/yyyy date formats to match the local standard.  I enabled the Basic HTTP Auth built into DataBoss, and it was ready to deploy publicly!  All in all, we had the entire admin finished and ready to deliver to the customer in just a few days.

I was pretty pleased with how easy it was to get working, and was a major saver for them to get the edit screens to their customer in time.  And now, they can use those ORM entities for future development on the application.  DataBoss Standalone is only 99 bucks which isn't bad considering the time it can save you.  Think about using it for that old legacy database you have no edit screens for, or to help you create your next database.  You can also download a trial to play around if you want.

Product Site:

http://www.data-boss.com/

Docs:

http://www.data-boss.com/docs/index.html

0

Intro To Couchbase For Caching And NoSQL - Webinar Tues 4/8/2014 1PM EDT

CacheBox, Caching, Performance

I will be presenting on how to get started using Couchbase for caching and NoSQL at a TeraTech webinar next month.  Couchbase is an up-and-coming server that mixes caching capabilities with a NoSQL JSON document store.  It has excellent performance and the best clustering/sharding/failover setup I've seen.  I'll be demoing the brand new CFML SDK for Couchbase as well as the Ortus Railo Extension.  Here's the session description.


 

nteractive applications have changed dramatically over the last 15 years. Today, they must support millions of users simultaneously and downtime is no longer acceptable. Three mega trends – Big Data, Big Users, and Cloud Computing – are driving the adoption of NoSQL technology over traditional relational SQL.

NoSQL document stores are reinventing the way we design our databases and cache layers. Couchbase open source server is a unique database with unparalleled performance, automatic replication and failover. 
In this webinar:

  • how document databases differ from the traditional RDBMS
  • the benefits and tradeoffs they bring to the table
  • a hands-on look at the new CFCouchbase CFML SDK
  • native caching and session persistence via the Railo Couchbase Extension.
  • Q&A

Register for free Now

0

Will A Piece Of Paper, Folded 42 Times, Reach The Moon?

General, Mathmatics

So I was at a friend's house Sunday night playing a game when this odd fact came up in conversation:

If you were to fold a piece of paper in half 42 times, it would reach the moon.

Several of those around the table scoffed at this, exclaiming that a single sheet of paper was simply too thin to have its thickness reach any substantial amount after only a few dozen folds.  I pointed out it was entirely possible seeing as how doubling the thickness with each fold would lead to an exponential increase in thickness that would increase slowly at first before quickly getting larger.  My friends were clearly imagining a linear increase in thickness.

I also knew that it is pretty much impossible to fold a single sheet of paper more than about 8 times -- though Myth Busters once folded a giant sheet the size of a football field 10 times. The resulting thickness (after hitting it with a bulldozer) was almost a foot tall, though there was quite a bit of air mixed in with the 1,024 sheets.  The formula for finding out how many of something you'll have after doubling it N number of times is as follows where O is the original number (or size in our case).

o * 2^(n)

A standard sheet of paper is about 0.1 mm so 42 folds would give us this:

0.1 * 2^(42) = 439,804,651,110 mm

That's 440 billion millimeters, or 439,804 kilometers.  The moon on average is 384,400 kilometers from Earth according to Google.  I'd say this checks out.  

To help visualize the data, I created a quick spreadsheet and graph that tracks the thickness of the paper for each fold.

# Folds Thickness (mm)
0 0.10
1 0.20
2 0.40
3 0.80
4 1.60
5 3.20
6 6.40
7 12.80
8 25.60
9 51.20
10 102.40
11 204.80
12 409.60
13 819.20
14 1,638.40
15 3,276.80
16 6,553.60
17 13,107.20
18 26,214.40
19 52,428.80
20 104,857.60
21 209,715.20
22 419,430.40
23 838,860.80
24 1,677,721.6
25 3,355,443.2
26 6,710,886.4
27 13,421,773
28 26,843,546
29 53,687,091
30 107,374,182
31 214,748,365
32 429,496,730
33 858,993,459
34 1,717,986,918
35 3,435,973,837
36 6,871,947,674
37 13,743,895,347
38 27,487,790,694
39 54,975,581,389
40 109,951,162,778
41 219,902,325,555
42 439,804,651,110

And to graph that out in kilometers looks like this:

2

Into The Box Movie Trailer

cf.Objective(), ColdBox

We've created a fun trailer for our Into The Box conference this May.  Please check it out and then register to come for a great day of learning that doesn't take itself too seriously :)

 
0

Modern JVM Languages and ColdFusion Venn Diagram

ColdFusion

2

Mainstream News About ColdFusion Venn Diagram

ColdFusion, Security

0

What's A Pull Request (Contributing To Open Source) cf.Objective() Preview

cf.Objective(), GitHub

Tonight the Nebraska ColdFusion User Group (NECFUG) rebooted themselves and I was honored to be able to share a preview of my cf.Objective() session for this year, What's A Pull Request (Contributing To Open Source).  I'd love to have feedback on the presentation so I can make it as good as possible for cf.Objective() this May.  Please give it a listen if you have the time and drop me a line with any thoughts you have.

0

Know Python? Help ColdFusion Get Proper Script Highlighting On GitHub

ColdFusion, General, GitHub

It's bothered me for a while, that GitHub and Gist don't have proper syntax highlighting for full-script CFCs like this one.  

They handle tags fine, and even do script inside of a <cfscript> tag, but just leave full script components as black text all the way down the page.

 ColdFusion has allowed all-script components since version 9 which was released 5 years ago.  I always just assumed that GitHub was aware of the problem and someone somewhere was hard at work resolving it.  Silly Me.

GitHub uses this Ruby library to determine what language a while is written in:

https://github.com/github/linguist

Which in turn uses this Ruby wrapper to spin up the syntax highlighter:

https://github.com/tmm1/pygments.rb

But that library is just a proxy to this Python library that actually does the color coding:

https://bitbucket.org/birkenfeld/pygments-main

It looks like there's already a ticket from 2012 to add support and Ben Riordan took a whack at it last year with no luck.  So I've forked the Pygments library, but know nothing of Python so I'm asking anyone who does to help me get this figured out.  Since script already works inside <cfscript> tags, it sounds like all the pieces are there-- we just need to properly identify script components and use the correct highlighter for them. Comment here or shoot me an E-mail if you'd like to help!

3

Who's Had More Vulns- PHP, Java, or ColdFusion?

ColdFusion, General, Security, Technology

I get tired of people on complaining about ColdFusion as a technology choice because it's "so insecure".   I regularly am told that it has more holes, more vulnerabilities, and a worse track record than other platforms. That's why I compiled this quick chart showing the number of Common Vulnerabilities and Exposures (CVE) by year for CF as well as PHP and Java (as reported by cvedetails.com) which are two of the most-used languages on the web.  I also threw in Apache Tomcat for comparison since it completes in the web space and CF10 actually runs on a version of it.

 

Click to enlarge

So to break this down, the red line riding out on top with a huge spike in 2007, that's PHP.  The purple line coming out of the backfield for a solid lead (?) at the end is Java.  The yellow line is Tomcat who still manages 10-15 vulns a year (and the only one to go LOWER than CF.  And that green line on the bottom with the lowest number of vulns every year, and nothing even reported until 2006- that would be CF.

So, sure-- there's a lot more info than just the counts on the chart.  My point also isn't that PHP or Java are bad-- I'm just trying to make the point that oft-used technologies are targeted by crackers and nobody is perfect.  And according to this data, CF is doing way better than several of the main techs out there.  It should also be noted that CF, Java, and PHP were all created the same year-- 1995, so don't give me any of this "old" crap either.  (Tomcat was created in 1999)

References:

 

10

Getting CFML Working On Runnable.com

ColdBox, Railo, Runnable

In my last entry, CFML, Meet Runnable.com For Live Code Sharing, I talked about what Runnable.com is and why it's worth looking into for anyone who's looking for a nice platform to publish live working code samples that people can launch in their web browser.    Today I'd like to cover the steps I took to getting CFML working on Runnable as well as gotcha's and other bits that weren't immediately obvious.  The great thing is, you don't have to know most of this to publish your own code!  Just click on one of my Runnables, click the "Save Draft" button, change the name, description, and code to your liking, and then Publish it!  You don't have to start from scratch; you can spring board off of my work.  For those of you who want to do it your way or are just curious, keep reading.

As discussed in the first post, each runnable is stored as a template of a Linux server called a "container" and is managed by a technology called Docker.io.  When a user comes to the site and clicks a runnable, a unique lightweight "instance" will be spawned from the container template just for that user.  This instance actually runs inside of a master linux instance that it shares resources with, but it is completely isolated from all other instances.  It will also be destroyed when the user leaves their web page.  As such, site users have root access to this instance and can run whatever commands and write whatever code they want, but they are isolated to their instance and securing the runnable is not necessary.

Here's a list of items in no particular order that I wish were documented somewhere on the site when I started:

Getting Started

  • If you want to start from scratch, visit http://runnable.com/new and click "bash". 
  • If you want to start from an existing runnable, view it and click "Save Draft"
  • You will need to create an account to make a runnable, but that makes sense
  • Edit the title of the runnable by clicking the pencil icon.  Make sure you hit save!
  • Edit the description of the runnable by clicking the pencil icon.  Make sure you hit save!  I have put in a suggestion that this allow rich text

Managing Files

  • The folder icon in the upper righthand corner will open a file explorer.  You can created folders and files here.  Click on a file to open it.  
  • Right click on a file and choose "Set Open by Default" for that file to default to being open in a tab when people visit your runnable
  • The editor has decent color coding and does allow you to copy paste in it.
  • The default folder for the file manager is /root.  You cannot change this, but if you ask Runnable, they will
  • The runnable guys can also filter what files and folders show up if you ask them.

Using The Terminal

  • Below is the terminal with a bash prompt.  Hit the icon to the right of the word "Terminal" to pop out into a new full screen tab.
  • You can copy text by highlighting and right-clicking
  • If you edit a command at the shell prompt it will appear as though it has overwritten your text.  Have no fear.  Press the "end" key on your keyboard and it will fix itself.
  • uname -a returns
    Linux runnable 3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Installing Software

  • You can use wget to download whatever installers you want
  • You can use apt-get to install whatever packages you want
  • You can install Git and clone repos (This is what I do)
  • As far as the server you set up, the world is your oyster.  Any servlet container, CFML engine, and configuration is valid as long as it runs on Ubuntu.
  • Note, I had issues getting the Railo Linux installer to run.  I have logged this issue with the Runnable guys.
  • I installed Tomcat via apt-get and deployed Railo as a WAR file in the root context.  To do this, delete the folder called ROOT under /var/lib/tomcat/webapps, rename the Railo file to ROOT.jar and place it in the webapps folder.  After a few seconds, Tomcat will pick it up and explode it out.  The /var/lib/tomcat7/webapps/ROOT folder is your new web root.  I asked the Runnable guys to default the editor file explorer to there.
  • If you have them disable Apache, you can bind Tomcat to port 80 but I just set up a reverse proxy so I could use Apache's rewrite module.

Configuring CFML

  • The config for the default Apache site is located in /etc/apache2/sites-available/ in a file called "default".  
  • By default the web root is /var/www.  I changed the DocumentRoot directive and <Directory> tag to /var/lib/tomcat7/webapps/ROOT
  • I also changed the DirectoryIndex directive to index.cfm
  • I created a file called "railo.conf" in the /etc/apache2/conf.d directory.  It is automatically included.
  • Inside I set up my proxy to the standard AJP port:
    <Proxy *>
    Allow from 127.0.0.1
    </Proxy>
    ProxyPreserveHost On
    ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
  • Check in /etc/apache2/mods-enabled and if proxy.conf, proxy.load, and proxy_ajp.load aren't listed, enable them with a2enmod
    sudo a2enmod module_name
  • Tomcat web config is located In /etc/tomcat7/server.xml 
  • Uncomment the AJP connector on port 8009
  • The web root is configured in the <host> block.  Check it if you're going somewhere different than the default context.
  • When "running", if you break the page out of the frame, you can access the Railo administrator at the usual URL by adding /railo-context/admin/server.cfm to the end of the URL
  • I didn't set the Railo password, but there's not security concern if someone accesses it since the entire instance is unique to them.

Running Code

  • For a web framework, you don't need to change the "Run cmd" or "Build cmd" options that drop down on the "Run" button.  
  • I would also recommend setting "Only Web" which will not show the terminal window along side the web page output.
  • When the Run button is pressed, a new window will open that hits your instance in an iframe.  A DNS name will be created on the fly that uses a GUID to make it unique.  You can click an icon to open your runnable address directly in the main browser tab.
  • Basically, whatever is spit back on port 80 in the web root is what the user will see.  There is currently no way to have the "run" button target a specific URL or query string, but I have requested that.
  • If everything is set up correctly, you should see your default page rendered.  If you've copied one of my runnables it will just work :)
  • Your sample can have multiple pages that the user navigates between.  You can have an entire site if you want!  I like to have instructions on the first page, and then links to view additional pages that show code running.
  • Your pages can submit forms, upload files-- there really aren't any restrictions.

Gotchas

  • You cannot paste text into the terminal window.  This is VERY annoying.
  • A very slick workaround if you need to download an extremely long URL is to shorten the URL with a URL shortner.  wget will follow the 302 redirect automatically and it's much less typing.
  • You cannot SSH directly to the instance via PuTTy.  I have suggested they allow this.
  • Apache is automatically running and bound to port 80.  The runnable guys can disable that, but you can't.  Whatever you do, it will come back.
  • Port 80 is the ONLY externally-accessible port.  That means you can't run Tomcat on 8080, etc.
  • Tomcat will NOT start by default and there's nothing you can do to fix it.  E-mail the Runnable guys and ask them to change your instance startup script to include Tomcat and they will happily oblige.
  • Tomcat takes a few seconds to spin up and Apache will throw a 503 the first time someone hits it.  I have reported this issue, and in the mean time I placed a custom ErrorDocument directive in /etc/apache2/sites-enabled/default like so:
    ErrorDocument 503 "<meta http-equiv=\"refresh\" content=\"1\">Loading..."
    This overrides Apache's default 503 error page with one that simply says "Loading..." and refreshes every second until Tomcat and Railo are ready to serve requests.
  • Runnables don't have access to public DNS so don't try to CFHTTP to cgi.server_name in your code as it won't resolve. localhost will work. (Ran into this on the HTTP Runner for TestBox)
  • Runnables are case sensitive-- good to remember if you're developing the examples on windows.
  • Your account won't be able to publish at first.  Just E-mail, Tweet, or fill out their contact form and they'll approve you.

Git Workflow

  • I have created a GitHub account called cf-runnable to store my samples: https://github.com/cf-runnable  Feel free to star, fork, and send pull requests to me.
  • I installed git-core with apt-get and clone the repo down into the web root.
  • No authentication is needed via this method so I don't have to worry about accidently leaving an SSH key on the runnable.
  • I created a bash script I called .setup and placed in the web root with this code in it:
    #!/bin/bash
    
    # Clean up dir
    find . ! -name .setup ! -path ./WEB-INF\* -delete
    
    # Clone repo into sub dir
    git clone http://github.com/cf-runnable/$1 ./__tmp
    mv -f __tmp/* ./
    rm -R __tmp

    Git repos can't be cloned into a non-empty directory, so what I do is delete everything in the web root but the script and WEB-INF.  Then I clone the repo into a folder called __tmp, move the files into the web root, and delete the temp folder
    To pull down the code for a runnable sample, simply run:

    $> ./.setup CFML_Templating_With_Tags
  • DON'T DELETE THE WEB-INF FOLDER.  Doing so will remove Railo and CFML will stop processing.  If you do this on accident, remove the entire ROOT folder, and restart Tomcat.  It should redeploy the Railo WAR.  My .setup script is located in the "admin" repo for cf-runnable.  You can easily modify it to point to your own repo.

  • So the process for creating a new runnable is fairly straight forward for me.  I create a new repo and copy over my last project into it including my .gitignore file.  I set up my tutorial on my local install of Railo and when I'm done, commit and push to GitHub.  Then I simply clone another runnable on the site with "Save Draft", edit the title and description and run "./.setup Repo_Name" from the command line and I'm done

Conclusion

That's enough of a brain dump for now.  Runnable is basically as flexible as you could want it to be.  Don't be scared away by all the stuff I typed here.  Most of it is already done for you so go play around with one of my runnables and get your feet wet.  I'll be adding more tutorials-- mostly centered around ColdBox and other Box libraries soon.  I think Runnable.com can be a very cool platform for the CFML community to publish example code on.

Here's some of the runnables I've created.  The full list will always be here.

0