Author Archive

Speaking OFX Using Go

Thursday, May 11th, 2017

I’ve been working on a web-based mint.com/Gnucash/Quicken clone I’m calling ‘moneygo‘ off and on in my spare time. One important feature of these types of programs is the ability to automatically import transaction and balance information from a user’s financial institution. In the US, this functionality is primarily supported by banks via the OFX specification.

I spent some time exploring my options and was unable to find an OFX library written in Golang capable of not only parsing OFX responses, but generating the request files as well. Generating the request file is important because otherwise the user must obtain the OFX file out-of-band (i.e. most likely logging into their bank and downloading it with a web browser). It is much more convenient for your financial management software to do this automatically for you. I actually ended up briefly using libofx before deciding that the C-to-Go interface was too awkward to make it a reasonable solution – converting complex types from C to Go is not fun.

So, I did what any self-respecting programmer would do – downloaded the OFX spec and wrote my own OFX generator and parser in Go: ofxgo. This process was somewhat tedious at times(there are a lot of OFX elements, particularly for investment transactions), and I didn’t implement nearly all of the spec. However, the result is a library that I’ve been able to use to download bank, credit card, and investment transactions and balances for all of my financial institutions! Along the way, I also created a sample Golang command-line client which can be used to test the library with your bank, download and/or parse OFX, or even to help detect the correct settings to use with your bank.

I hope my ofxgo library will enable others to more easily access their financial data using OFX, and am looking forward to getting it fully integrated with moneygo. Don’t hesitate to let me know if you find bugs or would like to see improvements in this library by creating an issue or pull request on github.

Installing Seafile Client/Server on Arch Linux

Monday, January 21st, 2013

I have previously hacked around some on my own open source Dropbox clone, but I haven’t had the time lately. I came across a project called Seafile, which looks promising as an open-source Dropbox alternative. Unfortunately, they don’t package their installation for Arch Linux, so I had to get my hands a little dirty to try it out. I created four AUR packages for seafile and its dependencies:

For the curious, my installation instructions and packages are based on the directions at https://github.com/haiwen/seafile/wiki/Build-and-deploy-seafile-server-from-source and https://github.com/haiwen/seafile/wiki/Build-and-use-seafile-client-from-source. In these instructions, I assume you are using Arch Linux, and that you are familiar with how to use makepkg, pacman & friends to build and install packages from the AUR.

Build/install the Seafile package

You must install the seafile package above, along with all its dependencies. The easiest way to do this is using the AUR helper of your choice, but you can also do this manually if you wish. For most of the AUR helpers, this will look something like

pacaur -S seafile

or

yaourt -S seafile

Install the Seafile server

If you simply want to use the seafile client with seafile.com and are not interested in hosting your own server, skip to the next section. Otherwise, read on to install the seafile server on your machine.

Now that the seafile package and all its dependencies are installed, create a directory where you wish to serve the seafile files out of. This should be somewhere with plenty of space, as all the files served by your seafile installation will ultimately live here. This directory should be owned by the user you want your seafile server to run as. In fact, you should su into that user and run the rest of these commands from there. I’ll refer to the directory you just created as $SEABASE from here on out.

Download seahub, the web server portion of the seafile server.

mkdir -p $SEABASE/seafile-server
cd $SEABASE/seafile-server
wget http://seafile.googlecode.com/files/seahub-latest.tar.gz
tar xf seahub-latest.tar.gz
mv seahub-${version} seahub
cd ..

Run the setup script to generate all the configuration files:

seafile-admin setup

Fill out the requested fields following the provided directions. You may now start/stop the seafile server using the following commands:

seafile-admin start
seafile-admin stop

Note that the seafile-admin commands must be run from the $SEABASE directory.

For more information, consult the Seafile wiki page for installing from source (but remember that the top part of the page won’t apply to you since your AUR helper has downloaded, built, and installed all necessary packages for you).

Using the Seafile client

At this point, the Seafile client shouldn’t need further installation. Running

seafile-applet

should start the client, presenting a configuration screen on the first time it is run.

 

Enjoy! And, of course, let me know if you encounter any problems.

 

Update (2013.03.08): Updated seahub-latest.tar.gz download URL.

Thankfulness: Thanksgiving Edition

Tuesday, November 27th, 2012

Having missed my normal shopping day because I was out of town visiting relatives and stuffing my face over Thanksgiving, I went to the grocery store tonight. As I pondered which type of beer I thought would work best as part of the “Becker Barbecued Shrimp” recipe I had picked out to try this week, I heard a faint “excuse me, sir”. From the way he asked, I don’t think it was the first time he had tried to get my attention.

