Copy To Clipboard in HTML

or Speed blogging Exposed…
or “Copy as Text Link” and “Copy as Image Link” Blogging Tools explained.

Usually when I post something technical, I include a detailed rambling explaniation of how it does what it does. In the post “Copy as Text Link” and “Copy as Image Link” Blogging Tools” I created a batch file that did some neat stuff. But I didn’t give a full explaination of the details. Now I will.

The batch file did the following neat stuff…
1. Used Environmental variables to create HTML files in a standard Windows directory
2. Dynamically add string and DWord registry entries
3. Demonstrated adding menu items to Maxthon & Internet Explorer (Unfortunatly these do not show up in FF or Opera.)
4. Displayed different contexts based upon what was selected.
5. Launched another IE window that does not effect the output but does process information selected in the first.
6. Demonstrated how to copy HTML source to the paste buffer via HTML and javascript.:
7. Copied text to the clipboard, formatting it into HTML

Not bad for a small batch file.

So, here’s how the magic was done…

First, the easy stuff. The batch file creates two text files. That is done using the redirection symbol (aka the output to file symbol) which is > (aka the Greater Than sign). The Greater than sign appends the displayed results directly to a file. Two greater thans in a row cause the file to be recreated. I use the Echo command to echo (go figure) text to two HTML files I will be creating. Since I use >> in the first line, those files will always be recreated if the batch file is run again.

Because HTML also uses GT and LT symbols, they must be denoted as literal symbols. That is done with the carot symbol ^. Thusly
[dos]
echo ^>%windir%\web\copytextaslink.htm
echo ^

[/js]

As you can see, the bulk of the file is JavaScript. The second line clearly declares it so. However, instead of putting Language=”JavaScript” (which is the old school way of doing things and how I learned originally), I should have specified it as a MIME type like this Type=”text/javascript” The end result is the same, however eventually the old language option will be dropped.

Another option that you might not be familiar with is the defer flag. This is a browser load time optimizer. It tells the browser that the contents of the script will not effect the layout of the page and therefore the browser can continue drawing the page.

The process is also pretty easy to follow because it uses Microsoft’s DOM technology. DOM is the Document Object Module and allows IE to handle all web pages as if it were Object Oriented. You can reference the document and the various parts/divisions of any web page. And that allows you to directly access properties or methods of these objects.

So what the code above does is asks for the document in the parent window (the one in which you right clicked). It then asks for the current selection (if any). It then gets the current selection as text and then asks for the clibboard object for the current window. At that point it is a simple call to SetData and the selected text is added (with a few additions) to the clippboard. There isn’t much more than that. One thing that should be noted is that the type of data in the clibboard must be specified, in this case, as text. You can read more about the other types of data that a clib board can handle in my article about Clipboard manipulation with Delphi HERE:

