| | Stumble It! | Add to Mixx! | | diigo it | | Slashdot |

Wednesday, December 31, 2008

Stirless coffee

utterli-image
Quick coffee tip - out cream and/or sugar in your cup BEFORE pouring the coffee & you won't need a spoon!

Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

SSH Streaming Media

I hope your Christmas was as good as mine! Five days! I had five days to spend with my family and let me tell you how much I loved that! Unfortunately, Katie's parents couldn't make it due to the snow, but it was still great family time.

And now with New Year's Day off as well, I'm amazed that I'm still able to put on my geek hat and get anything done.

One of the great things about my job is that I can listen to music (with headphones) while I work. Now I'm by no means an audiophile or in possession of a music library ... I don't even own a stereo, but I do likes me some geek solutions.

Until recently, I had stashed an external hard drive at work that held some of my music that I had in a playlist set to loop and random which gave the illusion of my own personal radio station. I wasn't dedicated enough to tote the hard drive back and forth with new music and I didn't want to hassle with anything like Last.fm or other web-based solutions.

Then in a flash of clarity I came up with a solution. My home computer runs an SSH server that I use to tunnel my WiFi connections and I had just read about sshfs, a Linux app that grafts an SSH server's file system into your computer's file system.
SSH server w/ music + sshfs = streaming media server!
It's rediculously easy with a Ubuntu laptop:
  1. Install an SSH server on your home computer.
  2. Install sshfs on your laptop:
    sudo apt-get install sshfs
  3. "Graft" your home computer's file system into your laptop's:
    sshfs username@home.computer.dns:/cygdrive /home/yourusername/sshfs
I've only used this from my laptop at work where I have .amazing. bandwidth, but I didn't notice any lagging, skipping or other connection related problems with actually playing music or video.

<geek>Ubuntu makes me feel warm and fuzzy inside.</geek>

... you'd better be careful home pc, one mis-step and I'm going to toss Windows XP and slap Ubuntu Server on you. If it weren't for my addiction to PC games I would have done so long ago ... but what's this ... WINE you say?

... interesting!

Saturday, December 27, 2008

New Family

utterli-image
Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Meow!

utterli-image
Mark being a kitty.

Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Monday, December 22, 2008

Wish me luck!

utterli-image
The trip home begins...

Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Work, work, work...

utterli-image
After digging & chipping my Civic hybrid out of the snow & ice, I braved the I5 made it all the way to work. I guess that years of driving in Alaska are paying off!

Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Wednesday, December 17, 2008

"Productivity"?

utterli-image
Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Geek much?

utterli-image
Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

Tuesday, December 16, 2008

Fun with playdough

utterli-image
Katie sent me a picture of this playdough dino that she & Mark built.

Sent from my Verizon Wireless BlackBerry

Mobile post sent by bandit36 using Utterlireply-count Replies.

SharePoint Calendar Item Pop-up Preview

This one is going to get a bit technical so if you're not ready to do some high-brain-powered activity, you may just want to pass this one by.

If you ARE looking to put in some effort and thought beyond just copy/pasting, then this may interest you.
The result of this project will make it possible for your users to get quick glances at the details of an event displayed on a SharePoint calendar without having to click the link and look at the page. To do it the way I did, you'll need SharePoint Designer so you can make the pop-up page. Not having SPD doesn't stop you, but it will mean that your event detail pop-ups will look strange.

So, if you're ready, let's begin:
Step 1 - Create the Calendar
  • Hopefully this is already done, but if not then it's time.
  • Make your Calendar list however you need to, but be sure to include a Calculated Column field with .AT LEAST. the following code:
    =CONCATENATE("<tag> <nobr style='font-weight:lighter;'><span onMouseOver=if(event.shiftKey){popUp('xxx')}>",[Title],"</span></nobr>")
  • You're welcome to add any other code you might want for colorification, but this code
  • MUST be included and working.
