DailyOje Made Open Source

I’ve open sourced one of my side projects, DailyOJE(Online Journal Entry). It was something I threw together quickly as a proof of concept as well as a testbed for Twitter OAuth integration.

Its a simple tool designed to eliminate all distractions when writing.

You can find it on Github.

The Homepage

The Login Screen with Twitter OAuth

Sample Entry

Projects

Wordpress to Octopress

Self hosting wordpress is no fun. Even without any plugins installed there is a constant stream of security updates to worry about. Every plugin you do use is a huge gaping security hole waiting to happen. With each and every wordpress update theres a 50/50 chance it will break your theme and/or plugins. Ever tried updating a theme that you made custom changes to?

Using a hosted platform like wordpress.com or WPEngine.com relieves you of most of this burden, but there are still the security exploits constantly being found. It also costs an arm and a leg for a humble personal blog.

My weekly reminder to update VPS and Wordpress Security

Octopress with free hosting on Github is one of the better options. Hosting on Github gives you the benefit of their reliability and CDN (not to mention its free!). Using Octopress means a completely (almost) static site thats easy to maintain and quick to load.

Starting an octopress blog from scratch is dead simple. Follow the directions here. Converting from Wordpress is a little bit tricky, but still manageable. Use ExitWP to convert your posts to markdown. If you have comments convert them to Disqus and they should seamlessly transfer if the URL stays the same.

Following these two guides as well as Octopress’ own documenation I was able to do the entire transfer in an afternoon.

Migrating 40,000 Posts from Wordpress to Octopress

Switching to the Octopress Blogging Engine

Good luck!

Tech

Move BitBucket Repository to Github

Alternatively titled “Move Remote Git repository to a new Host”. These instructions apply for any remote git hosts.

1
2
3
4
5
6
7
8
9
10
11
#What remotes am I currently configured for?
git remote -v

#Remove these remotes
git remote rm origin

#Set up new remote
git remote add origin https://github.com/kylethielk/DailyOje.git

#Push existing history to new remote
git push -u origin master

Sidenote: Referring to services like Github as ‘remote hosts’ is disingenuous since git is decentralized. All repositories are treated equal and our daily git routine is simply keeping all of them in sync. Referring to them in this manner can help clarify which copy we are referring to.

Tech

Include Native *.so Library in APK With Android Studio

Using the Android NDK is well documented throughout the internet if you are still using Eclipse. The process is basically the same with Android Studio until the time comes to build your APK. The APK will build fine, but your library *.so file will be missing from the APK and when you attempt to load it with System.loadLibrary(“mylibrary”) you will get:

1
java.lang.UnsatisfiedLinkError: Couldn't load mylibrary from loader dalvik.system.PathClassLoader

You can view the contents of your APK with the following command to verify libmylibrary.so is not in the APK:

1
unzip -l MyApp.apk

Android Studio’s build tool will not look in the usual place:

1
2
SharedLibrary  : libmylibrary.so
Install        : libmylibrary.so => libs/armeabi/libmylibrary.so