The second file proceeds much the same way except that it goes further into the DOM and retreives the Height and Width of the original image so that the pasting of the tag in your blog can include that information (most specifically, the aspect ratio.

[js]


[/js]

That’s it for the HTML. The only thing left is to create a couple of triggers to activate those two files. That’s done through the registry.

Internet explorer reads through the registry each time it pops up a menu. It first decides what is clicked and then looks at the registry entries under HKey_CurrentUser\Software\Microsoft\Internet Explorer\MenuExt\ all of the menu items that match the type of selection. MSDN has a full article that explains this in detail HERE, however, the following table is probably all you’ll need:

Context Value
Default 0x1
Images 0x2
Controls 0x4
Tables 0x8
Text selection 0x10
Anchor 0x20

So, the last step of the process is to route the text to the text processing HTML and the img tag source to the image text file.

That’s done in these two lines…
[dos]
reg ADD “HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Image as Lin&k” /ve /t REG_SZ /d “%WINDIR%\web\copyimageaslink.htm” /f
reg ADD “HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Image as Lin&k” /v Contexts /t REG_DWORD /d 2 /f
.
[/dos]

That’s it! You’ve got your full walk through! Any questions?

NOnces have arrived in WP

WordPress 2.03 is a critical security release. It eliminates the HTTP Referrer check and replaces it with a nonce system. What is a referrer check? Well, it is an attempt to confirm that an administrative action is being taken by an administrator instead of an automated bot. It was a good first step, but it didn’t go far enough and it did not work for everyone. Many systems are stripping of the referrer check. So WP2 didn’t initially work for a lot of people. Additionally, referrers, the browser’s way of indiciating where you came from, are easily forged.

Browsers really do tell a website alot about where you came from. For instance, I can tell which search engine people used to get to my site and what their search words were. Then you can use a tool like AWStats to give you a report. For instance, these are the phrases used to reach my website this morning:

Keyphrases used on search engines  
19 different keyphrases Search Percent
hiphopcaucus 2 9 %
menuext javascript 2 9 %
code cave 2 9 %
clipboard from delphi notepad 1 4.5 %
generating nonce with php 1 4.5 %
hiphopcaucus bot 1 4.5 %
timage in delphi 1 4.5 %
test.txt notepad.exe 1 4.5 %
timage assign 1 4.5 %
php5 binary location 1and1.com 1 4.5 %
neat eye [nitaigouranga@aol.com] 1 4.5 %
isbn vs. asin 1 4.5 %
binary blue scheme 1 4.5 %
level mode super gerball 1 4.5 %
event.srcelement.tagname firefox 1 4.5 %
mark edington 1 4.5 %
paste clipboard from delphi to notepad 1 4.5 %
delphi php developer programmer washington dc 1 4.5 %
paste clipboard from delphi notepad 1 4.5 %

That’s kind of neat, but it is a little bit of an invasion of privacy. Well, at least some people would think so. So, referrers are on their way out and Nonces are on their way in.

A NOnce, a Number variable meant to be used Once, is a temporary key that is passed along with the web page and is used to prove that the action taken was initiate from an administrator page. Basicly WordPress generates a unique number for you and passes that to your browser. Then when you take a secured action, your browser must pass it back. It’s another method for the same goal. Aditionally, a NOnce expires. So, even if someone grabbed it, it would soon go bad.

Why is this important? Why should this release be applied? Well, in short, one could pretty easily erase any post on any blog with an earlier version of WP. I’ve worked at creating an attack that could dynamicaly erase all posts at once, but that was blocked due to other difficulties. So the attacks must be made a post at a time, but that is still a pretty big vulnerability.

Now don’t go all APE on WordPress. The fact is that the web is not a secure place. You should backup your DB, no matter what software you use, regularly. And if you don’t, what you lose is your gone because of your own (in)actions. Besides, how many posts have you had that have been vandalized/erased? None? Well, then calm down, install the update and all will be fine.

The latest in the stable 2.0 series, 2.0.3, is now available for download. This is a bug fix and security release, and is recommended for all WordPress users. In addition to an issue that was raised on Bugtraq a few days ago, we’ve also backported a number of security enhancements from 2.1 to further enhance and protect your blog.

If you are interested in how these enhancements to WordPress security came to pass, look into the archives of the WP Hackers email list and you can see some of the details.
This is a good place to start…
http://comox.textdrive.com/pipermail/wp-hackers/2006-April/005666.html
Look for the thread labeled “Rethinking check_admin_referer()” and you can read along php coders (myself included discuss the issue…

Here’s the link for the download: http://wordpress.org/development/2006/06/wordpress-203/
If you want to get a smaller version of it, with only the changed files, go here: http://markjaquith.wordpress.com/2006/06/01/wordpress-203-upgrade-changed-files-zip-changes-diff-changed-files-list/
I haven’t verified his file. So, you should do so on your own, or just bite the bullet and upload the whole release.

I’ll let you know over the next few days how much better this version of WP is.

LG VX5200, LG VX6000, LG VX7000, LG VX8100 stuff

This is a collection of Info I’ve gathered on LG cell phones. Much of it is probably Verizon specific, but some may work with other providers and other phones.

As with any non standard usage of software or hardware, following these instructions could mess up your stuff. If you aren’t confident in what you are doing… don’t do it. If you aren’t willing to fry your phone and have to repurchase one at full price because you’ve just voided your warranty, don’t do this stuff…

If any of this stuff violates your particular contract with Verizon, only do it if you are willing to accept the subsequent fees and consequences. I haven’t tried nor even read through all of this stuff. So there could be a lurker in there that smokes your phone. I don’t know. Use it at your own risk. ’nuff said.

FYI: This post will grow and change… Check back periodicly to see if I ‘ve added anything new…

Continue reading LG VX5200, LG VX6000, LG VX7000, LG VX8100 stuff

Bike through Chernobyl

I found this site ages ago… I don’t know how… but it is pretty wild and sobering… Elena Filatova rides her ZX11 (Kawasaki Ninja) through the area devastated by the Chernobyl disaster.


Elena on her ride through Russia's forbidden zone...
http://www.angelfire.com/extreme4/kiddofspeed/chapter1.html

The pictures tell a story that deepens the chill people get when you hear the name… I’ve never seen pictures like this of the area anywhere other than this site…

Boats...

From inside...

Bumper cars...

A kindergarten...

It looks like she’s added some pictures to the tour and gotten a new url since I last visited… You can get to the top of her site by clicking here:

http://elenafilatova.com/
http://elenafilatova.com/

“Copy as Text Link” and “Copy as Image Link” Blogging Tools

Justin of JustInsomnia had a great idea for a FireFox plug in:

I want to be able to copy a quote and its URL at the same time, without having to so much as think about it. To do so, I wrote my first Firefox extension, which I opted to name the somewhat homely, Copy as HTML Link.

So he created Copy as HTML Link for Firefox and generously shared his moment with wp-hackers Subscribers .

The plugin looks good and he did a really good job documenting it (THIS IS RARE!):

Click to go to the original site.

I must say that since I’ve started using this method, it’s been a quite a time saver. This was a GREAT idea. Inspired! So, if you have FireFox, please head on over there and get that plug-in!

Ah, but here’s the fly in the ointment and the sand in my… socks: A Firefox plugin won’t work for Maxthon!!!! (Click to go to the original site.) or Internet Explorer!

You see, Firefox just doesn’t do it for me. Click to go to the original site. Opera comes darn close to being right, but I like the extra usability features in Maxthon.

So, I thought… Hey… I could do that for Maxthon and IE AND I could do it all from a BATCH file!

So, here it is…

Run this Batch file and you will have installed on your system, two new menu items. When you highlight text, you’ll have an option to “Copy as Link” and when an image is right clicked, you will get an option to “Copy Image as Link”. Hopefully I’ve chosen hotkeys that will work well for you… If not, you can change them in RegEdit at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\

BTW EVERY image and link up to this point in this post was created using this tool. Man, Good idea Justin!

Also – If you find that IE is prompting you asking for permissions to open the links, please post a comment and I’ll show how to fix that. I’ve gotten that message on other things I’ve like this I’ve created and know how to get past it. I’ve disabled that workaround on this computer and I am not getting that “Are you sure” message. So these menu items should be safe. ALSO, some popup blockers may block these items. You might have to add localhost as a site that is allowed to show popups in your particular popup blocker. Let me know if you have any problems.

Here’s the download: http://www.TheCodeCave.com/downloads/batch/AddCopyAsLink.bat

Here is the source:
[DOS]
@echo Off
:: Implements “Copy * as Link” menu items in IE and Maxthon
:: Written by Brian Layman
:: Visit me at: http://www.TheCodeCave.com
:: Version 0.1
:: Update Url: http://www.thecodecave.com/?p=152
:: Inspired by Justin’s Firefox Plubin
:: Found at: http://justinsomnia.org/2006/05/copy-as-html-link-for-firefox/

:: Create file for the Copy Text as Link
echo ^>%windir%\web\copytextaslink.htm
echo ^

Delayed Posting in WordPress

Has anyone else noticed that you can publish posts and not yet have them appear on the website?

If you choose “Edit Timestamp” and set the date to a time/date in the future before you hit publish, can you make your posts appear the next morning even if you are no where near the computer. Right now, as I am writing this, I have hmmm 3 or 4 posts that will just appear some time in the future.

Let’s make this appear…. Hmmm tomorrow at 1pm.

Kinda cool!

What is that “Friend Search” thing?

You may not have noticed it, but I’ve started an “Friend Search” page.

I’m thinkin’ that since every now and then I search for my own name to see what is out there about me, others probably do the same. So, maybe, just maybe, some of the people I’ve lost track of over the years might find my site and drop in and say “Hi!”

So, here it is:
Friend Search
The following are people I’d LOVE to get in touch with again, just to say “Hi!”. Posting this is somewhat risky. Please don’t be offended if you are not on this list. It doesn’t mean that you were/are not a dear friend. It probably just means that I have some idea of where you are and what’s been happenning with your life. There are many friends I’ve actually researched and for which I’ve discovered public history. So those are not on this list, but they are still important to me…

It’s also likely people on this list are tied emotionaly to other significant events in my life. For instance, many here are tied to Adventure Camp at Jumonville. So, when I think of adventure camp, I think of them.
Pastor John Logan
Jennifer Marie (Carr) Rabaey
Matthew (Matt) Hildebrand
Elizabeth (Beth) Hildebrand
The Cornerstone Crusaders
Adventure Campers – and Jumonville staff from 86-90 era
Michelle (Camp) Croyle FOUND!!!

————————————–
This page is VERY much under progress and will be edited and updated over time. Hopefully the search engines will revisit it or I’ll have to come up with another scheme that gets it refreshed… Every now and then I’ll repost this to get the search engines to dig back into that page and resurface it in the search results…

Developer Studio 2006 World Tour

This is where I’ll be on May 31 down in Columbus… Anyone else gonna be there?


Developer Studio 2006 World Tour in Europe, Asia/Pacific and the Americas – May/June 2006 – by David Intersimone

Abstract: Borland is going on tour to show the advanced usability and productivity offered by Delphi 2006’s new tool-set. We’ll also discuss the latest initiatives that are making Borland and our developer community bigger, better, and stronger than ever.
Join David Intersimone, “David I”, Borland’s Vice President of Developer Relations and Chief Evangelist, and other Borland developer tools team members at this quarter’s Developer Studio Worldwide Road Show. Seminars will be taking place in Europe, Asia/Pacific, and the Americas. The Road Show will also be an opportunity to discuss all of the latest initiatives that are making Borland and our developer community bigger, better and stronger than ever.

Developer Studio Key Features Include:
Enterprise Core Objects III (ECO™ III) Framework – includes valuable enterprise application services, such as object-relational-mapping and transparent object persistence, saving the time and complexity of building and maintaining custom services
Enhanced Visual Component Library (VCL) – provides easy graphical user interface (GUI) development with a large selection of GUI components, with auto-positioning and customisable guidelines
Extended IDE / ALM Integration – allows you to take control of the development lifecycle process by leveraging integration with leading Borland ALM products
“Live Templates” System – enables you to tab through fields and insert points of any template, significantly accelerating coding productivity

Why You Should Attend:
The Road Show is a unique opportunity to put yourself ‘in the know’ and:

Learn about great new technologies that will make a big difference to you and your users/customers
Discover exactly how Borland’s continuing investment in IDEs is building an even brighter future for the developer community
Meet and talk with the people shaping the future of the technologies that you know and love

What Will Be Covered:
The Road Show half-day agenda will be as follows:
Borland/Delphi update
IDE overview and Developer productivity
Break
Moving Delphi Client/Server applications to multi-tier
Build and run model Driven Software

MORE INFO FROM THE EMAIL…

—–Original Message—–
From: David I [mailto:davidi.bdn@borland.com]
Sent: Friday, May 19, 2006 8:02 PM
To: Brian Layman
Subject: Your place has been reserved

Your place has been reserved for:

Wednesday, May 31st 2006
Registration from 9.00am – Seminar starts 9.30am

We look forward to seeing you there.

David Intersimone
Borland

—–Original Message—–
From: David I [mailto:davidi.bdn@borland.com]
Sent: Friday, May 19, 2006 1:02 PM
To: Brian Layman
Subject: Join the Borland Developer Tools Group “Developer Studio 2006 Road Show” in Columbus – May 31st, 9:30am

Join the Borland Developer Tools Group “Developer Studio 2006 Road Show” in Columbus – May 31st, 9:30am
———-

Wednesday, May 231, 2006 – 9:30am to 1:00pm
Renassiance Hotel
50 N. 3rd Street
Columbus, OH 43215

Borland Presenter – Anders Ohlsson

The road show is designed to update you on the advanced new features of Delphi 2006. The Road Show is a unique opportunity to put yourself ‘in the
know’ and:
a) Learn about great new technologies that will make a big difference to you and your users/customers,
B) Discover exactly how Borland’s continuing investment in IDEs is building an even brighter future for the
developer community,
C) Meet and talk with the Thank you for registering for the Developer Studio 2006 Road Show.

Your place has been reserved for:

Wednesday, May 31st 2006
Registration from 9.00am – Seminar starts 9.30am

We look forward to seeing you there.

David Intersimone
Borland
Date and Location:

Wednesday, May 31st 2006 – Colombus, Ohio
Renassiance Hotel
50 N.3rd St
Wednesday, May 31st 2006
Tel: (614) 267-7300

people shaping the future of the technologies that you know and love.

What Will Be Covered:
1) Borland/Delphi and the “DevCo” spin-off update,
2) IDE overview and Developer productivity, 3) Moving Delphi Client/Server
applications to multi-tier,
4) Build and run model Driven Software

.
.0Registration/sign-in starts at 9am. The presentation starts at 9:30am and lasts for approximately three hours.

For more information and to register, use the following URL:

http://208.109.7.163/html/borland_inside/landing.htm

LEGAL NOTICES
———-
Legal notices covering this email message, software
documents, files and information are available at
http://www.borland.com/company/legal_notices.html

Borland Privacy Policy (effective date: August 31, 2004)
http://www.borland.com/company/privacy.html

———-

CANCELLING SUBSCRIPTION

To cancel your subscription to Borland Developer Network News, click on the following hyperlink:
https://community.borland.com/cgi-bin/login/nonews.cgi?BE09CCBM7H7CAL

Towel Day, May 25, 2006

You sass that hoopy Douglas Adams? Now there’s a frood who knew where his towel was. You are invited to join your fellow hitchhikers in mourning the loss of the late great one. Join in on towel day to show your appreciation for the humor and insight that Douglas Adams brought to all our lives.


Towel Day, May 25, 2006


What do I do?

Carry your towel with you throughout the day to show your participation and mourning.

When do I do it?

May 25th.

Where do I do it?

Everywhere.

Why a towel?

To quote from The Hitchhiker’s Guide to the Galaxy.
A towel, it says, is about the most massively useful thing an interstellar hitch hiker can have. Partly it has great practical value – you can wrap it around you for warmth as you bound across the cold moons of Jaglan Beta; you can lie on it on the brilliant marble-sanded beaches of Santraginus V, inhaling the heady sea vapours; you can sleep under it beneath the stars which shine so redly on the desert world of Kakrafoon; use it to sail a mini raft down the slow heavy river Moth; wet it for use in hand-to-hand-combat; wrap it round your head to ward off noxious fumes or to avoid the gaze of the Ravenous Bugblatter Beast of Traal (a mindboggingly stupid animal, it assumes that if you can’t see it, it can’t see you – daft as a bush, but very ravenous); you can wave your towel in emergencies as a distress signal, and of course dry yourself off with it if it still seems to be clean enough.

