Thursday, March 30, 2017

Nearing 500 Posts!

I'm closing in on 500 posts over the last 10 years, I know it isn't much but considering I don't actually post that much it's rather remarkable. I've also had well over 1 million views! So stay tuned because if you like to read my blog, I have some plans will bring even more of my ramblings to your screen.

Wednesday, March 29, 2017

More Ergonomics

It turns out I write quite a bit about ergonomics, and those are some of my most popular posts which is surprising but not too surprising since that is one thing that affects everyone.

Desk Ergonomics - Every Diagram on the internet is wrong!

Make the Apple Magic Trackpad Ergonomic

Ergonomics of Using a Cell Phone

Ergonomics

All these issues are still valid, in fact maybe even more so. Sit-stand desks are more popular than ever, but they still aren't good enough. Companies like Fitbit and Apple have pushed wearable devices to help but relatively few people wear them and I'm not sure how much they really help. I personally don't wear a device like a Fitbit or Apple Watch. If this is an interesting subject to you as a reader of this blog, write a comment or like this post so I know to write more. I have a lot more information and access to people who know even more and I believe sharing information is good.

Tuesday, March 21, 2017

C++: Convert Unicode String to ANSI String

I've seen so many examples and questions of how to convert between unicode string and ANSI string using C++. So here is by far the easiest way to do this conversion that I've implemented:

template <typename Facet>
struct TFacet : Facet
{
    using Facet::Facet;
};

wstring stringtowstring(string value)
{
    std::wstring_convert<TFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> conv;
    return conv.from_bytes(value);
}

string wstringtostring(wstring value)
{
    std::wstring_convert<TFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> conv;
    return conv.to_bytes(value);

}

Wednesday, March 1, 2017

Adding a Private Key to macOS Keychain

On macOS, the native SSH client can use the built-in keychain directly which is awesome because you don't have to type in the password every time. To add your private key to the keychain simply use the command:

ssh-add -K /path/of/private/key

For example if your private key's filename is ~/.ssh/id_rsa, you would use the command:

ssh-add -K ~/.ssh/id_rsa

You will then be prompted to enter your password. From now on it's all automatic. Viola!

Update: There appears to be an issue in macOS Sierra where the password is only stored for the currently session. You can follow a thread here. I'll add more information as I run across it.