Skip to main content

Posts

Showing posts from 2008

Java is Disappointing Sometimes...

What's Java's number one problem?  If you said "efficiency," then you win!  Why do we still use C and C++?  If you said "efficiency," then you also win! And so... yesterday, we learned about templates and generics and so forth, and I was able to ask a question that's been bugging me for quite some time.  "When you declare an ArrayList<Integer>, are Integer Objects being stored internally, or are primitive ints being stored?" Prior to yesterday, I had given this quite a bit of thought, actually.  I'd say about a year ago, I determined that since the classes like Integer, Byte, Float were final, non-inheritable classes, that Java could actually optimize the language by artificially storing primitive ints, auto-unboxing and auto-boxing them, as appropriate.  But, as it turned out, I was wrong! Java does not do that.  Instead, when you store a bunch of "primitive ints" in an ArrayList<I...

Headaches

Writing computer software sometimes goes a little something like this: Brainstorm Believe that writing software is easy Design Change the design Bang your head against the wall Wish you hadn't banged your head against the wall... ouch... Change the design... again... Write some senseless code Wake up the next morning and delete the senseless code Write gibberish on a whiteboard Erase the whiteboard Realize that your gibberish was actually somewhat important Finally get a design together Write some senseless code COMPLETELY SCRAP THE DESIGN AND THE CRAPPY CODE! Draft a decent design Write bad code Realize the code sucks Fall asleep on your keyboard Wake up at 3 AM and realize you did nothing except type 2000 pages of the letter L. Bang your head against your pillow... ahh... better than the wall.  Commence sleeping. Hide underground and crank out some code Attempt to compile code Add include statements and the semicolons you forgot.  Attempt to compile code... round 2 Begi...

Today's Quote

This is simply a brain dump.  I'm sleepy, and I want to type out some of the thoughts currently in my head. "Luck is where preparation and opportunity meet."  This is so remarkably true, and today I'm making it a mantra.  I believe that luck is merely an illusion that we perceive, but it truly when we have prepared ourselves for the right opportunity... and then a great opportunity comes along.  Many great opportunities pass us by every day.  Once we begin to recognize them and prepare for them, then we start to experience the thrill of luck. Interestingly, as described in "Good to Great", Mr. James Collins talks about how "Level 5" leaders often attribute their great success to luck .  That's a humble way of saying, "I planned on taking advantage of every opportunity ."   Hmmm...

Mind maps and Concept maps

Alright y'all.  I am starting to fall in love with the idea of "Concept maps."  Look it up: http://en.wikipedia.org/wiki/Concept_map .  Note how concept maps are better than mind maps: "Concept mapping can be contrasted with the similar idea of mind mapping , which is often restricted to radial hierarchies and tree structures ."  Humans simply don't think hierarchically most of the time.  In fact, it's often frustrating to limit thought in such a way.  I've finally found a concept map program that I like: http://cayra.net/ .  My sales pitch follows... keep in mind that this took a lot of time (30 secs) copying and pasting to compile this... so take the time to read it! Cayra is a free desktop application that lets you represent tasks , ideas , concepts and other items in a graphic, well-structured way. Cayra is based on such visualization techniques, as Mind Mapping and Concept Mapping and allows you to conve...

DOS Batch Files - Still Useful

I figured something out today - HOW TO: Separate filename and directory from a path. This is really fun!  The idea I had was to allow me to drag and drop a file onto a batch file and have it spit out the MD5 code for it.  Simple right?... hardly... Here's the code... @echo off REM Check to see if filename is specified if %1.==. goto end set filename=%1 REM Remove double quotes from filename for /f "tokens=1* usebackq delims=?" %%i IN ('%filename%') DO (     set filename=%%~i ) REM Build directory path set dir_path= :loop for /f "tokens=1,2* usebackq delims=\" %%i IN ('%filename%') DO (     set dir_path=%dir_path%%%i\     if not %%k.==. (         set filename=%%j\%%k         goto loop     )     set filename=%%j ) echo DIRPATH:%dir_path% echo FILENAME:%filename% pause :end

Analog Clock Trivia?

Alright... now I've seen some pretty weird stuff on the Internet... but how about this? Picture an analog clock with an hour hand, minute hand, and second hand, ticking every second.  Have you ever wondered... How often is the second hand between the hour and minute hands? At what time is the clock equally divided into three parts (by the positions of the hour, minute, and second hands)? ... ya, I think about this stuff all the time. (sarcastic) Well... in case you were wondering, I've found the answers.  The second hand is between the hour and minute hands about 32% (13832 of 43200) of the time.  There are a total of 43200 possible positions for the hour, minute, and second hands on an analog clock.  That is, 60*60*12. And... a perfect analog clock really never is divided equally into three parts by the hands (unless you count the times when the second hand is in motion to its next position... that is, in the middle of a "tick").  However, it...