More importantly, a towel has immense psychological value. For some reason, if a strag (strag: non-hitch hiker) discovers that a hitch hiker has his towel with him, he will automatically assume that he is also in possession of a toothbrush, face flannel, soap, tin of biscuits, flask, compass, map, ball of string, gnat spray, wet weather gear, space suit etc., etc. Furthermore, the strag will then happily lend the hitch hiker any of these or a dozen other items that the hitch hiker might accidentally have “lost”. What the strag will think is that any man who can hitch the length and breadth of the galaxy, rough it, slum it, struggle against terrible odds, win through, and still knows where his towel is is clearly a man to be reckoned with.


Please join me in celebrating Towel Day. And feel free to share pictures either here or at http://www.towelday.kojv.net/

Update: Well, what do you know? Will Wheaton celebrates Towel Day too! More on Will later…(And yes, somehow since I’m on a first name basis with Wesley (Crusher of Star Trek: The Next Generation), as any true geek is, I’m on aparently on a first name basis with Will…)

Congratulations on the Twins Brian Layman of North Canton, Ohio!

No, that’s not me. But I do have interaction with this fellow! See we live in the same county and have the same middle initial. We probably live within 5 miles of each other. Almost definately 10.

So, if I go to the Stark County library, I have to be very specific when I don’t have my card with me. Or if I hit the Blockbusters to the south instead of to the north, I have to watch which account is being accessed. Additionally, I’m sure others searching for me on the web have found him and visa versa.

Anyway, he and his wife just had twins in April, 2006!
“Juliet Ake-Layman and Brian Layman of Canton, twins, son and daughter.”
http://www.cantonrep.com/index.php?ID=282218&Category=births&r=2

Congratulations oh twinned named one. I wish you all the best.

This is the second (not counting me) Brian Layman I’ve met. My mother used to be babysit by a “Bryan Lehman” in Johnstown, Pennsylvania. Kind of funny that way.