Skip to content

Recent Articles

4
Mar

Widescreens on laptops, reducing vertical resolution

The trend in laptop screens has been to move away from a 4:3 aspect ratio and towards 16:9. Maybe it’s cheaper to produce the widescreens. Maybe it’s a marketing gimmick relating to widescreen HD video playback. But unless you’re using your laptop to play movies all the time, the loss of vertical resolution is really inconvenient.

My old 15-inch laptop, from 2005, has 800 pixels of vertical resolution.  All the brand-new 15-inch models have 768 pixels.  Considering you’ve got various menu bars, tool bars, status bars, and other things taking up precious vertical space, the actual main window (in your browser, word processor, etc.) has shrunk quite a bit, requiring a lot of vertical scrolling.  Assuming you spend most of your laptop time not watching HD movies, this is very frustrating.

I recently purchased a 17-inch laptop, which gives me an extra 100 vertical pixels over my old machine.  However, 17-inch laptops once came with 1200 vertical pixels.  They then shifted to 1050 pixels, and now a mere 900.  What a shame.  On the bright side, I don’t think laptop manufacturers will go any lower.

There is even a Facebook group about this issue.  (Then again, I suppose there is a Facebook group about every issue.)

3
Mar

Java member access levels – public, protected, private

Java access level cheat sheet:

Chart shows java access levels

 *no modifier is usually refered to as package-private.

  • Classes can be declared:
    • public
    • package-private
  • Methods and member variables can be declared: 
    • public
    • protected
    • package-private
    • private

It’s easy to remember the effect of public and private.  One grants total access, while the other restricts access to the class itself.  Both protected and package-private grant access to the package, but only protected grants access to subclasses.

Good practice dictates that you keep access as restricted as possible.  This enforces encapsulation and helps forestall bugs in the code.  Keep in mind, both public and protected members become part of your API forever (unless you want to break clients, which is not nice).  Preserving encapsulation ensures you are not tied to a particular implementation and keeps your API clean. 

More Here.

If you repost the chart above, please cite this blog.  (icons from famfamfam)

2
Mar

Spam in WordPress Comments

This blog is only a few weeks old, and I’ve managed to attract 12 comment spam attempts. 86% of the comments so far have been spam. When I was initially configuring WordPress I selected moderated comments, so I’ve had to review each one manually. Most spams are of the variety that attempt to fool the blog owner into thinking it’s a real comment. “That was interesting. I’ll have to think about it a little more.” I suppose these are all automated.

I’ve briefly looked into spam filter plugins.  I was about to enable Akismet when I learned it is a pay service.  I can’t justify paying for spam filtering on a new blog with few comments.  If anyone has any plugin recommendations, please share in the comments.  I promise to approve all legitimate responses! 🙂

UPDATE: I’m up to 92% spam comments now.  I guess the bots are starting to discover this blog.

2
Mar

Resize images in Java, preserving image quality

It shouldn’t be so difficult to do simple image manipulation in java.  Resizing images is a frequently-encountered need, often to create thumbnails or to shrink pictures taken from digital cameras to a reasonable display size.  But how to create thumbnails in java without sacrificing image quality?  Standard library image manipulation is severely lacking in this area.

Luckily, talented java programmers have worked to create better solutions.  I’ve thrown together an image utility, building off of the work of others, to expose a few basic image manipulation functions, namely: open (from a file, URL, InputStream or byte array), save to file, soften, resize, and resize to square.  This may be useful to your project.  Just read the important caveat toward the bottom of this post.

I make no warrantees about this utility.  If you like it, a link back to this blog would be more than welcome.

Read moreRead more

1
Mar

Best stats plugin for WordPress: ShortStat

unique hits to wordpress blogThis is just my opinion, based on what I was looking for, which is: a very simple WordPress blog plugin for gathering and reporting stats like unique and total hits, referrers, and search keywords. I wasn’t interested in a heavy-weight stats program. I already use Google Analytics, but for this blog I wanted a plugin to put exactly the stats I’m interested in on my WordPress dashboard.

ShortStat does exactly what I want.  It’s a simple and (as of this writing) actively-maintained WordPress stats plugin that provides a quick dashboard link, putting your stats a mere click away. Read moreRead more

27
Feb

Export Netbeans templates, font colors, and other settings

Once you’ve got your IDE set up just to your liking, it would be painful to start over with default settings.  So what if you switch to a new computer?  You’d want to take all your settings and preferences with you, not attempt to recreate them from scratch.

As far as I know, Netbeans does not have the ability to export / import your custom settings.  That’d be a real handy feature.  But for now we have to get by without it.

I’ve found two posts on the topic:

http://searjeant.blogspot.com/2007/10/migrating-netbeans-settings.html

http://wiki.netbeans.org/TaTCodeTemplateBackup

I will try these, when I get my new laptop set up with Netbeans, and will update this post with a story of success or failure.

