Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Monday, March 28, 2011

SharpDevelop /r mystery

If there is a SharpDevelop way of doing this

"C:\Program Files\Mono-2.4.2.3\bin\gmcs" prog.cs /r:Interop.IWshRuntimeLibrary.dll

(where Interop.IWshRuntimeLibrary.dll is in current directory), then I haven't been able to find out what it is.
I haven't tried it with that specific example, but for more common reference cases it's simply
-reference:System.Windows.Forms
or whatever

Monday, March 14, 2011

SQL Server unique clustered

Supposedly the 'primary key' constraint has the same effect as the 'unique clustered' one. But I have found that using the latter leads to a different execution plan (and much improved execution time) from the former.

Either way, if you're going to insert a lot of records into a temp table or table var, put a unique clustered constraint/index on it by some method.

Thursday, March 10, 2011

Javascript mistakes

Javascript is not Perl! if you mean

document.activeElement.getAttribute('name')

but you put

document.activeElement.getAttribute(name)

name will silently be created and evaluate as an empty string.

Tuesday, March 1, 2011

DOM simulating a click

Simulating a click on a page element:

click = document.createEvent("UIEvents");
click.initUIEvent("click", true, true, window, 1);
worked = theElement.dispatchEvent(click);

So we create an event of type UIEvents, initialise it as a (cancellable, bubbleable) click event, and send it to /theElement/ of our choice.

This method seems clearer than simulating mouse clicks, or focussing the element and simulating a spacebar press. Btw /worked/ is often false when the event was successfully despatched, I suspect I don't quite understand dispatchEvent yet.

(This is just a recipe from reading the Moz createEvent page)

Ruby ++ and --

This is the missing post from Aleksi Niemela explaining why Ruby hasn't got ++ and -- operators:

(1) ++ and -- are NOT reserved operator in Ruby. (2) C's increment/decrement operators are in fact hidden assignment. They affect variables, not objects. You cannot accomplish assignment via method. Ruby uses +=/-= operator instead. (3) self cannot be a target of assignment. In addition, altering the value of integer 1 might cause severe confusion throughout the program.


http://web.archive.org/web/20030901065005/www.ruby-talk.org/blade/2710

Coming from Perl, you've got to watch this: ++a silently does nothing (it's interpreted as two unary plus operators, +(+a) ) and a++ is an error.

ADO and GUIDs

Take note that when using ADO GUIDs come back formatted with enclosing curly brackets. These are NOT part of the GUID and need to be stripped off.

Show Desktop

I'm fed up losing this link - this is the code that should go in the "Show Desktop.scf" file in the toolbar directory:

[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop

Followers

Blog Archive