Friday, June 20, 2008

Will It Blend?

OK, so I found this website and I have to say I think it's pretty dang funny:

Willitblend.com

Basically, this happy looking guy takes everything under the sun and blends it with a blender. It's kind of like watching a trade show demonstration.

Thursday, June 19, 2008

Blogger Blogspot Pages scroll too much

OK, so, I just realized it's entirely possible some people have absolutely no idea why I went to the effort of making the posts script and the sidebar widget. It's simple really, when I read other peoples' blogs I find myself scrolling around like crazy. I hate scrolling, so I decided to come up with a solution to the problem rather than just complain about it.

Now, on this blog, you'll likely still do some scrolling (especially on long posts); however, you won't do as much with the navigation scripts place. It's kind of like tab-navigation for your blog.

http://blog.benfinnigan.com/2008/06/blog-post-navigation-script.html

http://blog.benfinnigan.com/2008/06/interesting-sidebar-widget.html

Blog Post Navigation Widget

I went ahead and tweaked out my sidebar navigation code to provide similar functionality for blog posts.

Here's the code:

<!-- BlogPostNav Widget By Benfinnigan.com /-->
<style type="text/css">
.postnavbutton {
cursor: pointer;
cursor: hand;
margin: 1px;
padding: 2px;
background-color: #ffffff;
color: #000000;
border-style: solid;
border-width: 1px 2px 2px 1px;
border-color: #C0C0C0 #000000 #000000 #C0C0C0;
}
.postnavbutton:hover
{
cursor: pointer;
cursor: hand;
margin: 1px;
padding: 2px;
background-color: #dddddd;
color: #000000;
border-style: solid;
border-width: 2px 1px 1px 2px;
border-color: #000000 #C0C0C0 #C0C0C0 #000000;
}
</style>
<script src="http://benfinnigan.com/js/blogpostnav.js" type="text/javascript"></script>
<!-- End BlogPostNav Widget By Benfinnigan.com /-->

Please give me a link back if you swipe the code and please let me know if you find errors.

Sidebar Navigation Widget



So, I just finished up a little sidebar navigation widget that helps de-clutter the ole blog.

Here's the code:

<!-- Sidebar Nav Widget By Benfinnigan.com /-->
<style type="text/css">
.sidebarnavbutton {
cursor: pointer;
cursor: hand;
margin: 1px;
padding: 2px;
background-color: #ffffff;
color: #000000;
border-style: solid;
border-width: 1px 2px 2px 1px;
border-color: #C0C0C0 #000000 #000000 #C0C0C0;
}
.sidebarnavbutton:hover
{
cursor: pointer;
cursor: hand;
margin: 1px;
padding: 2px;
background-color: #dddddd;
color: #000000;
border-style: solid;
border-width: 2px 1px 1px 2px;
border-color: #000000 #C0C0C0 #C0C0C0 #000000;
}
</style>
<script type="text/javascript">
//<!--
var sidebarid = 'sidebar';
var widgetClassPrefix = 'widget ';
var widgetClassDisqualifier = 'draggable-widget';
var blnsidebaraccordion = true;
// /-->
</script>
<script src="http://benfinnigan.com/js/sidebarnav.js" type="text/javascript"></script>
<!-- End Sidebar Nav Widget By Benfinnigan.com /-->

To add the sidebar navigation widget to your blog follow these steps:



If you play with it, please give me a link on your blog somewhere. If you find errors, please feel free to post a comment.

Wednesday, June 18, 2008

Pure ASP Hashing Function

Found this in some files I'd written a while back:


<% Option Explicit

' TITLE:
' Secure Hash Algorithm, SHA-1
'
' AUTHORS:
' Adapted by Ben Finnigan from VBA code by Iain Buchan
' http://wikisource.org/wiki/SHA-1_hash
' http://www.nwpho.man.ac.uk/Methods/Forms/DispForm.aspx?ID=6&Source=http:%2F%2Fwww.nwpho.man.ac.uk%2FMethods%2FForms%2FAllItems.aspx&RootFolder=%2FMethods
'
' PURPOSE:
' Creating a secure identifier from person-identifiable data
'
' The function SecureHash generates a 160-bit (20-hex-digit) message digest for a given message (String).
' It is computationally infeasable to recover the message from the digest.
' The digest is unique to the message within the realms of practical probability.
' The only way to find the source message for a digest is by hashing all possible messages and comparison of their digests.