UPDATE: I did try this, and it did work.

Here is what worked:

To transfer the settings, I copied the Editors, Preferences, and org-netbeans-api-project-libraries folders located in the .netbeans\6.9\config folder under my Windows user account to the second Netbeans config folder. (Note: I went from Netbeans 6.9 on one computer to Netbeans 7.0 on another.)

I was concerned that because the Netbeans versions were not the same, something would go awry.  But rest assured, nothing blew up.  I imagine certain version combinations may not play nicely together, though.  YMMV.

27
Feb

To sanitize user content, use an HTML parser

It is especially important, if you allow any HTML at all in user-submitted content, to sanitize that content by actually parsing the HTML and filtering it for any tags or attributes you wish to exclude. If you fail to do so, your site may be vulnerable to XSS (cross-site scripting) attacks.

Q: “But isn’t it overkill to parse the HTML?  Can’t I use other techniques, such as regular expressions or simple string replacement, to filter out dangerous tags and attributes?”  A: No, and I’ll explain why. Read moreRead more

26
Feb

Dell Inspiron 17R / N7010 Review

Dell Inspiron 17RI believe in getting the most out of existing hardware, but my aging Averatec laptop (purchased in 2005) was beginning to give me trouble, as old hardware will do.  Additionally, the old machine could not be counted upon to run an IDE like Netbeans.  It just lacked the horsepower.

So I’ve been doing a lot of research into mid-range consumer laptops, reading reviews, trying to find the one that strikes just the right balance between price and features.  I ended up purchasing a Dell Inspiron 17R (aka N7010) from Staples, on clearance for $600.

Read moreRead more

22
Feb

Validate that URLs exist using jQuery / PHP

It would be nice to have a pure javascript method of validating that URLs exist.  One imagines you could use an AJAX call and verify the HTTP status code (200, 404, etc.) returned.  However, browser security does not permit cross-domain AJAX calls.  So, this method would only work if you are validating that URLs exist on the same domain.

Perhaps there is a way to use a hidden iframe to test the existence of a URL.  I am not aware of a way to get the HTTP status code of a page that loads inside of an iframe, though.  I’m not sure it is possible.  So you must rely on javascript plus a server-side programming language to perform this validation.  I chose jQuery and PHP.

Read moreRead more

19
Feb

Groupon says what?

I can’t be the only one who finds “Groupon Says” completely pointless.  The sayings certainly aren’t “hyper-factual”, and neither are they humorous.  It just seems bizarre that a big-name company like Groupon would put this sort of thing on all their pages.  And, why a cat?  I guess the feature is supposed to add a quirky idiosyncrasy to the site, to make it more endearing and less corporate.  But it comes across like an idiosyncrasy as designed by committee.  I can just imagine how it went: “I have an idea!  Let’s add a picture of a cat!  Internet denizens seem to love pictures of cats.”  “Brilliant!”

18
Feb

Royalty-free image sources

Image copyright can be a thorny issue, and most web designers are not legal experts. But you’ve got to be confident that you have the right to use any image you place on your site. If you need an image for free, there are a few sources available. Two are PD Photo (PD standing for Public Domain) and the public domain category of Wikimedia Commons.  In fact, all images used on Wikipedia display copyright information when you click on them.  If the image has an expired copyright, you can use it royalty-free.

Another option is to check the Prints & Photographs Online Catalog at the US Library of Congress web site.  Not every image there is free from copyright restrictions, so always double check.  Here is their info page on copyright.

stock.xchng used to be a good source of free images, however they’ve been bought by GettyImages and require payment now for most of the available content.  If you are willing to pay a small fee, I’ve had a good experience with Dreamstime (they’ve recently added a free section, too).

Another possibility is to buy one of those stock image collections, such as Big Box of Art or Art Explosion. You get a huge number of searchable, royalty-free images.  A lot of the images are not the best quality, but some are useful.

One final note: always read the fine print.  Even “royalty-free” can have stipulations.  If the image features a person, also look for an indication that a model release form was signed (if your project is commercial).

UPDATE: I recently found this free image site that provides you with the Photoshop PSD files.

17
Feb

Using word clouds for SEO keyword analysis

Wordle is an online tool that creates “word clouds” out of text.  Basically, you feed it some text and it generates an image of jumbled up words, with the size of each word determined by how frequently it is repeated.  One way to think about it is, Wordle gives you a rough idea of how a search engine spider sees your page.  This may be helpful in your SEO efforts.

For example, here is a word cloud of my blog post on geolocation. (click for larger size)

word cloud

Instantly, the main theme of the post jumps out, with words such as “geolocation”, “city”, “code” and “GeoIP” featuring prominently.  Then you also see secondary words, such as “region”, “PHP”, and “database”, adding additional context.  In SEO terms, the larger words are your keywords.  The font size represents your keyword density.

Another word cloud after the jump: Read moreRead more