apocryph.org Notes to my future self

5Aug/1012

Installing Ubuntu Lucid Lynx (10.04) on Dell Precision M4500

I decided to switch my new work laptop, the Dell Precision M4500, from Windows 7 Ultimate to the latest Ubuntu release, Lucid Lynx (version 10.04).  This turns out to be…nontrivial.

You see, my laptop has the NVidia QuadroFX 880M graphics card, which means trouble.

Due to a known bug in the kernel mode setting feature in newer Linux kernels (here and here), the GUI installer on the Ubuntu 10.04 install CD doesn’t display correctly on my M4500, appearing instead as a blank screen.  Control-Alt-F1 doesn’t change that either.

Here’s how I got around it:

First, just as the Ubuntu install CD starts to boot (right after ‘ISOLINUX’ flashes on the screen), I hit Escape.  This prevents the GUI installer from launching, and instead displays the screen I’m used to from the Ubuntu 9.x installers, with operations like ‘Try Ubuntu without installing’ and ‘Install Ubuntu’.  I pressed F6 to display the advanced options, and selected ‘nomodeset’ from the list.  I then hit Escape to get out of the advanced options list, and selected ‘Install Ubuntu’ to launch the installer.

I proceeded through the install uneventfully, until it came time to reboot into the new Ubuntu install.  Just after the BIOS boot screen disappears, as Ubuntu is starting to boot, I held down Shift for a few seconds, which brings up the GRUB boot menu.  I selected the default boot option, then pressed ‘e’ to edit the boot configuration.  I navigated to the line that ended ‘quiet splash’ and added two additional words, ‘noapci’ and ‘nomodeset’.  ’nomodeset’ disables the Kernel mode setting feature that is so problematic for my card.  On my machine if I didn’t also specify ‘noapci’ the machine kernel paniced during the boot processs.

Once the boot configuration was edited I pressed Control-X to start booting.  It booted into Ubuntu without further incident.

Once in Ubuntu, I sent to System | Administration | Hardware Drivers and switched to the latest proprietary NVidia drivers (IMHO, the open source Nouveau NVidia drivers are simply not ready for prime time).  I waited for these drivers to download and install, then rebooted.

After the reboot, I no longer needed to disable KMS; I can only assume the proprietary NVidia drivers don’t suffer from the same problem.

Filed under: Uncategorized 12 Comments
31Jul/100

Completed first AR build

Thanks to a Brownell’s gift certificate generously provided by my parents for my 30th birthday, I finally acquired all the parts I needed to complete my first AR-15 build.  I’ve owned and shot AR-15s for years, but never had I built one of my own.  At least, not until today:

From BCM Mid-length AR build

If you’re interested in such things, here are the particulars:

  • Defensive Edge SLR15 stripped lower
  • RRA lower parts kit
  • Bravo Company Manufacturing (BCM) Mid-length 1/7 complete upper
  • BCM Full Auto bolt carrier group
  • BCM charging handle
  • Daniel Defense Omega Rail 9.0 mid-length handguards
  • MagPul MIAD grip
  • VLTOR mil-spec receiver extension tube
  • MagPul CTR collapsible stock
  • MagPul ASAP receiver extension plate
  • MagPul PMAG30 magazine
  • Brownells castle nut
  • Superior Shooting Chromoly/Silicon flat buffer spring

Not pictured but on the rifle now:

  • MagPul MS2 sling
  • EOTech 512 reflex sight

Not obtained yet but destined for the rifle:

  • BCM GunFighter charging handle
  • MagPul MOE rear BUIS

I used the Brownells AR-15 instructional videos on the Brownells web site to help me understand how the parts went together.  I didn’t have the lower receiver vise block, but all the other AR build tools were at my disposal.

I was quite surprised how easily everything went together.  Once I figured out which springs and roll pins in the lower parts kit went where, it was just a matter of watching the videos and following along.

