Maven has a handy site plugin which can generate a website about your Maven project. Once the website is generated, normally it needs to be published to somewhere. A simple web server using Apache httpd or Nginx will be enough. Use a SSH/SCP wagon to upload website files to the server. Or website can be published to AWS S3 using wagon provided by community. Nexus can also host Maven websites. So if you are already using Nexus as internal Maven server, then it’s a better choice to use Nexus to host the Maven site.
If you have a web page which updates itself using Ajax background refresh tasks, when the user’s session is timed-out, the response of the refreshing Ajax request will be a
302 redirect to log-in page. But the Ajax request may not be able to handle that and simply fails. The user may not see the updated results. In this case, web page should detect the session timeout and redirect the user to login page.
When using AngularJS’s
$http service for Ajax request, it’s very simple to handle session timeout. All you need to do is to add a
$http interceptor and handle the response. See CoffeeScript code below.
After you have created a Rails 4 project and want to use AngularJS for the front-end development, this post can provide some tips.
It’s a common practice to use Bower to manage front-end dependencies. Bower should also be used in Rails development. After Bower is installed, create
.bowerrc in project root directory to specify directory to put dependencies.
1 2 3
config/application.rb file to include Bower components. Add following line to your application configuration.
To install AWS CLI on Ubuntu, you need to use Python 2.7. If you use Python 2.6, there is a conflict error with
You may need to uninstall Python 2.6 first using
sudo apt-get remove python. Then install Python 2.7.
1 2 3
sudo apt-get install python pip, then install AWS CLI using
sudo pip install awscli.
When using JPA/Hibernate, there are some common errors.
javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session
This means when Hibernate is trying to save entities when committing the transaction, two new entities have been added but they are related to the same database table row. You should check the Cascading settings of your entities. You may declare
CascadeType.ALL on one of your entities, but still trying to persist dependent entities explictly using
save. This will cause two entities to be persisted: One from cascading and another one from explict persisting operation. You can remove the explict persisting operation and let Hibernate to manage dependent entities.
Capistrano is a good tool for deploying applications. It can deploy Ruby on Rails applications and other applications. This article is to show you how to use Capistrano to deploy a static website. The deployment process is very simple, just check out the code from Git and put into a directory hosted by Apache.
Prepare your local environment
On your local development environment, install Capistrano using
gem install capistrano.
Prepare your remote environment
Remote environment is where the application is deployed to. Add user
deploy to your remote environment. This user
deploy is the user Capistrano runs.
In Magento’s ‘Place order’ page, order item’s quantity is not shown by default. To show this value, file
/app/design/frontend/default/myshop/template/checkout/onepage/review/item.phtml should be modified. You can get the file path by enabling Magento’s Template Path Hints.
From this file,
$_item is the order item.
When using AngularJS, sometimes you may see this error “Referencing DOM nodes in Angular expressions is disallowed”. This may be caused by returning a jQuery expression in your scope functions.
For example, following code will have this issue.
If you want to do some journey planning in Auckland, basically you have three options:
- Google Directions API - For free API, you can only send 2,500 directions requests per 24 hour period.
- JSONP API used in AT’s public site - Not a public API, more like a hack
- Set up your own OpenTripPlanner instance
This post will show how to set up OpenTripPlanner using Auckland data.