How to Write Node.js Applications in Python using PythonJS on OpenShift

Today I came across an interesting library called PythonJS that converts Python to JavaScript. It converts to JavaScript and generates JavaScript, CoffeeScript, and Dart code for the given Python code. In this blog you will learn how you can use PythonJS to deploy Python’s Tornado web framework application to OpenShift’s Node 0.10 cartridge. Read the full blog here https://www.openshift.com/blogs/how-to-write-nodejs-applications-in-python-using-pythonjs-on-openshift

Java EE7 Development and Hosting on OpenShift with Wildfly: Part 1

This is the first blog post in a series where I will cover how to build web applications in Java using Java EE 7. Java EE 7 is the latest release of the Java Enterprise Platform, with a focus on HTML 5 and developer productivity.

Java EE 7 introduced five new specifications covering WebSockets (JSR-356), JSON Processing (JSR-353), Batch Applications (JSR-352), Concurrency Utilities (JSR-236), and Caching (JSR-107). Apart from these new specifications, three existing specifications (JAX-RS 2.0JMS 2.0, and EL 3.0) have major updates and a few other specifications have minor updates. We will cover most of these specifications in detail in this blog post series.

Read full blog here https://www.openshift.com/blogs/java-ee7-development-and-hosting-on-openshift-with-wildfly-part-1

Developing Single Page Web Applications using Java 8, Spark, MongoDB, and AngularJS

In this post you will learn how to use a micro framework called Spark to build a RESTful backend. The RESTful backend is consumed by a single page web application using AngularJS and MongoDB for data storage. I’ll also show you how to run Java 8 on OpenShift. Read the full blog here https://www.openshift.com/blogs/developing-single-page-web-applications-using-java-8-spark-mongodb-and-angularjs

Using Siege for quick and dirty load test — Apache Benchmark Alternative

Today, I wanted to run a quick and dirty load test on one of my applications. One of the alternative that most of the developers are aware of is Apache Benchmark(or ab). For some reason, ab does not work on my mac book because of Connection reset by peer errors. So, I looked around and found Siege. It is very similar to ab and works well on mac.

To test the GET request, you would run

siege http://example.com/rest/todos/3 -c 100 -r 100

To test the POST request, you would run

siege -H 'Content-Type:application/json' "http://example.com/rest/todos POST < ./data.json" -c 10 -r 1000

XWiki on OpenShift

1. Create an OpenShift application using following command
$ rhc app-create xwiki jbosseap –gear large

2. Downloaded the xwiki war file from the official web site.

3. Extracted the war file using $ jar xfv xwiki.war

4. Downloaded three jars — guice-servlet, guice, and h2 from http://mvnrepository.com/ and placed the jars in WEB-INF/lib directory. The application expects these jars but don’t bundle them.

5. Update the hibernate.cfg.xml. Basically, we have commented out hsql and uncommented h2. The NullPointerException that you were seeing was because xwiki does not work with JNDI datasource so you have to bind the url manually. If you want to use postgres or mysql then use proper connection url, username, password etc.

6. Pack the war file again using $jar cfv ROOT.war .

7. Copy the artifact to deployments folder in your app source code. Please delete src/ and pom.xml as you are deploying war file.

8. Git commit and push the war.

9. Check the logs.

Using Python Flask Jinja2 with Mustache

Today I was building a single page web application using Python Flask framework and Backbone.js and faced a problem where Jinja2 was parsing the mustache template. Both Jinja2 and Mustache use {{}} in their templates. When a user makes a first request, I render index.html that contains all my mustache templates as well. The solution to avoid Jinja2 from parsing Mustache templates is to put all the templates inside  {% raw %} and {% endraw %} as shown below.

{% raw %}
<script type="text/template" id="company-template">
	<a href="#companies/{{id}}/jobs" class="list-group-item">
    	<h4 class="list-group-item-heading">{{name}}</h4>
    	<p class="list-group-item-text">{{description}}</p>
  </a>
</script>
{% endraw %}