Sunday, July 6, 2014

Some Thoughts about Bitcoin

I had a flirtation with Bitcoin in the summer of 2013, and spent some resources mining for Slush's pool (https://mining.bitcoin.cz/), but hadn't thought about it in a while.  Until I got a postcard in the mail yesterday, from the Tokyo District Court Civil 20th Division:

I had an account at MtGox (http://www.mtgox.com/), with a few pennies (USD) in it, when they shut down.  Last summer, between mining and a little bit of trading (buying low, and selling a little higher, on average), I ended up about $114 ahead (less unknown electricity costs).

That got me wondering about where Bitcoin was today, and where I had left off.

Dedicated mining hardware is now generally available - Butterfly Labs has a 10GHash/sec miner (https://products.butterflylabs.com/homepage-new-products/10-gh-s-bitcoin-miner.html) for $249 plus $28 shipping, but this seems to be a toy given the computational complexity, and people serious about mining are using systems (like these at https://www.kncminer.com/categories/miners) with 1.5THash/sec - 3THash/sec for $3495 - $5995.

It turns out I have 0.00001891 BTC trapped in Slush's pool as my reward for mining that I did previously, but that never got paid out.  Because the minimum payout is 0.01 BTC, I need to earn 0.0099813 BTC more to get that payout.  Let's see how I can do that.

My graphics card runs at 70MHash/sec, and I earned about 0.00000197 in the last 24 hours running it again.  At that rate, I'll need about 13.8 years before I get up to the 0.01 BTC payout value.  Not really a good plan.

Extrapolating from those value, I think the Butterfly Labs device would earn 0.00028143 per day, and I'd hit the payout in 35.4 days.  But that needs a $277 investment, plus electric power.  At an estimated 80 watt power draw and a $0.10/KWhr electricity cost, for 35.4 days that's $7.20 added to my power bill.

And all that to get a 0.01 BTC payout, which at $630/BTC, is $6.30.  So the cost of electricity alone wipes the value of the BTC, not to mention the device itself.

So I guess all I can do is donate my 0.00001891 BTC to Slush - it'll never get paid out, and he made an extra 1.2 cents off my efforts.  He's running a pool with 5.5PHash/sec (yes, peta-hash per second) computational power and I think he deserves it.

I think I'll confine my Bitcoin involvement to keeping an account at https://coinbase.com/, in case I need to transact something in BTC.

Tuesday, June 17, 2014

Xamarin.Forms cross-platform mobile UI

I promised myself over a year ago that I'd learn some new tricks, and would write about them.  I've done some learning, but haven't had any "aha"s worth writing about ... until now.

My work team has been developing with Xamarin to bring our product to new places (hint: not just Windows).  I haven't contributed any real coding to that, but I've been trying to keep up and learn the environment & fun facts.  (Fun fact: to handle all scenarios and use cases, you should create your iOS application icon in 15 different sizes!)

Xamarin has run a couple of contents - there's a simple task you can perform after installing the software to get a free T-shirt, and their recent contest was to use the new Xamarin.Forms feature of Xamarin 3 to write a mobile app.

I started a "Quote of the Day" application.  The main window is simple -- a title for where the quote came from, the day the quote was published, the quote itself, and a settings button to get to any configuration (like where to go get quotes from).  A number of quote sites provide quotes as an RSS feed, so the non-UI part is just a HTTP request to get the RSS feed, and then some XML parsing.

By writing in C# against the Xamarin libraries, and especially against the new Xamarin.Forms UI library, the code can easily be made to run on iOS, Android, and Windows Phone, which is pretty cool.  The code to define the user interface is this simple:

using System;
using System.Net;
using System.IO;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace Xamarin.Forms.QOTD
{
 public class App
 {
  class MainPage : ContentPage
  {
   Label currentSource;
   Label currentDate;
   Label quoteView;

   public MainPage()
   {
    currentSource = new Label { Text = "<< source >>",
     HorizontalOptions = LayoutOptions.Center,
     VerticalOptions = LayoutOptions.Start,
     Font = Font.BoldSystemFontOfSize(NamedSize.Large),
    };
    currentDate = new Label { Text = "<< date >>",
     HorizontalOptions = LayoutOptions.Center,
     VerticalOptions = LayoutOptions.Start,
     Font = Font.SystemFontOfSize(NamedSize.Small),
    };
    quoteView = new Label { Text = "<< quote goes here >>",
     HorizontalOptions = LayoutOptions.Center,
     VerticalOptions = LayoutOptions.StartAndExpand };
    Button settingsBtn = new Button { Text = "Settings" };

    StackLayout mainContent = new StackLayout {
     VerticalOptions = LayoutOptions.FillAndExpand,
     HorizontalOptions = LayoutOptions.FillAndExpand,
     Children =
     {
      currentSource,
      currentDate,
      quoteView,
      settingsBtn
     }
    };
    this.Padding =
     new Thickness (4, Device.OnPlatform (24, 4, 4), 4, 4);
    this.Content = mainContent;

    LoadQuote();
   }

   async void LoadQuote()
   {
    // Select source of quote
    string source = "BrainyQuote.com";
    string url = "
http://feeds.feedburner.com/brainyquote/QUOTEBR";
    // Create callback object
    Progress<QuoteLoaderProgress> progressReporter = new Progress<QuoteLoaderProgress>();
    progressReporter.ProgressChanged += (s, args) => {
     currentSource.Text = args.Source;
     currentDate.Text = args.Date;
     quoteView.Text = args.Message;
    };

    // Kick off loading the quote
    Task<int> quoteTask = CreateQuoteLoaderTask(source, url, progressReporter);
    await quoteTask;
   }
  }
  
  public static Page GetMainPage ()
  {
   return new MainPage ();
  }
 }
}


My "secret sauce" for this application is fetching the quotes and parsing the XML, so I haven't posted that here.  I hope to finish the app and get it working well enough that I put it on my devices; if it works for me, another adventure would by publishing it in the app stores.

The running app looks like this (screenshot from my iPhone):

Sunday, March 3, 2013

I am a dinosaur

I am a dinosaur.

I've been programming personal computers since 1977 or so.  My first computer was an IMSAI VDP-40 (8080 running CP/M).  I bought my IBM Personal Computer model 5150 in the summer of 1982 (a year after the release).  I was a Macintosh programmer in 1984, the year that was released.  I was part of a team developing a commercial, "shrink-wrap" applications for Windows, and we did the bulk of the development under Windows 2.0 -- and couldn't believe our luck that Windows 3.0 was released before we were done, and it solved the memory management problems that we would have never resolved otherwise.  I had the good fortune to be asked by a smart man to be among the first to solve a particular technical challenge in Windows 3.0, and that proof-of-concept turned into a product, which has turned into the rest of my career.  The core technology built for Windows 3.0 needed to be updated for Windows 95, then Windows NT, and again for Windows 2000, and yet again for Windows Vista, and the application needed general updates for every Windows release.  So job security is pretty high in that respect.

But now I'm here in this new millenium, looking around at everything that I feel like I've missed.  My professional experience is still critical to my "day job", but is irrelevant to any sense of modern software development.  I have an iPad and an iPhone, and can't develop for them.  Applications are moving to the web, and the cloud, and I'm not really comfortable editing the HTML markup of this blog.  (Well, I just looked, and this markup is pretty simple, but you get the idea.)

There's a lot I can learn.  A lot I want to learn.  And maybe the dinosaur will learn some new tricks.