All posts by Rian

Line wrapping at word boundaries for console applications in C#

I didn’t like any of the solutions floating around the web for displaying blocks of text wrapped at word boundaries, so I wrote one.


This is a really long line of text that shoul
dn't be wrapped mid-word, but is

Becomes this:

This is a really long line of text that
shouldn't be wrapped mid-word, but is

Here it is:

public static string GetWordWrappedParagraph(string paragraph)
    if (string.IsNullOrWhiteSpace(paragraph))
        return string.Empty;
    var approxLineCount = paragraph.Length / Console.WindowWidth;
    var lines = new StringBuilder(paragraph.Length + (approxLineCount * 4));
    for (var i = 0; i < paragraph.Length;)
        var grabLimit = Math.Min(Console.WindowWidth, paragraph.Length - i);
        var line = paragraph.Substring(i, grabLimit);
        var isLastChunk = grabLimit + i == paragraph.Length;
        if (isLastChunk)
            i = i + grabLimit;
            var lastSpace = line.LastIndexOf(" ", StringComparison.Ordinal);
            lines.AppendLine(line.Substring(0, lastSpace));
            //Trailing spaces needn't be displayed as the first character on the new line
            i = i + lastSpace + 1;
    return lines.ToString();

Will Amazon provide pharmacy services that take market share from Walgreens and CVS in the future?

I wrote an answer to this question on Quora back in 2013.

Will Amazon provide pharmacy services that take market share from Walgreens and CVS in the future?

In other words, will Amazon be able to take market share from those companies that fill your prescriptions?

It’s unlikely, because it’s outside Amazon’s core strengths (warehouse automation and computing infrastructure), and there’s little benefit (for consumers or Amazon) in having Amazon fill your Rx’s.

A couple of things about filling a prescription that might help you understand the problem a little better:

  • Every prescription must be checked by a pharmacist before it is dispensed to a patient to ensure correctness. Therefore Amazon would have to hire a lot of pharmacists.
  • Copayments are, the same for at every pharmacy, assuming the pharmacy takes your insurance, and the cost of the medication is greater than your copayment in the traditional $10/$25/$50-type Rx copayment structure. The exception to this is when your pharmacy benefits manager (PBM) decides to offer you 3 months for the price of one (or two) if you do your Rx by mail. Sometimes retail chains will match this–but not often–and they’re effectively eating the loss when they do.
  • Not all prescriptions are recurring. You’re not going to get your antibiotic or painkiller filled at Amazon, because you need it now. These immediate prescriptions are 40-50% of pharmacy volume… this is enough volume to sustain neighborhood pharmacies well into the future.

The fact of the matter is, your PBM probably already offers the benefit of prescriptions by mail, and they do it cheaper than Amazon could.

Dispensing medications doesn’t scale well, and the people who have licenses to do it are expensive. When a pharmacist does QA on a prescription they’re checking a couple of things:

  • Does the drug match the prescription?
  • Are the instructions clear? Do they make sense?
  • Is the medication contraindicated with any of the other drugs the patient is taking?
  • Is the medication contraindicated with any of the medical conditions the person has?
  • Does it make sense from an age/weight/gender perspective?
  • Does the prescription itself make sense? (You’d be shocked at the percentage of prescriptions that have to be changed, which necessitates a call to the prescriber to correct whatever the problem is. IOW, it’s very labor-intensive.)

Electronic prescribing is a panacea for exactly two things:

  • It solves the bad handwriting problem
  • Drugs match the dosages they come in (I.e. You won’t see an Rx for Celebrex 15mg, because no such thing exists.)

It does not solve the:

  • Idiotic directions problem
  • The nonsensical quantity problem
  • The wrong drug selection problem
  • The wrong dosage problem
  • Any number of sanity problem permutations (which are alarmingly common)

Essentially, you have to solve the GIGO problem in a very, very reliable way in order to automate the practice of retail pharmacy. Most medication errors are prescriber errors, not dispensing errors. Error checking in health care is very hard to automate, because there are always exceptions to the rule, and you always need to be able to override normal parameters to account for it.

How I negotiated with Sallie Mae/Navient to save $115K on my student loans

March 22, 2015

This article is for people who have defaulted on their Sallie Mae/Navient student loans. If you haven’t defaulted, or if you’re paying traditional subsidized or unsubsidized federal loans, this won’t work for you. For those of you that ARE in this position, this post is for you. You can get your life back.

I’m sharing all of my actual numbers, because it makes the conversation more useful.

