mysqlguy.net

Friends

Google Drove by My House – Street View added for Rochester, NY

sim.plified.com - June 12, 2008 - 6:03pm

 Street view has been added to Google Maps in Rochester, NY.  This adds a whole new level of helpfulness in finding places online. 

Categories: Friends

Use jQuery to fix code that sucks

sim.plified.com - June 12, 2008 - 3:35pm

If you’re working inside of an institutional structure chances are you occasionally have to deal with code that sucks.  I know I do!  We have some third party apps at the institution where I work.  I believe they were designed in the early 90s before anyone knew the word “standards” or “css” and have not been revisited.  While working on one of these code bases I had the idea of using jQuery to remedy my brow furrowing. 

Problem

No IDs or class names on the the template code.  The templates were static and I didn’t want to do a global find and replace to try and fix the problem. 

jQuery to the Rescue

With jQuery’s selector support, I decided that I could use that to add the vital css, classes or ids I need to make the layout work.  Example:

1: $(document).ready(function(){ 2: // standard document formatting 3: $("BODY DIV:first").css("width", "800px").css("margin", "0 auto 0 auto"); 4: });

Instead of injecting css directly, I could have added a class and added my styling in the stylesheet like this:

1: $(document).ready(function(){ 2: // standard document formatting 3: $("BODY DIV:first").attr("class", "fixthishoriblecode"); 4: });

There you have it.  As simple as including the jQuery library and adding some lines of JavaScript. [of course is javascript is turned off, this is not going to work.. but I didn’t say this was a miracle solution for fixing your bad code, just a patch]. 

If you’ve had to deal with these types of code bases, share your story below of how you fixed the problem.

Categories: Friends

More about Simon

sim.plified.com - June 8, 2008 - 8:36am
Look Alike

When Simon was in the bouncy seat last night I thought I was having déjà vu.  I looked up and there was a picture of Caleb from about the same time up on the boy’s bookcase.  I brought it down and put it next to him. 

It might be hard to see in the picture, but he was a spitting image of Caleb.

Home on Day 1!

Amy and I were not eager to spend time in the hospital.  After doing this three times already, we have come to realize that there is “no place like home.”  We were very pleased to get the cooperation of the midwife, pediatrician and nurses so that we could bring Simon home on the day of his birth (it certainly helped that he was born at 5:30am in the morning).   Amy spent most of the day sleeping and feeding and we were able to be home at 5pm and eat around our dinner table.  In fact, after dinner we went outside and the boys declared they were having a “birthday party” for Simon.  Caleb even asked to have cake (which I might have gotten if I didn’t think I would have fallen asleep at the wheel). 

Always learning about the system

Whenever we interface with the hospital system there are always some interesting things to learn.  For one, the nurse said that Amy was the first person to check in and out on the same shift.  I’m not for rushing out of the hospital if you really are in need of assistance, but it’s evident that the hospital would love for you to stay a bit longer than you need (in the words of our nurse “if we don’t provide you with services we can’t bill you for anything”).

While Amy was in the room, the nurse came in and asked Amy to “lean forward so she could check her back.”  Amy did so, not realizing why she was being asked.  The nurse was astonished to find no wound from an epidural needle.  The nurse informed Amy that 95% of births at their hospital are performed with epidurals, making it a matter of habit to check women’s backs.

It is interesting to correlate these two pieces of information.  Epidural = longer labor and hospital stay = big fat hospital bill to the insurance company.  I wonder how many people who choose differently if they were footing the bill personally? 

Categories: Friends

A New Son and a New Name

sim.plified.com - June 7, 2008 - 3:06pm

First an introduction.  Simon Jacob Pollock was born on June 6, 2008 at 5:30 in the morning.   [This is where weight and height would be inserted.. but I’m not really sure why people give those stats, so I’m leaving them out.]  He looks just like a Pollock.  Below is his very first picture.

Now for the story of his name.

Simon’s name was not always to be Simon Jacob.  Just a day earlier it was to be Simon Clayton.  Clayton was a family name and so initially we thought it made a fine middle name for Simon.  The hours surrounding his birth would change all that.  On June 5th we traveled to be with friends who were celebrating the death of you their young son Jacob.

I say celebrated, and not mourned, because celebration definitely characterized the event.  The Fahmer’s believe, as do I, that a child who has not sinned is not subject to the demands of the Law and therefore the Wrath of God (not the case for the rest of us who have knowingly transgressed the commands of our loving heavenly Father).  It was a celebration because he is in heaven where he continually get’s to behold the face of the Lord Jesus and is free from the suffering that characterized his short life (138 days).

Jacob Fahmer was born with Trisomy 18, a life shortening condition (you can read his whole story here).  His life was short, by God’s own choosing, but it was not without value or significance.  He, like,all creatures made in the image of God, brought a certain reflection that is not limited by length of days. For one, the Fahmer’s life has forever been changed, by the gift of his life.  Secondarily, I believe (and you can read testimony for yourself in this post and in others on Jacob’s blog) that people have been caused to consider their lives and their God.   What other purpose and hope can one have?!  What else is lasting and enduring, than to have the effect of causing people to reflect on their standing with the Eternal God.?!

As we celebrated Jacob’s “home going” my wife began to experience the pangs of labor.  We gathered our children, said a few quick goodbyes and headed home (a hour and 15 minutes away).  On the way back, we could see that labor was beginning to set in. My wife’s contractions were becoming regular instead of fading away.  At one point I looked over to my wife and said “If we have this child tonight I want to call him ‘Simon Jacob’”.  My wife gave a quick nod of agreement.

Why the change?

I don’t believe in coincidence.  I believe that God orders our days, our death, and our birth.  It was not a mistake that my wife went into labor at Jacob’s funeral.  It was God’s plan.  It’s not just the timing of the event that leads me to see God’s hand, but also my understanding of God.  God brings life and death together.  He did it when His Son was crucified.  Jesus’ death brought forth eternal life.  The Creation testifies about this every day.  You have to be blind not to see that God has ordered death to life.  Plants & Animals that die and fall into the ground and nourish the next generation.  A simple walk through the woods could teach this to the attentive eye.  All through the Creation death and life are caught up together to point us to the revelation of Jesus’ death on the Cross and Resurrection three days later.

This is the story I want to characterize my life and the life of my family.  The story of Jesus’ death and resurrection.  He is embedding that story in our lives, even through the simple “happenings” of life.  Jacob’s death.. Simon’s life have been tied together in a narrative that God is writing.  I am happy simply to see it, acknowledge it, and worship because of it.

Simon Jacob – because God brings life out of death.

Categories: Friends

jQuery Edit in Place Implementation

sim.plified.com - May 20, 2008 - 7:40am

For PatternTap.com we wanted to use some edit in place functionality to allow users to change their name, location, etc.  I used jQuery to create our own implementation of edit in place. 

Here is an example of the markup for the input box (I have left out the server side coding that renders this markup):

<li class="first"> <span class="pro_label">Name:</span> <span id="update_real_name"><span class="editThis">[Users Name]<span class="edit_mark">edit</span></span></span> </li> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

The edit mark span is something that provides visual feedback to the user that the area is editable.   What is inside the "editThis" span is what will be edited.   The span that surrounds the both of those pieces serves as a place holder, so that the input can be swaped in and out of the DOM.

Here is the JavaScript that binds to the item and makes it editable.

$(document).ready(function() { bind_update(); // bind this on page load }); function bind_update() { // find all the editThis elements and find this functionality $('.editThis').bind("click", function(e){ // remove the edit_this mark $(this).children(".edit_mark").remove(); // capture some information about the selected element var parentId = this.parentNode.id; var editType = this.parentNode.className var revert = this.innerHTML; // check to see if this is a textarea or inputbox // note the save and cancel buttons are added along with the input or textarea if (editType == "textarea") $('#' + parentId).html("<textarea id=\"input_" + parentId + "\" >" + revert + "</textarea> <button onclick=\"update_value('" + parentId + "', true);\" value=\"Save\" >Save</button> <a id=\"cancel_" + parentId + "\" href=\"javascript:void(0);\">Cancel</a>"); else $('#' + parentId).html("<input type=\"input\" id=\"input_" + parentId + "\" value=\"" + revert + "\" onblur=\"\" /> <button onclick=\"update_value('" + parentId + "', true);\" value=\"Save\" >Save</button> <a id=\"cancel_" + parentId + "\" href=\"javascript:void(0);\">Cancel</a>"); //set the focus on the newly embedded input box $("#input_" + parentId)[0].focus(); $("#input_" + parentId)[0].select(); //bind the cancel functionality to the cancel button $("#cancel_" + parentId).click(function() { update_value(parentId, revert); }); }); } // this function sends the updated value back to the server function update_value(id, update) { if (update == true) { result = $('#input_' + id).val(); $.ajax({ type: "POST", url: "/people/change_user_profile/", data: "user_id=<?=$user['id']?>&field=" + id + "&value=" + result, error: function() { alert("There was a problem, please let us know.") } }); } else { // in the case of a cancel, update is the "revet" value result = update; } $('#' + id).html("<span class=\"editThis\">" + result + "<span class=\"edit_mark\">edit</span></span>"); bind_update(); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

 

I'm sure there are slicker ways to do this, but this certainly did the job for us.

Of course when you send the data to the server you are going to want to authenticate the user to make sure they are who they say they are.  This will prevent people from hacking the JavaScript and changing someone elses information. 

Technorati Tags: jQuery,AJAX
Categories: Friends

Finally.. Group Chat in Google Talk for the Desktop

sim.plified.com - May 14, 2008 - 3:49pm

I'm a beta nut.. I love the latest and greatest in an app.  Finally I found an edition of Gtalk that allows me to do group chat on the desktop component.  It's available from Google Labs: Click here to download.

Categories: Friends

Communion Hymn - Gather at the Table

sim.plified.com - May 10, 2008 - 2:16pm

My friend William Gucker (Bill) has written anther hymn.  This one if focused on communion and what it means to shre in the body and blood of Jesus together.  It is sung to the tune of "The First Noel".

Gather at The Table

At the table of the Lord, where the brethren meet.

     There's the heart of assembly, and fellowship sweet.

To know, and to be known. To declare where you stand.

     Pilgrims must walk together in this foreign land.

 

Our bodies are clean, yet we still wash our feet.

     We're aware that our sins may cause sickness or sleep.

Confess, repent, keep your conscience clean.

     Bless-ed is the pure heart, for the Lord shall be seen.

 

We remember through the bread, where the Lord of Lords led.

     His body was broken, follow me he said.

Rejoice and do not fear, to carry your cross.

     On the day of redemption you'll suffer no loss.

 

In the wine we see the blood, of a covenant made.

     Forgiveness of sins and a debt that was paid.

One cup is shared by all, and all are made one.

     Keep watch o'er your brother, so says the Son.

 

Heavenly marriage that is forged, groom coming for bride.

     An early taste now of what God will provide.

Dining all together now, a love feast so sweet.

     Eternally joyful at our saviors feet.

 

Technorati Tags: hymns,hymnody
Categories: Friends

Speed Up Web Browsing with OpenDNS Shortcuts

sim.plified.com - May 9, 2008 - 7:10am

A couple of months back I started using OpenDNS, a DNS service that offers a number of nice services. One that I have just started to utilize more is the shortcut feature. OpenDNS allows you to define short cuts that you can type right into the address bar of your browser.  The great part of using OpenDNS for shortcuts is that they are browser and system independent.  So on any browser on any computer connected on my network (OpenDNS is setup in the router), I can access my URL shortcuts.

I've started to add more short cuts to those commonly accessed urls.  Its very easy to setup:

So looking above you can see in order to get to gmail, all I have to do is type "g" in the URL address bar.

Filtering

Another nice thing about OpenDNS is the filtering service.  If you're one of those people who doesn't enjoy naked people showing up on their computer (expectedly or unexpectedly), OpenDNS is a nice way to filter your Internet connection from all sorts of nasty stuff.   If you have kids who can get near a computer and pound away on the keyboard, you will definitely want to consider this service. 

Technorati Tags: Shortcuts,OpenDNS,Productivity,Filtering
Categories: Friends

Dirty, Dirty, Dirty… Implementing IsDirty with JavaScript

sim.plified.com - May 7, 2008 - 3:06pm

Sometimes when a user is editing a page, you want to let them know that if they click on a link or a section of the main navigation that they will lose their changes. 

Here's a quick walk through on an IsDirty implementation I did with jQuery and ASP.NET.

Add this hidden field somewhere on your page

<input type="hidden" id="dirty" value="" /> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Here is the JavaScript that will manipulate the value.

 

<script src="js/jquery-1.2.3.min.js" type="text/javascript"></script> <script type="text/javascript"> window.onbeforeunload = checkExit; function confirmExit() { // this value will be return as a part of the confirmation message return "If you have made any changes to the fields without clicking the Save button, your changes will be lost."; } function checkExit() { if ($("#dirty").val() == "true") { return confirmExit(); } } function setDirty(changeVal) { $("#dirty").val(changeVal); } function confirmAndClean(msg) { setDirty(false); return confirm(msg); } </script> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

The only thing that remains it to make sure that you call these JavaScript client functions in the appropriate places.

With ASP.NET I would do something like this:

ddlCategoryPage.Attributes.Add("onclick", "setDirty(true);"); txtTitle.Attributes.Add("onkeyup", "setDirty(true);"); btnSavePage.Attributes.Add("onclick", "setDirty(false);"); btnCancelPage.Attributes.Add("onclick", "return confirmAndClean('Any changes you have made will be lost. Are you sure you want to cancel?')"); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

When I save the page I set the dirty var false so that the user is not prompted.  When the dropdown or title on the page is edited I set the dirty var to true.  The cancel button calls a function that clears the dirty var and displays a custom confirmation box.

With standard HTML I could call the functions like this:

<input type="text" onkeyup="setDirty(true)" /> <input type="submit" value="Save" onclick="setDirty(false)" /> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Seems to work like a charm so far.  Hope this helps you out.  If you have questions, do not be afraid to shoot me an email or post a comment.

Technorati Tags: JavaScript,ASP.NET,C#
Categories: Friends

19th Ward (Westside) Farmers Market

sim.plified.com - May 7, 2008 - 2:30pm

This notice went out on an email list today.  Here are the details I said I would announce when they became available:

The market in our neighborhood will celebrate opening day on June 17th!!!!!!

It will be called the Westside Farmers Market, serving the westside neighborhoods, as well as anyone else interested in shopping with us. Many westside neighborhood organizations have been involved in the start-up. It will be located in St. Monica's parking lot. The Wilson students are working on a logo now, and you will soon start to see sandwich boards, etc. Applications have been received from fruit and vegetable growers, nurseries. There is the possibility of homemade pasta, meat, jams, ice cream, baked goods. We hope to enjoy entertainment by local musicians, and gather for fun every Tuesday from 4:00 - 8:00 PM.

Technorati Tags: Rochester NY
Categories: Friends

Package Files for Zip Download with ASP.net

sim.plified.com - May 1, 2008 - 2:47pm

In some of my other posts I've talked about an application I have built that accesses the Flickr API and provides campus administrators with a filtered view of the images in our Flickr account. 

One of the features of this site is a photo bucket where users can "mark as favorite" certain images.  I have now included a function that allows them to download all of their favorite photos in a zip file. 

Dependencies:

This app utilizes the SharpZip Library - available here.

Props:

This tutorial was particularly helpful for me - click here.  Although my implementation is quite different.

Basically the user clicks on a button and the zip file presents itself for download

Markup:
<asp:LinkButton ID="lbDownload" runat="server" OnClientClick="$(this).html('Creating Zip File… this may take a moment')">Download All Images (.zip)</asp:LinkButton> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Note that I am using jQuery to handle some client feedback.

 

Code Behind:
Public Function CreateZipOfFavorites(ByVal intUserId As Integer) As String Try 'Get list of users favoriates from the database Dim dsFavs As DataSet = UserFavorites(intUserId) If Not IsNothing(dsFavs) Then 'Zip filename will be a simple datetime string Dim strNow As String = String.Format("{0:MMM-dd-yyyy_hh-mm-ss}", System.DateTime.Now) 'Create the Zip library Dim myZipStream As New ZipOutputStream(File.Create(HttpContext.Current.Server.MapPath("./Zips/") + strNow + ".zip")) 'This is the Photo object that comes from the FlickrNet.dll Dim myPhoto As PhotoInfo 'Loop through the favorites and add them to zip For Each drFav As DataRow In dsFavs.Tables(0).Rows 'Grab the files from flickr myPhoto = myFlickr.PhotosGetInfo(ImageGetFlickrId(drFav("pc_id"))) 'Sycronously grab the data (note, large files will take time) Dim fileClient As New Net.WebClient() Dim dataBuffer As Byte() = fileClient.DownloadData(myPhoto.OriginalUrl) 'Put the images into the zip library Dim zipEntry As New ZipEntry(myPhoto.PhotoId & "." & myPhoto.OriginalFormat) myZipStream.PutNextEntry(zipEntry) myZipStream.Write(dataBuffer, 0, dataBuffer.Length) Next 'Clean up and close up myZipStream.Finish() myZipStream.Close() 'Return the file name Return strNow & ".zip" Else 'Return blank if no zip is created Return "" End If Catch ex As Exception myErrorHandler.Exception = ex myErrorHandler.DefaultHandler() Return "" End Try End Function   Protected Sub lbDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbDownload.Click Dim fileZip As String = CreateZipOfFavorites(myPhotoCentral.UserGetId(Session("LogonUser"))) If fileZip <> "" Then Session("FlashMessage") = "Zip file created." Response.ContentType = "application/force-download" Response.AppendHeader("Content-disposition", "attachement; filename=" & fileZip) Response.TransmitFile("Zips/" & fileZip) Else Session("FlashMessage") = "Zip file creation failed." End If End Sub .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

 

That's about it for the implementation.  It's pretty straight forward.  Let me know if you have comments or questions.

Categories: Friends

"WHERE OR" in LINQ using "Contains"

sim.plified.com - April 18, 2008 - 11:34am

In on of my recent implementations I was looking to loop through a series of categories and then find all the jobs in those categories and add them to a the results list.  The most logical way of doing this would have been to "Where OR" a bunch of items together.  LINQ however does not contain a "WhereOr" operator.  Instead I was able to implement by 1) shoving the selected items into an integer array, and then 2) Using the "Contains" command to filter down the job/category link table.

Here's a code snippet:

'If the category selection method is selected then filter the jobs. If rblCategories.SelectedValue = "Some" Then 'Get all the categories and throw them into an array. Dim CategoryIdList As New ArrayList() For Each li As ListItem In cblCategories.Items If li.Selected Then Dim intCategoryId As Integer = li.Value CategoryIdList.Add(intCategoryId) End If Next 'Cast the array list into the an array of integers Dim intCategoryIdList As Integer() = CType(CategoryIdList.ToArray(GetType(Integer)), Integer()) 'Filter the category List Dim categories = From c In dbCareerServices.LQ_TBL_JOBS_TO_CATEGORies Select c categories = categories.Where(Function(ct) intCategoryIdList.Contains(ct.int_category_id)) 'Now filter the job list result = result.Where(Function(j) categories.Any(Function(c) c.int_job_id = j.int_job_id)) End If .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

 

If anyone knows of a better way to get similar results with LINQ, please let me know.

Technorati Tags: LINQ,ASP.NET,VB
Categories: Friends

CheckBoxList as and Unordered List (CSS Stylable)

sim.plified.com - April 18, 2008 - 11:02am

The CheckBoxList control in ASP.NET is great because the control handles all the data for you.  However, if you want to enhance the UI a little bit the control is left wanting for sure.  This led me to do some searching for CheckBoxList alternatives.  I came up with two blogs posts (one here, the other here) that recommended creating a Custom Server Control that encapsulated the CheckBoxList inside of an unordered list. I went this route and the results were fantastic:

I used the Server Control to change the CSS Class of the enclosing list item when the item is selected.  That allowed me to apply some nice CSS styling to to any item that was selected.  (As a side note the entire block is enclosed in an UpdatePanel, so clicking the options changes the data below dynamically).

I have enclosed my code for my custom server control below.  I borrowed from the the two blog posts above, but added some additional data to account for "AutoPostBack" and the applying CSS Styling to the selected item.  I'm am also making the compiled DLL available for download here.

Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Text Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace edu.roberts.its.CustomWebControls <DefaultProperty("Text"), ToolboxData("<{0}:ULCheckBoxList runat=server></{0}:ULCheckBoxList>")> _ Public Class ULCheckBoxList Inherits CheckBoxList Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) Controls.Clear() Dim inputFormatString As String = "<input id={0}{1}{0} name={0}{2}{0} type={0}checkbox{0} value={0}{3}{0} {4} {5} />" Dim labelFormatString As String = "<label for={0}{1}{0}>{2}</label>" If (Not MyBase.CssClass Is Nothing AndAlso MyBase.CssClass <> "") Then writer.WriteLine("<ul class=""" & MyBase.CssClass & """>") Else writer.WriteLine("<ul>") End If For index As Integer = 0 To Items.Count - 1 Dim inputBuilder As New StringBuilder Dim labelBuilder As New StringBuilder Dim checked As String = "" If (Items(index).Selected) Then checked = "checked=""checked""" End If 'Add selected class to the list item if the checkbox is checked. writer.Indent += 1 writer.WriteLine("<li class=""" & IIf(Items(index).Selected, "selected", "") & """>") writer.Indent += 1 Dim postbackScript As String = "" If MyBase.AutoPostBack = True Then postbackScript = String.Format("onclick=""javascript:setTimeout('__doPostBack(\'{0}\',\'\')', 0)""", MyBase.UniqueID & "$" & index.ToString()) End If inputBuilder.AppendFormat(inputFormatString, """", MyBase.ClientID & "_" & index.ToString(), MyBase.UniqueID & "$" & index.ToString(), Items(index).Value, checked, postbackScript) labelBuilder.AppendFormat(labelFormatString, """", MyBase.ClientID & "_" & index.ToString(), Items(index).Text) writer.WriteLine(inputBuilder.ToString()) writer.WriteLine(labelBuilder.ToString()) writer.Indent -= 1 writer.WriteLine("</li>") writer.WriteLine() writer.Indent -= 1 Next writer.WriteLine("</ul>") End Sub End Class End Namespace .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Technorati Tags: ASP.NET,CheckListBox,Server Controls,CSS
Categories: Friends

CushyCMS and UserVoice - found two great web applications in the same day

sim.plified.com - April 11, 2008 - 7:40am

Paying attention to my daily feeds I found a new web application called CushyCMS.  CushyCMS allow users to edit web content WITHOUT the necessity of installing any third party CMS software on the server. For existing sites and small projects this seems life a fabulous tool.  It seems to be be dead simple to use and setup.  I watched the 5 minute intro and found out most of what I needed to know!  On the technical side, the designer/developer simply includes a class on any of the DOM objects that he or she wants the editor to be able to edit.  CushyCMS parses the contents (accessing your site through FTP) and only allows the editor to edit the content areas you have designated.  Seems sharp, and easy to use.

When providing some feedback about CushyCMS I found that they were utilizing another new web application called UserVoice.

UserVoice looks like a simple bug tracking and user feedback program that allows the user to tell you what problems are most important to them.  I had a few problems logging in the first time, but other than that, the program seems to work well, allowing even anonymous users to vote on which issues they are seeing as problems or features that need to be added.  When developing my next web application, I may look to this app to get at my user base.

Technorati Tags: CushyCMS,UserVoice,CMS,User Feedback
Categories: Friends

Worm Hotel… Composting with Worms

sim.plified.com - April 10, 2008 - 9:14pm

Well since we have 3 boys (soon to be 4) we thought it only appropriate that we get well aquatinted with things slippery and slimy.  Actually, it was my wife who wanted to make the dive (or should I say squirm) into Vermicompost.  Now we have a hotel for worms in our backyard and lots of happy residents chowing down on our daily food scraps.   We have several small garden plots on our postage stamp size lot in the city, so I'm sure the ROI for compost is about 20 years at price it took us to build our hotel and populate it.  Cynicism aside, I have no doubt that the worm bin will not only provide us with some good compost, but hours on fun for our masculine element.  Check out the pictures below.  If you want to build your own hotel, here is one basic set of instructions.

Our New Hotel

 

New Residents.. wait.. maybe not.

 

The Real New Residents

Technorati Tags: compost,vermicompost,worms
Categories: Friends

Parsing URLs from Flickr Descriptions

sim.plified.com - April 10, 2008 - 8:52pm

PatternTap had its beginnings in flickr.  Instead of transferring all that data by hand, flickr's API allows us to access the data very nicely.  Unfortunately, the source URL for each images was not in a separate field, but in the general description field.  I wrote the following PHP function to parse the last URL out of the description and return it as a string.

// Returns the last URL in an HTML description // Input: HTML description // Output: URL string function return_url_from_description($desc) { $url = ""; $doc = new DOMDocument(); // shove the description in the dom $doc->loadHTML($desc); // search for anchor tags $a_tags = $doc->getElementsByTagName("a"); for ($i = 0; $i < $a_tags->length; $i++) { // get the href attribute of the anchor tag $url = $a_tags->item($i)->getAttribute("href"); } return $url; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
Categories: Friends

Creating Calendar Event Callouts for the ASP.NET Calendar Control

sim.plified.com - March 31, 2008 - 11:56am

Story

I needed to revamp our campus calendar and found a great css/javascript calendar callout implementation while browsing Squared Eye's UI gallery (soon to become Pattern Tap).  I wanted to do a similar implementation, highlighting the individual event, instead of the whole day.

My Version

Here is the visual end result of my calendar callout:

The date (or date span) appears in the header with a close button.  The event name, time, details, link and location are included in the box. At the bottom there is a permalink to the event in case people want to link directly to the Event information.  Click here to see the live implementation(Note: the calendar was still not live at time of blog article publication)

ASP.NET Implementation

I implemented this through a combination of the ASP.NET calendar control, some Ajax call backs, and the jQuery Javascript library.  I'll try to cover the basics of the implementations and point out the pitfalls I had to overcome below.

The events are show in the calendar day through implementing the DayRender event of the ASP.NET Calendar Control.  I loop through the events, add them to a string builder and then output that string into the control. 

... For Each dayEvent In events … myString.AppendFormat("<div id=""" & myEvent_ID & "_" & e.Day.DayNumberText & _ """ class=""event""><a href=""javascript: showEvent(" & myEvent_ID & _ ",'top','" & rightOrLeft & "', " & _ e.Day.DayNumberText & ")"" class=""e"">" & DisplayedLink & _ strDisplayedCalName & DisplayedTimeRange & "</a>{0}</div>", strEditLInk) Next 'Write the Event Info to the cell e.Cell.Controls.Add(New LiteralControl(myString.ToString())) .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

You can see that I have not included all my code, but you can see that each event is surrounded by an anchor tag that called the showEvent() javascript function.  This function passes a unique identifier of the event, how to display the box (e.g. top, bottom, left, right) and then the day number (needed to included day number because some events span multiple days with the same event number.  The day tells the javascript function which event in the UI to show the call out next to.

Javascript Functions

Here is the showEvent() function

function showEvent(id, posV, posH, day) { $('.event').attr("class","event"); $('.eventDetail').hide(); $('#' + id + '_' + day).attr("class","event eventSelected"); var myClass = 'eventDetail'; if (posV == "bottom") { myClass = myClass + " bottom"; } else { myClass = myClass + " top"; } if (posH == "left") { myClass = myClass + " left"; } else { myClass = myClass + " right"; } $.ajax({ type: "GET", url: "callbacks/ajaxcalendar.aspx?cmd=showEvent&id=" + id, success: function(htmlContent) { $('#' + id + '_' + day).append("<div id='hover_" + id + "_" + day + "' class='" + myClass + "'>" + htmlContent + "</div>"); } }); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

First thing it is resets the classes.  This has the effect of closing another callout box if one is currently open.  Then the currently selected callout is selected (given the class "eventSelected").  Additional classes are added to the event to tell the box where to render in relationship to the event.

The event id is then used to make an ajax callback to get the details of the event (this prevents a large amount of data having to be loaded into the DOM on page_load()). 

To close the call out there is a very simple call that resets all the classes on the event objects.

function closeEvent() { $('.event').attr("class","event"); $('.eventDetail').hide(); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

 

CSS

The CSS if very important in this implementation because it controls how the callouts are displayed.  An interesting bug I ran into while working on this is the IE 6/7 z-index bug that has been exceptionally well documented by Aleksandar Vacić.

Here is the important CSS

.event { position: relative; z-index: 1; font-family: Arial, Verdana; font-size: 9pt; line-height: normal; font-weight: normal; margin: 0; padding:0; } .eventSelected { color: #fff; background-color: #b22222; z-index: 2; } .eventSelected a { color: #fff; } .eventDetail { position: absolute; width: 290px; border: 5px solid #b22222; color: #333; background: #fff; z-index: 999; } .eventDetail .eventContent { padding: 10px; } .eventSelected .eventDetail .eventContent a { color: #b22222; } .eventDetail .eventHeader { background-color: #b22222; padding:0 0 6px 0; color: #fff;} .eventDetail .eventHeader a { display: block; float: right; } .eventDetail .eventFooter { text-align: right; margin: 5px 0 0 0; padding: 0; } .eventDetail h1 { margin: 0; padding: 5px 0 5px 0; font-size: 1.4em; line-height: normal;} .eventDetail h2 { margin: 0; padding: 0; font-size: 1.2em;} .eventDetail h1 IMG { border: 0; padding: 0 5px 0 0; } .top { top: 0; } .right { right: -300px; } .bottom { bottom: 0px; } .left { left: -300px; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

You can see that the z-index of event and eventSelected needs to be set differently.  This compensates for the IE6/IE7 z-index bug, ensuring that the event detail does show on the top of future events.

That's about the scope of it.  Please post any questions or comments you have.

Special thanks to Matthew Smith of Squared Eye who advised me on the layout.

 

Technorati Tags: ASP.NET,Calendar Control,jQuery
Categories: Friends

A Hymn of our Age - Governance

sim.plified.com - March 30, 2008 - 7:30pm

Today I had the privilege of hearing and playing a new hymn that I believe captures a keen prophetic word to the church of our age.

This song is sung to the tune of Come Thou Fount of Every Blessing

Governance
Written by William J. Gucker

Holy Spirit come and bind us, baptize us in your body
Though the Church has many members, we can live in unity
Make us people with one judgment, with one spirit, and one mind
Guard our souls from worldly wisdom, it is your way we would find

There’s no elder who serves as Moses, Jesus came to set us free
We are governed by the Spirit, walking in him we agree
There is one Lord, undivided, there is one truth, one way
We must learn to abide in him, so we are not led astray

Survey the world around you, it may tempt you to despair
Satan seeks to find a foothold, Jesus’ body he will tear
Keep your eyes upon the scriptures, walk by faith, and not by sight
Do not fear, your strength will fail you, live in resurrections’ light

Fleshly men suppressing knowledge, build their strongholds all around
Marching faithful, sound a clear note, and their walls will tumble down
Waiting for the second coming we shall know as we are known
What was dim will come to light and we shall reap what we have sown

In a day where the attractive leadership of individuals is often substituted for the oneness, unity and brotherhood of believers this is a much needed song!

For those of you familiar with hymnody, the tune name is Nettleton and the meter is 8.7.8.7.D. If you have an interested in contacting the author, let me know an I can put you in touch with him.

Categories: Friends

Some insight..

sim.plified.com - March 29, 2008 - 11:42am

Here is some insight into what us web developer type people do all day.

Categories: Friends

T-SQL Loop through SELECT Statement

sim.plified.com - March 28, 2008 - 10:22am

I recently changed the a data structure in calendar program and needed to move some data around.  Normally to do this I would write an external app to query the database and rewrite the data.  This time I decided to try using T-SQL.  It worked great.  Below is my code:

DECLARE @Event_ID int DECLARE my_cursor CURSOR FOR SELECT Event_ID FROM ITS_CALENDAR_EVENTS_LIST WHERE EVENT_SA_Flag = 1 OPEN my_cursor FETCH NEXT FROM my_cursor INTO @Event_ID WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO ITS_CALENDAR_EVENTS_TO_FLAGS (Event_ID, Event_Flag_ID) VALUES (@Event_ID, 1) FETCH NEXT FROM my_cursor INTO @Event_ID END CLOSE my_cursor DEALLOCATE my_cursor .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Technorati Tags: T-SQL,SELECT,LOOP
Categories: Friends

MySQL

Yahoo

Recent comments

About Me

Jay Janssen
Yahoo!, Inc.
jayj at yahoo dash inc dot com

MySQL
High Availability
Global Load Balancing
Failover

View Jay Janssen's LinkedIn profileView Jay Janssen's Facebook profile

User login

Friends

Links