Already I’m thinking about other builds.  I have two more LPKs, four stripped lowers, and one more BCM mid-length upper lying around.  I’d like to do something with one of the Spike’s Tactical mid-length .22LR uppers, plus I’ve often wondered what a 9mm build would be like; I have the C-Products 9mm mag block and 10 30rd 9mm mags just waiting for a gun to go in.

Much like PCs, the AR-15 platform is so modular and versatile you can build just about anything you want given sufficient funds and available parts.  Now that I see how easy AR builds can be, I’m sure to build at least a few more…

Filed under: Uncategorized No Comments
23May/100

Getting Reg-Free COM activation working between managed and unmanaged DLLs

At work I’m transitioning the logging framework used by one of our products, from log4cplus to the .NET logging framework NLog.  Since an increasing portion of our product code is in C#, using a .NET native logging framework made sense.  However, we still have a large body of legacy C++ code that I’m not willing to modify, so I needed some way of exposing the NLog logging code to the legacy codebase.

To simplify the situation somewhat, here are the components of my solution:

  • aadiag - A C++ DLL that exports methods for logging.  All of the legacy C++ code does its logging through this DLL
  • logging - A C# DLL that wraps NLog and is used by our C# code for logging.  This DLL uses COM Interop to expose a COM coclass, ComLoggerFactory, to unmanaged code
  • service - A C++ EXE that implements a Windows service of some kind

I modified aadiag so that it would instantiate and call the COM interop coclass in logger in order to perform its logging. That worked fine, except for one hiccup: I had to remember to register logging.dll. If I forget (and I do often since registration requires admin rights which I don’t generally run with), all the C++ logging fails.

To solve this problem I started researching Registration-free COM. Unfortunately, most of what I read did not address the use of COM interop, and assumed a simplistic architecture in which an EXE maintains one or more dependencies on in-proc COM coclasses. Since in my case I have an unmanaged DLL (aadiag) that depends on COM coclasses in a managed DLL (logger), the fairly straightforward instructions I found were useless.

Here’s what I did instead, broken down by component:

Logging (Managed DLL)

I added a new item to Logging’s Visual Studio 2010 project.  I used the ‘Application Manifest’ item template, but I threw out the entire contents the template generated for me.  Here’s the manifest I used instead:

Note the clrClass elements; they are the critical component. The clsid property is the value of the Guid attribute on each class; the name is the fully-qualified type name.

That creates the manifest, but it won’t automatically embed it in the DLL. In the project properties, the Application tab has a convenient dropdown where you choose which manifest to embed. One problem; it’s always disabled for Class Library projects. You’d think that would be a bug, right? That’s what this guy thought too. Only problem is, MSFT says this behavior is by design!

I imagine the Visual Studio team responsible for this particular tab couldn’t think of a single reason why anyone would want to embed a manifest in a DLL. After all, most of the features controlled by a manifest either don’t apply to .NET assemblies, or are only relevant in executable. Well, guys, here’s a reason I bet you didn’t think of: registration-free COM!

Fortunately, they did a pretty half-assed job of disabling manifests for class libraries. It’s only disabled in the GUI; if you edit the .csproj file manually you can still configure a manifest to embed. Just open the .csproj file in a text editor, and find the first PropertyGroup element. Insert this line at the end of that element:

<ApplicationManifest>app.manifest</ApplicationManifest>

Be careful with this, though; if anyone fiddles with any settings on the Application tab in the future, this gets blown away.

AaDiag (Unmanaged DLL)

First, aadiag needs a manifest too, which describes its dependency on the Logging DLL. I just created a new ‘Text File’ called ‘app.manifest‘, added it to the project, and filled it in. Unlike the C# projects, .manifest files are automatically merged into the manifest generated for the DLL. The contents of app.manifest are pretty simple:

That’s the easy part. The hard part is creating and activating a custom COM activation context which uses the manifest we just created to help resolve COM coclasses. In my case, there was one place in the code where I created the ComLoggerFactory coclass, so I only had to to this once. Your code might have more places:

And that’s pretty much it. Now, as long as Logging.dll and aadiag.dll are in the same directory, things Just Work. Too bad MSFT seem to go out of their way to make this hard.

Filed under: Uncategorized No Comments
18May/100

The Code Analysis feature in Visual Studio 2010 Sucks

I’m leading the switch from Visual Studio 2008 to Visual Studio 2010 at my company.  In addition to the usual migrating of countless projects and fixing niggling errors, I’ve thought it would be cool to use the Code Analysis feature built in to VS 2k10 to automatically run our new C# code through a set of rigorous checks for bad code smells and possible bugs.  From a policy perspective it was really easy; I made a new ruleset comprised of most of the MSFT rules which ship with the product, then configured the C# projects to perform code analysis with my custom ruleset file.  Then the FAIL started.

First, I wanted Code Analysis warnings to be included in the ‘Treat Warnings as Errors’ feature of the compiler.  That’s not possible, so instead I had to change every warning in my ruleset into an error.  Nice.

Next, I wanted to get existing code under analysis even though it generates tons of warnings, by excluding all existing files in my legacy projects.  This way, as files are added they will be checked, but existing files don’t have to be fixed all at once.  Turns out, you can’t do that.  The rules are the rules, for every file in the project.

After that, I brought a simple NUnit test suite project into the Code Analysis fold.  The project was dead simple, so I didn’t expect any Code Analysis violations.  Little did I know.  You see, most (actually, all) of my unit tests are public non-static methods which do not access any instance methods or variables.  Code Analysis issues warning CA1822, pointing out that the method could be made static for better performance.  Normally this is 100% correct and I want to be alerted to it, but these are unit tests.  They MUST NOT be static.  Thus, I decided as a matter of policy that CA1822 would be ignored for unit test projects.

Only, that’s not how it works.  The SuppressMessage attribute suppresses ONE instance of a warning.  If you have a code file with 100 warnings, there’s no way to suppress all warnings in that file.  None whatsoever!  I can only imagine the conversation between preening code bureaucrats at MSFT:

“We should probably have a way to disable some of these warnings on a file or space basis”

“Why?  Then stupid users will just disable the warnings instead of addressing them.  Let’s make them create a separate SuppressMessage attribute for every single violation.  It’ll make their code look like shit, and will piss them off so much they just quit using Code Analysis entirely”

“Prescriptive, simplistic, crude, and ultimately useless.  I like it!”

As a result, we have a feature that should’ve been integrated into Visual Studio long ago, implemented in such a way as to be useless to most real world software projects.

Filed under: Uncategorized No Comments
7May/100

Huge gotcha in TransmitFile

I’ve been pulling my hair out all day trying to get my code using TransmitFile to work right.  For some reason, it works great on my Windows 7 workstation, but fails with ERROR_INVALID_PARAMETER on my Windows Server 2008 R2 test server.

By dumb luck I ran across an old post of mine from four years ago, documenting an odd behavior I experienced with TransmitPackets, a more sophisticated sibling of TransmitFile.

I changed the nNumberOfBytesPerSend argument from 0 to 64K, and it started working fine on both machines. I don’t understand why, and I wish functions like this which are so critical to performant server-class systems weren’t so damned inscrutable, but I’m happy I took the time four years ago to document that little subtlety for my future self.

22Mar/107

Socialized Healthcare, Here We Come!

So Pelosi finally found the votes to pass ObamaCare in the House, and I think it’s reasonable to expect the Senate to ratify along party lines, so hooray for us, our healthcare system is finally reformed!  Even better, it will save us money, lower taxes for Democratic voters, improve health care quality, and pay down the deficit.  What’s not to like (unless you’re one of those godless insurance companies)?