Managing the chaos

Like many people, I was unemployed in 2009-2010. I had the bad fortune of graduating in the middle of the recession, and had quite a bit of difficulty finding a “big kid” job, i.e. one that would let me pay my bills–including my student loans. Also like many people who are struggling with debt they can’t pay, I was plagued by phone calls, and they were universally unproductive, because stones don’t have much blood to give. The first step to getting your feet under you is to create mental space, and the biggest thing is to stop the unwanted calls.

In addition to sending letters, I did this:

  1. Get a Google Voice number
  2. Log into your delinquent accounts, and use the Google Voice number as your only phone number
  3. Don’t answer numbers you don’t recognize
  4. Take down each collection agency’s contact information (phone number, debt they’re collecting on, etc.) when they leave you a voicemail
  5. Block each caller one by one

This builds a strategic rolodex for tackling your debts when you’ve got your feet under you. If getting back on your feet takes a while–it took me 2 years–you’ll notice that debt gets resold fairly often, and as it gets resold, the settlement offers get better and better. This is particularly true for unsecured, consumer debt, and less true with student debt.

Negotiating with Sallie Mae/Navient and FMS

Sallie Mae stops trying to collect debts themselves fairly quickly, and they tend to outsource this to other agencies. Unlike consumer debt, Sallie Mae does not sell the debt to the servicing organization. Instead they retain ownership of the debt, as well as the terms and conditions under which that debt may be settled. (In fact, if you try to call Sallie Mae directly, you will be redirected to the servicing agency without ever having talked to a human being.) The debt collector is just a proxy, but they’re the ones you’ll be dealing with.

My debt was serviced by an organization called FMS. You can Google them; there are many horror stories, but my experience was pretty good, barring a few incidents. I had settled a couple of smaller credit card debts to this point, so I made sure to unblock their phone number only when I had a small lump of money available to make a down payment. I knew I wasn’t going to be able to discuss a full settlement, but maybe I could do something to move the needle in the right direction. This ended up being a good move, though the benefits weren’t obvious until much later.

Default settlements

I’m going to use the term “default settlement” below. I don’t know for sure, but I believe that Sallie Mae’s proxies are authorized to offer some percentage (65-70% or so) as a settlement amount, without phoning the Sallie Mae mothership. The reason I believe this is true, is because they would periodically offer me settlements on the spot which didn’t require them to phone home. This was in contrast to my counteroffers which required a ~24-48 hour turnaround time where they had to talk to someone with more authority.

The reduced-interest plan

June 2011 balance: $144,586.

I brought my account up to date on July 25, 2011 with a $1,493.38 payment, and set up a recurring payment every two weeks for $372.56. This was their “reduced interest plan”, where the interest rate dropped to 0.01%. There was no discussion of a settlement at this point that I can recall. If there had been, it would have been WAY more money than I had, so it didn’t matter.

I made bi-weekly payments from July 2011 to May 2012.

The first settlement offer: the first $80K

In May 2012, I got a phone call from FMS to re-up my recurring payments. (They can only schedule 12 at a time.) At this time, the rep I had been dealing with all along offered me a settlement that was still too large for me to take advantage of in one shot. I told her as much, and if I recall correctly, she conferred with her manager and the Sallie Mae mothership, and they made me a counter-offer: an $80,000 reduction if I:

  1. Made a $7000 down payment by the end of the month
  2. Paid $800/month for 45 months
  3. At the 0.01% interest rate

This dropped the loan term from 155 months to 45 months, a 9+ year reduction. BUT, if I broke the terms, the full balance came back at the original interest rate, minus whatever I’d paid. I went for it, because saving $80,000 and 9 years was too good to leave on the table.

  • Settlement starting balance: $45,375
  • Made the $7000 down-payment (with my dad’s help) in May 2012, which
  • Reduced the amount left to pay to $36,375 (or so I thought, more on that below)

I set up a $400 recurring payment every 2 weeks, including months with 3 weeks to ensure I’d make the deadline with some headroom.

A bump in the road

Unfortunately, FMS wouldn’t send me paperwork stating the terms of the settlement, which (as I suspected) came back to bite me. I also hadn’t recorded our phone conversations, because until this point, there was no reason to think that I would need to.