The trick (thanks to this thread: https://groups.google.com/forum/#!msg/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J) is to move libmylibrary.so to:

1
src/main/jniLibs/armeabi/libmylibrary.so

Voila, your native code is now compiled into your APK. This should work with build tools 0.8+

Tech

VMWare Fusion 5: Could Not Open /dev/vmmon: No Such File or Directory.

I ran into this issue recently with VMWare Fusion 5. All of the sudden none of my virtual machines would start. They would all error out with “Could not open /dev/vmmon: No such file or directory.”

After much head banging I remembered that I had recently installed Intel HAXM. Taking a stab in the dark I uninstalled HAXM:

1
sudo /System/Library/Extensions/intelhaxm.kext/Contents/Resources/uninstall.sh

Voila! All of my VM’s happily start. My emulators run extremely slow, but at least I can run virtual machines. Will update if I figure out how to get them running in parallel.

Tech

Lending Club Strategy

Lending Club Screenshot

I was rather late to hop on the Lending Club bandwagon. I live in a state where it is not legal invest on the Lending Club platform. I can however invest on the secondary market.

Admittedly it took me awhile to warm up to the idea of investing on the secondary market. The platform used to SUCK both aesthetically and from a loan filtering standpoint. When there are currently over 100,000 loans to sort through, you need good filtering capabilities. Fortunately both issues have now largely been fixed and its actually quite easy to use.

Its true that you will more than likely pay a markup on any loan purchased through the secondary market. This markup is completely worth the cost as you get to benefit from seeing the lendee’s payment history. I personally think this is a much better indicator of likelihood of defaulting than any other. It certainly gives me more confidence when investing in low quality (but higher paying) loans.

These are the two sets of filter criteria I use(one a slight modification of the other):

For 36 Month Loan Term:

Interest Rate: All Loan Term: 36 Months Outstanding Principal: 0 – Any Loan Status: Issued,Current, Never Late * Remaining Payments: 28 Recent Credit Score: All Credit Score Change: Up or Same Original Note Amount: 25 – Any Asking Price: 0 – 100 Yield to Maturity: 13 – Any Markup/Discount: No more than 1% markup Exclude Loans I have already invested in: Yes

For 60 Month Loan Term:

Interest Rate: All Loan Term: 60 Months Outstanding Principal: 0 – Any Loan Status: Issued,Current, Never Late * Remaining Payments: 50 Recent Credit Score: All Credit Score Change: Up or Same Original Note Amount: 25 – Any Asking Price: 0 – 100 Yield to Maturity: 15 – Any Markup/Discount: No more than 1% markup Exclude Loans I have already invested in: Yes

* One filtering criteria not available but that I still do manually is: “Never been in grace period before.” I immediately reject any that have ever been in grade period. This adds some grunt work, but is important.

Notice I demand a slightly higher rate of return for 60 month loans. Its my opinion that 36 month loans are less likely to default simply because there is less time for something financially devastating to happen in.

I also cap the asking price at $100. It is important to spread your risk out over as many loans as possible. I am currently spread out over 767 loans with only 7 in grace period or worse.

This criteria is pretty strict. There are times when no loans will be available. You can often ‘unlock’ some more by bumping the maximum markup to 2%, but I prefer to wait.

General

Build iOS App With Jenkins: Code Signing Issues.

Building an iOS application in xCode is easy. It automatically handles all of your certificates and provisioning profiles. Sure it can be finicky at times, but for the most part it just works.

Automatically building your application (i.e with Jenkins) is not so easy. You have to ensure that your private key, certificate and provisioning profile are configured and available. Recently I found out that this is easier said than done.

Ensure your provisioning profile is available

This one is easy. Simply download your provisioning profile from the Developer Center to the build machine and double click it (make sure you are logged in as the user that will be used for your automated builds). xCode will automatically add it to your list of available provisioning profiles. You can see a list of all of your provisioning profiles by browsing to:

~/Library/MobileDevice/Provisioning\ Profiles/

Add your Certificate and Private Key

This is the tricky part. On your development machine you are more than likely running as an administrator (whereas on your build machine the ‘build user’ should not be). Simply adding your certificate and key file to the System/Login Keychain and just expecting them to work….well it won’t work. The solution is to create a new keychain, add your certificate/key here and tell your build to use this new keychain. Note: the creation of a new keychain is not 100% necessary, but I prefer it. Once you start building multiple projects on one machine it helps keep things organized.

The following is the pseudo code of what I use. First create new keychain:

1
2
3
4
5
6
#Create keychain
security create-keychain -p <i>YourPassword</i> NewKeychain.keychain

#Import Cert/Key - The -A flag is what allows non-interactive use of cert
security import /path/to/my.cert -t cert -k NewKeychain.keychain -A
security import /path/to/private.p12 -t agg -k NewKeychain.keychain -A

The build script can then be adjusted as so:

1
2
3
4
5
6
7
8
9
10
11
#Load keychain, and unlock it
security list-keychain -s "/var/lib/jenkins/Library/Keychains/NewKeychain.keychain"
security default-keychain -s "/var/lib/jenkins/Library/Keychains/NewKeychain.keychain"
security unlock-keychain -p "YourPassword" "/var/lib/jenkins/Library/Keychains/NewKeychain.keychain"

<Run Build>


#Reset to login keychain
security list-keychain -s "/var/lib/jenkins/Library/Keychains/login.keychain"
security default-keychain -s "/var/lib/jenkins/Library/Keychains/login.keychain"
Tech

Android Studio Unit Testing Setup

I am surprised that there is not official documentation to get a simple “Hello, world!”-esque unit test setup running in Android Studio.

Fortunately I stumbled on this dead simple guide for running your first unit test in Android Studio: http://nikolaj.hesselholtskov.dk/2013/10/how-to-add-unit-tests-to-android-studio.html

Tech

Objective-C: Instantiate Child Class From Parent

A common problem encountered (in any language) is how to instantiate a child class from an instance of a base parent in a generic way.  In Objective-C take for example:

1
2
3
4
5
6
7
8
9
10
11
@interface Vehicle : NSObject

@property (copy,nonatomic) NSString *name;

@end

@interface Motorcycle : Vehicle

@property (copy,nonatomic) NSNumber *engineCC;

@end

If we have an instance of Vehicle and we want to get an instance of a Motorcycle we could manually copy each property:

Manual Property Copy

1
2
3
4
5
6
Vehicle *vehicle = [Vehicle new];
vehicle.name = @"MyVehicle";

Motorcycle *motorcycle = [Motorcycle new];
motorcycle.name = vehicle.name;
motorcycle.engineCC = [NSNumber numberWithInt:200];

Seems simple enough in this case, but when the property count starts increasing so does the amount of typing. If only there were a better way…:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+ (void) copyParent:(id)parent intoChild:(id) child
{
    id parentClass = [parent class];
    NSString *propertyName;
    unsigned int outCount, i;

    //Get a list of properties for the parent class.
    objc_property_t *properties = class_copyPropertyList(parentClass, &outCount);

    //Loop through the parents properties.
    for (i = 0; i < outCount; i++)
    {
        objc_property_t property = properties[i];

        //Convert the property to a string.
        propertyName = [NSString stringWithCString:property_getName(property) encoding:NSASCIIStringEncoding];

        //Get the parent's value for the property
        id value = [parent valueForKey:propertyName];

        //..and copy into the child.
        if ([value conformsToProtocol:@protocol(NSCopying)])
        {
            [child setValue:[value copy] forKey:propertyName];
        }
        else
        {
            [child setValue:value forKey:propertyName];
        }

    }
}

Note: Make sure to import objc/runtime.h:

1
#import <objc/runtime.h>

Sample Usage (assuming we put the method in a class called Utils):

1
2
3
4
5
Vehicle *vehicle = [Vehicle new];
vehicle.name = @"MyVehicle";

Motorcycle *motorcycle = [Motorcycle new];
[Utils copyParent:vehicle intoChild:motorcycle];
Tech

Quicken: How to Not Do Customer Support

My “Express Web Connect” to Wells Fargo with Quicken 2014 just stopped working one day. Quicken displayed a generic “Error CC-502” and simply suggested trying again in a few days. Three weeks pass with the same result. I decide to contact Quicken Support via Online Chat.

The final outcome.

Dear Kyle Thielk,

I apologize, but due to technical limitations on how our connection works with Wells Fargo we will be unable resolve your connection problem. Your options at this time are to download your Wells Fargo accounts through Web Connect or contact Wells Fargo to see if Direct Connect is available option.

For Further clarification, you can contact your bank. Again we apologize for the inconvenience this will cause.

Sincerely, Quicken Customer Care

Comforting. Very comforting.

General