Posts

  • rsync Progress Demo

    A couple weeks ago, I wrote up how to get overall progress with rsync. I’ve been meaning to use Asciinema to show terminal screen recordings, and figured this would make a good example.

    Continue reading rsync Progress Demo.

  • Linear Fit using Python and NumPy

    I was working on a side project where I needed to find the linear fit to a set of data points. A linear fit is also known as a “linear approximation” or “linear regression”. This is quite easy using a Numbers spreadsheet. Numbers will even show you equation of the line in slope-intercept form:

    \[y = mx + b\]

    Unfortunately, there is no way that I know of to get the slope and Y-intercept from the Numbers plot besides visual inspection. I also wanted a way to do this from the command line. This post will explain how to do this using Python and the NumPy library.

    TLDR: Python One-Liners

    While the rest of the post goes into more detail, here are two quick Python one-liners to find the slope and Y-intercept, given two NumPy arrays, x and y. First, with Polynomial.fit():

    b, m = np.polynomial.polynomial.Polynomial.fit(x, y, 1).convert().coef
    

    And second, with Polynomial.polyfit():

    b, m = np.polynomial.polynomial.polyfit(x, y, 1)
    

    Both of these give you the slope in m and the Y-intercept in b. I also created a Jupyter notebook demonstrating these APIs.

    I’m honestly not sure why you would pick one over the other. Polynomial.polyfit() is less code, so that seems like the better option, to me. But if you know, please contact me! And please read on for more details.

    Continue reading Linear Fit using Python and NumPy.

  • Overall Progress with rsync

    A feature you may not know about recent versions of rsync is that you can display an overall progress of the transfer. And by “recent” I mean since version 3.1.0, released in September 2013. To use it, you want to add these options instead of -v and/or --progress:

    rsync --info=progress2 --human-readable --no-inc-recursive
    

    For example:

    > rsync --info=progress2 --human-readable --no-inc-recursive -a /Applications /tmp
              9.53G  21%  317.26MB/s    0:00:28 (xfr#83063, to-chk=443926/538653)
    

    Continue reading Overall Progress with rsync.

  • Improving Zsh Performance

    Zsh itself is a speedy shell, but it’s all too easy to blindly add stuff to its startup scripts and prompt that drastically slow it down. I’ve been using Zsh since around 2002 (narrator: that’s over 20 years ago, which is making me feel really old!), and my Zsh config has accumulated a lot of cruft. A few years back, there was a very noticeable delay when opening a new terminal tab where I’d stare at a blank screen for a bit. And worse, typing commands felt very sluggish even when the commands executed quickly.

    Once I started digging into it, I found some great optimizations to make it fast, without losing any functionality. In fact, by the time I was done, I had a much better prompt than I previously had, yet it was orders of magnitude faster.

    If you don’t want to read the whole post, the single best thing you can do is to use Powerlevel10k. And the next best thing is to avoid using eval $(some other command), if possible. But read on for the details.

    Continue reading Improving Zsh Performance.

  • git Merge Commit Messages

    The default git commit message for merge conflicts lists any files that were conflicts. However, it includes them as a comment with the # prefix. This means they’ll get stripped from the real commit message, by default. I like to keep them in the commit message, because it can useful to know which files were conficts later on. To do this, I would manually remove the comment prefix. Unitl now… TLDR: Use git commit --cleanup scissors, but the following example will explain how this works. I also answered this on Stack Overflow, but figured it would make a good blog post.

    Continue reading git Merge Commit Messages.

  • Moving to HTTPS with Let's Encrypt

    I recently moved my site, www.dribin.org, over to HTTPS. For other HTTPS sites I’ve setup, I’ve bought a certificate from name.com. Their cheapest option is $10/year, which is very affordable. But this time I decided to try out Let’s Encrypt and their Certbot. The installation was pretty painless and seemed to go smoothly. I haven’t yet gone threw a renew cyle, though, which is required every three months. I’ll report back in June if I have problems.

    This change did break all my embedded YouTube videos becuase those still used http. I needed to update the iframe URLs to also use https, and now all seems to be fine.

    And finally, I updated all the links to my own site, replacing http with https. This wasn’t strictly necessary, as I have a redirect in place, but I figured it’d be nice to avoid the extra round trip for the redirect. I don’t think I’ve broken anything, but please let me know if you see anything wrong.

  • Linode Recommendation

    I’ve been using Linode since about 2012, and I cannot recommend them enough. A few months ago, they announced a cheaper $5/month plan. I recently switched to that, and saved a bunch of money. I pay for their backup plan, so the total is $7/month. On their previouls plan, I was paying $25/month. I was worried the downgraded specs would be a problem. Then again, I don’t get much traffic these days. I’ve been running on this downgraded server a couple months ago, and it’s working perfectly fine. A static website doesn’t require that much CPU or memory.

    The downside is that you need to do all your own admin yourself. But I find it’s not that hard to setup Apache and some email services. If you’re willing (or wanting) to get your hands a bit dirty, Linode is great. If you want to give them a shot, you can try them out with my referral code: fb7465a0d5bef7335873ccdfc31bb8d3367c1945

    It’s actually pretty amazing at how cheap hosting has become. When I first started hosting my own domain back in 2002, I used a colocation service. I supplied the Linux box, and for $100/month, I was ready to go with full root access. At the end of 2003, the hard drive on that machine died, and I moved my hosting to Server Matrix for $60/month. This was a dedicated physical server, but I did not own it. The upside is that if a disk died, I wasn’t responsbile for fixing it. And I still had full root access to install whatever I wanted. I jumped to a few hosting providers around this time, some via acquisition. By 2012, I was paying $70/month on SoftLayer.

    But virtual private servers were becoming more popular around this time, and I didn’t need my own physical server. The cheapest Linode plan was only $20/month. So in 2012, I switched to Linode. Adding in $5 for backup, it was $25/month. But that was still way cheaper than SoftLayer. And now, with the new price reduction, I’m down to $7/month. And that’s quick summary of how, in the span of 15 years, my hosting costs have gone from $100/month down to $7/month, all with full root access. And I couldn’t be happier!

  • Switching to Jekyll

    After many years of faithfully using Movable Type, I have finally switched to another blogging system: Jekyll. I’ve been meaning to move off Movable Type for literally years, since they dropped SQLite support in version 5, released in 2010. Jekyll meets everything I laid out in my 2009 post, Requirements for a New Blogging System. What finally pushed me to switch was my desire to write some new posts and fix some of the link rot, such as the link to my C4[3] slides.

    After my server died in 2012, I was able to bring over the static content to the new server just fine with a simple rysnc. That alone is a huge testament to static content. However, I had no desire to try and get an old version of Movable Type up and running, which meant I could no longer edit posts or create new ones.

    I tried twice to switch to Octopress, once in 2012 and again in 2013, but I kept running into various snags. It’s a good think I waited because Octoproess has been pretty stagnant since then. Octopress is basically a customized Jekyll setup, and since 2013, Jekyll has improved enough on its own that I am able to use it straight-up.

    I’m now up and running on Jekyll and fixed the link to my slides. The installation went pretty smoothly, and everything seems to look okay. If not, please let me know. Right now, this is just the standard Jekyll install with a slightly tweaked Minima theme, but I’d like to customize it a bit more at some point.

  • My Unit Testing C4[3] Presentation

    I should have posted this literally years ago. Since I just learned that Keynote can easily publish presentations to iWork.com, I figure I have no excuse. iWork.com is dead. Thus, here’s my C4[3] presentation on unit testing: DaveDribin-UnitTesting-C4-3.pdf

  • Joining Apple

    Next week, I fly out to Cupertino to start working at Apple as a full time employee. This is a big move for me, as I’ve been working for myself since 2001. But this is truly a once-in-a-lifetime opportunity that I cannot pass up. As is the case for a lot of people my age, I began my computing experience on an Apple ][ and have been a huge fan of Apple ever since (with a slight defection to Linux in the late 90s and early 00s). Apple-related technology (Mac OS X and iOS) has been my main source of income since around 2006, so in many ways, this is a dream come true. I’m very excited to work with a great team and for a great company.

    Continue reading Joining Apple.

Archives

Subscribe via RSS