Apologists of this latest scheme will hasten to point out it’s not, strictly speaking, “government run” healthcare.  That’s true, inasmuch as it’s actually government mandated, government funded, government regulated health care provided by nominally private insurance carriers and medical facilities.  But don’t worry, we’ll have so much fun suckling at this teat that a “public option” won’t be far behind, after which we can finally put the last nail in the coffin of the evil insurance industry.

For those such as myself who believe strongly in the American founding principles of individual liberty and specifically enumerated Federal power, this is a dark day.  The Democrats in Congress, without a single Republican vote, have rammed through a health care bill which inserts the Federal government and its already-strained coffers  inextricably into the health care industry at every level, in clear defiance of both our Constitution and the will of the American people.  This is an entitlement we cannot afford (financial legerdemain notwithstanding) which will increase the cost of our care, reduce the quality of care we receive, and grow in power and cost beyond our ability to foresee.  The Democrats have done their country a grave disservice, and I hope they pay dearly at the polls.

Decimating their legislative ranks won’t unfuck us from our current predicament, but it will provide some temporary catharsis before the worst of the tax increases and rationing kick in.  In the spirit of taking what I can when I can, I’ll focus my attention there this November.  As I promised the Virginia Senate delegation back in December, if you’re a politician in Virginia and would like money and time from me to help you win, here’s all you have to do:

  • Identify a member of the Virginia congressional delegation, House or Senate, who cast a ‘yay’ vote on either the Senate or House healthcare bill or in conference committee
  • Run against that member for his/her seat
  • State as one of your policy positions that ObamaCare is an extra-constitutional power grab bought with money we don’t have, and that you will make it a priority to kill it, water it down, undermine it, discredit it, or throw a shoe at it

That’s it!  But wait, there’s more!

If you’re a politician interested in a House or Senate seat outside of VA, there might be some money in it for you too!  Same deal as the VA politicians, but I don’t have enough money to support the campaigns of every possible opponent of every Democrat asshat on Congress, so find one who’s believed to be vulnerable and let me know; if I think he/she is vulnerable as well, then presto!  Money’s on its way.  Bonus if you’re running against that gullible fuckstick Bart Stupak.

Finally, let me suggest some cool fundraising ideas:

  • Tar’n'feather dinner.  It’s like a regular fundraising dinner, only a random drawing of your Gold and Platinum contributors selects three lucky guests who get to tar and feather an effigy of either Pelosi, Reid, or Obama.
  • Phonebook Congress.  Set up a campaign website and Facebook page for ‘Random Name from Phonebook’ to run against your opponent.  Coordinate a money bomb.  Show that statist asshole just how despised he/she is.  You can even keep the proceeds for your own campaign warchest
  • Pitchfork mob.  Get a bunch of supporters together and storm your opponents’ office armed with pitchforks and torches.  I’m kidding.   Sort of.  But not really.

There you have it.  There’s a ton of money to be made on this thing, even if you’re not a Democratic congresstard.

4Jan/100

Results of First SEG Pin Match, December 2009

I shot the first ever Bowling Pin match held at SEG this past December.  I’ve attached the scores; I finished 11th out of 40 overall.  I’d hoped to crack the top 10, but this was my first match so I had a rough start.  As you can see from my numbers, my fastest time was only about 0.5 seconds slower than the winning time, so with some more practice I should finish higher next time.

I didn’t have anyone there to shoot video, but my brother Seth took some stills with his SLR.  You can see them here.  The best of the lot is this one:

From Adam Bowling Pin Match Dec 2009

It should also be noted I didn’t leave a single pin standing in any of the stages. Say what you will about my times, but my accuracy is more than sufficient.

19Dec/092

Open letter to Virginia’s Senate delegation

Senators Webb and Warner:

Today Senator Nelson was somehow swayed (no doubt with favors most outside Washington would consider “bribery”) towards support of Senator Reid’s as-yet-unread legislation to “reform” 1/6th of the nation’s economy to the tune of $1 trillion in debt and a sweeping expansion of federal power over individual health care choices.  As both of Virginia’s senators you have expressed at least tentative support for this extra-constitutional usurpation with claims of lowered healthcare costs, improved health insurance coverage, and higher quality medical care.  I submit to you these goals cannot be achieved with anything resembling the Democratic majority’s attempts thus far.