Step 2 - Create the Pop-up Display
  • In SPD, navigate to the folder where you have your calendar saved, usually it's something like "Lists > calendar".
  • Create a new ASPX file.
  • In the new ASPX file, go to "Insert > SharePoint Controls > List Form..."
  • In the pop-up window, select the calendar list that you are working with, click the "Display item form (used to view list items)" option, and uncheck the "Show standard toolbar" option.
  • You may need to set the style URL to "/_layouts/1033/styles/core.css".
  • Go to "Insert > SharePoint Controls > Web Part..." and add a "Content Editor Web Part" to the bottom of the page with the following code - it will remove the "Close" button and some other unwanted fields (like the "Workspace" field) from being displayed:
    <script type="text/javascript">
    var theTRs = document.getElementsByTagName("TR");
    var r=0;
    while (r < theTRs.length)
    { try
    { strLabel = theTRs[r].innerText || theTRs[r].textContent;
    strLabel = strLabel.replace(/\t/g,"").replace(/\n/g,"");
    if (strLabel.search("cc") == 0 || strLabel.search("Workspace") == 0)
    { theTRs[r].style.display = "none"; }
    }
    catch(err){}
    r+=1;
    }

    var theButtons = document.getElementsByTagName("INPUT");
    var b=0;
    while (b < theButtons.length)
    { try
    { if (theButtons[b].value == "Close")
    { theButtons[b].style.display = "none"; }
    }
    catch(err){}
    b+=1;
    }
    </script>
  • Name this file "popupDisplay.aspx" and remember the URL for where you save this file.
Step 3 - Customize Calendar.aspx
  • Open your browser to the Calendar.aspx page that you've been working with.
  • Go to "Site Actions > Edit Page" in the upper right and add a Content Editor Web Part to the bottom of the page.
  • Click on the "Source Editor..." button and add the following code:
    <div id='popUpDiv' style='display:none;position:absolute;'>
    <div
    onClick='hidePopUp()'
    style='border-style:solid;
    border-width:1px;
    background:red;
    position:absolute;
    top:0px;
    left:456px;
    cursor:pointer;'>
    close(x)
    </div>
    <iframe
    id='popUpFrame'
    frameborder='0'
    src=''
    style='width:520px;
    height:600px;
    border-style:solid;
    border-width:1px'>
    </iframe>
    </div>
    <script type="text/javascript">
    var theTags = document.getElementsByTagName("A");
    var i=0;
    while (i < theTags.length)
    { try
    { TagContent = theTags[i].innerText || theTags[i].textContent;
    if (TagContent.search("<tag>") >= 0)
    { strId = theTags[i].href.substr(theTags[i].href.search("ID=")+3);
    theTags[i].innerHTML = TagContent.replace(/xxx/g,strId);
    }
    }
    catch(err){}
    i=i+1;
    }

    function popUp(x)
    {
    var popUpFrame = document.getElementById("popUpFrame");
    var popUpDiv = document.getElementById("popUpDiv");
    popUpFrame.src = "http://path.to/popupDisplay.aspx?ID=" + x;
    popUpDiv.style.display = "";
    popUpDiv.style.top = "25%";
    popUpDiv.style.left = ((screen.width - 520)/2);
    }

    function hidePopUp()
    { popUpFrame.src = ""; popUpDiv.style.display = "none"; }</script>
  • Be sure to modify the "http://path.to/popupDisplay.aspx" to point to the URL you hopefully remembered from Step 2.
Now when you view the page, just hold the shift key while you hover the mouse over the event title and you should see a pop-up window showing just the details for that event.

Enjoy!

Thursday, December 11, 2008

Popup Google Maps for SharePoint

UPDATED - 10:00am PST, 10 Feb 2009
Thanks in large part to help from George Rhee, I was able to isolate a bug in the code that prevented it from working properly on certain sites. The problem came about if the Maps Link column was the last column on the list and manifest itself by demolishing the columns and formatting of the list. I found a way to prevent this and now it will work regardless of where the column is in relation to other columns in the list.

