Thursday, May 30, 2013

Epic Paddling Carnage

Like lambs to the slaughter, one by one, rafts get sucked into this hole and paddlers go for a swim. Check it out . . . Couldn't stop laughing.

Saturday, April 13, 2013

What keeps a train on the tracks? How sure are you?


What keeps a train on the tracks? Yeah, right, that flange on the inside of the wheels. Obvious right?

Wrong.

What I like about this information is not just how the truth of the matter, despite it having seemed obvious to me since I was a kid, is incorrect, but how the truth of the matter is so subtle and elegant and beautiful.

And isn't this always the pattern of discovery?  And how many other much more complicated truths do I hold that might be debunked by subtle, elegant, and beautiful re-understanding?  Lots, I hope.

First seen at www.boingboing.net

Tuesday, April 02, 2013

Monday, April 01, 2013

Capital Punishment

The prosecution is seeking the death penalty for James Holmes, the protagonist in the Aurora movie theater shootings last summer.  This raises in my mind the issue of capital punishment, and since I have a blog and a few minutes to kill...

If murder is wrong, then murdering a murderer is wrong.  If murder is illegal for citizens, murder should be illegal for the state.  The state has a right to defend itself, but incarceration is a sufficient self-defense, and I don't believe there should be state sanctioned vengeance for families and loved ones of victims. 

We don't assault those found guilty of assault.  We don't steal from those caught stealing.  We don't sexually offend sex offenders.  There is no sense to me in employing a punitive act which is itself the crime we are punishing.

To me, these things are self evident.

Friday, February 15, 2013

Access Developer Extensions: Specify data type for Additional Registry Settings, Value parameter

I'm deploying my first MS Access 2007 runtime database using the Access Developer Extensions add-in, but code won't run on target machines because the Trust Center->Macro Setting is "Disable All Macros".  I need "Enable All Macros" or my database VBA code won't run, and there is no way to set this using Access in a runtime file, OMG, what am I going to do?!?

Yeah, tweak the registry, and ADE makes this easy with the Additional Registry Keys section on page three of the setup wizard.  Here are the keys I want to set ...
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security [VBAWarnings] = dword:000001
... and ...
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations [AllowNetworkLocations] = dword:000001
... but where I got stuck is how to specify the data type of the Value parameter.  The registry needs a REG_DWORD value or it has no effect.  So after much googling I finally found the solution here at UtterAccess posted by Mr. Albert Kallal, who refers us back here to a useful Microsoft page.

And since this is the kind of info I'll use infrequently enough to forget, here's the secret.
Prefix #x
The value is interpreted and stored as a hexadecimal value
(REG_BINARY).

Prefix #%
The value is interpreted and stored as an expandable string
(REG_EXPAND_SZ).

Prefix #
The value is interpreted and stored as an integer (REG_DWORD)
But it's a secret, OK.  So don't tell anybody.

Monday, January 21, 2013

MS Word 2007: Hide Content Control Placeholder Text During Printing

Here's the code, which goes in the ThisDocument module of the stylesheet you'll be using.

Private WithEvents m_wd As Word.Application
Private m_showingPlaceholders As Boolean

Private Sub Document_Open()
   Set m_wd = Application
   m_showingPlaceholders = True
End Sub

Private Sub m_wd_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
   Dim cc As ContentControl
   For Each cc In Doc.ContentControls
      If cc.ShowingPlaceholderText Then cc.Range.Font.Color = wdColorWhite
   Next
   m_showingPlaceholders = False
End Sub

Private Sub m_wd_WindowSelectionChange(ByVal Sel As Selection)
   Dim cc As ContentControl
   If Not m_showingPlaceholders Then
      For Each cc In Sel.Document.ContentControls
         If cc.ShowingPlaceholderText Then cc.Range.Font.Color = wdColorBlack
      Next
      m_showingPlaceholders = True
   End If
End Sub


So when the document opens, the Word.Application object is assigned to a WithEvents variable that allows us to handle application events in the stylesheet.

Then we handle the DocumentBeforePrint event, which provides a document object, Doc, which has a ContentControls collection, which we enumerate, and wherever the ContentControl.ShowingPlaceholderText property is true, we set the color of the text to white.  We also set a flag to indicate that placeholders are hidden.

After printing we handle the WindowSelectionChange event which is bound to occur when the user interacts with the document.  First we check our flag to see if the PlaceholderText is still hidden.  If so, we get our ContentControls collection from the Document object in the Selection object, Sel, that the WindowSelectionChange event provides.  We enumerate that collection and again, wherever the ContentControl.ShowingPlaceholderText property is true we set the color back to black.

Wednesday, January 09, 2013

Sunday, January 06, 2013

Wednesday, December 19, 2012

Kid who got snatched by eagle

EagleShitYouNot From 9gag.com in response to this hoax video.

