Archive

Author Archive

Burning DVD’s with NEC 3500AG

March 15th, 2008 No comments

Just recently I bought a computer from a colleague of mine. It has been working like a charm since getting everything set up. And today I am installing Gentoo on another machine. So I downloaded the ISO from Gentoo and was attempting to burn it to a CD.

My first problem was that I didn’t have any CD burning software on my machine. But thanks to some Ubuntu documentation I happened to be looking at it mentioned InfraRecorder (a side note: I am extremely pleased with this software).

But I couldn’t get it to recognize my CD/DVD burner. I wasted almost an hour until it dawned on me. When I installed Windows XP and set up all the accounts, I put everybody as a normal user and not as an Administrator (I am trying out the whole ‘running with least priviledges’ concept). Once I ran InfraRecorder as an Administrator it all worked fine. This is the expected case, but I wonder if there is a group policy or something I can modify so anybody can scan the SCSI/IDE bus.

Something to look into.

Categories: General Tags:

OpenStreamOnFile Does Not Support Unicode?

February 28th, 2008 No comments

I have been working on converting .msg file to .eml files and I just couldn’t get anything to work correctly. I was wanting to have my small converter project work with Unicode. All the functions returned as though everything worked correctly, the only problem was that nothing was written out to the eml file.

I googled around and found the following post from Google Groups.

I will be watching the documentation for this function as I left snide remark for MSFT feedback.

I will be posting the converter project which I am using. I have written a C++ DLL to access the MAPI items, and then wrote a small wrapper C# DLL to make it easy for managed developers to use in there projects.

Categories: Programming Tags:

Vim Search

January 24th, 2008 No comments

I assume that most people that use Vim know how to use the basic search functionality, such as / and ?. I am wanting to elaborate on those a bit.

<CR> represents the actual enter key. If /<CR> is used then the search is executed again using the previous pattern, just hitting ‘n’ also does
the same thing. If you need to go in the opposite direction then use ‘N’. Another quick way to search is by using ‘*’. If your cursor is underneath the
word you want to find, then just hit ‘*’ to go to the next occurrence, this is also in a Vim tip, can’t remember which one however (:he * will get you there
also).

The pound sign, ‘#’, can also be used to search for a word closest to the cursor, however instead of searching forwards, it will search backwards.

When using ‘*’ and ‘#’ the search will only match words, an example is the word foo will not match foobar. If you precede those with a ‘g’ then this will also find matches that are not a word, so using ‘g*’ as foo as the word, then foobar will be a match.

Programmers will be interested in :he gd and also :he gD. I will not discuss these here (possibly will in the future).

I also recommend turning the increment search on in your vimrc file (:he incsearch).

While searching it is by default that your search will wrap. Meaning that once your search hits the end of your buffer, then the search will continue at the beginning of the buffer. In order to turn this feature off and to stop searching once the end of the buffer is found turn wrapscan off, :help wrapscan will tell you more about it or just do ‘:set nowrapscan’.

To find the carrot symbol ‘^’ you need to escape it, such as ‘/foo\^bar’. This will find ‘foo^bar’. The carrot symbol is also used to match at the beginning of a line (hence the need to escape it), so to find ‘foo^bar’ at the beginning of a line the search pattern will be ‘/^foo\^bar’.

Categories: Vim Tags:

Vim Reformat

January 24th, 2008 No comments

While I am typing in Vim I do not let the text wrap, I put in returns manually. This causes problems when I came back to it later and add in some text within the middle of paragraph. The line will continue on to the right margin and the text will wrap, then when I have to adjust the line I have to fix all the following lines to be ended correctly on the right side.

Well, using ‘gq’ you can somewhat auto format your lines. This will use what ‘textwidth’ is set to, if it is not set then the width of the screen is used up to 79. In order to format the current line ‘gqq’, to format the paragraph ‘gqip’ (ip for inner paragraph).

For further reading try :he auto-format and :he text-objects.

Categories: Vim Tags:

Vim Range

January 24th, 2008 No comments

