Easing JavaScript Development with Builds under Symfony with Assetic

Dojo has a great build process which allows you to create a optimized and minimized files for the client side (and more!).

In a production environment, this greatly improves performance.

However, building the code after every change will slow development significantly.

Since Dojo can load the required modules dynamically, you can load the source files and work with them directly, and maintain your profile file as you work. Running a build at the end of each development session will help to ensure the code and profile stay in sync.

Assetic can be used to switch between the source and built version of files by placing the JavaScript configuration in config_dev.yml and config_prod.yml. The templates don't need to be modified.



    use_controller: true
                - 'common/dojo-release-1.10.4-src/dojo/dojo.js'
                - 'common/app/main.js'
                - 'common/app/admin/user.js'



                - 'common/release/dojo/dojo.js'
                - 'common/release/app/main.js'
                - 'common/release/app/admin.js'

twig template that references the Assetic assets.



{% javascripts
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}

@admin_js is specific to only the admin pages, it would be referenced there.

Ansible SSH issues under CentOS

I needed a CentOS 6.5 guest under a CentOS 6.6 host for development and to prepare for deployments.

I could not get Ansible to SSH into the box.

I took the provisioning out of the Vagrantfile and began running the playbook on the command line with:

ansible-playbook main.yml -i inventories/vagrant -u vagrant -vvvv -k


  • Offending key in /home/user - removed offending key
  • sshpass not installed - installed sshpass
  • SSHed in directly using the user (vagrant) that will be provisioning
  • Set the .gui flag to true in the Vagrantfile - http://docs.vagrantup.com/v2/virtualbox/configuration.html. This made it easier to see what was happening.

A Very Simple Node/Express JSON Form Example

Link: https://nodejs.org/

Server-side (file is named server)

This code is invoked with: node server

Once it is invokec, call the page with http://example.com:1337/form.html


// Express is a framework used with node that provides many important constructs
var express = require('express');
// The application is an Express application
var app = express();
// bodyParser is used to convert the request data into JSON
var bodyParser = require('body-parser');
// Express.static is used to serve the static files
// This receives a request posted to / and processes it
app.post('/', function (req, res) {
  var data = req.body;
  if (data['first-name'].trim().length > 5 && data['last-name'].trim().length > 5) {
  } else {
// The application will listen on port 1337


The client side code is in the static directory. There is a simple form:


  <label for="first-name">First name<input type="text" id="first-name"></label>
  <label for="last-name">Last name<input type="text" id="last-name"></label>
  <button type="button" id="go">Go</button>
<div id="status">

And a little bit of JavaScript.

This code fires when a button with the id of "go" is clicked. It gets the values of the inputs, creates an object and sends it to the server.


document.getElementById("go").onclick = function() {
  var i,v,inp = ["first-name","last-name"];
  var data = {};
  for (i in inp) {
    v = inp[i];
    data[v] = document.getElementById(v).value;
  var xmlhttp;
  xmlhttp=new XMLHttpRequest();
  xmlhttp.addEventListener("load", done, false);
  function done()
    response = JSON.parse(xmlhttp.response);
    document.getElementById("status").textContent = response["status"];

Notes for those who are patient or really desperate.

  • app.post doesn't make a post request, it accepts one with the URL in the first parameter. In this case, it will accept a post response for / on port 1337.
  • Express is a nice framework for node. Use it.
  • You need to use npm to install both Express and body-parser.
  • bodyParser parses the request body from JSON. It can handle other formats, too
  • Be sure to put the static files in the static directory, or update the express.static call accordingly.
  • Note that there is no charset on the content type header sent to node. Node is looking for "application/json"
  • The validation is really limited, the goal of this code is to show how to set up the form.
  • You may have to update your firewall settings to allow access to port 1337. If you are on an Amazon instance, use their web console.
  • When all else fails, read the documentation.

Bash Create User Script

This is a very simple script to create users and set them up in a userdir enabled Apache environ.


if [ "$#" -ne 1 ]; then
    echo "Usage: ./mkacct.sh <username>"
    sudo useradd --'/bin/bash' $1
    sudo chmod 711 "/home/$1"
    sudo mkdir "/home/$1/public_html"
    sudo chmod 755 "/home/$1/public_html"
    sudo chown "$1.$1" /home/$1/public_html
    sudo passwd $1

Screen Resolution - Web development

Link: http://gs.statcounter.com/

I have used the statcounter for several years to help me adjust page layouts for web development.

The mistake I have been making is that the browser does not usually have the entire screen resolution available.

Today I took some time checked the window dimensions on a Windows 7 laptop with a 1366x768 screen and several browsers.


  • Full screen with menu and bookmark bar 1366x608
  • Windowed, full height x600

Internet Explorer

  • Full screen with menu, bookmark, DebugBar 1301x548
  • Windowed, full height x540


  • Full screen 1366x667
  • Windowed, full height x639

These dimensions depend on the toolbars in use, etc, but they provided a very helpful reminder that 1366x768 screen resolution is not the same as a 1366x768 browser page.

In addition, the best way to test a page under Internet Explorer is to use Internet Explorer, and if you you need to test different versions (you do!), you can use IE or IETester (http://www.my-debugbar.com/wiki/IETester/HomePage). Sometimes there is simply no substitute for target machine and browser testing.

:: Next >>