|
|
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
|
|
|
|
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
|
|
|
|
Friday, April 02, 2004
|
|
| |
Trapping Turtles
This is a turtle tag. If you are a turtle seller or recreational turtle trapper, all of your traps require one. The DNR sells about 50 turtle licenses each year. Three people here have told me they taste like chicken. If not prepared properly they can be very high in contaminants because their fatty tissues store contaminants from their scavenger diet.
To prepare a snapping turtle, you chop the head off and let it bleed out for 24 hours because the involuntary movements last that long. If you don't hang them up while they are bleeding, they can crawl away without a head and get lost. Turtle is a popular item on the menu of area restaurants west of St. Cloud. I want to find out where I can try some.
11:13:33 PM
|
|
|
|
Thursday, April 01, 2004
|
|
| |
Roland just came by the office. He is always interesting to talk to. His work is organizing fishing education events. He is putting together a kids fishing training event outside the Twins game on May 10. The DNR puts on lots of great family events like this. The schedule for all of these is on the DNR events calendar . He also told me about two blogs by friends of his: True Life and David Anderson's Lost City.
4:02:37 PM
|
|
|
|
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
|
|
|
|
Wednesday, March 17, 2004
|
|
| |
Static
1 exerting force by reason of weight alone without motion
2 showing little change
6:55:17 PM
|
|
|
|
Tuesday, March 16, 2004
|
|
| |
New Minnesota weblog. All about canoe racing. A Radio weblog. He works at the DNR, in fisheries no less.
11:16:55 PM
|
|
My Findings on HashMaps:
- 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.
- The special thing about Maps is that the way you look up your objects in a Map is with another object.
- A Map is like an associative array in PHP. It is a container for key - value pairs.
- 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.
- 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();
- 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.
- with a HashMap, your objects will not be sorted the way you expect
- with a TreeMap, the objects are sorted in a way that makes sense.
12:20:32 PM
|
|
|
|
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
|
|
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
|
|
|
|
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
|
|
|
|
Thursday, March 11, 2004
|
|
|
© Copyright
2004
mcgyver5.
Last update:
4/7/2004; 4:26:26 PM.
This theme is based on the SoundWaves
(blue) Manila theme. |
|
| 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 |
|