list page 6 - Dave's Blog

Search
My timeline on Mastodon

Insite | Google’s advanced operators for journalists

2009 Jul 24, 5:29Contains a few operators I hadn't seen, like '~[word]' for results that contains the synonym of the word, '*' for wildcards within quoted phrases, and 'info:[URL]' for their cache results, links to and from the page, etc.PermalinkCommentsvia:sambrook google search operators technical

Blog Layout and Implementation Improvements

2009 Jul 19, 11:44

Monticello, home of Thomas Jefferson, Charlottesville, Va. (LOC) from Flickr CommonsI've redone my blog's layout to remind myself how terrible CSS is -- err I mean to play with the more advanced features of CSS 2.1 which are all now available in IE8. As part of the new layout I've included my Delicious links by default but at a smaller size and I've replaced the navigation list options with Technical, Personal and Everything as I've heard from folks that that would actually be useful. Besides the layout I've also updated the back-end, switching from my handmade PHP+XSLT+RSS/Atom monster to a slightly less horrible PHP+DB solution. As a result everything should be much much faster including search which, incidentally, is so much easier to implement outside of XSLT.

PermalinkCommentsblog database redisgn xslt mysql homepage

RSS Pillow | Boing Boing Gadgets

2009 Jul 1, 6:06Its an RSS logo pillow: looks good! But it does not help you get to sleep by reading New York Times RSS feeds to you...PermalinkCommentshumor rss cute pillow wishlist technical

PowerShell Scanning Script

2009 Jun 27, 3:42

I've hooked up the printer/scanner to the Media Center PC since I leave that on all the time anyway so we can have a networked printer. I wanted to hook up the scanner in a somewhat similar fashion but I didn't want to install HP's software (other than the drivers of course). So I've written my own script for scanning in PowerShell that does the following:

  1. Scans using the Windows Image Acquisition APIs via COM
  2. Runs OCR on the image using Microsoft Office Document Imaging via COM (which may already be on your PC if you have Office installed)
  3. Converts the image to JPEG using .NET Image APIs
  4. Stores the OCR text into the EXIF comment field using .NET Image APIs (which means Windows Search can index the image by the text in the image)
  5. Moves the image to the public share

Here's the actual code from my scan.ps1 file:

param([Switch] $ShowProgress, [switch] $OpenCompletedResult)

$filePathTemplate = "C:\users\public\pictures\scanned\scan {0} {1}.{2}";
$time = get-date -uformat "%Y-%m-%d";

