Tuesday, June 10, 2008

Photos from Tech Ed IT Pros: Bob Muglia Keynote, part I

My first batch of snapshots from Bob Muglia's keynote this morning, including a selection of programmatically stitched panoramas.

General call to conference organizers on technology topics: I am happy to exchange unrestricted rights to the thousands of photos I invariably shoot at these events for comps on conference registration fees.

IMG_8455
IMG_8360 Stitch
IMG_8108 Stitch
IMG_7994
IMG_8012

IMG_8084 IMG_7977 IMG_7970

IMG_8271
IMG_8299

IMG_8280

 IMG_8308

IMG_8246

 IMG_8248

Comments: Post a Comment
Links to this post

Sunday, June 08, 2008

Photos from Tech Ed 2008 Tweener Weekend: Sunday

 

IMG_7788 copy
EventForce meets da Vinci's Last Supper.

 

IMG_7763
SharePoint Fundamentals

 

 

IMG_7771
SharePoint Fundamentals

 

 

IMG_7783
SharePoint Fundamentals. 

 

 

IMG_7789
OpenSpace

 

IMG_7794
Schwag!
Comments: Post a Comment
Links to this post

Photos from TechEd 2008 Devs: Party at Universal Studios Orlando

Copy of IMG_7239 Stitch
This panorama comprises five horizontal photos.
(Somewhere, Encarta's copy chief is smiling. Even after all these years, I remember the ESG's recipe: "pancake batter comprises butter, milk, eggs.")

 

IMG_7261
 
IMG_7316 Stitch2
 

 

IMG_7253 Stitch
This very weird panorama comprises six horizontal photos.
It isn't totally successful but it's sure fun to look at.

 

 

IMG_7289
 

IMG_7308
 

 

IMG_7329
 

 

Labels: , , ,

Comments: Post a Comment
Links to this post

Photos from Tech Ed 2008 Devs: Carl Franklin plays the show floor

Sunday now and I'm finally finding time to catch up on all the pictures I shot during Tech Ed Developers last week. The co-host of .NET Rocks!, Carl Franklin has a fine voice and plays guitar with exceptional skill.  Many of us milling the conference floor ceased our schwag-collecting and stopped by to hear Carl play.

 

IMG_7127

IMG_7119 Stitch 

 

IMG_7088

 

IMG_7112 IMG_7130 IMG_7101 IMG_7133

 

 

IMG_7156

Labels: , , ,

Comments: Post a Comment
Links to this post

Saturday, June 07, 2008

Check out the last half of Tech Ed Tweener Weekend!

This post comes late, but hopefully it gets a few folks off the fence. A chap named Joe Healy from Microsoft noticed that his company had already shelled out for two weeks' rent of Orlando's Orange County Convention center to accommodate both the "Tech Ed Developers" and "Tech Ed IT Pros" events... why not do something useful with the in-between ("tweener") weekend?  MSFT donated space and some staff to Florida's .NET user-group community to organize free technical sessions on Saturday and Sunday.

Though I was completely worn out from my week with Jeff Prosise and Tech Ed Devs, and will shortly be attending the Tech Ed IT Pros + PreCon, I dragged my reluctant brain out of bed this morning and checked out the day's events. Tech Ed Tweener Weekend is great! The morning sessions on Silverlight cemented what I'd learned at Prosise's precon, Microsoft's Karen Liu did a great session on VS.NET C# 2008 tips and tricks, and Joseph Briatico offered a solid intro to WPF. The presentations were on par with what we're paying real money to see at conferences like Tech Ed, and the sessions were small enough that it was easy to have some one-on-one interaction with both the speakers and fellow Tweeners. Recommended.

If you're wondering whether the Sunday sessions are for you, Just Do It. The price is right (FREE!) and there's probably something in the schedule to interest you.

As for the schwag story, well, I did better at Tweener Weekend than I did at Tech Ed Devs:

IMG_7755
Free books@Tweener weekend! Woooo hoooo!
Comments: Post a Comment
Links to this post

Tuesday, June 03, 2008

Microsoft Tech Ed 2008 Developers | Panoramic images from Bill Gates' keynote

Programmatically stitched panoramic images. I shot these pictures during Bill Gates' keynote on Day 2 of Microsoft Tech Ed 2008 Developers. Non-panoramic images to come.