He was a thin man with a taut face and scraggly hair. He was still wearing his work clothes, a pair of paint-splattered jeans and a too-small sweatshirt. It was hard to tell whether the patches of white in his hair were flecks of paint from today’s job or from years of hard labor. He softly said “Could you tell me if I need an oven for this pie, or if it’s already cooked? I can’t read too good.”, as he handed me a frozen apple pie. I turned the box over a few times, looking for the instructions. As I found them, my heart sank, and I told him “it says ‘pre-heat the oven to 400 degrees’, so I think you need an oven.” As I handed the frozen pie back to the man, he explained he didn’t have an oven so that wouldn’t work. He thanked me and walked away, not visibly upset.

As I reflected on my interaction with this unnamed man, it evoked more emotion then I’d felt in weeks. Here was a man with no stove at home, forced to resort to asking passers-by whether he would be able to eat what he’d picked from the shelves. Moved, I immediately wanted to do something to help him. But what? How? I considered trying to tell the cashier I would cover his groceries, but worried about how to do it discretely as I continued shopping, and the opportunity passed. I don’t know that paying for a day or two of his groceries would have helped him much in the long run, but it may have brightened his day. I felt thankfulness, pity, shame, and helplessness all at once.

Thankfulness that I wasn’t in his shoes. Pity for a man obviously knocked around by life. Shame for being born into the life I was without ‘deserving’ it. Helplessness because this man’s problems weren’t something I could quickly, easily, discretely fix by throwing a few dollars his way – my desire to ‘fix’ his life couldn’t be instantly gratified as so many of my other desires can.

The traditional American Thanksgiving involves sitting in front of a TV all day, devouring a meal so extravagant we’ll have to spend more money on a gym membership come January, and fighting in line with other people to buy the latest gadget we don’t really need. Apparently we as a culture think that sheer indulgence is the best way to demonstrate how thankful we are for our good fortune. Don’t get me wrong, I appreciate the value of taking a break from our labors and getting to see friends and family. It’s just that our traditional Thanksgiving behavior doesn’t exactly demonstrate the type of true humility I associate with thankfulness.

When the man approached me to ask about the pie, I had 10 cans of fruit and vegetables in my cart to be donated to a local food pantry. When I put them in my cart, I felt like I was doing more than my fair share, since my employer had only asked us to bring 4 cans each. After talking to this man, it seemed silly, futile even – my ‘generous’ 10 cans aren’t going to buy this man a stove or to teach him to read. They cost me $10, when I have plenty to spare each month.

This holiday season, I encourage you to be more than merely thankful, but to be helpful and generous to those you would rather forget about. I am going to do my best to do the same. Even if it means sacrificing a little more than my meager 10 cans.

I am Ashamed to be a North Carolinian Today

Tuesday, May 8th, 2012

North Carolina passed a constitutional amendment banning same-sex marriage today. This is the most ashamed I have ever been of my state. Yes, much of what this amendment does was already law, but codifying bigotry more firmly into the law is a step in the wrong direction.

The amendment will add this language to the North Carolina Constitution:

“Sec. 6. Marriage.
Marriage between one man and one woman is the only domestic legal union that shall be valid or recognized in this State. This section does not prohibit a private party from entering into contracts with another private party; nor does this section prohibit courts from adjudicating the rights of private parties pursuant to such contracts.”

Though it is unclear if and how this amendment will affect heterosexual couples, it is clear that it firmly prohibits same-sex marriages and civil unions. Much campaigning against the amendment has been done on the grounds that it will affect non-gay couples and their rights also. Even if this is true (I’m not qualified to say), I believe this is a weak argument which entirely avoids the main issue. Below I address the popular arguments against same-sex marriage and the reasons I support it.

Separation of Church and State

Does no one care about this any more?

I am Christian, and am getting married in a little over two months. I am a firm believer that marriage is an institution of the church and a holy covenant. However, I am equally sure that the Bible says absolutely nothing about making sure only heterosexual couples can jointly file their taxes or have other legal benefits. We have conflated the religious concept of marriage with the state concept of marriage. Ideally, we might have the two separated – i.e. have a ‘civil union’ which is recognized by the state, and a ‘marriage’, which is recognized by the church.

However, for various cultural, religious, political reasons, this is not going to happen. We might just have to settle for the next best thing: the state allowing marriage between any two adults who wish to become legally married. In this arrangement, individual churches/denominations/religious groups are not forced to marry anyone, but are given the freedom to do as they choose. In fact, this is exactly what would happen if the amendment was repealed and the current law prohibiting same-sex marriage was stricken from the books. Your church doesn’t have to marry gay people if it doesn’t want to, but the state has to recognize such a union as a matter of civil rights.

On the “Sanctity” of Marriage

I have a very hard time accepting the argument against same-sex marriage on the basis that it destroys the sanctity of marriage. The sanctity of marriage is destroyed by those who get married before they are ready, abuse their spouses, divorce without trying reconciliation, and those who get married just for fun on a whim. The gay couples I know are just as committed and loving towards each other as any heterosexual couple (perhaps even more so because of all the hardships they have had to endure).