' REFERENCES:
' For a fuller description see FIPS Publication 180-1:
' http://www.itl.nist.gov/fipspubs/fip180-1.htm

' SAMPLE:
' Message: "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
' Returns Digest: "84983E441C3BD26EBAAE4AA1F95129E5E54670F1"
' Message: "abc"
' Returns Digest: "A9993E364706816ABA3E25717850C26C9CD0D89D"

Function AndW(w1, w2)
Dim arr(3)
arr(0) = w1(0) And w2(0)
arr(1) = w1(1) And w2(1)
arr(2) = w1(2) And w2(2)
arr(3) = w1(3) And w2(3)
AndW = arr
End Function
Function OrW(w1, w2)
Dim arr(3)
arr(0) = w1(0) Or w2(0)
arr(1) = w1(1) Or w2(1)
arr(2) = w1(2) Or w2(2)
arr(3) = w1(3) Or w2(3)
OrW = arr
End Function
Function XorW(w1, w2)
Dim arr(3)
arr(0) = w1(0) Xor w2(0)
arr(1) = w1(1) Xor w2(1)
arr(2) = w1(2) Xor w2(2)
arr(3) = w1(3) Xor w2(3)
XorW = arr
End Function
Function NotW(w)
Dim arr(3)
arr(0) = Not w(0)
arr(1) = Not w(1)
arr(2) = Not w(2)
arr(3) = Not w(3)
NotW = arr
End Function
Function AddW(w1, w2)
Dim I, arr(3)

I = CLng(w1(3)) + w2(3)
arr(3) = I Mod 256
I = CLng(w1(2)) + w2(2) + (I \ 256)
arr(2) = I Mod 256
I = CLng(w1(1)) + w2(1) + (I \ 256)
arr(1) = I Mod 256
I = CLng(w1(0)) + w2(0) + (I \ 256)
arr(0) = I Mod 256

AddW = arr
End Function
Function CircShiftLeftW(w, n)
Dim d1, d2

d1 = WordToDouble(w)
d2 = d1
d1 = d1 * (2 ^ n)
d2 = d2 / (2 ^ (32 - n))
CircShiftLeftW = OrW(DoubleToWord(d1), DoubleToWord(d2))
End Function
Function WordToHex(w)
WordToHex = Right("0" & Hex(w(0)), 2) & Right("0" & Hex(w(1)), 2) & Right("0" & Hex(w(2)), 2) & Right("0" & Hex(w(3)), 2)
End Function
Function HexToWord(H)
HexToWord = DoubleToWord(CDbl("&H" & H))
End Function
Function DoubleToWord(n)
Dim arr(3)
arr(0) = Int(DMod(n, 2 ^ 32) / (2 ^ 24))
arr(1) = Int(DMod(n, 2 ^ 24) / (2 ^ 16))
arr(2) = Int(DMod(n, 2 ^ 16) / (2 ^ 8))
arr(3) = Int(DMod(n, 2 ^ 8))
DoubleToWord = arr
End Function
Function WordToDouble(w)
WordToDouble = (w(0) * (2 ^ 24)) + (w(1) * (2 ^ 16)) + (w(2) * (2 ^ 8)) + w(3)
End Function
Function DMod(value, divisor)
DMod = value - (Int(value / divisor) * divisor)
If DMod < 0 Then DMod = DMod + divisor
End Function
Function F(t, B, C, D)
Dim casenum
If t <= 19 Then casenum = 1
If t <= 39 And t > 19 Then casenum = 2
If t <= 59 And t > 39 Then casenum = 3
If t > 59 Then casenum = 4
Select Case casenum
Case 1
F = OrW(AndW(B, C), AndW(NotW(B), D))
Case 2
F = XorW(XorW(B, C), D)
Case 3
F = OrW(OrW(AndW(B, C), AndW(B, D)), AndW(C, D))
Case 4
F = XorW(XorW(B, C), D)
End Select
End Function
Function sha1(inMessage)

Dim inLenW
Dim w(79)
Dim temp
Dim A, B, C, D, E
Dim H0, H1, H2, H3, H4
Dim K(3)
Dim arr(3)
Dim inLen, padMessage, numBlocks, blockText, wordText, I, t

inLen = Len(inMessage)
inLenW = DoubleToWord(CDbl(inLen) * 8)

padMessage = inMessage & Chr(128) & String((128 - (inLen Mod 64) - 9) Mod 64, Chr(0)) & String(4, Chr(0)) & Chr(inLenW(0)) & Chr(inLenW(1)) & Chr(inLenW(2)) & Chr(inLenW(3))

