Not !Important

I’m currently working on a SharePoint project that’s going to involve a number of fairly kludgy bits, mostly because… SharePoint. I think I may be able to get a few mildly amusing blog posts out of this project. Today’s one is about the !important directive in CSS.

This article titled “When Using !important is The Right Choice” should probably be one word long: never. Understanding specificity in CSS is important, and there are occasions where it’s appropriate to use !important, but only a few. Using it in a site-wide template for a SharePoint site is not one of them, under most circumstances. I had to write a little JavaScript (using jQuery) to hide part of a SharePoint page, and that task was made more difficult than it needed to be due to overuse of !important in the site template.

I’m the first to admit that I don’t know nearly as much about CSS as I should, but I know enough to know when I’m looking at a careful design, and when I’m looking at “let’s just try random stuff until this looks right.” Heck, I probably shouldn’t criticize; the base CSS on a SharePoint site is probably already pretty bad, so someone designing a custom template likely has an uphill battle getting his or her own CSS to work well within the framework provided by Microsoft. SharePoint is old enough that it’s supporting a lot of dead weight from old versions, most of which probably can’t be trashed without breaking too much stuff.

Happy New Year 2016

The last couple of years, I’ve been writing year-in-review/goals posts on New Year’s Day, and I’m going to continue with that this year. For reference, here are links to the 2015 and 2014 posts.

Weight & Health
This category is pretty simple, so I’ll start here. I was at 200 pounds on New Year’s Day in 2014, and 165 on 1/1/2015. Today, I’m at 150. I had set a goal at 160, and got there, then everything past that just happened very gradually. I’ve been between 150 and 155 for the last few months, and I’m comfortable with that. So, for 2016, I’m just going to try and maintain my weight, within that range. Using the Lose It app has become enough of a habit now that it would seem weird not to log all my calories and weigh myself (almost) every day, so I’m going to keep doing that.

On the fitness front, I haven’t made much progress, though I’ve kept up with my habit of doing as much walking as I can. I haven’t started doing any other kind of exercise, and any thoughts I had about that were put aside when I had my hernia surgery a few months ago. I think I’ve healed up enough now that I could consider some new exercise ideas, and I might do something about that in 2016, though I’m not sure what.

My neck and back continue to bother me a bit, and I’m still not sure what, if anything, I’m going to do about it. I will likely buy a new mattress in 2016, which should help, since my current mattress is ten years old.

Speaking of mattresses, I’ve started using Sleep Cycle on my iPhone to track my sleep. I’m still not sure if it’s really that helpful, but it’s at least a little better than my old alarm clock, so I’m going to stick with it in 2016. I used to go to bed around 11pm most nights, but I’ve gotten into the habit of going to bed at 10pm lately. I get up at 6am, so that’s giving me eight hours in bed rather than seven, which is probably a bit healthier. And I’ve started setting my alarm on weekends also, so my time in bed is a bit more consistent now, from day to day. I still have trouble sleeping on some nights, and I’m not sure why. I know that afternoon coffee drinking definitely affects me, but I can have trouble sleeping even when I’m not drinking much coffee. So I’m going to keep thinking about this, and see what else I can do to improve my sleep.

Education / Programming
I didn’t do much in this area this year. I did learn a lot about SharePoint development, for a project at work that never really came to fruition. And I spent some time learning Ruby (and Ruby On Rails). I took Michael Uslan’s Rise of Superheroes course on EdX, but didn’t take any programming courses on EdX or Coursera. And I spent some more time on F#, starting a new book, Real World Functional Programming. I haven’t looked at it in a couple of weeks, but I want to pick it back up this month and get through it. Aside from that, I’m not really sure what I want to do in 2016. My day job is still going to be mostly Dynamics AX work, and I don’t have any consulting work coming up. So I’d like to continue with F#, and Ruby, and maybe more iOS development, but I don’t have any concrete projects that I’m working on or particularly interested in right now. So that’s something to think about.

