Browsing Category: Useful Computer Stuff

Enable macros in Office 2007

Monday, June 2nd, 2008

ms officeIn older versions of Excel, you could allow macros using the Tools menu (Options, Security tab, Macro Security button).

Office 2007 is totally different from 2003 and earlier versions. Here is the link to their help document detailing how to enable macros to run without the prompt (Enable all macros).

Enable or disable macros in Office documents

Basically, they moved the security settings from the Tools / Options menu to the new Trust Center.

When good friends go bad: trojan files

Tuesday, March 25th, 2008

Habit is an amazing thing. Your auto-pilot saves you a great deal of thinking throughout your day. Just imagine what your simple commute to work would be like if you didn’t have a habitual route. Every day would be as if an accident had happened and a road was blocked - you’d have to really think and plan where to go, where to turn, when to merge, and when to slow down.

We RELY on our habits. So much so that we often go into auto-pilot; we do things without really thinking first. This can lead to such hilarity as the infamous unintended reply-to-all. We tend to just click OK to things without really reading the dialog, or accept file downloads without paying attention to the source.

download.jpg
Worse, however, are malicious scripts like trojans that pretend to be your friends. The dialog box pictured pops up if you happen to click on a certain malicious link that is sent via instant messenger (such as MSN Messenger).

Unfortunately, the double-whammy of the link being sent via IM from a known source coupled with our habit to just click Open or Run when we see it, makes this little trojan quite the prolific little tease.

The trojan then hijacks your instant messenger client and IMs all your online buddies, pretending to be YOU, sending them the same link. They see the message, think it’s from you, and open it. The cycle repeats and the trojan is spread like wildfire.

The moral of the story, of course, is never to trust your friends.
Just kidding.
You do need to bear in mind, though, that just because a message, whether in IM or an email, appears to be from a friend doesn’t 100% guarantee that it IS. Malicious scripts can take over a person’s instant messenger, spoof email headers to pretend to be from someone else, spoof web addresses in email to get you to click on a link, and kidnap your first born.

It is, just as the dialog warns, possible to harm your computer by opening files you don’t know the origins of. If you aren’t careful, you too can be the next person everyone in the office laughs at for being gullible.

How to replace text in a bunch of files

Saturday, March 15th, 2008

pieGenerally speaking, I’ve transitioned from Unix to Windows pretty nicely. But one thing I miss terribly is sed. Say you have a directory full of files, and you want to look through them and find some text that matches a pattern, you’re pretty much screwed. You can try the Find Files functionality, but it bites, in my humble opinion. If you want to replace any of that text, you’re royally screwed.

It’s one thing if you have 5 files. It’s another if you have 5000. Don’t even think about it for giant backup directories. Normal code IO is FAR too slow to work for that sort of thing even if you wanted to bother to write it.

Some time back we ran into that issue and I played with cygwin for it. But that was a hack solution, really, because of shared directories and the need to install a bunch of stuff.

I’m not the world’s biggest perl fan, but hey, I have no decent shell here. It took me less time to install ActivePerl and google up a perl script to replace text in a list of files than it would have taken me to run the Find Files applet.

I share with you - pie.

perl -pi -e ’s/old_string/new_string/g’ file_pattern

If you’re familiar with sed, the regexp is pretty much the same. The file pattern supports wildcards, so you can *.txt it or whatever. Sweet. Thanks Perl!

On The Mythical Business Layer

Monday, January 7th, 2008

If you’re a developer and you haven’t read this post, The Mythical Business Layer, on The Daily WTF, please drop what you’re doing and go read it. I have it in my starred items in Google Reader because it’s vital to me to be able to explain insanity to my boss when he starts getting notions that resemble the ERE.

Concepts like this one from the article make perfect sense to me, but I don’t explain it as well as Alex does.

I’ll bet some of you, without even seeing the rest of specs, excitedly envisioned a CancelationWorkflowProvider that inherited from the abstract RequestWorkflowProvider and implemented the IPermissionRequired, IPropogationStatusRequired, and IExpenseAllocationTypeRequired interfaces, and was powered by the all-encompassing WorkflowManager. Why? Because that’s so much more challenging than writing a simple IF-ELSE code block.

I personally am a huge believer in KISS. I read the specs and indeed DID see IF-ELSE blocks. Call me boring. I prefer to not overcomplicate things. I code as much as needed, but no more, to achieve the desired result in a way that is easy to maintain. If it needs extensions later, great! We can do that. But to code a behemoth for the sake of principle is, in my opinion, idiotic.

Code, by its nature, is fluid. Specs change. Applications evolve. Refactoring should be a part of a program’s life cycle. Don’t fear change. Sure, you want to soft code some things that change depending on where the application is installed, such as settings. Business logic, however, should be hard-coded. Sure, you want to have code re-use with functions/methods, but you don’t need them so generic that they no longer have a real purpose. Your platform of choice likely already has generic functions to do things like format strings, convert dates, and whatnot. Don’t waste your valuable time reinventing the wheel.

I blame a lot of the crap I see these passed off as code these days on the fact that new developers are shoved directly into OOP instead of being taught programming from the ground up. If you’re never taught procedural code, you try to make everything an object, a factory, a pattern, or a method. You try to create abstractions where none are needed.

Too many developers are, as Alex says, using a hammer to create something that can pound in nails. Stop that, kids. If you’re bored, go learn a new language instead of abusing the one you’re using.

Intranet: linking to shares for both IE and FF

Friday, November 2nd, 2007

This is how you form the links so they work in BOTH browsers.

<a href=”file://///serverName/share$/path/to/directory”>link</a>