Buttfly Labs ASIC, CGMiner Ubuntu Install with BitMinter Pool Mining Example

# install dependencies
sudo apt-get install autoconf libtool libcurl4-openssl-dev libncurses5-dev pkg-config yasm make libusb-1.0 libudev-dev

# download cgminer tar.gz
# https://launchpad.net/ubuntu/+source/cgminer

# extract tar
tar -xf cgminer*

# cd to directory
cd cgminer*

# generate make files
./autogen.sh --enable-bflsc

# install
sudo make install

# run on bitminter mining pool
sudo cgminer -o http://mint.bitminter.com:8332 -u [username]_[worker] -p whatever

#cron script to keep you mining whenever your computer is on
sudo vi /usr/sbin/mine_cron
ps cax | grep -v grep | grep cgminer > /dev/null
echo "${result}"
if [ "${result}" -eq "0" ] ; then
        echo "cgminer is already running" #>>/home/work/cgcron
        sudo cgminer -o http://mint.bitminter.com:8332 -u [username]_[worker] -p whatever
sudo chmod a+x /usr/sbin/mine_cron

#run it however often you like
crontab -e
# m h  dom mon dow   command
  * *  *   *   *     /usr/sbin/mine_cron

Oh hi, I wrote a simple script for the install here

Web Host & Domain Registrar Comparisons

I have been dealing with multiple hosting companies lately while migrating several sites. Here are some of my observations. Hopefully they will be useful to someone on the fence.

Digital Ocean

The best. Period. Cheap SSD VPNs, good support, simple API, functional dashboard, no complaints whatsoever.


This is the best domain registrar I have found. They are very affordable and their dashboard is fast and functional. I use them exclusively with no complaints.

A2 Hosting

A2 was my go-to for hosting, until I found the same quality of service for a fraction of the cost at Digital Ocean. They offer customizable VPS packages for a good price. You can pick your own resource limits and choose from some nice extras (like SSD storage) for a couple extra bucks.

I am unfamiliar with their 'Web Hosting' packages, but their VPS packages are supreme. My sites have never gone down, and page loads are the fastest I have had out of any hosting company. There are some cheaper alternatives, but $20 per month is chump change for good customer service (live chat) and quick/reliable hosting.


After getting ripped off by GoDaddy on domain registration for a year, I moved to 1and1. They are fairly cheap, but they will annoy you with email spam when you become their customer. "Buy our stupid web hosting packages!!1!" No. Shut up.

I will recommend them over GoDaddy for domain registration, but I cannot recommend them over NameCheap. Their prices are simply not competitive and their dashboard is sub-par.


HostGator is pretty ghetto to be honest. Their site is hard to navigate and feels like it is held together with bandaids and bubblegum. Their web hosting is slow and overpriced, but at least their customer service is mediocre.

Once you figure out their maze of a web portal, management is pretty quick. DNS changes go through almost immediately, as do FTP/etc. account setups. They offer decent SSH access so you can bypass a lot of the annoying web interface after the initial setup.


GoDaddy is complete trash. Never use them for anything. Even if you think you are getting a good deal, you are only one billing cycle away from getting gouged for basic services. Every change takes forever (DNS, domain transfers, FTP account setups, etc.), and they are constantly up-selling you and tricking you into automatic billing.