Work
I’ve been at SHI since January 2013, so I’m just coming up on my three-year anniversary. SHI does performance reviews at year-end, so I just had mine recently, and it went well. I’m reasonably content with my day job, and I’ll likely stick with it through 2016. Since I’m only doing Dynamics AX work there, though, I should really try to get involved in some other projects, outside of work. I didn’t do any of that in 2015.

GTD / organization
I did pretty good on this front in 2015. I’ve kept up on my bills and paperwork, for the most part, and have finally switched over my Merrill statements to paperless. (I blogged about this last month.) I’m got things pretty well-organized in OneDrive now, and I’ve making effective use of my Evernote account. I had started consolidating all my personal notes into Evernote back in November 2014, and I’m pretty happy with the way that’s worked out, enough so that I recently paid for another year of Evernote Premium.

Comics and Books
I donated most of my comic book collection to Superheroes for Hospice early last year, and successfully avoided buying them all back. I have been on a bit of a tear with Comixology and Humble Bundle sales recently, but that’s all digital so none of that stuff is cluttering up the apartment the way 25 long boxes of comics did.

For reading, I’d set myself a goal of 50 books in the Goodreads reading challenge for 2015. I came in at 96, so that’s good, but many of those were comic book TPBs, so it’s not as impressive a number as it could be. In fact, I see that the last prose novel I finished was a Dresden Files paperback, in August. So I should probably start reading a new novel soon, just so I don’t forget how to read the darn things. I’ve done a fair bit of non-fiction reading this year too, long form (but not book-length), mostly New Yorker articles that I read either in the printed magazine or that I’d saved in Instapaper. (I kind of wish that Instapaper had a statistics page I could look at to see what I’ve read recently, but if they do, they’ve hidden it well.) And hey, this article on good news from 2015 looks like one I should save and read!

Life-logging, journaling, and blogging
I’m not sure if I’m using the right terms here, but I’ve definitely been doing more and more of this “quantified self” stuff over the last few years. And also more of the “qualitative” stuff via blogging and journaling. It looks like I wrote a little over 100 posts on this blog in 2015. That’s a pretty respectable number, and some of them took a bit of work and thought to put together. Overall, I think blogging has helped me work through problems, set goals, and keep track of them. (And I occasionally write a post that might actually be useful to someone else, though not as often as I’d like.)

Via my iPhone, I’m now tracking everything I eat, my weight, my sleep, and my daily step count, and I’m actually paying attention to all of those things. I’m not sure how much good it’s doing me, except in the weight loss area, where it has definitely made a huge difference over the last few years. So I’m going to keep doing all that in 2016.

In addition to this blog, I’ve also been keeping a five-year journal for the last nine years. (I’m just starting the last year on the second book.) It’s somewhat useful, but there’s not much room to write anything beyond a few lines, and of course it’s old-fashioned paper, so it’s not searchable. I’ll keep up with it this year, but I’m not sure if I’ll start a new one next year.

I bought Day One for iOS about a year ago, when it was on sale for a buck, but didn’t really start using it. I bought the Mac app last month, when it was on sale for $7, and I want to start using it this year, to supplement the stuff that I post publicly on this blog, and the stuff that I scribble in my five-year journal. If using it becomes a habit, I’ll probably drop the five-year journal in 2017. The guys from The Sweet Setup wrote an ebook on Day One that looks interesting. I may pick that up, and see if it gives me any good ideas.

Hardware and Software
I didn’t do too much with major hardware or software purchases in 2015. I didn’t buy a new desktop or laptop computer. I didn’t buy a new iPhone or iPad. I did buy a $35 Kindle Fire, but that’s a pretty minor purchase. My biggest purchase of the year would be the TiVo Bolt, which is working well for me. I replaced a hard drive cable in my MacBook and the speaker in my iPhone, so I could squeeze a bit more life out of those.

