Monday, August 21, 2017

vlog02 - Pringles eclipse viewer

This morning I made an eclipse viewer. If you can't make one, just go out and look under a tree. Where there should be sun spots you will see eclipse spots, which are crescent shaped unless you happen to be where there's a total eclipse.

vlog 02

Sunday, August 20, 2017

vlog01 - So I'm starting a vlog

This has been a long time coming, and it is no coincidence that this is my 500th blog post, but after multiple family emergencies and about 6 months, it's finally here. Introducing my vlog:

I plan to explore this new format, share a more, especially using more than just words. I have a lot of ideas, so if I can get even half done I'd be more than happy. I hope you all enjoy.

P.S. I might be copying existing vloggers styles that I like until I get a style of my own.

Tuesday, June 13, 2017

How to Find The Entitlements a macOS App

Sandboxed apps have their entitlements embedded into the signing data. To see what any app's entitlements are, type the following in Terminal:

codesign -d --entitlements - /Applications/
This will print out a plist. For example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Thursday, April 27, 2017

Bash Scripts Auto Download Dependencies

Often times bash scripts I run depend on other tools. Tools that are sometimes updated. So once in a while I add the following curl command to download the latest tool.

  curl -O [filenameURL]

Tuesday, April 25, 2017

Building a Raspberry Pi Security Camer - Part 1

1. Download motionEyeOS ( For example I have a Raspberry Pi 2 so I downloaded "motioneyeos-raspberrypi2-20161125.img.gz".

2. Next, figure out which volume your SD card is. Insert your SD or micro SD card. On macOS, run terminal and type:

>diskutil list
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *480.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage                         479.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Main                   *478.9 GB   disk1
                                 Logical Volume on disk0s2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB    disk2

   1:             Windows_FAT_32 NO NAME                 15.9 GB    disk2s1

3. If the card has already been partitioned and mounted then continue with this step. Run diskutil unmountDisk /dev[disk#]. For example: diskutil unmountDisk /dev/disk3 will unmount the SD card volume. Alternatively you can run Disk Utility and unmount the SD card volume.

4. Run:

>sudo dd if=motioneyeos-raspberrypi2-20161125.img of=/dev/disk2 bs=1048576

then wait a little while as the image is written to the SD card.

5. Put the SD card in the pi with a video camera installed and viola!

Next I'll post about some options for housings for the pi.

Monday, April 24, 2017

macOS Window of Application has gone off screen

Once in a while a window of an application goes off screen and it can't be moved or resized. I've seen various approaches to get the window back but by far the easiest is to change the resolution. Once you change the resolution all windows are moved to be back within the screen and you'll get the window back.

Tuesday, April 11, 2017

Super Awesome Debugging Technique with Comments

Here is a trick I learned many many years ago and it remains one of the best tools in my debugging toolbox for all programming languages. This example just happens to be in C++.

#include <iostream>

int main(int argc, const char * argv[]) {
    std::cout << "Hello\n";
    std::cout << "Hello, World!\n";
    std::cout << "A different Hello!\n";
    return 0;


now remove the first slash in the front of the first comment and you get:

#include <iostream>

int main(int argc, const char * argv[]) {
    std::cout << "Hello\n";
    std::cout << "Hello, World!\n";
    std::cout << "A different Hello!\n";
    return 0;


This is such a handy debugging technique.

Thursday, April 6, 2017

Programmatically Creating a Window on macOS

Programmatically creating windows without using a NIB file can be tricky on the Mac. Especially if you're developing in C or C++ instead of Objective-C. Here's one of the issue most common that may come up.

Assuming you got the window creation code right, you may be thinking everything is going to work, but you get this error:

Oct 30 17:34:39  myapp[48617] : kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Oct 30 17:34:39 myapp[48617] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

This means your NSApplication is not being initialized. In other words, the Objective-C side of your system needs to be properly initialized. Adding the following line may help:

[NSApplication sharedApplication];

Most likely you aren't trying to do this so it is never an issue, but for those few souls out there this might just save you some serious time.

Thursday, March 30, 2017

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


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.