There are numerous commands that can accept a range preceding the command as well as others that range can follow the command. As the name implies you can restrict a command to execute within a particular number of lines.

One such example is with the substitute command. The following command will replace see with saw only in lines 3, 4, and 5.

:3,5s/see/saw

Some people tend to believe that the second number is a line count, but this is incorrect. As you can see in the preceding example, the first number indicates which line to start at, and the second number specifies which line to stop at.

As I stated in the beginning it is also possible to have a range follow the command. But a note taken from the help:

“The commands that accept a count are the ones that use a range but do not have a file name argument (because a file name can also be a number).”

To copy yet again from the help is an example with the range following the command, this will substitute ‘x’ with ‘X’ in the current line and four following lines:

:s/x/X/g 5

Another neat way to specify ranges are used with marks (:help mark). If you have a mark on a line, mark name is ‘a’, then you can delete the line that the mark is on by doing

:'ad&lt;enter&gt;

You can also use two marks as a range, if you had a mark ‘a’ and a mark ‘c’ then you can delete those marks and any lines in between by :’a,’cd<enter>

As I mentioned previously with line numbers, if the mark ‘a’ is located at a line that is following mark ‘c’, you will be shown an error message saying that the range is backwards.

Another special character for ranges is ‘%’, this translates to 1,$ (the dollar sign signifies the last line in the file). Using this you can easily delete all lines by:

:%d&lt;enter&gt;

Categories: Vim Tags:

Vim Substitute Command

January 24th, 2008 No comments

The following command is the substitute command, you can learn more about this command by reading :help substitute (or if you prefer the shorthand version :he su). If you did the preceding you will notice that the help shows the substitute command as :[range]s[ubstitute]/{pattern}/{string}/ (the help also shows all of the possible flags, which I omitted here on purpose). Just in case you didn’t know, since range is enclosed in square brackets that means it is optional. Also you will notice that the :s can also be spelled out as :substitute, I am sure that most people will prefer the :s syntax.

To replace the first occurrence of aspirin with foo in the current line:

:s/aspirin/foo

To replace the first occurrence of aspirin with foo in every line:

:%s/aspirin/foo

You will notice the only difference in the two preceding lines is the % sign. The % sign specifies a range, basically saying every line in the file, but the help (:he range) says that it is equal to 1,$. You are probably confused with the dollar sign also which you probably think of as the last character on the line but $ is range command meaning last line in file. I will not continue more with ranges (to read more about ranges, see my range tutorial), I just wanted to show what all is possible and where to look.

You will notice that both of the operations above will only work once for each line. So if you have aspirin in a line more than once, then only the first instance will be changed.

In order to change every occurrence of aspirin to foo:

:%s/aspirin/foo/g

One problem that many users face is editing DOS/Windows files on Linux, when viewed with Vim you will see ^M at the end of the lines. One way to fix this problem is the following:

:%s/\r//g

The \r is the extra character that Windows adds for the end of line marker, there is an empty string to replace it with as noted with //

Some of the special characters can easily be handled by escaping them, just use a preceding \ in these cases. There are a few others which need an extra step, such is the case for the ? character. In order to replace this character with a string (such as foo) then one would use the following command:

:s/\v\?/foo/

Categories: Vim Tags:

Being a Computer Scientist

January 23rd, 2008 No comments

At one of my previous places of employment, I made a comment which made numerous of my co-workers very angry at me. I felt as though I was completely justified in saying it, but I soon found out how much I upset them.

I believe I was talking about Bill Joy, I honesty can’t recall off the top of my head who I was talking about, but a co-worker asked who that was. I responded with a rhetorical question in awe that they didn’t know who I was talking about. I rattled off a few other (in my opinion) popular/famous Computer Scientists, as a line of questioning to see if they knew any others … which they did not. FYI, I believe I mentioned Alan Turing, Larry Ellison, Donald Knuth, and Steve Wozniak among others.

I then made a comment which made a few of them mad at me “I don’t understand why somebody being a programmer, a computer scientist, and not knowing the pioneers in our field”. The conversation continued for a short while, but it became readily apparent I was in the minority.