I think there’s a good chance I’ll buy an iPhone 6c in 2016, if such a thing is actually released. My iPhone 5s is working fine, except that the battery is clearly on its last legs, so I’m going to need to replace either the battery or the phone before 2016 is over.

I’m almost definitely going to buy a new desktop computer soon. My current machine was purchased in 2010, so it’s about time for a new one. I’d rather just upgrade some parts in it, but it’s old enough that it’s not going to be able to run Windows 10 without replacing the motherboard, and I don’t want to do that. (And I’m not even sure if I can, and don’t want to waste a lot of time trying to figure that out.)

For software, I’m going to keep up my Office 365 subscription. Even though I’m not doing much with Office itself, the subscription is worth it for the OneDrive space. And I’ll keep using a lot of the applications I’ve been using, like Evernote and 1Password.

Summary
Well, this has turned into a long post, much like last year’s one. I started writing this around 10am, and it’s now 11:45, so I should really wrap this up and start thinking about lunch. It’s nice to have nothing important to do on New Year’s Day. It’s been quiet outside on Main Street all morning, and pretty quiet here in my apartment building. I’d like to go out for a walk, but it’s a bit cold out there today. Maybe after lunch it’ll be warm enough for a quick walk around the block.

Visual Studio 2013 update 5

After upgrading my laptop to Windows 10, I thought about maybe taking a shot at installing Visual Studio 2015. I may do that eventually, but I don’t have any reason to do it right away. But last night, I decided to at least apply the latest update to VS 2013, which is update 5. I’ve had some bad luck with Visual Studio updates in the past (going back to VS 2005 and 2008), but recent updates have been pretty smooth. Well, I don’t know what went wrong with this one, but I started installing it last night, and it’s still going this morning. It seemed to hang at about the halfway point. Rather than cancel it, I decided to just let it keep running overnight.

When I woke up this morning, it had made a lot of progress. Right now, it’s at the step that says “Configuring your system. This might take a while.” So it’s pretty close to the end, I think. I guess I’ll let it keep going while I’m at work, then see if it’s done when I get home. So this could well be a full 24-hour update install. I understand that updating a complex product like Visual Studio isn’t easy, but really, there has to be a better way to do it.

fun with credit card expiration dates

I’m doing some work on credit card processing right now. This is all related to my company’s upgrade from Dynamics AX 2012 RTM to 2012 R3. There were major changes to the credit card processing code in R2, and we’ve customized the code from RTM quite a bit, so there’s a lot to do. I’d like to write more about it, but it probably wouldn’t be of any general interest, plus I don’t want to get into any company-specific stuff.

But one very minor thing came up yesterday that was a little bit interesting. I noticed a support ticket from a user who was entering a new card, and wanted to enter an expiration date that wasn’t shown in the drop-down. (It was too far in the future.) This didn’t have anything to do with the upgrade, per se, but it made me curious enough to look at the code in RTM and in R3, to see what was being done. I was curious if maybe we had something in there like this example from The Daily WTF, or something where the upper-limit on the year was hard-coded to a specific year.

Well, it’s not quite that bad, but it is a bit questionable. In RTM, there’s a drop-down that is populated with years from (current year) to (current year + 7). In R3, it’s pretty similar, except that, when editing the expiration date after initial entry, you can go to current year + 8. (That’s probably an off-by-one error, rather than an intentional extension of the range.)

This all made me wonder what a reasonable upper-bound for expiration year would be, which lead me to this Stack Overflow question, which seems to indicate that there’s no agreed-upon maximum, but that it’s probably safe to go with 15-20 years. So Dynamics AX could stand to be be a bit more flexible on that range.

The other thing that bothers me about the way AX handles expiration dates is that (in 2012 RTM) they’re stored in the database as “MMYY”, which makes it difficult to sort and filter out expired cards. I was hoping that would be corrected in R3, but they’ve only changed it to “MM/YYYY” (without any leading zeroes on the month), which has the advantage of being more easily-readable by a human, and also of storing the full 4-digit year, but the disadvantage of being even more difficult to sort on, since the year sometimes starts in the 3rd position and sometimes in the 4th.

