Archive for June, 2007

Gtkpod and the always shuffling iPod shuffle

iPodshuffleSome days ago, I bought an iPod shuffle: a wonderful thing that change my life in better. I love it. I can load 12-15 cd and then listen to them every day going to job, while reading some books.

I’m planning to hack my car radio in order to plug it into (it’s a 7-10 years old radio), but this is another topic.

Well, as free software fan, I dislike using iTunes and actually there’s no porting for linux. Finally I used gtkpod and banshee (I will search for a banshee plugin for managing iPod) on my Debian etch.

I like listen to cd in their order, not in shuffle way. This because most cd I listen to are “concept” (like the Ayreon’s universal migrator) . Then I noticed that when I uploaded files to the iPod in the order I needed, the listen order was always shuffle but the switch was triggered on sequential.

I discovered (?) what I think it’s a bug but more probably it’s me that didn’t know how to use the tool. In order to keep the selected layout, you first need to load all files in the local podcast (see 1 on the picture below), then order them as you like and finally select needed tracks and drag them into the iPod podcasts playing list (see 2).

If you need to create additional playing list, create them it the iPod space and then dram into the desired tracks from the iPod podcasts playing list.

I don’t know why, but in this way, I’m able to keep the desired playing order.

gtkpod

Comments

Gimp: drawing a circle

As usual google is your friend :)

Use the elliptical select tool, hold down CTRL key to constrain as circle, fill the selected area with new color, right click on selected area, choose SELECT, SHRINK, shrink selection by whatever number of pixels you want your circle width to be, right click again in selected area, choose EDIT, CUT. Voila, one beautifully antialased circle.

Gimp FAQ.

Comments

J2EE: deny direct jsp call

A customer of mine asked me, for a web application that all the direct jsp request will be forbidden. All except to jsp that reside in a /public/ or deeper directory.

J2EE come in our help with Filters. It’s very easy to implement.

First of all an edit to /WEB-INF/web.xml in order to tell the application that a filter is on the run. Add something like the following. Make it fit in your configuration file; for example if you have other filters (here is for a quick download JspFilter: web.xml).

<filter>
    <filter-name>JspFilter</filter-name>
    <display-name>JspFilter</display-name>
    <filter-class>path.to.filters.JspFilter</filter-class>
    <init-param>
        <param-name>forbidUrl</param-name>
        <param-value>/forbidden.jsp</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>JspFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

What’s said here is that you have a new filter in the specified package, that should come in use for every jsp request (*.jsp) and has a parameter (forbidUrl) that specify which page should be displayed for error. You could specify even a servlet or a static html.

Create the needed jsp. In my case is /forbidden.jsp.

Now the filter class (download code).

package path.to.filters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * Listen for every call and filter every jsp request redirecting to a forbidden page
 * if not in public (or deeper) directory.
 */
public class JspFilter implements Filter {
    private static final Log logger = LogFactory.getLog(JspFilter.class);
    private FilterConfig config = null;
    /* (non-Javadoc)
     * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
     */
    public void init(FilterConfig config) throws ServletException {
        this.config = config;
    }

    /* (non-Javadoc)
     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
     */
    public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
        logger.debug("JspFilter::doFilter()");

        HttpServletRequest http = (HttpServletRequest) request;

        //if in "/public/" directory normal chain
        if(http.getRequestURI().indexOf("/public/")>=0){
            chain.doFilter(request, response);
        }else{
            RequestDispatcher disp =  http.getRequestDispatcher(config.getInitParameter("forbidUrl"));
            disp.forward(request,response);
        }
    }

    /* (non-Javadoc)
     * @see javax.servlet.Filter#destroy()
     */
    public void destroy() {
    }

}

Comments (2)