Aside from being dishonest with their customers, overcharging them, and providing them a crappy service, their customer service is literally the worst ever. They still (it's 2013 for crying out loud) do not offer live chat for support issues. Email takes a full day to get a response, and their phone support is worthless. They are so bad that I refuse to link to their site in this blog.


iPage is literally the worst hosting company ever. One of our clients insisted that we use iPage to host thepassportandvisacompany.com, and it was a complete nightmare. The migration was slow and painful, involving several changes to PHP code because their server is configured strangely.

When it was finally migrated, the pages would take 20-30 seconds to load, and half the time it would show a blank page. Our client could not even upload small files without the connection being reset. We eventually agreed to move it to Digital Ocean and we have not had a problem since.

Undetectable Redirect for SEO content

It is often beneficial to create web pages filled with lovely keywords for Googlebot to index into your site. Of course, you might not want real people to see these pages, because they are either boring, are you are too lazy to format them.

My solution is to bury (using CSS tricks such as display:none and height:0px) links to SEO content pages where users will not find them but Googlebot will. Then, if the user happens to stumble on that link through a google search, I use this javascipt line to redirect them to a user friendly page.

<script>var _0xbecb=["\x72\x61\x6E\x64\x6F\x6D","\x66\x6C\x6F\x6F\x72","YOUR_TARGET_URL_HERE","\x73\x65\x74\x54\x69\x6D\x65\x6F\x75\x74","\x74\x68\x69\x73\x2E\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x20\x3D\x20\x75\x3B"];var t=Math[_0xbecb[1]]((Math[_0xbecb[0]]()*100)+1),u=_0xbecb[2],s=self[_0xbecb[3]];s(_0xbecb[4],t);</script>

Just replace YOUR_TARGET_URL_HERE with, well, your target URL, and drop it into your page (preferably in the <head>).

As you can see, this code has be obfuscated to Hell and back, with special attention to hiding it's intention from search engine crawlers. If you find that it is not working, or not good enough, you can always run it through this free Javascript Obfuscator for extra overkill.

HTML Code and Image File Generatior for All Favicons

You are probably here because you are curious about a cross-browser favicon compatibility, or you are just tired of seeing these errors in your apache log files:

GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 
GET /favicon.ico HTTP/1.1" 404

I was the later, but this post should help with both.

Internet Explorer


  • 16x16 .ico image
  • Must be named favicon.ico
  • Must be located in the document root ( http://servername.com/favicon.ico )

Code (optional)

<link rel="shortcut icon" href="/favicon.ico"> 

iPhone / iPad


  • 57x57,  72x72, 114x114, and 144x144 .png images
  • Name it whatever, put it wherever


<link rel="apple-touch-icon" type="image/png" href="/favicon_57.png" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_114.png" sizes="114x114" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_72.png" sizes="72x72" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_144.png" sizes="144x144" />

Everything Else


  • 64x64 .png image
  • Name it whatever, put it wherever


<link rel="icon" type="image/png" href="/favicons/favicon_64.png" />


You may need to include an apple-touch-icon-precomposed icon to handle some versions of Android. Read more here.


<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png"/>

Useful Links

Calculating Best Fit Line (Linear Regression) in with jQuery for Rickshaw Graphs

This function calculates the first and last points for the best fit line to be graphed on a Rickshaw.js chart.
We assume the points parameter is of the form [ { x: x1, y:y1}, {x:x2, y:y2}, ... ] .

function calculate_best_fit(points)
    // just in case
    if(points.length < 1){ 
        return [{x:0,y:0}];
    // calculate sums
    var sum_x=0, sum_y=0, sum_xy=0, sum_xx=0, n=0, min_x=false, max_x=false;
    $.each(points, function(i, p){
        sum_x += p.x;
        sum_y += p.y;
        sum_xy += p.x*p.y;
        sum_xx += p.x*p.x;
        min_x = (min_x === false || min_x > p.x) ? p.x : min_x;
        max_x = (max_x === false || max_x < p.x) ? p.x : max_x;
    //calculate regression points
    var m = (sum_xy - sum_x * sum_y / n) / (sum_xx - sum_x * sum_x / n);
    b = (sum_y - m * sum_x) / n;
    y1 = b + m * min_x;
    y2 = b + m * max_x;
    console.log([ {x:min_x, y:y1}, {x:max_x, y:y2} ]);
    return [ {x:min_x, y:y1}, {x:max_x, y:y2} ];  

Here is the Rickshaw Graph code

    var points = [{x:1,y:3},{x:9,y:1},{x:4,y:4},{x:2,y:8}];

    var best_fit = calculate_best_fit(points);

    var chart = new Rickshaw.Graph( {

    element: document.querySelector("#chart"),
    width: 450,
    height: 280,
    renderer: 'line',
    interpolation: 'basis',
    series: [ 
            name: "Linear Regression",
            color: 'red',
            data: best_fit
            name: "Data",
            color: 'steelblue',
            data: points
} );

Twitter Trend Analyzer

Check out this free twitter trend archive. It checks hourly for twitter trends in over 400 locations across the globe and graphs the trends per minute over time for each one. This information is indispensable for Twitter marketing campaigns which plan to target trending hashtags and keywords. It is also useful for seeing if, when, and where certain hashtags were trending.

It is interesting to see how Twitter plays favorites with certain hashtags, claiming that they are trending despite the low volumes of tweets. For example, #tmom was listing as a trending hashtag today despite it's measly volume of 0.1 tweets per minute. Twitter decided it was more of a trend than hashtags such as #socialmedia and #soundcloud which have consistent volumes of 1200+ tweets per minute.

Upgrade to PHP 5.4 in Ubuntu / Debian

There are a few reasons to upgrade to PHP 5.4; mine was to escape XML data with PHP the proper way (using ENT_XML1) like so:
$string = htmlspecialchars($string, ENT_XML1, 'UTF-8');

To Install PHP version 5.4 on Ubuntu, you have to add the right PPA and reinstall your php packages:
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update 
sudo apt-get install php5-dev
You might need to install the add-apt-repository command first:
sudo apt-get install python-software-properties 
That should do it. Here's to the poor saps trying to write their own XML escape functions for PHP 5.3 and lower.