I've also updated the code so that the maps popup will show up within the body of the page you're viewing. No more having to scroll right and/or down to see your maps!

If you have a list of addresses that you want to create dynamic Google Maps for then this blog's for you! It's actually really easy ... I promise.
Here's how:
  1. You'll need a list that has a column of addresses. For the purpose of this post, I have cleverly decided to use the column name of "Address" to represent my column of addresses. Yes I've had 5 cups of coffee today, why do you ask?
  2. Create another column to hold the links that will open the Google Map. Again, I have cleverly titled this column "Google Maps Link". This column will be a calcuated column with the following code:
    =CONCATENATE("<div style='cursor:hand' onClick='showMap(this, event)'>",Address,"</div><tag>")
  3. At the bottom of the page that will display these addresses, include a Content Editor Web Part with the following code:
    <div id='mapDiv' style='display:none;position:absolute;'>
    <div
    onClick='hideMap()'
    style='border-style:solid;
    border-width:1px;
    background:red;
    position:absolute;
    top:0px;
    left:554px;
    cursor:hand;'>
    close(x)
    </div>
    <iframe
    id='mapFrame'
    frameborder='0'
    src=''
    style='width:600px;
    height:600px;
    border-style:solid;
    border-width:1px'>
    </iframe>
    </div>

    <script type="text/javascript">
    //
    // declare variables
    var theTags = document.getElementsByTagName("TD");
    var i=0;
    var objFrame = document.getElementById("mapFrame");
    var objDiv = document.getElementById("mapDiv");
    var out = document.getElementById("output");
    //
    // write the calculated column into the page code
    while (i < theTags.length)
    { try
    { TagContent = theTags[i].textContent || theTags[i].innerText;
    if (TagContent.substr(TagContent.search("<tag>")) == "<tag>" && theTags[i].className == "ms-vb2")
    { theTags[i].innerHTML = TagContent; }
    }
    catch(err){}
    i=i+1;
    }
    //
    // function to make the map appear at the mouse
    function showMap(obj, event)
    {
    urlMaps = "http://maps.google.com/maps?q=";
    objFrame.src = urlMaps + (obj.innerText || obj.textContent);
    objDiv.style.display = "";
    (event.clientY + 600 > document.body.offsetHeight) ? objDiv.style.top = (document.body.offsetHeight - (event.clientY - 600)) : objDiv.style.top = event.clientY;
    (event.clientX + 600 > document.body.offsetWidth) ? objDiv.style.left = (event.clientX - 600) : objDiv.style.left = event.clientX;
    }
    //
    // function to hide the map
    function hideMap()
    { objFrame.src = ""; objDiv.style.display = "none"; }
    </script>

Enjoy!

Tuesday, December 9, 2008

SharePoint Bookmarklets

I've put together three little JavaScript bookmarklets to help me in my everyday endeavors with SharePoint and thought that I'd share them here.

Open File Explorer
- This link will open a Windows Explorer window showing the contents of the directory that the page lives in that you had been viewing.

Manage Web Parts
- If you've ever broken a web part so much that you can't even remove it from the page, this bookmarklet is for you! This will open the back-end web part management window that will let you manually remove any of the web parts on the page (HT to Dennis Reil).

Edit This Page
- This link will let you add or remove web parts from a page. On normal SharePoint web pages, this link is relatively redundant since you can just go up to the "Site Actions" button and select "Edit Page", but for pages that don't give you that option, this bookmarklet is invaluable.

To use these, right-click on the links and add them to your favorites or bookmarks. Then when you're viewing a page that you want to perform one of these functions on, you simply have to click on the bookmark!

If you have your own, please feel free to share them!

Monday, December 8, 2008

pullOut(hair)