The Senior Lead at that time was Paul Carter, he agreed with me during the whole conversation but I was the one who took all the heat. I have kept in touch with him since leaving and received an email from him just the other day.

His email had a link to a blog post about Donald Knuth, and thought about that conversation. I am glad to see someone else who has a very similar stand as I do:

If you don't know who Knuth is, then you're not a programmer. If you're a programmer and you don't know who Knuth is, well... I have no idea what rock you've been hiding under, but you should probably be fired.
Categories: Programming Tags:

PHP Equality and Identity Operators

January 1st, 2008 No comments

I am working on learning the Zend Framework, and along with that PHP as well (of course). I stumbled upon a code snippet on the internet which I didn’t realize would work. I have seen the use of the identify operator in PHP before but I soon realized I didn’t know all that I should. So I dived into this topic a little bit more and soon found out that more seasoned PHP programmers aren’t too fluent in the differences between the two operators and what is (and not) possible.

Most programmers are accustomed to the equality operator as noted by ‘==’. This operator performs a check on the operands and if they are equal (you will soon learn equal has a very broad definition) then it will return true. What I mean by a broad definition is that the PHP interpreter will perform a conversion based upon what the operand contains. In an attempt to keep my examples more simple I will be talking about numerics and strings.

If both operands are a string value, but both contain a numeric expression the interpreter will attempt to convert both expressions to a numeric value then perform the numeric comparison. If one of the operands is a numeric value and you compare it to a string type, the string is converted to a numeric value as well. If the string conversion fails, then a 0 is returned. As an example, if you run the following code, it will print out ’1′.

<?php
  // This prints 1
  print ("000" == "0" && "0" == 0 && 0 == "cat");
?>

The following will result in a string comparison instead of a numeric comparison. The PHP interpreter recognizes “0″ as a numeric expression, but since “cat” is not a numeric expression then they are both left alone and compared as strings.

<?php
  // Does nothing
  print ("0" == "cat");
?>

If you are more comfortable with a strongly typed language such as Java or C++ then the identity operator is going to be what you would be more accustomed to. In PHP this is denoted as ‘===’, this performs tests as you are more familiar with. The identity operator will return true if both operands are equal and of the same type. The above two examples, if used with the identity operator would return false in all cases.

In the following example since $a is not of a valid numeric expression no conversion takes place and a string comparison is performed. Conversely $c is a valid numeric expression (see Scientific Notation) this is converted and evaluated.

<?php
  $a = "0f0"; // This is not hex, as it does not start with 0x, ex. "0xf0"
  $b = "000";
 
  // This fails
  print ($a == $b); // "0f0" == "000"
 
  $c = "0e0";
 
  // This is successful
  print ($c == $b); // "0e0" == "000"
?>

Just one more last example, here both variables are valid numeric expressions. They both evaluate to 0 using the scientific notation.

<?php
  $a = "0e2";
  $b = "0e3";
 
  // This is successful
  print ($a == $b);
?>

I hope this has shed some light on the subject. The following are some references which helped me understand this a little better.

BlueShoes PHP Syntax Exam

PHP Docs for Comparison Operators – And a comment which started me on this journey

Categories: PHP Tags:

Why I choose my title

August 18th, 2007 No comments

We all have good friends in our lives, and because of them we will usually learn from them or obtain habits from them. A gentleman I have known for my entire life uses this saying to end a phone call conversation. I feel this simple saying is something most people should live by. After all a bad person can do a good deed to ensure your trust if only for a short while. But a good person … well … is salt of the earth.

Categories: General Tags:

Turn off balloon popups

February 16th, 2007 Comments off

The balloon popups have been driving me up the walls lately and I finally decided to google and figured out how to turn it off. This mainly hits a nerve when my wireless drops out, or the ASP.NET Development Server starts up. Using the ‘Run’ command, type GPEDIT.msc, look under User Configuration -> Administrative Templates -> Start Menu & Taskbar then bring up Remove Balloon Tips. From here I would assume you can figure out how to enable or disable this ‘feature’.

Categories: Uncategorized Tags: