Alan’s Mind


How to Open a Link in a New Session with IE8

Posted in Development by waissguy on the July 7, 2009
Tags: , , , , ,

There are some occasions when you want to sign into the same site twice with two different user IDs.  For instance you might be developing a new web application and need to compare how the application looks if you’re an administrator vs. a non-admin so you want to sign in twice to compare the two side-by-side.

In IE7 or under, you could simply click a shortcut to start a new instance of IE and the new instance would have its own session, but in IE8, they changed things a bit when they introduced their new process model.  Now all the separate processes share the same session unless you explicitly tell IE to start a new session.

To do this, you open the file menu (press Alt if the main menu isn’t shown) and choose “New Session”.  This opens a new IE window with its own session.  As far as I know, the cookies are kept completely separate.

For those of you who like the command line, you could also run iexplore.exe (located in C:\Program Files\Internet Explorer by default) with the -nomerge parameter.  This also means that you can create a shortcut to start a new instance of IE with a new session.

What I wanted though was to be able to right-click a link and choose “Open in New Session”.  This is a little harder, but turned out to be easier than I thought.  I originally thought I would have to dust off my C++ skills and finally learn to use COM (which I’ve tried my best to avoid), but all I wound up needing was an html file and a registry entry.

First, create an html file.  You can simply right click the folder where you want to create the file and choose New → Text Document, then rename the file to something with an “htm” extension.  I used C:\Program Files\NewSession.htm, though you can use any name or path you want, just make note of it when you create the registry entry.

Then open the file in your favorite text editor (i.e. Notepad) and copy/paste the following:

<script language="javascript">
var a = external.menuArguments;
if(a && (a = a.event) && (a = a.srcElement) && (a = a.href))
{
	var shell = new ActiveXObject("WScript.Shell");
	shell.run("\"C:\\Program Files\\Internet Explorer\\iexplore\" -nomerge \"" + a + "\"");
}
</script>

Then save the file.

Note:  Modifying the registry can be harmful to your computer if you don’t know what you’re doing.  If you’re unsure of yourself or you simply want to be careful, it’s best to ask for help from a friend or associate with knowledge of computers.

Then start the registry editor by holding the Windows key and pressing R, typing regedit in the run dialog and clicking OK.  In the registry editor, navigate to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt and add a new key named Open in New Session.  Click this new key then double-click the (Default) REG_SZ and change the Value data to the path to your html file (e.g. C:\Program Files\NewSession.htm) and click OK.  Then add a new DWORD (32-bit) value named Contexts and modify the value to set it to the hex value 20 (32 in decimal).

That’s it!  you can close the registry editor and restart Internet Explorer.  When you right-click a link, there will be a new option “Open in New Session”.  When you click this option, a new instance of Internet Explorer will open with the URL of the link you clicked.  This new instance will have a brand new session.

Resizing Columns in Word 2007

Posted in Uncategorized by waissguy on the June 15, 2009

This might apply to previous versions of Word as well, but I came across some interesting tidbits related to resizing columns in Word 2007.

When you move the mouse in between two columns and get the column resize cursor, if you resize a column, in the middle of the table, it makes the next column wider as the previous column shrinks.  If you’d rather resize the whole table, hold the Shift key as you resize.

Every now and then you might find that just the one cell resizes rather than the whole column – in this case, make sure the cell isn’t selected – when one or more cells are selected, the resizing only affects the selected cells.

Use JavaScript to get the position of the caret in a Text Box

Posted in Development by waissguy on the May 1, 2009
Tags: , , ,

If you have an <input type=”text” /> on your web page and that element currently is in focus, you can use this cross-browser function to retrieve the current position of the caret/cursor:

function GetCaret(input)
{
	if(document.selection)
	{
		var range = document.selection.createRange().duplicate();
		//moveStart returns the # of characters moved.
		return -range.moveStart("character", -input.value.length);
	}
	else if(input.selectionStart)
		return input.selectionStart;
	return -1;
}

Internet Explorer doesn’t support the selectionStart property used by FireFox (I’ve heard Opera uses selectionStart and I believe Safari does as well) so instead we get the currently selected range via document.selection, use the selection object’s createRange method to create a TextRange object which is what IE uses to manipulate text data. There doesn’t seem to be a direct way to get the position of the TextRange within the parent object, but we can use the moveStart method to move the start point of the range. This method returns the number of characters moved, which happens to be the position of the caret – technically the negative of the position of the caret since you had to move the selection backwards to reach the start.

This method could easily be modified to get the ending position of the selection by using range.text in IE to retrieve the text selected (range.text.length would be the length of text selected) or use input.selectionEnd in other browsers.

How to Rearrange Your Start Menu in Vista without UAC

Posted in Uncategorized by waissguy on the April 10, 2009

I found a good tip at keyliner.blogspot.com that if you give yourself full access to the folders “C:\Users\Public\Desktop” and “C:\ProgramData\Microsoft\Windows\StartMenu”, you won’t get the UAC nags when you rearrange, delete, or customize items in your start menu.  That was a huge annoyance for me since I like a well organized start menu.

World of Warcraft Interface Idea

Posted in Uncategorized by waissguy on the March 26, 2009

Blizzard should release a change where you could right-click on the map and you automatically run to that point.  It would be easy if you were on a flying mount.

The Internet wasn’t built for Media

Posted in Uncategorized by waissguy on the March 25, 2009

Online distribution is increasingly popular these days due to streaming services such as Hulu.  It’s easy to watch what you want, when you want it.  Cloud computing is taking us back to client-server days where the “cloud” (a bunch of servers) do all the computing and you interact with the cloud via a browser.  Now there’s even talk about streaming video games.

The problem with online distribution is that the internet wasn’t built for mass distribution.  Every time you request a video, a separate connection is made and the content is sent to you individually.  For a few users or small requests, this works well and efficiently – the content is only sent to those who request it – but when you look at large numbers of users streaming large video files, the system starts to break down.  Each user is using separate bandwidth whether they’re watching the same file or different files.

In contrast, TV services from your cable or satellite company are broadcast based.  They send the same signal to everyone.  They might use a lot of bandwidth sending all the channels to everyone and within each household, the vast majority of this bandwidth is wasted, however it’s much more efficient for a mass audience because the signal is only sent once.  You can choose to tune in to the broadcast or not, but the bandwidth used it based on the number of channels being sent, not the number of users using the service.

The ideal distribution method would be a combination of the two ideas: Allow each user to request content, but allow download sharing.  Rather than sending each packet to each user individually, send each packet once, but specify multiple addresses so the content can be shared.

Where’s this cool stuff I keep hearing about?

Posted in Trivial by waissguy on the February 18, 2009

A short list of the things I keep hearing about and want the most:

  1. An electric car.  Even better would be a plug-in hybrid that can go around 60 miles on pure electric before needing to start the Internal combustion.  That would mean I could go to work and back on electric-only, yet I could still be able to go on longer trips if needed.  If I can’t have that, I’ll take a small electric car to get me to work and back and keep my current car for those longer trips.  Photovoltaics on the roof would be great too – even if it couldn’t fully charge my car while I’m at work, it would still reduce the amount of juice needed when I plug it in.
  2. A new smart phone.  I haven’t decided which one in particular, but I’d take a 32 GB iPhone, a phone running Windows Mobile 6.5 (like the HTC Touch Diamond2 or Touch Pro2) or one of the new Android phones like the Magic.  I need it now, not in Q2!
  3. A flying car.  I’ve been promised one of these in movies since the 80s.  Where’s my flying car?

We need gender-neutral pronouns

Posted in Uncategorized by waissguy on the October 16, 2008

Who’s in charge of the English language these days?  I’d like to make a suggestion:  Gender-neutral pronouns.  Back in the old days, it was perfectly acceptable to use male programs (he/his) in times when you don’t know the gender of the person you’re referring to.  This is standard practice in many other cultures and languages in modern times as well, but with the politically correct nature of modern English, this is often frowned upon and we’re forced to result to saying and writing “he or she” or “his or her” to refer to a single person.

What I propose is the addition of a few pronouns to refer to these cases.  I’m leaning towards “ve” for the subjective and “vir” for the possessive, though I’m open to suggestions.

Maybe if we all start using these words, they’ll make it into the dictionary.  Wrappers make up words all the time.  Why can’t we make up some that are actually useful?

Listen to what is Said

Posted in Politics, Responsibility by waissguy on the October 16, 2008
Tags: , ,

After watching the debate, as always what stands out in my mind isn’t the policies themselves but the way people hear what is said, apply their own fears, selectively filter other information, and regurgitate it to make it totally different.  I also notice that neither candidate’s plan is correct – the correct answer either lies in the middle, or is addressed by neither.

I admit I may be biased myself, but I find Obama to be the victim of this phenomenon more often than McCain.  An example:

Health Care:  Obama said he wanted to let you keep and reduce the cost of employer-based health care, but if your employer doesn’t offer health care or you don’t like the offered plan, you have the option of enrolling in the government’s plan.  He also wants to introduce mandates that exclude small businesses, but ensure that those that can afford health care plans actually spend the money to get them.

Through filters and fears, this somehow equates to government-run health care.  This simply isn’t true.  What this actually means is reduced cost of health care.  At least on the surface.  The real problems that I notice with his plan are pre-existing conditions and the failure to address the real reason for the high cost of medical care.

I’m not sure on the details with the mandates against exclusion for pre-existing conditions (I advise you to look into them yourself).  If by this, he means that the insurance company must cover your medical needs even if you had the condition before you were covered (though you were likely unaware of the issue), then I agree.  If he’s saying that you must give insurance to someone even though they have a pre-existing (and costly) condition that you do know of, then I have mixed feelings.

The problem with known pre-existing conditions is that the cost of treatment will undoubtably be more than the cost of the insurance – the whole reason it’s called insurance is that it’s something of a gamble.  For most people the cost of the insurance will be much less than the cost the insurance company pays.  This is actually necessary because those that do need insurance will need more than they put in.  Money goes into a pool and is paid out as necessary.  It absolutly should be prevented that an insurance company cut you off if you actually do start needing your insurance.  You’re paying for the assurance of health care coverage, you should get what you paid for.  You “won” the gambit, though you probably don’t see it that way.

The real reason for the high cost of health care however, is the frivolous lawsuits.  I’m not talking about criminal negligence, though I do think that the amount awarded is typically far too high, I’m talking about the cases of honest mistakes.  If a doctor makes an honest mistake or unintentionally misses something, I don’t think a lawsuit is right.  Since your chances if you didn’t go to a doctor were 0%, I don’t see how you can hold a doctor responsible for a mistake.  Again, in cases of real negligence, it’s different.

While on the topic of frivolous lawsuits, that’s a big economic issue too.  One of the reasons everything costs so much is because everyone keeps suing everyone else for ridiculous things.  Judges need to throw these things out at the start before the defendent spends loads of money on lawyers or settles to avoid the cost of a trial.  If people weren’t awarded for stupid lawsuits, they’d stop spending the money on starting them.

Why so serious?

Posted in Photoshop by waissguy on the October 7, 2008
Tags: , , ,

From Photoshopping My Co-workers

This one took some time, but wasn’t as bad as you might think. I started with the original joker picture from the Dark Knight, then added Jake’s head, resizing and rotating it appropriately. As I often do, I then copied the base layer and pasted it on top so I could cut a hole through it and see the head I had added, smudging the edges to blend it correctly. I then had to adjust the colors and levels to make the skin tones match up to the actual skin tones that are really only shown without makeup in the neck. The “makeup” was applied using the paintbrush tool set at about 20% opacity. I used different layers for the white, dark, and red colors in case I screwed up.

You can view all my creations on my Picasa page at http://picasaweb.google.com/AlanWaiss/PhotoshoppingMyCoworkers.

Next Page »