I've been struggling with a BASH script in cygwin for the last couple days that I just could .NOT. figure out. The script was supposed to read a text file as input, run a simple ping command against each entry in the text file, and parse the output into an easily readable report.

I had copy/pasted a couple scripts that worked just fine, but when I typed it in myself, all my arrays had only one element in them. The code was identical, but it wasn't working. I figured it might be execution permissions, but (as far as I can tell) cygwin doesn't worry about that. I figured I was missing a package on the install, but when I ran the commands from the terminal, they all worked.
So this morning, in my desperation, I turned on "Show All Characters" in Notepad++ (my text editor of choice). BINGO! The difference between my code and the code that I copy/pasted is that I had carriage returns and line feeds in my code and there were only line feeds in the code that worked. I was able to correct this by telling Notepad++ to format the text in "Unix Format". After doing this and running the script, my arrays were full of the lines in the text file.

Friday, December 5, 2008

Parse URL Query String with Javascript

UPDATE!!! - I published a better, more elegant way to parse the query string here.

Here is a small bit of JavaScript to help you sort through a query string on a page. For example, say you want to use the variables sent to "State.aspx?s=Utah&id=5&person=Bob", this code will extract those variables and make them usable further down in the code:
<script type="text/javascript">
var aryV = location.search.replace("?","").split("&");
var i=0
while (i < aryV.length)
{ if (aryV[i].indexOf("s=") >= 0)
{ strState = aryV[i].substr(aryV[i].indexOf("=")+1).replace(/%20/g, " ");
strState = strState.replace(/\+/g, " ");
}
else if (aryV[i].indexOf("id=") >= 0)
{ strID = aryV[i].substr(aryV[i].indexOf("=")+1).replace(/%20/g, " ");
strID = strID.replace(/\+/g, " ");
}
else if (aryV[i].indexOf("person=") >= 0)
{ strPerson = aryV[i].substr(aryV[i].indexOf("=")+1).replace(/%20/g, " ");
strPerson = strPerson.replace(/\+/g, " ");
}
i+=1;
}

document.write("<tt>The State is : " + strState + "<br>");
document.write("The ID is : " + strID + "<br>");
document.write("The Person is: " + strPerson + "</tt>");
</script>

Thursday, December 4, 2008

Mass Cisco Device Scanner

I actually got to do some network related work over the last few days and let me tell you how much fun it was! To top it off, I got to flex my (very) rusty BASH scripting muscles.

The Challenge: We need to update the firmware of some of our Cisco network devices.

The Problem: We have MANY of these devices and no current inventory of which devices have what firmware installed (that I know of anyway). So I needed to generate the list of devices that need the update. The simple way is to log into the devices, run a "show version" command and record the firmware version for the device. Repeat that process a couple hundred times and you can see why this is a problem.

The Solution: BASH scripting on Ubuntu Linux. After doing a bit of research & studying other people's scripts to access devices, I managed to pull together a couple scripts to automate the process of logging into a device, running a command, and logging/processing the output. Here's how:
Step 1 - Acquire a list of the devices you want to scan. Put them in the "hosts.txt" file, one per line. You can list them by DNS or IP address.
Step 2 - Put the commands you want to run on the hosts into the "cmds.txt" file. One per line just like you were executing them yourself.
Step 3 - From your Linux box (I used Ubuntu on my EeePC) run the "./ciscoScanner.sh" script like this:
./ciscoScanner.sh USERNAME PASSWORD text|to|find
Step 4 - Monitor the progress in the terminal window.
Step 5 - When the script is done you'll have a file named "[date].scan.log" with only the lines from the fields you put in "text|to|find". You can then parse this in Excel or any other method that's convenient for you.
You can download the scripts in a .zip file here.

I used these scripts successfully on Ubuntu 8.04 (Hardy Heron). You'll need to install the most current version of "expect", "ssh", & "telnet". I did some basic testing with cygwin and met with limited success, though it shouldn't be that difficult to solve for someone with a bit more experience than I.