Archive for the ‘ Software ’ Category

Java Word Wrap Algorithm

On a recent coding project I’ve been working on, I had need for a simple line-wrapping method.  I googled around, but couldn’t find anything useful — so, like any coder, I made my own.  I think it’s pretty nice, if I do say so myself:

public static String wrap(String in,int len) {
if(in.length()<len) return in;
if(in.substring(0, len).contains("\n"))
return in.substring(0, in.indexOf("\n")).trim() + "\n\n" + wrap(in.substring(in.indexOf("\n") + 1), len);
int place=Math.max(Math.max(in.lastIndexOf(" ",len),in.lastIndexOf("\t",len)),in.lastIndexOf("-",len));
return in.substring(0,place).trim()+"\n"+wrap(in.substring(place),len);

That first “in.indexOf()” has the space string (” “) as an argument, not an empty string.

I apologize for the difficult-to-read-ness of this code; I had it nicely spaced and indented but WordPress ate my formatting.
If you want to be really fancy, switch out the “\n” with a System.getProperties(line.separator).


Gedit Themes

Okay, first of all, I realize I have posted anything in nearly three months.  This has no excuse; I am shamed.  SHAMED.


So, I was thinking, I want to do another computer-y post. But then I thought about how so far I’ve really just done software reviews and stuff — and it’s not like that doesn’t already exist elsewhere.  I don’t need to reinvent the wheel.  So I decided to post something more original — two gedit themes I created.

gedit (all lowercase, always) is the default GNOME text editor.  It handles syntax highlighting, line numbers, margins, adjustable tab width… it’s pretty full-featured.  Visually, it starts out pretty basic but it’s got great plugin support and some pretty good built-in color themes.  However, all of them had something that bugged me; I decided to fix it.

Screenshot of my Oblivion++ theme

Click through for large size!

My first theme, Oblivion++, is based off the ships-with-gedit theme Oblivion.  It’s much bluer.

You can download the .xml file here or view it here; scroll  to the bottom of the post for installation instructions.

Screenshot of my gedit theme Vim Stylin'

This one has a large size too -- click it!

My other theme is Vim Stylin’, based off Vim color interpretations.  You can download the .xml here or view it here, just like the other.  Also just like the other, scroll to the bottom of the post for installation instructions.

If you do want one of these (if I do say so myself) pretty cool themes, download them to ~/.gnome2/gedit/styles, which may need to be created first.

gedit, as far as I know, works on Linux, Mac OS, and Windows, but comes with and works best on Linux.  If you have gedit on a non-linux OS, the file location will be different; it /should/ work okay from somewhere else but I haven’t tested it.

Once it’s downloaded and saved, open gedit.  In the menu bar choose Edit and navigate to Preferences.  Once there, click Fonts & Colors and click the Add button.  Navigate to and choose the downloaded theme; it should change immediately.


Edit:  The text in the images is a bit of the code of Keylime Py, a fail-pun-named text-based adventure game I’m writing in python.  I’ll be blogging about it once it’s ready to be let out to teh interwebs.

Why DRM is Bad: The Law of Unintended Consequences

DRM is software used to restrict your access to your files.  And it is one of the worst ideas of the modern world. To quote Cory Doctorow in his book Someone Comes To Town, Someone Leaves Town,

No one woke up this morning and said, “Damn, I wish there was a way to do less with my books, movies and music.”

It was intended, originally, to keep copyright laws working.  Before about the 20th century, copying another work was an arduous process (no computers, no recording mechanisms, etc), so restricting the copying of an item (like a song, or a picture) was most easily done at the stage of copying.

All that has changed.  Now we have computers, cheap cameras, video recorders, scanners, recorders, and so on.  It’s suddenly very hard to keep people from copying.

The Law of Unintended Consequenses states:

Any intervention in a complex system may or may not have the intended result, but will inevitably create unanticipated and often undesirable outcomes.

Basically, that means “Anything you do might work, but it will always do something you didn’t expect or want.”

The attempt to keep copyright working in today’s day and age is DRM, which keeps you from copying and using files how you want.  And it’s not just constricted to copying, either:

  • In July of 2009 Amazon deleted copies of two books from Kindles, as the books were illegally placed in the Amazon ebook store.  Ironically, they were Nineteen Eighty-Four and Animal Farm, both by George Orwell.Now, assume a leaked copy of a secret eight Harry Potter book (of which there are in fact rumors) is bound by an individual and placed in Borders.  You walk in and want to buy it — you don’t know that it shouldn’t be there.  The teller, who doesn’t really like fantasy, doesn’t know that they shouldn’t be selling that book.  Later that night, it is revealed to the manager that this book was sold.  Some of his workers break into your house, take the book (you had already been reading it; you were about halfway through) and leave.  I believe you would be sufficiently enraged.  What’s to stop Amazon from deleting or editing any book you have on a Kindle?
  • DRM is on many DVDs in order to keep the market from getting too segmented — spread out over too many demographics, which is a huge hassle (if I read correctly) for marketing and the company in general.  Now, assume you just bought a new DVD.  You’re going on vacation to Japan soon, and haven’t yet had a chance to watch it.  You bring with you, to watch in the hotel one night.  Woops, too bad!  Many DVDs only work in players manufactured for the same country the DVD was manufactured in, and possibly a few others.
  • Or maybe, while in Japan, you buy some anime DVD to watch at home. Too bad, so sad.
  • Don’t like Safari on the iPhone?  Want, perhaps, Opera Mini?  Oh wait — everything on the iPhone is slathered in DRM.  You can’t use third-party software not from the App Store, and Opera Mini hasn’t been accepted yet.  So, it does get accepted, then an update changes its code some.  Apple doesn’t like the new version.  Oh, sorry, it appears Opera Mini isn’t on your iPhone anymore.  Download a vehemently anti-Apple article on your iPad?  Nope.  It’s deleted.  They can do that, if they want.  At any time.  To any one.  On any thing.
  • So, you just downloaded this ebook and man, is it great.  You want your friend to read it, but he doesn’t want to buy it.  “Okay,” you think, “I’ll just send it to him.”  Woops, sorry!  You can’t share your files if their DRM says so.
  • Any song you download from iTunes has DRM on it. You can only have iTunes accounts on three computers, and those songs are very restricted. This is doubly stupid. Not only is DRM a bad idea, but each of those songs is available on CD without DRM. iTunes DRM’s its songs because the big music companies say so, but then they release unlocked CDs (which is a great thing) that you can rip.

And get this — DRM doesn’t, for the most part, do a thing except annoy people.  Pirates have cracked every DRM scheme out there.  Any file with DRM is available on BitTorrent without it.

Help spread awareness:  DRM is bad.

Ubuntu Netbook Remix

So, I recently installed Ubuntu Netbook Remix on my MSI Wind (dual-booting FTW!) and am really enjoying it… simple downloading, nice main menu layout, better battery life handling (2 hrs at max battery on Windows, 3.5 hrs at max battery on UNR).  Once I iron out some kinks with Firefox and Wine, I might make it my main OS.  Any tips or ideas from someone out there who’s experienced in Linux/Ubuntu/UNR?

Cleanup and Maintenance

My little brother was running out of hard disk space on his computer.  When it got to the point he had 9 MB (that’s not a typo) of free space left, he called me in.  That computer is several years old, so there were a lot of old files neither he nor my parents needed.  I cleaned out old files, uninstalled programs, defragmented, fixed startup, and so on and so forth.  End result?  Fourteen and a half gigabytes of free space.  Even if your computer hasn’t yet gotten to the critical disk space yet, I still highly recommend you do at least some of these steps:

Note that they are in no particular order, and you can do any of them at any time – except defragmentation, which should be done last.

1.  Uninstall Old Programs
You’d be amazed at what is lurking on your computer.  Don’t use the Add or Remove Programs option;  it leaves incredible amounts of stuff behind.  Instead, use Revo Uninstaller – which even has a portable version if you’re adverse to installing more programs.  Be sure to download the free version.

2.  Empty Recycle Bin Norton Protected Files
If you happen to have Norton, right-clicking on the Recycle Bin has an option, “Empty Norton Protected Files.”  The files in that folder don’t get cleaned up by emptying the Recycle Bin; I found at least two gigabytes of files in that folder.  Just click the option in the Recycle Bin context menu. 

3.  CClean
CCleaner empties the Recycle Bin, clears out stuff like old temporary files, old browser history, and so on.  Like Revo, you can get a portable version of this one too.

4.  Clear Out Old Files
This one’s the most tedious – but possible the most helpful – of the steps.  Go into My Documents (or the equivalent).  Open every single file, one at a time.  Decide which ones you no longer need.  Delete them.  Be sure to empty the Recycle Bin after doing this – otherwise the deleted files are just sitting on your disk.  Also, if you didn’t create the file, check with whoever created it.  Mom and Dad still had some stuff on that computer that they really wanted to keep.

5.  Clear Out Program Files
If a program was uninstalled through Add or Remove Programs, there’s a good chance its folder is still in Program Files (C:\Program Files).  Any folder that belongs to a program you know you no longer have, delete.  If you don’t know what is, don’t delete it – it could be important.  Just use good judgment.  Keep in mind that deleting a program’s folder in Program Files does not remove the program from your computer – uninstall programs you don’t want anymore.

6.  Startup
If you have too many programs set to startup, they all try to launch at once at drastically slow down your computer for a while – much like what would happen if four cars all tried to merge into the same spot in the same lane at the same time.  Startup Delayer can help.  It automatically finds which programs are set to startup, and lets you delay them – you probably don’t need, for instance, your printer manager right at startup – so delay for 30 seconds or five minutes or however long you need. You can also disable programs from starting, if you don’t need them at startup anymore.

7.  Defragment
My favorite defragmentation tool is Defraggler – made by the same people who created CCleaner – which also has a portable version.  Once the program has launched, click “Analyze.”  Once it’s done click “File List” and check the checkbox just to the left of the “Filename” column.  This should select all.  Then press “Defrag Checked” and let it run.  Repeat until no files come up after analyzing.


Enjoy your cleaner, hopefully faster computer!

How To Change the Color of Office 2010

This is, in essence, an update to my previous post, How To Change The Color Of Office 2007.

If you’re running the beta version of Microsoft Office 2010 (available free (as in beer!) from the Microsoft website), you can change the color scheme from blue (default) to black or silver, just like in Office 2007.  If you’ve already changed the color, I found that Office 2010 preserved that change upon install.  If you haven’t yet, or if you want to switch the color, or if it didn’t preserve that color change, here’s how to do it:

For pictures with each step, see this Instructable.

0.  Steps 1 – 3 detail how to download the Office 2010 Beta.  If you already have it, skip to step 4.

1.  Go to this site and click through the various Download Now buttons until you can actually download the installer.  You’ll need a Windows Live ID (if you don’t have one, click the link anyways; the site’ll tell you how to make one) and you’ll have to sign up (email, name, country) to use the beta.

2. Save the installer to your Desktop or wherever you put installer downloads, DON’T CHANGE THE FILE NAME.

3. Once the download completes, run the installer.  Follow the instructiono in the subsequent window.

4.  Open any Office 2010 window (Word, PowerPoint, Excel, etc)

5. Click on ‘File.’  In different programs, this button will be different colors:  Red in PowerPoint, Blue in Word, Green in Excel, and so on.

6. Click Options, the second-to-last button.

7.  Make sure the subsequent window is set to the ‘General’ tab.

8.  Under the dropdown list titled Color Scheme currently set to blue, choose either Black or Silver.  I personally prefer the black scheme.

9.  Click OK.

10.  You’re done!  Doing this affects the following Office 2010 windows: Word, Excel, PowerPoint, Outlook, Access, OneNote, and Publisher.  I do not have any other Office programs.




Piriform Speccy

Brought to you by the same people who made Defraggler, CCleaner, and Recuva, Speccy tells you everything you wanted to know about you hardware and quite a bit you didn’t really need to know.

Tells you –in great detail – about your OS, CPU, RAM, Motherboard, Graphics, Hard Drives, Optical Drives, and Audio.  For instance, it turns out my hard drive’s model is WD1600BEVT-00ZCTO

Tells you more than you needed?

Rating:  9   9/10

Get this great program here, and have fun.

The window

About the ratings: 
I copied Wired Magazine’s rating system because I like and I think it works well.  Here’s the key:
1 = A complete failure in every way
2 = Barely functional – don’t get it
3 = Serious flaws, proceed with caution
4 = Downsides outweigh upsides
5 = Recommended with reservations
6 = A solid product with some issues
7 = Very good, but not great
8 = Excellent, with room to kvetch
9 = Nearly flawless – get it now
10 = Metaphysical product perfection