Digg-Style Pagination in Java
public ArrayList getPagingLinks(){
ArrayList pages = new ArrayList();
if (pageCount < (7 + (adjacents * 2))){
for(int i=1; i<=pageCount; i++){
pages.add(i);
}
} else if(currentPage < ((adjacents * 3) + 1)){
for(int i=1; i<=(4 + (adjacents * 2)); i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else if(((pageCount - (adjacents * 2)) > currentPage) && (currentPage > (adjacents * 2))){
pages.add(1);
pages.add("e");
for(int i=currentPage -adjacents; i<=currentPage +adjacents; i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else{
pages.add(1);
pages.add("e");
for(int i=pageCount - (adjacents *3); i<=pageCount; i++){
pages.add(i);
}
}
return pages;
}
Basically, it creates a list of links to pages determined by the displayCount. If the page number equals the current page or the page number is greater than the page count, then no link will be added, only the page number.
The Passionate Programmer: a review
Creating a Remarkable career in Software Development
by Chad Fowler

My favorite part of the book was the “Act on It!” sections that give you suggestions for things you can do now to act on the concepts introduced in the chapter. If you are looking for a springboard of ideas on how to enliven and improve your career as a software developer, this book gives you over 50 concrete actions to move in that direction.
I am so excited about using these suggestions in my life; I have already started with some of them. Of the 50 or so suggestions shared in the book, the following are the ones that really stood out to me.
- Figure out how the internals of the vm you program for work. Determine how external libraries are loaded or imported. Take time to learn the mechanics of how source code is compiled.
- Be the worst musician in your band. This means that you should surround yourself with developers who challenge you, who are better than you are…. so that you are continually challenged and feel the impetus to keep up and perform at your best.
- Practice
- I love this one… Questions you should ask yourself and your boss
- Was I worth it today?
- How could you make your development team more efficient?
- How could you creatively save your company money?
- Keep a development diary—what did you work on, why did you write it that way. I have started trying to do this and initally my ‘diary’ was more like a hit list of what i accomplished that day. What I have started doing differently is picking out some snippet that i wrote that day and pasting it into my diary post and then commenting on different lines.
- Try to do the boring stuff perfectly. I’ve tried this as well; it will add life back into your most tedious tasks.
- How to Fail
- raise the issue as soon as you know about it
- take the blame
- offer a solution
- ask for help
- One of my new goals after reading this book is to talk to all of the developers I work with face to face more often.
- Always have your “elevator speech” ready. What are you working on? Could you explain what you are working on to the CEO of your company?
I definitely recommend the book; it is inspiring and will silence even the whiniest of developers. While reading, you will want to take notes while you are reading or keep a to do list handy.
The Passionate Programmer: Creating a Remarkable Career in Software Development (Pragmatic Life)
Django: first impressions
A month or so ago I was anticipating a move into Django. I started on some of the Hello World tutorials on the django site, and I wanted to share the few observations from my very brief encounter with Python via Django.
- Double underscores?!! Whose idea was that? Does that end up being a pain when writing in Django? I remember that Ruby uses the double underscore too, but Rails doesn’t use this construct frequently from what I remember. Please someone write in and tell me I am mistaken about the frequency in use of double underscores in Django.
- The setup with sqlite was straight forward and simple—more simple than in Rails. It has been my impression, however, that this ease (or lack of ease) has more to do with the database installation on the operating system, than it does with actual integration with the framework. In other words, the problems that I have encountered with setting up database connections in other frameworks occur while trying to setup the data source itself.
- Is the settings.py file supposed to be like the web.xml in j2ee and the environment.rb in Rails? It seems that database information goes in this file, which is different than in j2ee and Rails where you have separate files to specify the database connections (e.g. context.xml and database.yml).
Overall, I would be interested in working more with Django.
506 tar xzvf Django-1.1.1.tar.gz 507 cd Django-1.1.1/ 508 sudo python setup.py install 509 python 510 ls -al 511 vi INSTALL 513 django-admin.py startproject Test 514 cd Test/ 515 ls -al 516 python manage.py runserver 517 python manage.py syncdb 518 python manage.py startapp polls 519 cd polls 520 python manage.py sql polls 521 cd .. 522 python manage.py sql polls 523 python manage.py syncdb

