Notebook



Ran across a very nice collection of 1900x1200 wallpapers on Hamad Darwish's personal web site. Apparently he is the Flickr photographer commissioned to shoot Windows Vista wallpapers. Anyways check out the wallpaper. I got the link from another very-Vista web site, istartedsomething.com.

If you're into wallpapers, checkout a previous post of mine.


February 26 2007
Comments [0]
Filed under:


I occasionally get questions on how I do my thumbnail images for my photo gallery. This site runs on ASP.NET and the photo section automatically creates thumbnails of JPEG images on the fly. In the real world, a web site like flckr.com wouldn't work if thumbnails were always created on the fly, but for my small amount of pictures it works just fine. Below is the code that creates a scaled thumbnail from a JPEG path and writes it back to the browser. This code is used within an HTTP handler that just serves thumbnails.

A couple points of interest. The code encodes the thumbnail at 75% quality. If the original image is smaller than the requested width and height, it won't scale it but will send it to the browser.

 

   1:  Public Sub ScaledImage(ByVal Path As String, ByVal Width As Integer, ByVal Height As Integer)
   2:      Dim originalWidth As Integer
   3:      Dim originalHeight As Integer
   4:      Dim image As bitmap = bitmap.FromFile(Path)
   5:   
   6:      originalHeight = image.Height
   7:      originalWidth = image.Width
   8:   
   9:      Dim heightRatio As Double = CDbl(originalHeight / originalWidth)
  10:      Dim widthRatio As Double = CDbl(originalWidth / originalHeight)
  11:   
  12:      Dim desiredHeight As Integer = Height
  13:      Dim desiredWidth As Integer = Width
  14:   
  15:      Height = desiredHeight
  16:      Width = Convert.ToInt32(Height * widthRatio)
  17:      If Width > desiredWidth Then
  18:          Width = desiredWidth
  19:          Height = Convert.ToInt32(Width * heightRatio)
  20:      End If
  21:   
  22:      If Height > originalHeight Or Width > originalWidth Then
  23:          Height = originalHeight
  24:          Width = originalWidth
  25:   
  26:          image.Save(Response.OutputStream, ImageFormat.Jpeg)
  27:      Else
  28:          Dim thumb As Graphics
  29:          Dim bitmap As bitmap = New bitmap(Width, Height)
  30:          thumb = Graphics.FromImage(bitmap)
  31:          thumb.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
  32:          thumb.DrawImage(image, 0, 0, Width, Height)
  33:   
  34:          Dim codec As ImageCodecInfo = GetEncoderInfo("image/jpeg")
  35:   
  36:          Dim eps As EncoderParameters = New EncoderParameters(1)
  37:          eps = New EncoderParameters
  38:          eps.Param(0) = New EncoderParameter(Encoder.Quality, CLng(75))
  39:   
  40:          bitmap.Save(Response.OutputStream, codec, eps)
  41:   
  42:          thumb.Dispose()
  43:          bitmap.Dispose()
  44:          eps.Dispose()
  45:      End If
  46:      image.Dispose()
  47:   
  48:      Response.ContentType = "image/pjpeg"
  49:      Response.End()
  50:  End Sub
  51:   
  52:  Public Function GetEncoderInfo(ByVal MimeType As String) As ImageCodecInfo
  53:      Dim myEncoders() As ImageCodecInfo = ImageCodecInfo.GetImageEncoders()
  54:      Dim myEncoder As ImageCodecInfo
  55:      For Each myEncoder In myEncoders
  56:          If myEncoder.MimeType = MimeType Then
  57:              Return myEncoder
  58:          End If
  59:      Next
  60:      Return Nothing
  61:  End Function

Works for me.

February 26 2007
Comments [0]
Filed under:


Hashing is a reproducible process to calculate a hash value from some data. The hash values are unique and specific for the data it was derived from. Wikipedia has a good explanation of hashing. i will be showing some VB.Net code in this article that uses the SHA1 algorithm to do some hashing.

