Ruby, Elixir, Macintosh and Other Technical Maunder.

Minimizing NSA PRISM

With the recent revelation about the illegal NSA spying on American citizens, it is advisable to do what we can in order to curb or limit the NSA’s ability.

Below are some of the ways you can do this.


Use Firefox

Why would anyone want to use Google’s Chrome browser when they (Google) are the largest provider of PRISM data in the world? Does anyone actually trust Google with their data? The question is obviously rhetorical since we know that millions of users use Google services and applications.

Firefox allows extensions. I don’t want to get into any religious argument over why Chrome, Opera, Safari or any other wannabe browser is better. The fact is that Firefox, with the right extensions, is the safest, most secure browser available today. Just use it!

There are some very good extensions that I would simply not want to live without:

  • NoScript. NoScript disables Javascript by default. When you need to use Javascript you simply allow it temporarily. There is no good reason to allow Javascript to run on every web page you visit. It can be malicious and is the number one way for companies and governments to track you on the web, so why trust it?
  • Ghostery. Ghostery notifies you of, and blocks by default, web tracking through cookies, invisible pixel images, etc.
  • Disconnect. Another plugin to help prevent tracking on the web. This will catch most anything that Ghostery doesn’t.
  • MaskMe. MaskMe’s free email masking is perfect for eliminating spam. It provides masked emails on the fly and forwards emails until you tell it to stop. Let’s say you go to a job hunting website like monster.com and sign up using a MaskMe email address like ‘abcdefg@opayq.com’. When Monster sends you an email it gets forwarded to your real email address. But all of a sudden one day you start getting emails from jobhat.com, and other such websites that you never signed up for. Simply disable or block that particular masked email and the spam goes away, forever. Never give out your real email address again. Ever!

Search Engine

Then there is the search engine. I remember back in the 90’s when Google was just trying to hold their own next to Yahoo. I was a big Google evengelist because I didn’t, and still don’t, like mega-corporations and the data they collect. Google has since become far more nefarious than Yahoo ever was. They actively participate in the illegal NSA PRISM program, and every time you search using Google your information is captured and stored for future use against you in a criminal, or possibly military, court. In addition most websites now use Google analytics, Google fonts or Javascript stored on Google. That means every time you visit a website that uses one of these services, Google tracks and saves a record that you, “insert name here”, visited that particular website, the time of day, what you clicked on or downloaded and possibly any data you entered while there.

It is purely speculation, but what happened to all of the legal trouble Google was in back in 2012? There were antitrust issues, alleged copyright infringments and other alleged predatory practices. All of that seemed to silently just go away before this new PRISM revelation. Coincidence? I think not. Google has likely made a deal with the US government to provide private information in return for prosecution exemptions.

Let’s face it… Google is evil! Period.

Use Startpage or Ixquick for a more secure search experience. They are from the same company and located in the Netherlands.

Startpage provides anonymous Google results, and Ixquick provides a separate index, but both aparently privately as they say they do not track your IP address or use cookies for anything but storing preferences.

Operating System

It is clear that Microsoft and Apple are both participating in the PRISM program. The safest OS is Linux-GNU. Why? Because you can download, examine, modify and compile the kernel and all of the GNU tools and utils. That said, OSX (a FreeBSD derivative) can be made relatively safe as well.

I will not personally use Windows, ever. Nor will I allow anyone in my immediate family to use any of the horrible and unstable Microsoft operating systems.


If you use OSX, as I do, it is simply a must to purchase and learn to use Little Snitch.

I also own an Apple Airport router. Recently I fired up my AirPort Utility application and Little Snitched warned me that it (AirPort Utility) was trying to send information to “dni.gov”! I am not kidding. The Director of National Intelligence website! This is a good site to block, so I told Little Snitch to never let any of my applications contact dni.gov. Of course they will likely modify their code to use some arbitrary IP address, to which I will promptly block as well. Using Little Snitch, always block unless you are sure of the traffic you are allowing. If you have a question about a particular IP address or application use Startpage to search for answers.