Guns, WTF.

Guns are obviously great things to have.  They're fun to shoot and you can also protect yourself from people who might want to harm you.  Not long ago there was that guy in the hoodie terrorizing that neighborhood, what was he doing again, carrying candy and ice tea home from the store or something, but it was dark and he was black.  If you have a gun you can protect yourself from people just like that, and you can shoot them.

Historically, guns have been great too.  In America before the revolution there was a democracy, and then the taxes got high and there was tax on everything, even tea, and people got annoyed, but the more annoyed they got, the less the government behaved democratically, and the less democratically the government behaved, the more annoyed the people got.  This, of course, got worse and worse until it was a war.  Since then, Americans have legally ensured that citizens could shoot their way out of oppression, and shoot their way right back to democracy.

This worked in Iraq too, and Afghanistan, and in Libya, and Syria, people are just shooting their way to democracy and peace, so guns essentially are like an envelope you can use to send peace and democracy anywhere you want. 

Another amazing thing about guns is that the more of them there are, the less they can hurt people.  That may seem counter-intuitive, but wait, this is how it works:  Criminals harm people using guns, but if there are more people carrying guns, criminals will also be subject to harm, and so the fear you might have of getting shot turns you into a mean killer, which makes the criminals scared and they'll shoot first knowing they might get shot at, but then the good guys'll shoot back and with all the shooting, well, as we discussed earlier, shooting everything up is how to get out from under oppression, and the safer everyone will be, obviously.

And not to belabour the point, but not only are more guns safer, but guns that shoot more bullets are also safer, so like this kid that shot all the kindergarten kids was using one of these so called, automatic assault weapons, but imagine how much safer things would be if the principle had one.  She came out of her office and was immediately shot, but if she'd had more and better weapons, and if other teachers were similarly armed, this would never have happened.  The kid would have been too scared to show up at school since all the teachers would have just shot him first.

So, as you can see, guns are great things to have and they are also fun, but most of all, they are a tool that makes everything safer for everybody, and the more people who carry more destructive guns, the safer and more free we all will be.

Eagle Snatches Kid

Unbelievable.  Good thing the kid was just a little too heavy ...
Edit: Despite our incredibly rigorous journalistic standards here at TFM, we were hoaxed. Check it out.  Montreal 3D animation students needed 100,000 views on YouTube to get a perfect grade, and these guys got 5,000,000 in one day.  That video represents 400 hours or so of work.  Nicely done dudes!
Edit II:  Click here for a reaction from the kid.

Tuesday, December 18, 2012

OMFG Penguins

Here's a video my wife shot on South Georgia Island with her iPhone ... 200,000, give or take, King Penguins. The brown ones are the young. The parents go fishing and come back to feed the kids and that's what all the noise is about: "Are you my mommy? Are you my kid?" Incredible.

Saturday, December 15, 2012

I Love Penguins

Hey internet, I just got back from a trip to Argentina, the Falkland Islands, South Georgia Island, and the Antarctic peninsula.  Escape the madness of the latest bad news in the world, and check out some cool photos here.  Here's a sample ...

DSC_7714
More later.

Sunday, October 07, 2012

How to create a public shared instance of a class module in VBA

To create a public shared instance of a class in VBA, export a class module to text and load it into a text editor of your choice.  You'll see something a lot like this at the top of the module...
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
Option Explicit

Property Get Notice() As String
    Notice = "This is a shared class"
End Property
Then, change the values of the GlobalNamespace and PredeclaredID attributes to True and re-import the module. To test it in the immediate window type...
? Class1.Notice
...and you'll see This is a shared class printed in the immediate pane. I'll use this capability to create a single cSystem class that can both raise and handle events, and that provides system-global exposure for classes and members that I like to hang on to for the lifetime of an application.  I'm curious to see how this affects load speed of an application, since until now I've opened a hidden "Form_fSystem", but it seems to load very slowly. 

How to create a collection class in VBA

What you need is a NewEnum property of type IUnknown, which is a type exposed by the stdole library which Access, and presumably other VBA environments, references by default.
Private m_items As VBA.Collection

Private Property Get Items() As VBA.collection
   If m_items Is Nothing Then Set m_items = New VBA.Collection
   Set Items = m_items
End Property

Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
    Set NewEnum = Items.[_NewEnum]
End Property
Note how the NewEnum property returns an enumerator for the collection object that is contained by the class module.  Also note that the code to populate that collection is not shown. You could define an Add method...
Sub Add(Item, Optional Key, Optional Before, Optional After)
    Items.Add Item, Key, Before, After
End Sub 
...that simply leverages the Add method of the collection contained by your class, but the cool thing is that consumers won't be able to distinguish your custom collection from a VBA.Collection.  But note also the Attribute line.  To add an attribute, export the module to text, add the Attribute in a text editor, and re-import the module.