Hashing by itself does nothing to prevent tampering with the data. Message Authentication Codes (MAC) are a way to prevent this. MACs use symmetric encryption methods to protect the sent hash. Symmetric encryption uses one private session key and both the sender and receiver require to have a copy of this key.

Below is the VB.Net code to generate a MAC using HMACSHA1:

   1:  Imports System.Security.Cryptography
   2:   
   3:  Public Shared Function ComputeHash(ByVal Data As String, ByVal Key As String) As String
   4:      ' initialize the keyed hash
   5:      Dim sha1Algo As New HMACSHA1(System.Text.Encoding.ASCII.GetBytes(Key))
   6:   
   7:      ' compute hash 
   8:      Dim hash As Byte() = sha1Algo.ComputeHash(System.Text.Encoding.ASCII.GetBytes(Data))
   9:   
  10:      ' convert to string and return
  11:      Return System.BitConverter.ToString(hash)
  12:  End Function
  13:   
  14:  Public Shared Function VerifyHash(ByVal Received As String, ByVal Data As String, ByVal Key As String) As Boolean
  15:      ' hash our data
  16:      Dim hash as String = ComputeHash(Data, Key)
  17:      
  18:      ' compare strings
  19:      Return (Received = hash)
  20:  End Function
  21:   

This code was derived from a more in-depth article: Hashing, MACs, and Digital Signatures in .NET.


February 21 2007
Comments [0]
Filed under:


Yesterday Steve was telling me about something that happened to him at the local Ruby Tuesday. He was saying his wife ordered a grilled chicken salad and the waiter accidentally brought a fried chicken salad instead. To Steve and his wife, it was no big deal. It was a big deal to the restaurant's manager. He came over immediately, explained how quality and customer satisfaction is important to the restaurant. He assured them that the new meal was on it's way out and insisted that the meal be removed from the bill. Steve would kill me if I didn't explain that he wasn't looking for any kind of reimbursement or even an apology, but the manager made it happen anyways. Steve was impressed and passed the news on to at least three other people and will probably tell even more.

I read an article this morning from Joel on Software that talks about the same things and in fact explains a similar situation with his company and Lands' End. Check out the article, it's relevant to any software company (or any company that supports customers for that matter).


February 20 2007
Comments [0]
Filed under:


Our team is headed back to good old Lancaster County today. Things will be back to normal on Monday with momentum building for the first SalesWorks release. Until then there are a couple things you can do to help us get SalesWorks out the door.

1. You can download Beta 1 from the Mission Research web site and send us any feedback you have.

2. Read and contribute to the SalesWorks Beta blog.

3. Stay tuned to my Mission Research CTO blog. My team is responsible for building SalesWorks and now that we have a beta launched I will be covering it and the impending release in that blog.

4. Read up on more SalesWorks stuff on Steve Fafel's blog. He is the dev team's head honcho and will most likely show some cool stuff that can be done to extend SalesWorks.


February 02 2007
Comments [0]
Filed under:


I was forwarded a great writeup on SalesWorks. Jim Forbes writes about "Demo 2007's Tasty Treats" and about a quarter of the way through he talks about the software and the opportunity he sees for it in the small business marketplace.

"Salesworks is a great set of tools that fits tongue and groove with an emerging critical CRM tools for small business professionals"


February 02 2007
Comments [0]
Filed under:


The SalesWorks demo went well and is now online. Here are some links to the Demo bloggers...

Conferenzablog - Demo07: Opening Morning Session

InfoWorld - Demo update - the tech keeps getting better

InformationWeek - Demo '07 Conference Showcases

PCMag - SalesWorks Could Make Sales Less Work

Here is one quote I liked the best...

"SalesWorks looks like it could be the next-gen Salesforce.com application, bringing a new level of ease – and offline – use."

Right now these are blogs are just reporting on the demo itself. Soon we should have some feedback on the actual beta which can be downloaded now. This is an early beta and will change based on feedback we get. Please try it and let us know what you think.


February 01 2007
Comments [0]
Filed under:


Flickr Show

Past Articles


Ads



Other Links

Search


Article Tags


Photo Links

giftworks clown
fungus tools