Do NOT use iCloud if you are using an Apple product. Just turn it (iCloud) off and store your data locally. Backup to USB drives or external drives but never use their cloud.

Cloud Services

Avoid cloud services like DropBox and obviously GoogleDrive when storing any sensitive information. It is also a good bet that Amazon cloud services are part of PRISM. Avoid if possible.


It is difficult to find a proven secure email hosting service. Even Hushmail has its issues. A good alternative is to encrypt your own email and when sending unencrypted email to anyone, just assume that the NSA and every other government agency will get their eyes on it.


Mac users have a wonderful option in GPGMail. The main drawback is that most users don’t understand or use email encryption. You cannot send an encrypted email to anyone who does not have a public key.

Spread the word and convince everyone you know to use GPG encryption for their email.


Lastly, avoid non-free scanning programs like: PrivacyScan that supposedly do everything for you at the click of a button, for a price. They can do a few good things but they will not change your bad habits or force you to use Firefox and GPG encryption. You can do more to protect yourself by following the ideas and tips in this article or doing your own research for free.

EVGA UV + 19: Mac Third Monitor Testing

Disclaimer: I am not paid to review products. This post is here in hopes that it will benefit someone wanting more than 2 monitors for their Macbook laptop. If you do happen to click on one of the Amazon links below and purchase one of these products, Amazon will add a few cents to a gift card for me to use the next time I want to buy a Kindle book.

As a software engineer I value my Mac hardware a great deal. My ideal setup would be a Mac Pro tower at the office, with 3-4 monitors and more RAM than I would ever use. However, in this business we need to be mobile so we can work at the office, from home or while we are at the beach in Belize. Onsite is almost always out of the question, but that is another rant.

So, we are stuck with our Macbook Pros supporting only 8GB of RAM and a single external display. Us Mac users really love the ability to attached a huge second monitor to our Macbook Pros. It is invaluable for software development, especially when pairing remotely, but a third monitor would be even better. After looking at several different options I came up with two likely solutions.

  1. EVGA UV + 19: $58.49 from Amazon
  2. Matrox TripleHead2Go: $306.99 from Amazon

With Amazon’s excellent return policy, I decided to start with the less-expensive EVGA solution. If it doesn’t work I will return it and spring for the Matrox hardware.

I got the UV Plus from Amazon within 3 days. Opened up the package and found the following:

  • The small 2.5-inch square device, 7/8ths of an inch thick
  • A retractable USB cable
  • A VGA-DVI adapter


I planned to try out the device at the office where my large third monitor lives. Being impatient as I am, I decided to install the driver and hook it up to my second large monitor which lives at home, and is usually plugged into the mini-dvi on my Macbook Pro. Installing the driver requires a reboot, but after I found that the device does indeed work. The video had a slight, noticeable lag when moving the mouse or dragging a window. But the Display manager worked and allowed my Macbook to arrange what it considered a new monitor, and I could drag things to it and away from it.

Being happy that it worked, I unplugged the device and plugged my second monitor back into the mini-dvi interface. My Macbook then began acting increasingly strange. Apps started being unresponsive and everything start to crawl along at intolerably slow speeds. Finally, I uninstalled the driver using the uninstall icon that came with it and everything went back to performing normally.

Before I send it back I plan to try it again at the office where I can leave the third monitor hooked up. I have a feeling that the EVGA device will end up being returned in favor of the Matrox solution.

Stay tuned for updates…

Update: 01/10/2012: After setting up my 2 external monitors at the office, re-installing the DisplayLink (EVGA Plus) driver, and plugging everything in, I am extremely pleased to announce that everything works! No race-conditions occur, even when unplugging the EVGA monitor. I have a feeling that plugging in a monitor to the EVGA device that was previously setup as an OSX native second monitor causes race conditions.

3 Monitors

Anyway, now I have three monitors and my development setup couldn’t be more perfect. Another monitor would cause me to strain my neck :)

Conclusion: For less than $60.00 USD. the EVGA UV Plus 19 works! This makes me extremely happy!