Furthermore, if you believe the value of your own marriage (past, present, or future) depends on whether or not others’ marriages are recognized, I pity you. Personally, I will value my upcoming marriage based on the love and respect we have for each other.

On Homosexuality Being A Choice

Homosexual teens suffer from a tremendous amount of bullying in today’s schools. The number of homosexual teens who have suicidal thoughts or attempt suicide is much higher than their heterosexual peers. According to the various studies summarized in this brief from the Suicide Prevention Resource Center, LGB (lesbian, gay, bisexual) youth are between one and a half and seven times more likely to report having attempted suicide than their straight peers. I have witnessed this first-hand – it is real and it hurts. What, then, is the benefit to them of ‘choosing’ to be gay? If they had any sense at all, they would just start being heterosexual in order to avoid that stigma and embarrassment, right? Unless, of course, it isn’t a choice.

It has been shown that the tendency to be homosexual is affected by birth-order in males and furthermore that there are measurable differences in brain activity between people with different sexual orientations (see this article). There is an excellent movie entitled “For The Bible Tells Me So” which tackles the issue of homosexuality and religion together. Here’s a clip from its discussion on whether homosexuality is a choice.

On Marrying Your Toaster

A common argument is that if same-sex marriage is allowed, it might be a “slippery slope” which leads to people marrying their monkey, rhinoceros, tomato, or toaster. This is almost too absurd of an argument for me to comment on. In my experience, slippery slope arguments are usually the product of fear rather than rational consideration. Marriage (the state form, at least) is a legal contract between two people. Unless your monkey or your toaster is capable of consenting to marrying you and signing the marriage application/license at the courthouse, you won’t be able to marry it.

On Fear

This is why Amendment 1 passed. It is fear of something not understood. According to this article, the amendment’s “most visible patron”, Speaker of the House Thom Tillis, notes that he thinks “it will be repealed in 20 years.” This attitude suggests that those voting in favor of the amendment know that equality under the law is surely coming, but they are personally intimidated by something they don’t understand and wish to put it off as long as possible. This attitude is unacceptable.

Shame on you, North Carolina.

How To Fix A Non-Booting Thinkpad From 5342 Miles Away

Wednesday, July 20th, 2011

For reference, 5342 miles is the distance it would take sound approximately 7 hours to travel, or 1.4 times the length of the Amazon River. Of course, distance is somewhat irrelevant with the Internet, but it sounds more impressive that way.

So, on to how it all started. I got a message saying “hi, something is wrong with my computer”. We’re okay so far – that’s a fairly regular occurrence in the life of someone in a technology-related field. Then she told me it wouldn’t go past the very first screen. After a few questions, I figured out she meant the BIOS boot screen, where it does the POST. She had already rebooted several times to no avail. So, the next course of action was to get to the CMOS/BIOS settings and see if we could reset them. After some trial and error, she reported that she couldn’t get that to come up (being a Thinkpad, all you should have to do is press the ThinkVantage button). It was starting to look really bad. At this point, I just about gave up and decided that her motherboard or some other crucial hardware component was failing and that she needed a new laptop.

Fortunately, I turned to Google instead. With a bit of Google-fu and following a few links, I found this somewhat sketchy page (the link is now dead), which explains in broken English that a broken USB port can cause a Thinkpad T400 not to boot. I’m not entirely sure why I didn’t click past that page immediately. Perhaps I looked into it because I remembered her mentioning using a USB drive earlier in the day. Maybe it was because at this point I had gone through just about everything else I knew to do to debug the problem. At any rate, I continued our game of 20 questions by asking her if any of her USB ports looked broken, or like they had pins that were bent in a way so that they were touching each other. It took us a bit of back-and-forth to iron out which port was the USB port she had plugged the USB drive into earlier in the day, and to identify any other USB ports which may be the damaged culprit.

She reported that she had one USB port, and another port beside it that wasn’t quite the same. After some more questions back and forth, we established that the other port was indeed a USB port, but that it was missing the plastic middle piece, much like what the sketchy link described. After she managed to take and send me a picture over her fairly slow Internet connection with the friend’s laptop she was using, I began to hope that there might actually be something to this. The pins in the second USB port were all bent over, and were almost certainly shorting out when she tried to boot it.

Broken USB

USB Port Missing Plastic Pin Support (On Right)

She began attempting to straighten the pins with tweezers and a sewing needle. After she managed to get the pins straight enough so they weren’t touching each other or the grounded sides of the port, she tried to boot the laptop again, and it worked! I am quite proud of the fact that we managed to debug and fix a seemingly defunct laptop from opposite sides of the equator, using only instant messages and one picture.