Technology : General Technology Notes: Diary of a late,late adopter.
Updated: 4/27/2004; 10:56:59 AM.

 

Frequent Visits

Subscribe to "Technology" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Tuesday, April 27, 2004

While every article about application development impresses upon us the importance of separating the data, logic and presentation layers,  MS Excel gleefully mixes the three. While this gets sneers from most developers, it is precisely the reason that so many people use it and love it and get themselves into all kinds of trouble with it... and then ask me to help. So I was very excited to get my copy of Excel Hacks today. Among other things, it has a lot of tips for separating the data from the formulas and the data from the presentation, making a complex Excel spreadsheet more maintainable.  Other things I was glad to see:
  • Chapter devoted to the SpreadsheetML, or the xml/xslt format used to describe spreadsheets. This facilitates generating spreadsheets using PHP and Java and other technologies that have nothing to do with Excel
  • Lots of hints for overcoming limits imposed by Excel: For example, override the number of undos allowed and override the limit to criteria for conditional formatting of cells.
  • Lots of easy to understand VBA code
  • Ways to recover data from corrupt workbooks
  • Long chapter on charts with some neato ideas for custom charts. I get asked a lot of questions about Excel charts and I never really learned more than basic charting skills.
  • And a question I have tried to solve several times, never getting a graceful solution: How to fill in empty cells with values
  • Solutions to pivot tables

I am working my way through each of the 100 hacks and in almost every one, I am saying to myself, "Gee, I didn't know excel could do that"  In summary, the O'Reilly hacks series has produced some excellent books and this one is one of the best.  It is clear, concise, error free, and doesn't assume you have the most recent version of Excel.  It is full of nuggets such as the fact that Excel purposely doesn't recognize that the year 1900 was a leap year (link blames it all on Lotus!).  Who knows, you might encounter that some day.


10:56:46 AM    comment []

Wednesday, April 07, 2004

DNR Trout Stream Easement GIS Layer

My cube neighbor is creating a database of all the easements owned by the state along trout streams.  It will soon be available in GIS format.  That is, you can download the data and make pictures like this, which is the new data layed over arial photos.  This particular selection is Lower Gavin Brook in Stockton, MN: 


4:23:59 PM    comment []

Tuesday, April 06, 2004

I wanted to remove a range of items from a list using the List.subList method. I tried the following:
	// al is defined previously as ArrayList al = new ArrayList();
        List l = al.subList(20,50);
        al.removeAll(l);

That got me the java.util.ConcurrentModificationException

The documentation says that a subList is dependent on the List that it is sublisting from. So, while a sublist is open, it is manipulating the parent list and seems to have a lock on it.   Instead, you can create a brand new ArrayList and fill it with the subList, thus freeing up the sublist so that a future call can modify the original List:

	ArrayList sl = new ArrayList(al.subList(10,40));
    	al.removeAll(sl);
		

So why does

 List = myList.subList(10,30);

get you a different animal than

ArrayList temp = new ArrayList(myList.subList(10,30)); ??

because in the first snippet, I haven't instantiated a new object, I just created a reference to an existing object.   In the second snippet, I created a brand new object.  That's what the word "new" gets me.


6:06:45 PM    comment []

Sunday, April 04, 2004

Compacting Radio DataFiles

I just compacted my data files in Radio.  I noticed that I had all these huge files under the folder RadioUserland/datafiles  weblogData.root was 16 Megs.  After running compaction that file is just 2 Megs.  aggregatorData.root went from 37 Megs to 400 kb

I also noticed when backing up that problems occur when you have radio open and you try to copy a 37 Meg file that radio is trying to use.


7:42:40 AM    comment []

Monday, March 29, 2004

IntelliJ IDEA If you use IntelliJ 4.0 to check out projects from CVS make sure you click the "Change keyword substitution" to binary button in the CVS checkout procedure. Failure to do this could cause your project to fail to compile since the jar files will be corrupt.
3:03:37 PM    comment []

IntelliJ IDEA, the Java development tool that I am liking more and more, uses log4J to build a log file that is stored as : USER_HOME\.IntelliJIdea\system\log\idea.log

(On my windows installation, USER_HOME is C:\Documents and Settings\timcguir )

This file has lots of information about the internal workings of IDEA and has error messages that explained to me why the IDEA GUI Builder wasn't working like I expected.


11:19:57 AM    comment []

Friday, March 26, 2004

You can put a link tag on your web page that tells the visiting browser to start downloading another page while it is idle so that your browsing seems faster:  

< link rel="prefetch" href="/images/big.jpeg" >

from 0xDECAFBAD


4:12:08 PM    comment []

Wednesday, March 17, 2004

Static

 

1 exerting force by reason of weight alone without motion