Update: 01/17/2012: Another few days went by and I have started to see problems. Processes seem to be running slow, video on all three monitors seems to jump and be slow as well. The actual CPU usage is very low but nevertheless performance has started to suffer. Unfortunately I cannot tolerate these kinds of issues during a typical workday. I have uninstalled the driver. Will give it one more shot before I send it all back. At this point I am disappointed. I may make one more updated entry if anything changes (i.e. if performance doesn’t drop off during my next test). Otherwise I have changed my conclusion.

Updated Conclusion: The driver still seems a bit buggy. Performance suffers intermittently. Work becomes intolerable. If you don’t want to deal with these kinds of issues, I sadly recommend not using this product. Hopefully the DisplayLink people will fix the driver issue soon.

Update: 06/27/2013: After a year and a half of using the EVGA UV Plus 19 I can say that the initial weirdness has gone away. Every now and then it will do strange things like lag severely but overall it works pretty well. For the money spent I cannot complain.

– Midwire

Ruby Performance : Case vs. If-elsif

In this edition of Ruby Performance I take a look at case vs. if-elsif.

In my testing, links below, it is clear that case statements are consistently more expensive than if-elsif. The difference in a single call is insignificant, but that difference adds up over time to possibly matter.

I am certainly not recommending that you use if-elsif in every instance. There are times when the trade-off may be worth the difference in performance.


Case offers less typing, but implicitly compares using the more expensive === operator. Case may also offer more concise code when determining if a value falls within a range of values or a non-contiguous set of multiple values. Case code also looks prettier in most instances.

If - Elsif - Else

If-elsif-else offers speed of execution and more conspicuous code in some instances. But the fact remains that it is always faster than case.

Here are the timing summaries for strings:

Timings for [case when using strings]
Total: 3.587024

Timings for [if elsif else using strings]
Total: 2.380505

Here are the summaries for integers

Timings for [case when using integers]
Total: 3.495027

Timings for [if elsif else using integers]
Total: 2.570731

I also wanted to see the difference between the === operator with if-elsif and case which implicitly uses ===

Timings for [case when using integers]
Total: 3.495027

Timings for [if elsif else using integers with ===]
Total: 3.561783

So in this case, no pun intended, the case statement is faster slower.

Find the tests here: https://github.com/midwire/ruby-profiles/raw/master/case_vs_if.rb


– Midwire

Ruby String Modification Performance

Having used many programming languages over the years; when I began using Ruby I expected to find that string interpolation performance would be slow and similar to other languages. I was surprised!

In Ruby, 1.8.x versions, string interpolation is always faster. Here are the timings:

Ruby String Modification Performance string_quotes.rblink
Profiler.time_this("Single Quotes (+ operator at end):") {
  x = ''
  (0..MAX).each do |i|
    x = 'This is a test ' + i.to_s

Profiler.time_this("Single Quotes (+ operator in middle):") {
  x = ''
  (0..MAX).each do |i|
    x = 'This is a test ' + i.to_s + 'x'

Profiler.time_this("Single Quotes (<< operator at end):") {
  x = ''
  (0..MAX).each do |i|
    x = 'This is a test ' << i.to_s

# Very slow
Profiler.time_this("Single Quotes: (<< operator in middle)") {
  x = ''
  (0..MAX).each do |i|
    x = 'This is a test ' << i.to_s << 'x'

Profiler.time_this("Double Quotes (interpolation at end):") {
  x = ""
  (0..MAX).each do |i|
    x = "This is a test #{i}"

Profiler.time_this("Double Quotes (interpolation in middle):") {
  x = ""
  (0..MAX).each do |i|
    x = "This is a test #{i}x"


Timings for [Single Quotes (+ operator at end):]
Thread ID: 2148446640
Total: 0.785381

 %self     total     self     wait    child    calls  name
 59.14      0.79     0.46     0.00     0.32        1  Range#each (ruby_runtime:0}
 22.29      0.18     0.18     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
 18.57      0.15     0.15     0.00     0.00   100001  String#+ (ruby_runtime:0}
  0.00      0.79     0.00     0.00     0.79        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}

Timings for [Single Quotes (+ operator in middle):]
Thread ID: 2148446640
Total: 1.094465

 %self     total     self     wait    child    calls  name
 57.92      1.09     0.63     0.00     0.46        1  Range#each (ruby_runtime:0}
 26.46      0.29     0.29     0.00     0.00   200002  String#+ (ruby_runtime:0}
 15.62      0.17     0.17     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
  0.00      1.09     0.00     0.00     1.09        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}

Timings for [Single Quotes (<< operator at end):]
Thread ID: 2148446640
Total: 0.806073

 %self     total     self     wait    child    calls  name
 55.94      0.81     0.45     0.00     0.36        1  Range#each (ruby_runtime:0}
 22.95      0.18     0.18     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
 21.11      0.17     0.17     0.00     0.00   100001  String#<< (ruby_runtime:0}
  0.00      0.81     0.00     0.00     0.81        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}

Timings for [Single Quotes: (<< operator in middle)]
Thread ID: 2148446640
Total: 1.090110

 %self     total     self     wait    child    calls  name
 55.56      1.09     0.61     0.00     0.48        1  Range#each (ruby_runtime:0}
 27.31      0.30     0.30     0.00     0.00   200002  String#<< (ruby_runtime:0}
 17.12      0.19     0.19     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
  0.00      1.09     0.00     0.00     1.09        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}

Timings for [Double Quotes (interpolation at end):]
Thread ID: 2148446640
Total: 0.567917

 %self     total     self     wait    child    calls  name
 65.52      0.57     0.37     0.00     0.20        1  Range#each (ruby_runtime:0}
 34.48      0.20     0.20     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
  0.00      0.57     0.00     0.00     0.57        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}

Timings for [Double Quotes (interpolation in middle):]
Thread ID: 2148446640
Total: 0.580440

 %self     total     self     wait    child    calls  name
 67.23      0.58     0.39     0.00     0.19        1  Range#each (ruby_runtime:0}
 32.77      0.19     0.19     0.00     0.00   100001  Fixnum#to_s (ruby_runtime:0}
  0.00      0.58     0.00     0.00     0.58        1  <Class::Midwire::Profiler>#time_this (/Users/midwire/Source/ruby/ruby-profiles/lib/midwire/profiler.rb:12}
  0.00      0.00     0.00     0.00     0.00        1  <Class::Object>#allocate (ruby_runtime:0}


– Midwire

A Portable Bash Environment

Working with computers over the years I’ve built up a set of shell environment preferences, aliases, functions, etc. Bash is my shell of choice and incredibly powerful if used correctly.

My Macbook Bash environment sports a plethora of command aliases and functions that make work relatively easy. My shell preferences are all neatly stored and sourced on opening the Terminal application. However, I am often required to login to new servers to do work.

A new, default Bash environment makes me cringe. Missing my tools and aliases makes things very frustrating. For example when I want to change directories up three times, in my home environment I can just type 3.. instead of cd ../../... When I try to type 3.. and the shell barfs back -bash: 3..: command not found, it gives me that “oh crap” feeling.

To help solve this situation I published my environment on GitHub. Now I can just login to the new box, clone git://github.com/midwire/.env.git, then add the following to my .bashrc file:

Append this to your .bashrc file
[[ -r $HOME/.env/source.sh ]] && . $HOME/.env/source.sh

This recursively sources each *.sh file beginning with your ~/.env directory. What I like about this as opposed to the all-in-one .bashrc file is that it keeps everything compartmentalized for easy maintenance, and it’s portable from a location standpoint.

The next step is to make it portable from a platform standpoint. For instance, I want to have the environment get sourced according to the type of platform it is on. In other words, if I am on a Solaris box the aliases and functions may need to be different in comparison to a Mac OSX box.

Feel free to clone the repository, update and send me a pull request.


– Midwire