Navigation

Search

Categories

On this page

Read the Syntax carefully
Array.FindAll Anonymous Delegate Syntax
Converting a DMG to ISO in Mac OSX

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Friday, April 04, 2008
Friday, April 04, 2008 10:46:55 AM (Mountain Standard Time, UTC-07:00) ( )

It's every so important to read the syntax carefully in computer science. Missing the specifics will get you every time.

Compare these two statements.

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC @sql

to this

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC(@sql)

I'm sure you've caught it by now. It's the parenthesis.

Syntax

Execute a stored procedure:

[ [ EXEC [ UTE ] ]
    {
        [ @return_status = ]
            { procedure_name [ ;number ] | @procedure_name_var
    }
    [ [ @parameter = ] { value | @variable [ OUTPUT ] | [ DEFAULT ] ]
        [ ,...n ]
[ WITH RECOMPILE ]

Execute a character string:

EXEC [ UTE ] ( { @string_variable | [ N ] 'tsql_string' } [ + ...n ] )

It's even in bold in the documentation. One would think it might jump out and grab my attention. However sadly, it did not.

Comments [0] | | # 
Friday, April 04, 2008 8:40:06 AM (Mountain Standard Time, UTC-07:00) ( )

I could not find this easily on the web, so I hope this saves someone a search.

Take the following under consideration

string root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

// We're interested in details, so we'll work with DirectoryInfo instead of Directory and strings
DirectoryInfo rootDirectory = new DirectoryInfo(root);
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories("*", SearchOption.AllDirectories);

DirectoryInfo[] hiddenDirectories =
Array.FindAll<DirectoryInfo>(subDirectories,
delegate(DirectoryInfo d)
{
return (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
});

It's wasn't immediately obvious to me how the syntax for Array.FindAll<T> worked. I hope this clears up any confusion in the future.

As a side note. C# 3.0 is the cats meow. This is not 100% equivalent to the above. I think we can all agree we're getting closer to expressing programmers intent.

string start = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

DirectoryInfo root = new DirectoryInfo(start);

var subDirectories = root.GetDirectories("*", SearchOption.AllDirectories).AsQueryable();

var hidden = subDirectories.Where(d => (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);

alternatively in comprehension syntax...

var hidden2 = from d in subDirectories where (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden select d;

Comments [0] | | # 
# Thursday, March 20, 2008
Thursday, March 20, 2008 8:46:46 AM (Mountain Standard Time, UTC-07:00) ( Mac Sucks )

Using the Disk Utility application on OSX, it's easy to get an image of a CD as a file on the hard drive.
The unortunate thing is that the image file is going to be a DMG by default.

I wanted to convert this to an ISO, so I could burn the file to media later with software that understood this format.

Conversion is fairly painless. Drop to your console, and use the following.

hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso

Comments [0] | | #