I have not yet seen the Senate’s latest attempt to “fix” healthcare, as Reid’s bill emerged from a smoky back room just yesterday, thus I cannot offer criticisms of specific provisions of the bill for your consideration.  However if previous Senate attempts at “reform” legislation are any guide, Senator Reid’s latest will achieve none of the stated goals of “reform”, and instead will bring potentially ruinous consequences down upon us all.  Allow me to address some of my objections to what is sure to be in the next permutation of the bill up for a vote this coming week:

* Most offensive of the provisions is a federal mandate forcing individuals to buy health insurance.  Whether this mandate is dressed up as some sort favorable tax treatment for insurance premiums or left naked as an overtly coercive regulation carrying with it the penalty of law, we have fallen far from our roots as a constitutional republic.  What would the founders of our country, not to mention the jurists presiding over the first 150 years of our legal history, make of such an extra-constitutional compulsion?  I daresay they would take a dim view indeed.

What right have you as my elected representatives, or have the unaccountable federal bureaucrats to whom the Executive delegates, to compel me to spend my money to purchase a product or service?  Where in the US Constitution did we the people delegate to you our elected government the power to force us to spend our money with anyone, let alone insurance companies squirming under the boot heel of federal regulators?  It is an outrage which, if perpetrated, will no doubt be regarded as a pivotal moment in our country’s history.

* Next on the egregiousness list is a new regulatory regime imposed upon the health insurance industry in the name of controlling costs and keeping premiums affordable.  These schemes call to mind the Randian legislator who in his hubris believes himself capable of simply legislating away problems of “unfair” wages, “dog eat dog” industrial practices, an “unequal” opportunities without consideration of unintended consequences or any regard for the liberty of the subjects of his benevolent ministrations.

Among the regulatory schemes proposed are measures restricting variations in premiums between the  young and healthy and the old and infirmed, mandates requiring coverage of a long and sure to grow list of procedures, and in some bills even a profitability cap requiring a minimum percentage of premiums go to paying claims.

To illustrate the ruin that will come from this short-sighted scheme, allow me to share with you some details of my particular, but in no way unique, situation.  As one who is young, healthy, and requires only coverage against catastrophic medical bills, these ‘reforms’ will cause my health care costs to skyrocket.  Today I pay about $110/month for my high-deductible insurance plan, along with tax-free contributions to my health savings account.  If I need a heart transplant or brain surgery, I can pay the first $5000 from my accumulated tax-free health savings, after which my insurance covers the rest.  Odds are I won’t need expensive medical services any time soon, so I can accumulate my own savings for my own health care on my own terms.

Under the new regime, Federal bureaucrats will be presumed to know better than I what’s best for me.  I will be forced to pay into a more traditional health insurance scheme which will provide coverage for a wide range of procedures I don’t care about.  My premiums will rise not only to cover these additional unwanted procedures and lower deductibles, but much more so because of the restriction of the “unfair” insurance company practice of setting premiums in accordance with risk.  In effect my financial freedom will be curtailed to the tune of thousands of dollars a year so the old and infirmed are spared the “unfair” experience of paying for insurance in proportion to what they will consume.  If I choose to defy the Congress and the executive bureaucrats, I will face Federal sanctions including fines and God knows what else.

Sadly, it’s not as though you’ve no way of knowing this is coming.  Individual coverage mandates and government-set “minimum” coverage standards have been tried with the same results in Massachusetts and elsewhere.  Be assured the presence of 535 legislators and an army of Federal bureaucrats won’t make it go any better.

* The third and–due only to verbosity considerations, final–error I wish to call to your attention is the ruinous fiscal consequence of this grand experiment in government social engineering.  The CBO’s estimates for these schemes ranges from $800 billion to over $1 trillion for the next ten years, and that’s with absurd assumptions like scheduled Medicare cuts being permitted to take place, and government cost projections being accurate.  Historical evidence suggests the real number will be well in excess of $1 trillion.

Federal finances are already in terrible disarray, particularly after the massive bailout scheme to spare us the horror of 10% unemployment and the bankruptcy of institutions too big to fail.  Medicare is already going broke with no solution in sight.  Now the Congress would pile a nearly unimaginable amount of debt atop an already hopeless mountain.    Surely you must recognize this is the sort of thing that precedes the fall of empires.

You are both intelligent and accomplished men; I’ve no doubt you recognize politically convenient financial legerdemain when you see it, so you must realize this ‘reform’ scheme carries with it a devastating cost.  You must therefore believe the potentially ruinous economic consequences, not to mention the serious blow to our liberty, to be worth the price.  I cannot for the life of me understand why.

What contempt or disdain for deliberative democratic governance is required to participate in an effort to ram this ruinously expensive and coercive legislation through Congress by the barest of partisan majorities?  What disinterest in the concerns of constituents and the American people must one possess to at least tacitly support this effort at a time when a majority of Americans oppose the plans put forward thus far?  Shouldn’t a wholesale restructuring of our economy along statist and command-and-control lines happen in the light of day, with deliberation, or at the very least with time to read and evaluate the bill?

I’m not rich, or powerful, or a special interest, or a shill for insurance companies, or a Republican partisan.  I am a young professional Virginian who loves his liberty and reads his Constitution and votes his conscience, and I make you this promise: if any member of the Virginia congressional delegation wins re-election after voting to support a health care bill that takes some of my freedom and more of my money in the name of  ’reform’, it will be in spite of my dedication of time and money to their opposition.  Understand that this isn’t like a promise of open and transparent government, or thoughtful and deliberative legislating; this is a promise that will be kept.

Sincerely,

Adam Nelson

Filed under: Uncategorized 2 Comments
12Dec/090

Motorola DROID one month in

I’ve had the Motorola DROID for about a month now.  It’s my first smart phone, and only my second phone with a color display, so I’m catching up on the last several years of phone innovation.

Early impressions:

  • Battery life is much lower than my K1m.  I have to charge it every night or it’ll be dead sometime the next day.  If it spends all day in my dead-zone of a basement, the battery is kaput by sundown.  The the DROID is generally said to have good battery life.  I’d hate to see what bad battery life looks like.
  • Killer apps so far are ShopSaavy, Google Maps with turn-by-turn directions, and Google Places
  • Get the car mount and car charger; who needs a dedicated GPS?
  • Having email and a web browser wherever I am is kickass
  • Screen is gorgeous, and touch interface is very responsive
  • Switching from landscape to portrait is laggy but reliable
  • My K1M would fit in the pistol magazine pocket of my 5.11s.  The DROID is too big so it goes in a front pocket, which sucks.  Too bad phone holsters are so gay and flimsy
  • Verizon service fairly reliable, but forget 3G inside my aluminum-sided house
  • Camera is crap.  Do some people really use their phone’s camera exclusively?
  • Physical keyboard is usable, but I never use it.  Onscreen keyboard is fine for me
  • Wifi sucks battery life like an electron vampire.  Don’t use it.
  • Google Latitude is fun but I can’t figure out what it’s used for
  • FourSquare is cool but I keep forgetting to check in to places I go
  • I haven’t taken advantage of Android’s open architecture, but it feels good knowing that Steve Jobs can go fuck himself

Overall, I like it and don’t want to go back.  If I had to pay for the service myself instead of expensing it, I probably wouldn’t do it, just because it’s not worth the $100 to me.

Filed under: Uncategorized No Comments
8Dec/094

Christmas 2009 Wishlist

Filed under: Uncategorized 4 Comments

Delicious Bookmarks

Recent Posts

Meta

Current Location