December 2013 rolled around, and I received a phone call telling me that I was almost out of time, and that I owed like $45,442 by ~February 2014, which didn’t sound right. Unfortunately, I was dealing with a new representative, and she couldn’t decipher the notes of the previous representative. It was my notes against theirs… and when you’re in this position, the other party holds all the cards; you’re just along for the ride, hoping they don’t fuck anything up too badly. (That said, I’m very confident that my notes were more accurate. Not that it mattered then, and I can’t imagine it would have mattered in a courtroom.)

There was about a week of back-and-forth, but the takeaway was that I owed the $45.4K, but that the terms were extended until September 20, 2018. That was a big relief–there was no way my pre-wife and I could have come up with the money in that time.

I made sure to record that conversation should things go awry again. Check the laws in your state… my state is a two-party state which means that I needed the rep’s permission to record the conversation.

The final $20K

Because FMS can’t schedule more than 12 payments at a time, I end up talking to them about once a year. While re-upping my payments for this year, the rep mentioned that for whatever reason, Sallie Mae was accepting settlements “for pennies on the dollar this month”. That’s just a figure of speech, so I didn’t know if that was literally pennies or what, but she asked if I was interested in seeing if they would re-negotiate the settlement, because I’d basically paid $35K already, and was a model citizen. Of course I said yes, and they offered me their default settlement of $24K on the $35K owed on the spot, which is 68 cents on the dollar. I told them I couldn’t do more than $10K–a true statement–fully expecting a counteroffer for somewhere between $10-20K, whereupon we’d have to borrow some money from my wife’s parents. They said they’d have to call SLMA to see if they’d approve it.

The next morning, I got a call back: Sallie Mae had approved the $10K for the remaining $35K. The rep was shocked. The manager was shocked. They told me no one in the office had thought it would go through, which I believe. I get the feeling I’m going to be an office legend for the foreseeable future.


  • $144,586 original balance
  • $45,898 paid over 3.25 years
  • $98,688 saved
  • 68% discount (or 32 cents on the dollar) when all was said and done

FMS payments

Here’s a Google spreadsheet that shows all the debits over that time. Alternatively, you can download the Excel version.

FMS payments 2011 to 2015

Total student loans paid during this time

I have more traditional subsidized and unsubsidized student loans that actually had interest rates, so I focused on overpaying those during this time.

All student loans between 2011 and 2015

Conclusions and tax implications

Once you wrap up your settlement, you’ll have taxes to pay. In my case, my income tax burden for 2015 is now my salary + $98,600, which is… a lot. Depending on where you are financially, you may be able to reduce the canceled debt “income” by whatever your net worth is, if it’s negative by filing a Form 982. To determine if this is available to you, you can fill out the worksheet on page 8 of this IRS form. If the sum you come up with is negative, you can subtract that amount from your paper “income”. (I suggest you talk to an accountant if this applies to you, though.)

Other options include maxing our your pre-tax retirement contributions (401k/403b), and/or using your FSA plan to do something expensive like getting the LASIK you always wanted. Unfortunately, doing this latter thing requires knowledge ahead of time that you’ll be settling during this particular FSA year.

Otherwise you’ll want to adjust your tax withholding, because you’ll pay an underpayment penalty in addition to the tax on this “income” if you don’t pay enough tax throughout the year.

So I settled on a settlement saving my wife and I about $100,000 and ten years. This will let us buy a house and start a family years earlier than we had thought we’d be able to. I think my situation may be unusual, but I don’t believe for a moment that I am a beautiful and unique snowflake. Three and a half years ago, my Sallie Mae situation seemed hopeless, and now… it’s over. It took a lot of hard work, and an unwavering focus to get here, but it can be done.

If I can do it, so can others.

Addendum – June 1, 2015

I wrote this article back on March 22 — 3.5 months ago. I had expected to be able to publish this much earlier, when I got the statement that our business was concluded. During this period, a few things happened

  • I never received the paperwork stating that I had fulfilled my side of the deal
  • Sallie Mae/Navient and FMS parted ways as business partners, which made it harder for me to get information from either one of them
  • I had to fight with Sallie Mae/Navient in an attempt to get them to send me paperwork. They never did. When I talked to them on the phone, they stopped allowing me to record our conversations for some reason

Until today, I had no idea whether this was really done or not. I pull my credit report every year, and was expecting to wait until the summer in order to see if the status of my Sallie Mae/Navient loans were changed. But I bought a new car last week, and part of the financing involved the dealership pulling my credit report, which I was able to take a picture of. It indicated that the loans were settled for less than the balanced owed.

I feel reasonably confident that this is the end. Finally.