And let me end this blog post with a link to my very favorite publicly-documented method in AX, related to credit card processing: CreditCardWizard.codeCoverageFudge. I’m not entirely sure why this method exists in the released product, but I’m guessing it was added to fudge the code coverage numbers in some unit testing metrics. Maybe a certain percentage of code coverage had to be achieved, but there was no easy way to write meaningful tests for the remaining uncovered code, so they just wrote a method that does nothing, and a unit test for it?

inverting a binary tree on a whiteboard

I kinda love this tweet from Max Howell, and many of the replies it generated. I’ve never interviewed with Google (and I doubt they’d be interested in me) but I have gone on interviews where I was asked this kind of question. A question I could have answered, straight out of college, but that I’d be pretty fuzzy on, 20+ years later.

Of course, I’ve never written anything as cool or popular as Homebrew, so I do expect to have to prove myself a bit more than Mr Howell should have to. Which is one of the reasons why I occasionally work on Project Euler problems, or take an Algorithms course on Coursera.

Fun and games with SharePoint and Open XML

I’m starting to work on a SharePoint project right now that sounds like it should be simple, but is actually kind of complicated. Or at least if seems to me like it is, possibly because I’m still new to SharePoint and I’m not always stumbling across the “right” way to solve the various problems I’m encountering.

The basic problem is to take a purchase requisition, stored as a normal SharePoint list item, and allow the user to save it to a nicely-formatted Word document or PDF, so that it can be sent out to a vendor as a purchase order.

I went through quite a few ideas for this, most of which are likely very wrong. What I’ve settled on, for now, is creating a new ASP.NET application page which will take the ID of the purchase requisition on the query string. I can then link to this page through a custom action on the regular list item display/edit form. The new page will read the fields of the list item via the SharePoint object model, substitute them into a Word document template, then allow the end-user to download that document from their browser.

Previously, I’ve always used third-party libraries, such as EPPlus, to generate Word and Excel files. But, in this case, I wanted to avoid third-party DLLs and see if I could do what I needed with just the Open XML SDK.

I’m discovering a lot of interesting things about Open XML as I go. First, there’s a tool in the Open XML SDK, called the “Productivity Tool”, that can take a Word document and generate the C# code necessary to create that Word document from scratch. When I started working on this project, I was concerned about where I would store the document template; now, it turns out that I don’t have to store it at all! I can just generate it from scratch in code each time. And I can just modify the generated code a bit so that the values I need to substitute in can be variables instead of constants.

The generated code, unfortunately, is pretty messy. My first shot at running my purchase order template through the tool resulted in 10,000 lines of code. I made some changes in the document to simplify things, and I got down to about 7500 lines, which is still a lot.

I also discovered the “Power Tools for Open XML” library, which can be used to simplify the formatting on a Word document a bit. I ran it on my template, then generated new C# code, and now I’m down to 7200 lines. Still a lot, but it’s manageable.

So it seems like I now have a viable solution that doesn’t need to read or write anything to/from the file system, doesn’t have any oddball DLL dependencies, and should be pretty straightforward to code, test, and deploy.

Microsoft Build

I kept an eye on the news coming out of Microsoft Build yesterday. There’s a good overview at The Next Web. At some point, I’d like to try out Code on my Mac. It’ll be interesting to see if it gets any traction, and how this affects Xamarin Studio. There are a lot of short articles out there on Code, but there’s not much substantial information in any of them. I just checked Scott Hanselman’s site, though, and he has a good post up about it. He makes it clear that this is more of an editor than a full IDE:

This a code-focused and code-optimized lightweight tool, not a complete IDE.

So it’s not exactly a direct competitor to Xamarin Studio. Maybe more of a competitor to Sublime Text? This makes me wonder, though, if they have bigger plans for Mac/Linux, or if this is just a weird little side project that will fade into oblivion a few years from now.