2 showing little change

  • An early frustration in learning Java is the error:   non-static method foo( ) cannot be referenced from a static context
  • Perhaps you are trying to call a simple method of your class from the main() method.  The main method is a static context.  The quick solution is to instatiate your object with MyObject mo = new MyObject right inside your main method.  now you have an instance of MyObject  
  • A static variable or method is going to persist across all the objects instantiated.
  • Static means that you lose the use of the 'this' keyword because the use of 'this' implies that you have an instantiation of an object.
  • Static means that it doesn't depend on the instantiation of an instance of the object. It still exists and can be called from an instance of the object, but it can also be called without creating the object.
  • The main() method is static because you have to call it to start a java program. That is, you call it before any objects are instantiated.
  • Consider the following class: 
    public class AddMe{
    	
    	static int num = 100
    	
    	static int add(int i){
    		int sum = i+2;
    		return sum;
    	}
    }
    
  • When I want to access the variable num, I can just say, myNum = AddMe.num and get the number 100.
  • I can also instantiate AddMe am = new AddMe() and then call myNum = am.num with the same effect.
  • Same with the add method. myNum = AddMe.add(2) sets myNum to 4 and so does myNum = am.add(2)
  • During my one week java class from Sun, I completed an exercise by using all static methods. I could then call the methods just like I made function calls in PHP or VB. My solution was used as an example of bending Java to act like a procedural language. Which, in case you need to be told, was frowned upon. It avoids all the Object Oriented concepts of Java. You don't even ever need to instantiate a class!

6:55:17 PM    comment []

Tuesday, March 16, 2004

My Findings on HashMaps:
  1. A Map is one type of Collection in Java. Collections are used to hold a bunch of objects. Different Collections let you look up your objects in different ways.
  2. The special thing about Maps is that the way you look up your objects in a Map is with another object.
  3. A Map is like an associative array in PHP. It is a container for key - value pairs.
  4. To get values out of a Map, you iterate through the Map's keys and use the get() method to get the value associated with that key back out.
  5. Map is the interface, Hashmap or TreeMap is the implementation of that interface, just like ArrayList is an implementation of List. So, to make a new HashMap, you would say Map myHashMap = new HashMap();
  6. A HashMap uses the hashCode() method available to all Java objects to take the hashCode of your object so that it can quickly find it when you want it.
  7. with a HashMap, your objects will not be sorted the way you expect
  8. with a TreeMap, the objects are sorted in a way that makes sense.

12:20:32 PM    comment []

Monday, March 15, 2004

JavaScript Disable Links

Here is the javascript function I used to disable the link that people often click more than once:

 function disable_links(){ 

// this function disables all the links on the page 

  for(var i=0; i < document.links.length;i++)

  {

      document.links[i].onclick=function () { return false; }

      document.links[i].title = "The exam has been submitted. Please wait for results page";

  }

  return true;

}


12:52:50 PM    comment []

For two weeks I had this really frustrating problem:

When users submitted the online fisheries exam, sometimes they would get an error page while the results would be emailed with no problems. I kept testing it and never got the error. I wondered if the database was crapping out because of too many open connections, I wondered about browsers caching error pages.

Then I watched someone submit the exam. They were like, "it sometimes takes several clicks before it submits"..... click click click. It is second nature to me not to submit a form more than once, no matter how long it takes the server to process the form.

 So, when testing, click all the buttons more than once, because it's a sure bet your users will.

In any case, there should be some code that handles this problem, but I didn't write the thing, I just inherited it.


9:39:39 AM    comment []

Roger's Cadenhead, the author of the excellent Radio Userland Kickstart, has released the first version of his workbench.root

It has two scripts:

  • Workbench.viewCategories(), a script to display category links on your home page template and other pages.
  • Workbench.viewPostIndex(), a script to display links to your posts in reverse chronological order

  • 8:16:13 AM    comment []

    Saturday, March 13, 2004

    I had the hardest time using an ArrayList.  I had an ArrayList full of Fish objects and getting them out with ArrayList.get() and wanting to do some Fish type operations such as printing out data about the Fish and comparing it to another Fish.

    To get the third Fish out of the ArrayList it is in, I tried

    currentFish = myArrayList.get(2);

    The trick is that ArrayLists (and other containers) store all objects as Objects instead of as Fish or Dogs or Cats or Cars or Strings.   This behavior happens for all types of java Collections.  So when you call an object back out of an ArrayList, you have to cast it back into whatever object it is supposed to be 

    currentFish = (Fish)myArrayList.get(2);

    Further confusion happens because every object has toString() over-ridden and automatically available so that when you think you are getting a string back from an ArrayList and want to print it out, it works fine.

    I even had it print out the results of getClass() on the Object I was retrieving from myArrayList and even that told me it was a Fish!  But still, it was being treated like an Object until the cast.


    7:57:53 AM    comment []

    © Copyright 2004 mcgyver5.



    Click here to visit the Radio UserLand website.

     


    April 2004
    Sun Mon Tue Wed Thu Fri Sat
            1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30  
    Mar   May