numBlocks = Len(padMessage) / 64

' initialize constants
K(0) = HexToWord("5A827999")
K(1) = HexToWord("6ED9EBA1")
K(2) = HexToWord("8F1BBCDC")
K(3) = HexToWord("CA62C1D6")

'initialize 160-bit (5 words) buffer
H0 = HexToWord("67452301")
H1 = HexToWord("EFCDAB89")
H2 = HexToWord("98BADCFE")
H3 = HexToWord("10325476")
H4 = HexToWord("C3D2E1F0")

'each 512 byte message block consists of 16 words (W) but W is expanded to 80 words
For I = 0 To numBlocks - 1
blockText = Mid(padMessage, (I * 64) + 1, 64)
'initialize a message block
For t = 0 To 15
wordText = Mid(blockText, (t * 4) + 1, 4)
arr(0) = Asc(Mid(wordText, 1, 1))
arr(1) = Asc(Mid(wordText, 2, 1))
arr(2) = Asc(Mid(wordText, 3, 1))
arr(3) = Asc(Mid(wordText, 4, 1))
w(t) = arr
Next
'create extra words from the message block
For t = 16 To 79
'W(t) = S^1 (W(t-3) XOR W(t-8) XOR W(t-14) XOR W(t-16))
w(t) = CircShiftLeftW(XorW(XorW(XorW(w(t - 3), w(t - 8)), w(t - 14)), w(t - 16)), 1)
Next

'make initial assignments to the buffer
A = H0
B = H1
C = H2
D = H3
E = H4

'process the block
For t = 0 To 79
temp = AddW(AddW(AddW(AddW(CircShiftLeftW(A, 5), F(t, B, C, D)), E), w(t)), K(t \ 20))
E = D
D = C
C = CircShiftLeftW(B, 30)
B = A
A = temp
Next

H0 = AddW(H0, A)
H1 = AddW(H1, B)
H2 = AddW(H2, C)
H3 = AddW(H3, D)
H4 = AddW(H4, E)
Next

sha1 = WordToHex(H0) & WordToHex(H1) & WordToHex(H2) & WordToHex(H3) & WordToHex(H4)
End Function
%>

If you find it useful, please post a comment letting me know.

Firefox 3.0 DOMI (Dom Inspector) is missing!

So, I went and downloaded Firefox 3.0 on download day. Awesome, much faster JS support. Question I have is where did DOM Inspector go?! Anyway, I found it:

https://addons.mozilla.org/en-US/firefox/search?q=Dom+Inspector&cat=all

The weird thing is that if you don't click the add to firefox button directly from that page you actually get an Add-On not found page that forwards you back to the search page... LAME. Anyway, the one by Shawn Wilsher (sdwilsh) is the right one, Enjoy!

Ceiling Fan Bulb Bases

OK, so I went to the store to buy a light for a fan I have up in my house and lo and behold I'll be darned if Home Depot or Lowes has a light with medium (non-candelabra) bases. I have no idea why these are moving in that direction as I would think a single standard base would be more desirable. Who knows, maybe knuckleheads are burning down their homes putting bulbs in that are over the 60W limit.

Tuesday, June 17, 2008

Firefox Download Day Blues

Today Tuesday 6/17/2008 at 1PM EST Download Day for Mozilla Firefox 3.0 officially started. Since then the spreadfirefox.com site ( http://www.spreadfirefox.com/worldrecord/ ) has been experiencing many of the symptoms of a DDOS (Distributed Denial of Service). What I'm seeing in Firefox 2.0 is "The server at www.spreadfirefox.com is taking too long to respond."

So, in the meantime, if you want Firefox 3.0 and want to be able to download it now, then try browsing to their other download site:

http://www.mozilla.com/products/download.html?product=firefox-3.0&os=win&lang=en-US

Friday, June 13, 2008

Mario Kart is Awesome!

So, we bought a Wii with our stimulus package and I love it! I got out of console gaming because there were getting to be too many buttons on the controllers and I couldn't just sit and play a game. Now, with the Wii I find games intuitive and easy to play again.

Mario Kart is an excellent example of intuitive gameplay... You have a wheel, use it to steer.

Thursday, June 12, 2008

Blogger as my web page

I've had benfinnigan.com for a while now and it's been useful a couple of times, but now it's time to hand over the maintenance to blogger/blogspot. I found I mostly just wanted a blog anyway and kept the web space around for tinkering- I guess now I'll have to tinker on my localhost.