setting up a SharePoint 2010 development VM

I’ve blogged previously about my failed attempt to set up a SharePoint dev VM at home, on my laptop. I’ve given up on that for now.

But one of the SharePoint projects at work finally got far enough through the “spec” phase that I could justify asking our IT ops people to help me get a SharePoint dev VM set up at work. The regular help desk guys set up the base image (Windows Server 2008 R2), and the SharePoint admin guys then installed SharePoint 2010 on it, so I don’t have too much insight into that part of the setup.

Having been handed a working VM with SharePoint 2010 Server installed, it was then up to me to get Visual Studio up and running. That wasn’t much of a challenge. I installed VS 2012 Ultimate. The installer actually gives you the option to install the SharePoint tools, so I didn’t even have to do that separately.

I did have a bit of a problem, post-install, in that some Windows Update that came down automatically killed SharePoint. I had to re-run the SharePoint config wizard several times, make a couple of registry patches, restart some app pools in IIS manually, and so on and so forth. In the end, I’m not entirely sure which combination of random trickery was actually responsible for getting things running again, but whatever it was, I seem to have a working environment again.

But that pretty much killed the entire day, so I have to say that setting up a working SharePoint dev VM is not a trivial task, even if you’ve got experienced admin guys doing the bulk of the initial setup work.

Not at RailsConf

I’m spending a little bit of my spare time right now trying to learn Ruby, and Ruby on Rails. I recently finished a course in Web Application Architecture on Coursera, which used Rails as part of a general overview of modern web apps.

And now I’m working on Michael Hartl’s Rails Tutorial book. The book is free to read online. I’m enjoying it so far, and getting a lot out of it.

Meanwhile, RailsConf 2015 is going on right now, in Atlanta. I should keep an eye on that on Twitter, and see if anything interesting comes up that might be useful for a guy who’s new to Rails.

Text Editors

Possibly the most time-honored and effective way for a programmer to procrastinate on his or her work is to spend time messing around with text editors and/or IDEs. There’s a good case to be made that spending time selecting the right editor/IDE, and tweaking it appropriately, pays off in spades, due to increased productivity over time. But honestly, I can’t say that I haven’t sometimes spent time messing around with my text editor or IDE just as a procrastination tactic.

Yesterday, a new beta of Sublime Text 3 was released, along with the new version of Komodo Edit/IDE, so it makes sense to think about editors a bit.

I bought a personal copy of Komodo IDE about a year ago, and I’ve been using it on the Mac and on Windows, mostly for PHP programming. And now I’m using it for Ruby too. It’s a little heavy to use it as a general text editor. For quick text file editing, I’m using Notepad++ on Windows and TextMate on the Mac. But Komodo is pretty good for PHP and Ruby.

I messed around with Sublime Text a few years ago, but didn’t really like it enough to stick with it. (And, at the time, I didn’t really have a good use case for it anyway, given the kind of work I was doing then.) Occasionally, I think about giving it another try.

At work, I don’t really need to worry about text editors much, since nearly all of the work I do is being done in either MorphX (the Dynamics AX IDE) or Visual Studio. Both of those environments work fine, for their intended use, and (in both cases) it wouldn’t be realistic to consider using a different tool for text editing.

But, for my recreational programming, whether that be PHP, Ruby, or whatever else, it’s nice to have a good programmer’s editor handy. I’ve already shelled out the $59 to upgrade my personal license for Komodo IDE to version 9. (If I thought I was going to need to do any serious Ruby development, I’d probably give Sublime Text another shot and see if it was significantly better than Komodo.)

I keep thinking I should be a real programmer, and learn more about VIM and/or Emacs, but I never quite get around to it. VIM Adventures looks like it might be a fun way to learn VIM. (Of course, I’ve been saying that I should learn more about VIM and Emacs for years; I just found blog posts from 2008 and 2005 saying basically the same thing I just wrote here.)