IMG_7030 Stitch 
Empty. Stitched from ten vertically-shot images.

IMG_6641 Stitch 
Full! Stitched from six vertically-shot images.

IMG_6649 Stitch 
billg takes the stage. Stitched from ten vertically-shot images.

 

IMG_6668 Stitch

 

IMG_6964 Stitch
Lineup for the Q&A with billg

 

IMG_6967 Stitch (2)

Quizzing Mr. Gates.

IMG_6709 Stitch 
This one's an uncropped mess but I sort of like it anyway. Next year maybe I'll bring a full-frame fisheye lens to shoot the keynote.

General call to conference organizers on technology topics: I am happy to exchange unrestricted rights to the thousands of photos I invariably shoot at these events for comps on conference registration fees.

Labels: , , ,

Comments: Post a Comment
Links to this post

Tech Ed 2008 Photographs | Monday | Jeff Prosise and Panoramas

Following up on adventures documenting Tech Ed 2006 in pictures (as well as the opinionated musings of Tech Ed's little-appreciated wildlife), I returned to Tech Ed 2008 Developers determined to take a picture or two.  I took the photographs below during Monday's pre-conference sessions. Stay tuned for images from Bill Gates' Tuesday morning keynote.

Many of the images below were programmatically stitched into panoramas from several pictures, a technique I've been playing with recently to communicate the scale of things and to combat the grain associated with shooting handheld in low light.

General call to conference organizers on technology topics: I am happy to exchange unrestricted rights to the thousands of photos I invariably shoot at these events for comps on conference registration fees.

IMG_6352
Inside: Orange County Convention Center entrance.

 

IMG_6467
Outside: Orange County Convention Center entrance.

 

IMG_6340 copy
Most denizens of the IT world will appreciate this bus-borne commentary on organizational teamwork. Nice to start Tech Ed with a smile.

 

IMG_6342_crop
Colors!

 

IMG_6379

IMG_6380

IMG_6407

IMG_6427

IMG_6432

Jeff Prosise hard at work during his Silverlight PreCon.


IMG_6417
Jeff Prosise

 

 

IMG_6445_crop
Jeff Prosise, looking contemplative as he confronts the existential crisis of Q&A.

 

 

Copy of IMG_6399
Jeff Prosise with us Q&A groupies

  

IMG_6475 Stitch
Orange County Convention Center at dusk. This panorama comprises eight vertically-shot images. I'm not satisfied with this  -- but I've got the rest of Tech Ed Devs and Tech Ed IT Pros to do better!

 

IMG_6504
 
Comments: Post a Comment
Links to this post

Monday, March 17, 2008

http://blogs.uwnews.org/politics on dasBlog

My colleague Catherine O'Donnell at the University of Washington has put together a rather nice blog on http://uwnews.org, the University of Washington's news site. Called "Professors on Politics," (http://blogs.uwnews.org/politics/)  it's built on the dasBlog open-source blogging platform. 

In general, I like dasBlog a lot, but there's a couple things that could improve it:

  • Comment expansion available as a default. Seeing comments "open" encourages additional posts from visitors. This behavior can be built by editing one of dasBlog's constituent controls, but non-techs aren't going to do that.
  • SQL Server versus XML as a data store. Ideally this could be done so an interface could map to an existing schema. Ideally there would be an easy tool that would allow someone to set up the necessary code by programmatically inspecting an existing datasource and exposing both "ends" in a graphical IDE. Again, this serves the non-tech.

That all said, dasBlog is a great package that we were able to get up and running in just a few hours. Thanks, guys!

Comments: Post a Comment
Links to this post

Saturday, October 20, 2007

Totally unique: Virginia Woolfe describes sunrise in _The Waves_

Jeanette Winterson ( ... The Passion, The Powerbook ... ) wrote a fine essay called a "A Gift of Wings" in Art Objects, telling us why and how to read Virginia Woolfe's The Waves. I had no exposure to Woolfe in school so discovering her style has been a pleasure.

The Waves is like nothing I've ever read: the entire story appears to be rendered as continuous soliloquy by six co-equal characters. They describe their perceptions in strange poetry: beyond mere sensations, each character describes hopes, fears, and conscious and unconscious motivations in a weirdly voiced present tense. Interesting and totally unique. From the novel's opening:

"I see a ring," said Bernard, "hanging above me. It quivers and hangs in a loop of light."

"I see a slab of pale yellow," said Susan, "spreading away until it meets a purple stripe."

"I hear a sound," said Rhoda, "cheep, chirp; cheep chirp; going up and down."

"I see a globe," said Neville, "hanging down in a drop against the enormous flanks of some hill."

"I see a crimson tassel," said Jinny, "twisted with gold threads."

"I hear something stamping," said Louis. "A great beast's foot is chained. It stamps, and stamps, and stamps."

"Look at the spider's web on the corner of the balcony," said Bernard. "It has beads of water on it, drops of white light."

"The leaves are gathered round the window like pointed ears," said Susan.

"A shadow falls on the path," said Louis, "like an elbow bent."

"Islands of light are swimming on the grass," said Rhoda. "They have fallen through the trees."

"The bird's eyes are bright in the tunnels between the leaves," said Neville...

I find myself re-reading each chapter of The Waves many times: the text is dense with description and clogged with allusion, like Nabakov. One of the characters describes bathtime quite memorably.

Pay attention to how the first sentence of the excerpt below runs on and on, clause after descriptive clause, pregnant, ripe, hanging in space; you wait for the inevitable shock of falling water along with the narrator. Quick declarative sentences follow, rushing like water running down the speaker. Neat trick.

"Mrs. Constable, girt in a bath-towel, takes her lemon-colored sponge and soaks it in water; it turns chocolate-brown; it drips; and, holding it high above me, shivering beneath her, she squeezes it. Water pours down the runnel of my spine. Bright arrows of sensation shoot on either side. I am covered with warm flesh. My dry crannies are wetted; my cold body is warmed; it is sluiced and gleaming. Water descends and sheets me like an eel. Now hot towels envelop me, and their roughness as I rub my back makes my blood purr. Rich and heavy sensations form on the roof of my mind; down showers the day -- the woods; and Elvedon; Susan and the pigeon. Pouring down the walls of my mind, running together, the day falls copious, resplendent. Now I tie my pyjamas loosly round me, and lie under this thin sheet afloat in the shallow light which is like a film of water drawn over my eyes by a wave."

Comments: Post a Comment
Links to this post

Wednesday, October 17, 2007

Ken's Oct. 14 Long Beach Marathon: 3:30:19

Exactly one month after my first marathon in Maui (which I finished in a relaxing 3:48) I ran closer to home in the Oct. 14 Long Beach Marathon. Dr. Fine joined me on this adventure: me on foot, Essie snapping pictures and cracking encouraging jokes from her bicycle the whole way (example: "Don't hold back, Ken! Remember, I know CPR!!!")

Blogging provides a nice look back at the journey. Way back in March I posted pictures from my first training runs in San Francisco, and using Gmap-Pedometer I quickly established the routes that would become the core of my training (Costa Mesa to Newport Pier, Costa Mesa to Huntington Pier, Costa Mesa to chocolate bananas on Balboa ... ) 

Kudos to the organizers of the Long Beach Marathon: it was a super well-planned and well-executed event, a beautiful course, and a whole lot of fun. I thought it was especially great how they thawed Elvis from his cryogenic storage to cheer us on (pictured below).  I will be back for more running fun at Long Beach next year.

The stats for the first printing of my trading cards...

Pace: 8:02 per mile / 3:30:19 total chip time
Place overall: 171 out of 2343
Place among men: 152 out of 1462
Place in my age group (35-39): 29th out of 243

I'm still well off of a Boston qualifying time of 3:15:59, but I'm sure that with enough time and practice, I'll get to that pace and better. Most important: I'm very much enjoying these stabs at amateur athleticism. Try.

n539469574_375042_4147 n539469574_375122_1637

n539469574_375041_8859

Comments: Post a Comment
Links to this post

Monday, October 08, 2007

Vienna Teng house concert: Minneapolis, MN, Nov. 9

I'm spending most of November traveling recreationally: a week in New York City; the Flash on the Beach conference in Brighton, UK; and Henri Lubatti's wedding celebrations in France and Italy. But amid this far-flung exotica, one of the trips I'm most excited about is a visit to Minneapolis, MN, where Ms. Vienna Teng -- aka Cynthia Yi Shih (史逸欣) -- will be playing a small concert at someone's house.

The short story of Teng's rise is guaranteed to warm the hearts of geeks everywhere: she dumped pre-med at Stanford to pursue a computer science degree, singing in Stanford's a cappella group on the side. Following graduation, Teng worked for two years at Cisco Systems as a software engineer before ditching high-tech to focus on her music. Six months later she was playing on Letterman and plugging her first album, Waking Hour, to which Letterman offered a characteristic endorsement: "There's not a dud on it."

A singer-pianist, Teng is often compared to Sarah McLaughlan or Tori Amos. There are superficial similarities: Teng puts piano front and center, and charges her lyrics with emotion, narrative, and personal history (not plagiarized; poke around.) Get past the obviousness of women wielding pianos, and you'll notice plenty of distinctions.

The closest thing Teng has to a pop song is "Gravity" ( or have a look at this interesting alternate live version, performed at a public library very early in her career: Teng's hair is cut charmingly, boyishly short.) Gravity's lyrics are a guilty pleasure: geeks in love just can't avoid connecting themselves to celestial mechanics as they try to work through their obsessions and heartache.

Some of Teng's most interesting stuff will probably never suit the requirements of radio or commerce.

Vienna Teng will be playing her piano and singing her songs by donation in Minneapolis on Nov. 9 for dozens, not thousands. I wonder if this signals a fundamental change in the music biz. An admirer of Teng has surrendered her house for an evening, 100% of our generous cash donations (small bills and untraceable) will be passed to Teng, and the result is a different experience and a new math for artist and audience alike. Perhaps wonderful.

Comments:
Hi there Ken. Vienna's manager here. I read your blog as I receive google alerts on Vienna daily. Thank you for the post! The house concert that Vienna is playing in November is happening based on the desire and passion of one person - Amy from Collected Sounds. We attempted to do something with her years ago and simply couldn't work out the details. She's always been very supportive so I am glad that we were able to make these shows a reality. I hope that you enjoy the show!
 
Post a Comment
Links to this post

Sunday, September 09, 2007

Synaptics Touchpad driver setup on Vista and Dells

Upgrade your Dell laptop to Vista, and you will likely have a really lousy touchpad experience if you don't pay careful attention. The short story is that you need to make sure you get the right Synaptics driver from Dell and install it; what Vista sets up by default for your touchpad is not what you want. I learned everything below the hard way.

Recent-vintage Dells use a hardware pointing device made by a manufacturer called Synaptics. Unfortunately, Vista rather stupidly installs a generic USB pointing device rather than the Dell-specific Synaptics driver set, which has many many features and improvements beyond what's offered by the generic USB pointing device. Among the most important of these improvements is "PalmCheck", which prevents errant and unintended input while you are typing. I find working with a touchpad-equipped laptop that doesn't have PalmCheck enabled to be unproductive and extremely annoying: every few minutes my pointer goes somewhere I don't want it to even if I type very cautiously. Other missing functionality includes "EdgeMotion," a feature that lets you scroll pages horizontally and vertically by dragging on the edge of the pad, and programmable "tap points" on the four quadrants of the pad that let you easily execute windowing commands, navigation commands, or custom macros.

Sooner or later most semi-savvy people realize that their touchpad is screwed up and they go hunting for a better driver. This leads to common mistake #2: they Google around and then go to the Synaptics website and try to download an appropriate driver from there. The generic driver on Synaptics' site is only marginally better than the generic USB device that Vista installs. Indeed, Synaptics' website points people to the correct answer: you need to go to the manufacturer's (Dell's) website and find the current driver.

As of September 2007 this was the current Synaptics driver from Dell for 32-bit OSs. The driver, dated Jan 2007, solved all of my Touchpad concerns on an Inspiron E1405 and a Dell XPS Gen II with 17" display. You can generally tell if you've found the right driver if, after installation and reboot, an icon appears in the tray whose properties offer many tabs of options for how to configure the touchpad.

Comments: Post a Comment
Links to this post

Wednesday, August 01, 2007

One possible classification scheme for the UW Office of News and Information: Hierarchical classification structures

We've discussed the problem of classification from time to time and at some point we're going to have to create a classification system that answers our immediate and future needs.

I'll outline some of the thinking I introduced in the meeting yesterday: there may be some useful ideas here.

A big problem with our existing classification set is what they call in the biz, "intellectual managability." As in, even an expert user can't keep all of the details of the system in their head. It's too much to handle.

A second issue is extensibility: the only way to extend the present system is to add to a fairly "flat" structure, which has the unpleasant effect of making the system yet more complicated.

A hierarchical classification system solves for these issues, allowing simple high-level views and a logical path to more detailed views. In the world of computing, it is one organizational paradigm that has been a runaway success. The entire USENET news hierarchy was built around the idea:

rec.arts
rec.arts.film
rec.arts.film.blazingsaddles
comp.sci.lang.visualbasic
comp.hardware.video

... and so on. Similarly, from the world of programming, Microsoft organized the .NET Framework and Sun organized the Java class framework around a similar hierarchical structure, allowing programmers to "mentally manage" a bazillion different programmatic classes:

System.IO
System.Web.UI
System.Web.UI.HtmlControls
System.Security.Cryptography

There are literally thousands of classes in the .NET framework and even brilliant programmers do not remember all of them. However, the simple high-level structure of the thing allows programmers to find what they need pretty successfully: if I want a symmetric encryption scheme and I don't want to build it from scratch myself, I know that poking around "System.Security..." will probably take me to what I need. Once I drill down to "System.Security", the options include "System.Security.Cryptography", and that's my ticket.

Aiding this process of "discovering" categories are the abilities of tools to prompt you what the available options might be, as you are writing out parts of the hierachy. See this post of mine, read the second paragraph regarding "Intellisense", and scroll to the section marked "step 1" and "step 2":

http://kenfine.blogspot.com/2007/03/vsnet-2005-basics-part-1-xml.html

As more of a classification's hierarchy is typed, the available options are constrained to the available options, and you can "autocomplete" things with very little typing. This is useful and efficient. Have me demo it live if this doesn't make sense.

With these ideas in mind, let's consider the problem of our classifications. We could have a high-level hiearchical structure similar to this:

  • uw
    • uw.academics [a catchall, see below]
      • uw.academics.programs
        • uw.academics.programs.projectneptune
      • uw.academics.units
        • uw.academics.units.collegeofengineering
          • uw.academics.units.collegeofengineering.computerscienceandengineering

...

    • uw.orgs
      • uw.orgs.student
        • uw.orgs.student.greek
      • uw.orgs.administration
        • uw.orgs.administration.development
        • uw.orgs.administration.mediarelationsandcommunications
    • uw.persons
      • uw.persons.employees
        • uw.persons.employees.staff
          • uw.persons.employees.staff.classifiedstaff
          • uw.persons.employees.staff.professionalstaff
            • uw.persons.employees.staff.professionalstaff.kenfine [key by uwnetid]
        • uw.persons.employees.faculty
          • uw.persons.faculty.jwalk
      • uw.persons.students
      • uw.persons.issues
        • uw.persons.issues.employment
          • uw.persons.issues.employment.salary
          • uw.persons.issues.employment.retention
    • uw.outreach
      • uw.outreach.diversity
      • uw.outreach.k12
    • uw.fiscal
      • uw.fiscal.budget
        • uw.fiscal.budget.olympia
    • uw.places
      • uw.places.buildings
        • uw.places.buildings.gerberdinghall
      • uw.places.grounds
        • uw.places.grounds.washingtonbotanicalgardens
        • uw.places.grounds.liberalartsquadrangle
      • uw.places.planning
        • uw.places.planning.2020campusmasterplan
      • uw.places.issues
        • uw.places.issues.openspace
        • uw.places.issues.earthquakemitigation
    • uw.misc
      • uw.misc.security
        • uw.misc.security.uwpolice
        • uw.misc.security.computing

...

This is a starting point. The beauty of this kind of structure includes that facts that:

  • The structure can be very deep, but the number of high level "base concepts" are few: misc, places, fiscal, outreach, orgs, academics, and persons. The high-level structure is intellectually managable.
  • Things classified within this structure can be viewed at any level of complexity. If you want a view of ALL campus buildings, you or a system can inspect uw.places.buildings. If you want a specific building, you can drill down to uw.places.buildings.gerberdinghall.
  • It is readily and rationally extensible without complexifying the base concepts.
  • The user of this system is "prompted" down a rational path: all they really need to know is the appropriate highest-level category, and the system effectively asks the person a series of questions at each "step."
  • These classifications are fast to type, and adaptable to timesaving UIs and tools.

 

-KF  

Comments: Post a Comment
Links to this post

Saturday, July 21, 2007

Question: How do I show comments expanded/open by default in Blogger.com?

If anybody can tell me how to get comments showing as automatically "opened" on this blog page, such that the user doesn't have to click to see comments, please let me know. I spent several hours with the docs for what's the formerly-beta Blogger.com template syntax and got nowhere. 

I'm using the Minima template and the "new" Blogger.com syntax.

Comments:
With your level of developing expertise, I think you'd enjoy a blog engine that lets you tinker below the hood a bit more. It doesn't even have to be on your own server, but it does help if the blogging engine is more open. To only be able to adjust css and bits of html is just so myspace-ish...

I'm using wordpress, and could probably make comments show up on my blog's front page with a one or two line change to the code that displays the page. I could make things really easy on myself and steal that bit of code relating to comments from the page that already displays single posts with comments, and then just wrap the comments in a div.

Here's how wordpress displays blog posts, it's really easy to customize:
http://codex.wordpress.org/The_Loop

Or maybe I'm wrong and blogger does give you that level of control?
 
Thanks Zach. Commenting on my own post, here: ultimately the simplist fix was to revert to using blogger.com's "old" template structure.

I was able to find plenty of instructions on how to make the old templates show expanded comments. I couldn't find any instructions on how to make the new blogger system expand comments automatically. Both templating systems use the sorts of functional tags you describe, but the old tags seem better documented, at least as far as the expanded-comments thing is concerned.
 
Post a Comment
Links to this post

example | C# .NET ASP.NET | Writing a directory's contents as XML, and binding that XML to an ASP.NET databound control

Intent: Write an XML file that describes each file in a directory, and then use that XML file as a datasource for an ASP.NET databound control.

Discussion: .NET has high-level abstractions for creating XML in the form of the XmlTextWriter object. It is fairly easy to use.

Overview: Instantiate a DirectoryInfo Object. Instantiate a FileInfo array by calling the .GetFiles on your instantiated DirectoryInfo object. Instantiate a MemoryStream object. Instantiate an XmlTextWriter object and set its character encoding to UTF-8. Initate a foreach loop over the FileInfo[] array, instatiating a fileInfo object on each iteration of the loop. To open a new element and populate it, call XmlTextWriterObject.WriteStartElement, then call XmlTextWriterObject.WriteString  to assign the content of the element, and then call XmlTextWriterObject.WriteEndElement() to close it. Note that elements can be nested; be sure to call the .EndElement() method at the appropriate place for your nest. Write the finished Xml to a file by instantiating a FileWriter object, calling OpenWrite(Filename), instantiating a byte[] array and calling the MemoryStream.ToArray() method, and finally calling the FileStream.Write() using the byte array as a parameter of the method. Once the XML is written, specify it as an XmlDataSource by assigning the byte array to the XmlDataSource.Data property and calling the XmlDataSource.DataBind() method. (whew!)

Weaknesses: I'd like to know how to avoid writing the Xml to a temporary file, as shown below. How can this all happen in memory?

 

   protected void ShowPhotoGrid( string jobID)
{

DirectoryInfo dir = new DirectoryInfo(@"R:\whatever\"+jobID);
FileInfo[] fis = dir.GetFiles("*ld200.jpg");
//FileInfo fi = new FileInfo();

MemoryStream s = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(s,Encoding.UTF8);
xw.WriteStartDocument();
xw.WriteStartElement("filesystemitems");
string largefilename = "";

foreach (FileInfo fi in fis)
{
xw.WriteStartElement("filesystemitem");
xw.WriteStartElement("filename");
xw.WriteString(fi.Name);
xw.WriteEndElement();
xw.WriteStartElement("filenameandpath");
xw.WriteString("http://whatever.org/content/whatever/" + jobID +"/" + fi.Name);
xw.WriteEndElement();
largefilename = StringManipulation.LeftOfRightmostOf(fi.Name, '_');
largefilename = (largefilename + "_ld600_watermark.jpg");
xw.WriteStartElement("filenameandpathlarge");
xw.WriteString("http://whatever.org/content/whatever/" + jobID + "/" + largefilename);
xw.WriteEndElement();
xw.WriteStartElement("filesize");
xw.WriteString(Convert.ToString(fi.Length));
xw.WriteEndElement();
xw.WriteEndElement();
}
xw.WriteEndElement();
xw.Flush();

// Write memorystream to a file. This is not the most efficient way to do this. What's better?
FileStream fs = File.OpenWrite(@"R:\whatever\blahblah.txt");
byte[] data = s.ToArray();
fs.Write(data, 0, data.Length);
fs.Close();

// Convert the data array to a string and response.write it
string myString = System.Text.Encoding.UTF8.GetString(data);
// Response.Write(myString);


XmlDataSource1.Data = myString;
XmlDataSource1.DataBind();
DataList1.DataBind();

}
//???? How do I convert my MemoryStream object to a string
        // It involves Writing the MemoryStream to a byte array, and converting it to a string, but I can't get things working quite right
}
Comments: Post a Comment
Links to this post

example | C# .NET ASP.NET| Binding image names from a filesystem to an ArrayList, and binding that to ASP.NET databound control

Intent: Sometimes you want to display photographs contained in a filesystem directly, without referencing  an intermediate data layer like a database store or XML file. You

Overview: Instantiate an ArrayList. Iterate over the output of the Directory.GetFiles() method, specifying the image extension as a mask. Build up HTML that should be placed in each cell of a databound control. Call the ArrayList's .Add method to write the HTML string to the ArrayList. Assign the Array as the DataSource of a DataList.  Bind that DataList to an <ItemTemplate> using the <%# Container.DataItem %>    syntax.  Call the DataList.DataBind(); method.

Discussion: The example below also allows the user to adjust the number of displayed columns via a DropDownList selection. This works by programmatically assigning the DataList.RepeatColumns property to the DropDownList.Selected property. 

        ArrayList pics = new ArrayList();

string code;
string image;
//string myFile;
foreach (string myFile in Directory.GetFiles(("T:\\WHATEVER\\WhateverSubDir"), "*.jpg"))
{
image = YOUR_DIRECTORY + Path.GetFileName(myFile);
code = "<img src=\"" + image + "\">";
code += "<br /> " + Path.GetFileName(myFile);
pics.Add(code); // add the image to your ArrayList
}
// Bind the pics to a DataList
dlImages.DataSource = pics;

dlImages.RepeatColumns = Convert.ToInt32(DropDownList1.SelectedValue);
dlImages.DataBind();
 
    <form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Value="1">One column</asp:ListItem>
<asp:ListItem Value="2">Two Columns</asp:ListItem>
<asp:ListItem Value="3">Three Columns</asp:ListItem>
<asp:ListItem Value="4">Four Columns</asp:ListItem>
</asp:DropDownList>
<asp:DataList ID="dlImages" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<%# Container.DataItem %>


</ItemTemplate>
<ItemStyle Font-Names="Arial" Font-Size="X-Small" />
</asp:DataList></div>
</form>
Comments: Post a Comment
Links to this post

example | C#, .NET | Evaluating whether a string is a date

A perennial question on USENET. The code below isn't mine; I'm putting it here for convenience. C# doesn't have an IsDate function built in. The code below duplicates the behavior of IsDate.

 

    public static bool IsDate(string date)
{
DateTime dt;
bool isDate = true;
try
{
dt = DateTime.Parse(date);
//If this cannot parse, the format is incorrect
}
catch (FormatException e)
{

isDate = false;
}
return isDate;
}
Comments:
how about:
DateTime temp;
return DateTime.TryParse("date", out temp);
 
Thanks. That is much more terse and clear.
 
Post a Comment
Links to this post

example | C#, .NET, EntitySpaces | Testing whether an item is already in the database

Intent: Using the EntitySpaces ORM framework, test whether an item exists in a database or not. The example below shows a test of whether a "tag" appears in the database.

Overview: Write a function which accepts the item to test as a string parameter.  Instantiate an EntityCollection. Execute an ES Query  on that collection, using the Like operator and using the tag string as the parameter. Execute the ES .Load() method to load all available items into a collection. Run a comparison operation on whether Entity.Count is greater than or equal to one. If you wish to return a property of the found items, iterate over the EntityCollection using foreach, instantiating a single item within the collection on each loop. Return the property of the found item if you wish.

Discussion: Useful if you want to enforce single entries to a database table. The tags example below is a good application of this: you want to build a directory of categorical tags and list them only once, referencing the single tag many times using a Join table.

 

    public int IsTagInDatabase(string tagToCheck)
{
TagsCollection tagcoll = new TagsCollection();
tagcoll.Query.Where(tagcoll.Query.Name.Like(tagToCheck.ToLower()));
tagcoll.Query.Load();
int tagID = 0;
if (tagcoll.Count >= 1)
{

foreach (Tags tag in tagcoll)
{
tagID = Convert.ToInt32(tag.Tagid);
}
return tagID;
}
else
{
return 0;
}
}
Comments: Post a Comment
Links to this post

example | C# .NET | Isolating a directory that DOES or DOES NOT contain a particular substring

Intent: This is useful in instances when you have a highly organized archive with different, similarly-named directories in them, e.g. FolderNameRAW and FolderNameTIF

Overview:   Declare a string array using the Directory.GetDirectories() method. Iterate over each string in the array. Use the string.IndexOf method to  isolate the substring of interest. Execute a comparison, with a result of >= 1 meaning that the substring is found, and a comparison of == -1 indicating that the substring was not found. 

 

   string[] dirs = Directory.GetDirectories(sourceImageDirBase);

foreach (string dir in dirs)
{
if (dir.IndexOf("RAW") >= 1)
{
                    // Do something here to images that DO have the string RAW as part of their name
}

{
if (dir.IndexOf("RAW") == -1)
{
                    // Do something here to images that DO NOT have the string RAW as part of their name
                    }

}

}
Comments: Post a Comment
Links to this post

Saturday, April 07, 2007

A pet peeve of mine is expensive tools that do trivial things; their expense is a function of their specialization. I'm hoping the process of programmatically testing for SQL injection vulnerability is trivial. If that's the case I could roll my own application to scan my applications and save my employer, the Great University of Washington, a few hundred or a few thousands of dollars.

Posted the question below to microsoft.public.dotnet.framework.aspnet tonight in the hope that someone can get me started on this. I'll update this post as I get more information. If this is easily done, I'll share whatever C#/ASP.NET code I end up writing to effect this for the UW; maybe we can even get a little open-source project going on this one.

There are assorted "SQL Injection vulnerability assessment tools" out there.
They scan your site and send your report. They also take your money.

We don't have the money so I was wondering if I could replicate the tool's
behavior myself. I am guessing that they work by attempting a
non-destructive injection attack against your DB and evaluating the success
or failure of that test.

I am curious if a) I'm correct about this, and b) if anyone could suggest a
starting point for a "safe" injection test and an evaluation of the result
using C# / ASP.NET.

Thanks,
-KF



UPDATE #1

Some very useful replies on microsoft.public.dotnet.framework.aspnet. Thanks to Bruce and Mark, both of whom I've seen helping the community a lot with questions great and small.

Bruce writes that "the easiest test is to enter a single ' into each form field. if you get
a sql syntax error on postback you have an open door."

Mark offers the simple syntax in .NET for testing the return of a SQL error; it's just a simple try/catch:

        try
{
// ADO.NET code
}
catch (SqlException ex)
{
// handle the error
}


I am wondering if there are other tests that SQL vulnerability tools do to test for holes.


I will update this post as I develop code that actually does something.


A next step will be to recurse the filesystem for webpages to test. Better would be to a tool that could spider a site, seeking out unique pages. I've never done this, but I suppose I can learn... (anyone have .NET-specific spidering tutorials or suggestions?)



Technorati tags: , , , , , , ,

Comments:
Started thinking about the very same things. Found the following which also relates (plus there already is a design pattern, and some pro-s and con-s for automatic detection). On specific per-site tests (pages < 100) having the user review the processing results of each page is a good solution, at least to start while the parsing rules are worked out.

http://portal.spidynamics.com/blogs/msutton/archive/2006/09/26/How-Prevalent-Are-SQL-Injection-Vulnerabilities_3F00_.aspx