[void]([reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll"))

$deviceManager = new-object -ComObject WIA.DeviceManager
$device = $deviceManager.DeviceInfos.Item(1).Connect();

foreach ($item in $device.Items) {
        $fileIdx = 0;
        while (test-path ($filePathTemplate -f $time,$fileIdx,"*")) {
                [void](++$fileIdx);
        }

        if ($ShowProgress) { "Scanning..." }

        $image = $item.Transfer();
        $fileName = ($filePathTemplate -f $time,$fileIdx,$image.FileExtension);
        $image.SaveFile($fileName);
        clear-variable image

        if ($ShowProgress) { "Running OCR..." }

        $modiDocument = new-object -comobject modi.document;
        $modiDocument.Create($fileName);
        $modiDocument.OCR();
        if ($modiDocument.Images.Count -gt 0) {
                $ocrText = $modiDocument.Images.Item(0).Layout.Text.ToString().Trim();
                $modiDocument.Close();
                clear-variable modiDocument

                if (!($ocrText.Equals(""))) {
                        $fileAsImage = New-Object -TypeName system.drawing.bitmap -ArgumentList $fileName
                        if (!($fileName.EndsWith(".jpg") -or $fileName.EndsWith(".jpeg"))) {
                                if ($ShowProgress) { "Converting to JPEG..." }

                                $newFileName = ($filePathTemplate -f $time,$fileIdx,"jpg");
                                $fileAsImage.Save($newFileName, [System.Drawing.Imaging.ImageFormat]::Jpeg);
                                $fileAsImage.Dispose();
                                del $fileName;

                                $fileAsImage = New-Object -TypeName system.drawing.bitmap -ArgumentList $newFileName 
                                $fileName = $newFileName
                        }

                        if ($ShowProgress) { "Saving OCR Text..." }

                        $property = $fileAsImage.PropertyItems[0];
                        $property.Id = 40092;
                        $property.Type = 1;
                        $property.Value = [system.text.encoding]::Unicode.GetBytes($ocrText);
                        $property.Len = $property.Value.Count;
                        $fileAsImage.SetPropertyItem($property);
                        $fileAsImage.Save(($fileName + ".new"));
                        $fileAsImage.Dispose();
                        del $fileName;
                        ren ($fileName + ".new") $fileName
                }
        }
        else {
                $modiDocument.Close();
                clear-variable modiDocument
        }

        if ($ShowProgress) { "Done." }

        if ($OpenCompletedResult) {
                . $fileName;
        }
        else {
                $result = dir $fileName;
                $result | add-member -membertype noteproperty -name OCRText -value $ocrText
                $result
        }
}

I ran into a few issues:

PermalinkCommentstechnical scanner ocr .net modi powershell office wia

Onion Store - The Sports Team From My Area Is Superior To The Sports Team From Your Area

2009 Jun 25, 12:33A shirt from the Onion store reading 'The Sports Team From My Area Is Superior To The Sports Team From Your Area'. Humor!PermalinkCommentshumor onion tshirt wishlist sports purchase

Linking to or Embedding a Portion of a Video

2009 Jun 19, 10:12

I'm excited by HTML5's video tag as are plenty of other people. Once that comes about and once media fragments are adopted, linking to or embedding a portion of a video will be as easy as using the correct fragment on your URL thanks to the Media Fragments WG who has been hard at work since the last time I looked at fragments.

However, until that work is embraced by browsers, embedding portions of videos will continue to require work specific to the site from which you are embedding the video. On the YouTube blog they wrote about how to "link to the best parts in your videos", using a fragment syntax like '#t=1m15s' to start playback of the associated video at 1 minute and 15 seconds. Of course if you want to embed part of a Hulu video it will be different. Although I haven't found an authoritative source describing the URL syntax to use, you can follow Hulu's video guide on linking to part of a video and note how the URL changes as you adjust the slider on the time-line. It looks like their syntax for linking to a Hulu page is to add '?c=[start time in seconds](:[end time in seconds])' with the colon and end time optional in order to link to a portion of a video. And the syntax for embedding appears to be "http://www.hulu.com/embed/.../[start time in seconds](/[end time in seconds])" again with the end time optional.

For more sites, check out the Media Fragments WG's list of existing applications' proprietary fragmenting schemes.

PermalinkCommentshulu technical media fragment wg url youtube video html5 uri fragment

Existing Technologies Survey - Media Fragments Working Group Wiki

2009 Jun 17, 7:17A list of how some existing sites do URL-fragment-like things.PermalinkCommentsvideo web w3c url uri fragment

YouTube - "Weird Al" Yankovic - Craigslist

2009 Jun 16, 10:41Multiple friends on Facebook posted "Weird Al" Yankovic's Craigslist. Obviously a great topic for a Weird Al song: plenty of room for rhyming arbitrary nouns.PermalinkCommentsvideo humor weird-al doors music music-video youtube psychadelic

Implementations in Web browsers - WHATWG Wiki

2009 Jun 8, 4:56"List of known implementations of HTML 5 in web browsers (list is incomplete, feel free to extend it)"PermalinkCommentsreference browser html ie8 firefox html5 opera whatwg wiki

Category:Astronomical observatories in Washington (U.S. state) - Wikipedia, the free encyclopedia

2009 May 3, 8:07Wikipedia's list of observatories in Washington.PermalinkCommentswikipedia list todo observatory washington tourist

Amazon.com: Shatnerquake: Jeff Burk: Books

2009 May 1, 11:25Seems like this would be a good gift for someone. "...all of the characters ever played by William Shatner are suddenly sucked into our world. Their mission: hunt down and destroy the real William Shatner. Featuring: Captain Kirk, TJ Hooker, Denny Crane, Rescue 911 Shatner, Singer Shatner, Shakespearean Shatner, Twilight Zone Shatner, Cartoon Kirk, Esperanto Shatner, Priceline Shatner, SNL Shatner, and - of course - William Shatner!"PermalinkCommentshumor book gift wishlist william-shatner shatner startrek via:boingboing

What is the best comment in source code you have ever encountered? - Stack Overflow

2009 Apr 21, 1:13List of humorous comments folks have found in source code.PermalinkCommentshumor code programming comment via:scott

Time Travel Essentials - TopatoCo: We Sell T-shirts by the e-Shore

2009 Apr 15, 7:42"If you're like us, you live in constant fear of slipping into a wormhole and getting spit out in the 13th century, and the only real useful knowledge you have for your ignorant ancestors is 'watch out for that Hitler guy' and 'some of the Popes are evil.'" Its like they're inside my head! Love this shirt and poster telling you everything you need to know in case you accidentally fall back in time.PermalinkCommentstime-travel time shirt poster wishlist gift awesome

Awesome Spokesmen Billy Mays and Vince Offer

2009 Apr 8, 4:06
Vince Offer photo from onebutan-iphoneBilly Mays photo from onebutan-iphone

There can be no doubt that infomercial pitchmen Billy Mays and Vince Offer are awesome, but how can I decide which is my favorite?

Infomercial Performance.
Among other things they sell Zorbeez and ShamWow respectively, both of which are absorbant towels so first up I can get a somewhat apples-to-apples comparison on informercials for comparable products. Thankfully someone has created a Vince Offer vs Billy Mays youtube video featuring these informercials.

Billy has an upbeat yell to everything he says while Vince has an endearing condescension to his "You followin' me camera guy?" In the end I must give this one to Vince Offer.

Extracurriculars.
Billy Mays has a new show Pitchmen on the Discovery Channel, a reality show involving folks pitching inventions to the pitchmen Billy Mays and someone else. Vince Offer was arrested for assaulting a prostitute. A clear win for Billy.
Intra-pitchman Interactions.
Billy has challenged Vince to a pitchman-off which on the surface sounds like a point for Billy, but if you listen to the challenge Billy says that Vince attempted to extend the olive branch. Billy Mays calls out Vince on the Adam Corolla Show
PermalinkCommentspersonal2 infomercial stupid vince offer billy mays

Amazon.com: The Complete April Fools' Day RFCs: Thomas, A. Limoncelli, Peter, H. Salus: Books

2009 Apr 8, 10:40A good gift for a particular subset of people I know. "Also has commentary from Limoncelli and some other internet gods. Worth many geek points - full of lulz!!"PermalinkCommentsgift wishlist book ietf reference rfc humor

Thoughts on registerProtocolHandler in HTML 5

2009 Apr 7, 9:02

I'm a big fan of the concept of registerProtocolHandler in HTML 5 and in FireFox 3, but not quite the implementation. From a high level, it allows web apps to register themselves as handlers of an URL scheme so for (the canonical) example, GMail can register for the mailto URL scheme. I like the concept:

However, the way its currently spec'ed out I don't like the following: PermalinkCommentsurl template registerprotocolhandler firefox technical url scheme protocol boring html5 uri urn

Notes on Creating Internet Explorer Extensions in C++ and COM

2009 Mar 20, 4:51

Working on Internet Explorer extensions in C++ & COM, I had to relearn or rediscover how to do several totally basic and important things. To save myself and possibly others trouble in the future, here's some pertinent links and tips.

First you must choose your IE extensibility point. Here's a very short list of the few I've used:

Once you've created your COM object that implements IObjectWithSite and whatever other interfaces your extensibility point requires as described in the above links you'll see your SetSite method get called by IE. You might want to know how to get the top level browser object from the IUnknown site object passed in via that method.

After that you may also want to listen for some events from the browser. To do this you'll need to:

  1. Implement the dispinterface that has the event you want. For instance DWebBrowserEvents2, or HTMLDocumentEvents, or HTMLWindowEvents2. You'll have to search around in that area of the documentation to find the event you're looking for.
  2. Register for events using AtlAdvise. The object you need to subscribe to depends on the events you want. For example, DWebBrowserEvents2 come from the webbrowser object, HTMLDocumentEvents come from the document object assuming its an HTML document (I obtained via get_Document method on the webbrowser), and HTMLWindowEvents2 come from the window object (which oddly I obtained via calling the get_script method on the document object). Note that depending on when your SetSite method is called the document may not exist yet. For my extension I signed up for browser events immediately and then listened for events like NavigateComplete before signing up for document and window events.
  3. Implement IDispatch. The Invoke method will get called with event notifications from the dispinterfaces you sign up for in AtlAdvise. Implementing Invoke manually is a slight pain as all the parameters come in as VARIANTs and are in reverse order. There's some ATL macros that may make this easier but I didn't bother.
  4. Call AtlUnadvise at some point -- at the latest when SetSite is called again and your site object changes.

If you want to check if an IHTMLElement is not visible on screen due how the page is scrolled, try comparing the Body or Document Element's client height and width, which appears to be the dimensions of the visible document area, to the element's bounding client rect which appears to be its position relative to the upper left corner of the visible document area. I've found this to be working for me so far, but I'm not positive that frames, iframes, zooming, editable document areas, etc won't mess this up.

Be sure to use pointers you get from the IWebBrowser/IHTMLDocument/etc. only on the thread on which you obtained the pointer or correctly marshal the pointers to other threads to avoid weird crashes and hangs.

Obtaining the HTML document of a subframe is slightly more complicated then you might hope. On the other hand this might be resolved by the new to IE8 method IHTMLFrameElement3::get_contentDocument

Check out Eric's IE blog post on IE extensibility which has some great links on this topic as well.

PermalinkCommentstechnical boring internet explorer com c++ ihtmlelement extension

XSPF: XML Shareable Playlist Format: Home

2009 Mar 10, 11:31"XSPF is the XML format for sharing playlists." Supported by the Yahoo! Media Player.PermalinkCommentsreference internet xml playlist music opensource

Yahoo! Media Player

2009 Mar 10, 11:26I've seen Yahoo's media player javascript widget around but until I read the dev. instructions I didn't appreciate it. You just include their js file and it finds all your links to mp3s (finer grained and more explicit control available too), adds them to its playlist, and sticks a simple play/pause button on each link.PermalinkCommentsmp3 music ajax design yahoo javascript

The Moth Podcast

2009 Mar 6, 5:36"The Moth, a not-for-profit storytelling organization, was founded in New York in 1997 by poet and novelist George Dawes Green, who wanted to recreate in New York the feeling of sultry summer evenings on his native St. Simon's Island, Georgia, where he and a small circle of friends would gather to spin spellbinding tales on his friend Wanda's porch."PermalinkCommentsmoth podcast humor rss story nyc community
Older EntriesNewer Entries Creative Commons License Some rights reserved.