Showing posts with label geeky. Show all posts
Showing posts with label geeky. Show all posts

Tuesday, September 16, 2008

Firefox is the Safest Browser Because...

Recently the Firefox start page started advertising itself as the world's safest browser. For the record the merits of this are up for debate, no one has decisively claimed that title yet. (Also, the add-in's that have helped make FF so popular may increase or decrease security.)

Anyway, the best part of the whole thing is this:

Using [Firefox] is the safest way to surf the web because:

  • We don’t try to tackle the problem alone. An international community of security experts is working around the clock to make your web browsing safer (thanks to our open source way of doing things). It’s like having your neighborhood watch led by a group of highly trained ninjas. [Emphasis Added]
[...]


Hmk, so that's what those Firefox developer's are up to...

@ Tubagirl: Not all of my posts that show up were written during work hours, but scheduled to show up during the morning. If I write several posts at once I generally schedule them out two or three days in a row.


Wednesday, September 10, 2008

Browser Crash... Go Boom


I've been playing with Google's new Chrome Browser, a browser that they call in Beta, but that is pushing it. Anyway, there was a bug loading a page so I found their bug reporting tool and found one of the best bug reporting options ever: "Browser crash... go boom".



The only other computer error message that comes close to beating this is the GIMP's out of memory message, "Out of memory. Bad things will happen soon!"

See? Geeks can be funny!


Wednesday, August 13, 2008

Wildcards in Excel

Recently at work we had a situation where we had to remove just under 1,200 vendor part numbers from the names of our products. E.g., we had "Name of product (Vendor Part #123), 10 ounces." The vendor part numbers had gotten into our spreadsheet with said (internal) names accidently. (It's a long story. And it's not our fault.)

So I ended up writing a longer email about replacing these vendor part numbers with nothing (E.g., so pretend product name becomes "Name of product, 10 ounces.") and thought I might as well share it, editted only to make it generic. VP stands for Vendor Part, VP# for Vendor Part Number. (A serif font [a font with "feet"] is used to make some of the quotations, literally, clearer.)

I thought that this would work but decided to check first.

If you search for "(VP*)" and replace it with "" (nothing) all VP#'s should disappear. However, you'll have two problems, the first is that there will be a lot of double spaces, one from each side of the parentheses. So you'll have to do another find and replace, this time for "  " (two spaces) replacing it with " " (one space).

Also, in some cases ", " precedes the VP#, e.g., "Tumbler, (VP123) 10oz" which would yield "Tumbler,  10oz" when you were done. So you might want to search for ", (VP*)" replacing it with a single space, then searching for "(VP*)" replacing it with "", and then finally replacing all the double spaces with a single space. If you want to make sure there aren't double spaces run the same search a couple of times. When I've done this in the past I've left triple or quadruple spaces somewhere in whatever data I was working with. Each find and replace would take out one space, from 4 to 3, from 3 to 2, and finally from 2 to 1.

Obviously, all the searches don't actually have the quotes around them when you stick them into Excel. "*" is a wildcard that matches all characters. So if we are looking at the word "Wildcard", "Wild*" would match it, "*dca*" would match it and so on. "?" is a single wildcard that only matches a single character. Looking at "Wildcard" again, "?ildcard" would match, "Wil?card" would, "W???card" would, but "W?dcard" would not (missing either the "i" or the "l"). You can combine them: "?ildca*" would match. "*car?" would match any string that had "car" in it.

In Excel, prepending a tilde to the wildcards searches for the actual wildcard. So if a question mark is what you are looking for you need to prepend a tilde to it.

"*" and "?" are fairly standard wildcards, the preceding tilde to cancel them as wildcards isn't as much. Probably across MS Office, but I don't know beyond that.

Ok, that was a longer email than I meant to write...


Saturday, April 12, 2008

Stripping Down Filenames in Bash

I've seen these two questions asked multiple times and have both haunted me from time to time, so I thought I would provide some answers, although the second is rather rudimentary.

1. Stripping the path off of a file
How often have you needed only the filename, not the path that precedes it? Fortunately most Linux distros make it pretty easy to strip off with the basename command. E.g.,

user@host:~$ basename /etc/apache2/httpd.conf
httpd.conf


Note that if the path contains spaces you will need to enclose it in quotes or escape it:

#Escaping
user@host:~$ basename /home/madjon/youth\ room\ shots/local\ youth\ demographics.xls
local youth demographics.xls

#Quoting
user@host:~$ basename "/home/madjon/youth room shots/local youth demographics.xls"
local youth demographics.xls


2. Stripping the file extension
This takes some bash string manipulation which you can find all about at tldp. If we take httpd.conf again:

# First, assign the filename to a variable:
user@host:~$ f=/etc/apache2/httpd.conf
user@host:~$ echo $f
/etc/apache2/httpd.conf

#Next, strip out any string, starting from the end of $f that matches ".*"
user@host:~$ echo ${f%.*}
/etc/apache2/httpd


Note that the variable substitution (the curly brackets) doesn't have the $ inside it. E.g., the general syntax is:

VAR=whatever
echo ${VAR%.*}


If we want to put them together:

user@host:~$ f=/etc/apache2/httpd.conf
user@host:~$ f=`basename $f`
user@host:~$ echo $f
httpd.conf
user@host:~$ echo ${f%.*}
httpd


I'm sure that this could be accomplished easier with some regex and awk or sed, but all three of those are confusing to me; simple bash scripting makes much more sense to me. I hope this helps whomever.