Leave a comment

  • If it’s your first comment on my blog, it will probably go into the moderation queue. Don’t worry, it’s not lost; I just need to approve it. It could be a few minutes, hours, or days. I will get to it, though.
  • Try to explain how your situation is different than people that have commented before you. Questions that amount to “I owe money, but can’t afford payments. What should I do?” aren’t constructive.
  • I will assume all questions are about private loans only. Federal loans are a completely different kettle of fish.

1099-C update – Feb 2, 2016

I received ten(!) 1099-C forms from Navient on Jan 28. When I reported them on my taxes, I collapsed them down into a single entry for the total amount. I also filled out insolvency Form 982. I was deeply insolvent at the time of the discharge, so instead of paying income tax on an extra $115,282, I only paid income tax on $32,313, because I was underwater by $82,969.

I used TaxAct, which made the process very straightforward. I collapsed the ten forms into a single line item because TaxAct cannot handle more than five 1099-C forms, and their Form 982 worksheet can only be applied against a single line item. We’ll see if the IRS complains. (I don’t know why they would:- the numbers are identical whether they’re reported across ten line items or one.)

Settlement amounts from other readers

Saying no

Here’s a short list of things I’ve said no to in the last two weeks:

  • Joining Toastmasters
  • Joining a second developer book club
  • Joining a reading competition at the library
  • Taking a second class
  • Participating in an ongoing lean and agile forum

I’ve come to really enjoy doing things deliberately: focusing on a handful of things I really care about and enjoy.

By contrast, here are some thing I haven’t said no to:

  • Spending time with my wife cooking and playing video games
  • Spending an extra 20 hours a week on my side project
  • Taking an extra 2 hours to practice some problem sets to make sure I really understand the material in the one class that I am taking

Time is finite. Your attention is finite. Spend them both deliberately.

Doing things well takes time

I’m not the world’s fastest programmer, nor am I the slowest, and much like any person who does creative work, there are times when things come easily, and times where it’s a slog. But regardless of the day-to-day ups and downs, I’ve come to appreciate a simple fact in recent weeks: doing things well takes time.

A little while ago, I started working on a computational biology library that I’m calling BCompute. The idea came as I was working my way pretty quickly through the challenges at If you look at the challenges there, you’ll see that most of them are pretty easy to solve in a script-y way that works for a narrow set of cases. (I.e. the one you’re working on.) String manipulations, analysis, and so forth are pretty straightforward in most high-level languages.

Somewhere around problem 5 or 6, I got to thinking that it would be fun create a compbio library exploring the domain, and becoming a better developer along the way. I didn’t want to just build a collection of scripts; I wanted to build a real, performant library with concepts modeled at the proper level of abstraction, with a type-safe, unit tested, composable domain model that could be used for more than just toy problems. So I started reworking those scripts into something real.

Now, about a month later, I have a library that is getting closer to being able to Do Stuff, and will mostly keep you from doing the wrong thing. Along the way, I’ve learned a lot, and had quite a bit of fun. But man does it take time to do things The Right Way–even when you understand the domain pretty well, which is an advantage that I certainly don’t have. (Though I’m getting there.)

  • Writing tests takes time
  • Squashing bugs takes time
  • Refactoring objects and interfaces takes time
  • Building composable objects takes time
  • Learning and then accounting for the biochemistry edge cases takes time
  • Applying a growing body of domain knowledge to your object model–which appears deficient in new and interesting ways the more you learn–takes time

After 100+ commits, 130+ unit tests, and more refactoring than I can even remember, the most salient thing I’ve learned is that it all takes time. (And there’s still a long way to go…)

“What would happen if I took a shot of mercury?”

Short answer: probably nothing.

Longer answer: Two guys I work with asked me yesterday what would happen if they each took a shot of mercury. Unfortunately I was in the middle of addressing a production issue, and couldn’t really answer, but it was a fun question, so here’s the answer…

Elemental mercury (quicksilver) isn’t absorbed very well by your GI tract. In fact, it appears that less than 0.01% of whatever amount you consume will be absorbed, assuming you have a healthy GI tract. Conversely, this means 99.99% will be excreted without it reaching your bloodstream. So a shot of liquid mercury is unlikely to do you any lasting harm, though I wouldn’t recommend it.

Much more dangerous is aerosolized mercury which is readily absorbed in the lungs, where absorption rates reach 80%. Also dangerous is methylmercury, an organic compound. (This is the mercury that you’ll find in fish.)

(One of these days, I will import all of my old pharmacy blog posts into the archives…)