<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bhaskar Karambelkar</title>
    <description>The latest articles on Forem by Bhaskar Karambelkar (@bhaskar_vk).</description>
    <link>https://forem.com/bhaskar_vk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F8789%2Fafa566dd-d7b7-458e-adab-afa2c8a2631a.jpg</url>
      <title>Forem: Bhaskar Karambelkar</title>
      <link>https://forem.com/bhaskar_vk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bhaskar_vk"/>
    <language>en</language>
    <item>
      <title>Bash Shell Tricks </title>
      <dc:creator>Bhaskar Karambelkar</dc:creator>
      <pubDate>Sun, 09 Jul 2017 00:22:53 +0000</pubDate>
      <link>https://forem.com/bhaskar_vk/bash-shell-tricks</link>
      <guid>https://forem.com/bhaskar_vk/bash-shell-tricks</guid>
      <description>&lt;p&gt;This was originally published on my &lt;a href="https://www.karambelkar.info/2007/06/bash-shell-tricks/"&gt;blog&lt;/a&gt; back in 2007, I am glad to see that this has aged well. I still find personally using many of the tricks mentioned here even today.&lt;/p&gt;

&lt;h1&gt;
  
  
  Quick Command editing
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;^orig^repl^&lt;/code&gt; replace 'orig' in previous command with 'repl' and execute the new command.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  File Name Generation
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;cp filename{,.bak}&lt;/code&gt; Copy 'filename' as 'filename.bak.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;mkdir -p dir{1,2,3}/subdir{1,2}&lt;/code&gt; Create &lt;code&gt;dir1/subdir1&lt;/code&gt;, &lt;code&gt;dir1/subdir2&lt;/code&gt;, &lt;code&gt;dir2/subdir1&lt;/code&gt;, &lt;code&gt;dir2/subdir2&lt;/code&gt;, &lt;code&gt;dir3/subdir1&lt;/code&gt;, and &lt;code&gt;dir3/subdir2&lt;/code&gt; directories&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Completion
&lt;/h1&gt;

&lt;p&gt;No I am not talking about completing command/file names. I am talking about completing arguments to various commands, completing filenames based on application. This is one of the touted features of&lt;br&gt;
'zsh', but unknown to many is the fact that it is also available in bash.&lt;br&gt;
All you need to do is install &lt;a href="http://www.caliban.org/bash/index.shtml#completion"&gt;bash-completion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With bash completion installed you can use the &lt;code&gt;TAB&lt;/code&gt; key to complete arguments to common commands like &lt;code&gt;rpm, apt, find, grep&lt;/code&gt; etc. Also bash-completion will complete host-names&lt;br&gt;
for &lt;code&gt;ssh, scp&lt;/code&gt;, by looking up hosts inside your &lt;code&gt;$HOME/.ssh/authorized_keys&lt;/code&gt; file. For &lt;code&gt;rpm&lt;/code&gt; based distros, bash-completion will even lookup package names already installed.&lt;/p&gt;

&lt;p&gt;The feature I find most handy is file-name completion based on the context of the command. e.g. if you type &lt;code&gt;tar -zxvf&lt;/code&gt; and then press the TAB key twice, you will get a list of only files ending in &lt;code&gt;.tar.gz or .tgz&lt;/code&gt; rather than a list of all files in the directory.&lt;/p&gt;
&lt;h1&gt;
  
  
  Socket Communication
&lt;/h1&gt;

&lt;p&gt;I bet a lot of you haven't heard of this, but bash can indeed perform basic socket communication via &lt;code&gt;/dev/tcp, /dev/udp&lt;/code&gt;. These are pseudo devices that bash uses to communicate with network sockets. In fact if you did &lt;code&gt;ls -l /dev/tcp /dev/udp&lt;/code&gt; you will get a 'No such file or directory' error message.&lt;/p&gt;

&lt;p&gt;So how to use them, we below I present 2 examples.&lt;/p&gt;

&lt;p&gt;One to quickly check headers from a HTTP Server. Here is a simple function you can put in your &lt;code&gt;$HOME/.bashrc&lt;/code&gt; that will check for headers of HTTP server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;headers&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;80&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
  &lt;span class="nb"&gt;exec &lt;/span&gt;5&amp;lt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/tcp/&lt;span class="nv"&gt;$server&lt;/span&gt;/&lt;span class="nv"&gt;$port&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"HEAD / HTTP/1.0&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Host: &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;5&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;cat &lt;/span&gt;0&amp;lt;&amp;amp;5&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;exec &lt;/span&gt;5&amp;gt;&amp;amp;-
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply invoke it by&lt;/p&gt;

&lt;p&gt;&lt;code&gt;headers &amp;lt;servername or ip&amp;gt; &amp;lt;port&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The port number defaults to 80 if not provided.&lt;/p&gt;

&lt;p&gt;Second example is a quick way to check if a port is open or not. You can always use netcat or telnet, but I find this easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;testPort&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;proto&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;3&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;tcp&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
  &lt;span class="nb"&gt;exec &lt;/span&gt;5&amp;lt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/&lt;span class="nv"&gt;$proto&lt;/span&gt;/&lt;span class="nv"&gt;$server&lt;/span&gt;/&lt;span class="nv"&gt;$port&lt;/span&gt;
  &lt;span class="o"&gt;((&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; 0 &lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;exec &lt;/span&gt;5&amp;lt;&amp;amp;-
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again invoke it by&lt;/p&gt;

&lt;p&gt;&lt;code&gt;testPort &amp;lt;servername or ip&amp;gt; &amp;lt;port&amp;gt; &amp;lt;protocol&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The protocol can be either tcp or udp and defaults to tcp.&lt;/p&gt;

&lt;h1&gt;
  
  
  Arithmetic Evaluations
&lt;/h1&gt;

&lt;p&gt;Bash can perform arithmetic evaluations. They are much easier to using &lt;code&gt;expr&lt;/code&gt; tool. Below are some examples.&lt;em&gt;Note the absense of $ prefix for variable names.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;((&lt;/span&gt;count++&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#increment value of variable 'count' by one.&lt;/span&gt;
&lt;span class="o"&gt;((&lt;/span&gt;total+&lt;span class="o"&gt;=&lt;/span&gt;current&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="c"&gt;# set total = total+current.&lt;/span&gt;
&lt;span class="o"&gt;((&lt;/span&gt;current&amp;gt;max?max&lt;span class="o"&gt;=&lt;/span&gt;current:max&lt;span class="o"&gt;=&lt;/span&gt;max&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="c"&gt;# ternary expression.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>unix</category>
      <category>linux</category>
      <category>bash</category>
      <category>scripting</category>
    </item>
    <item>
      <title>Data Scientists and Software Engineering</title>
      <dc:creator>Bhaskar Karambelkar</dc:creator>
      <pubDate>Fri, 14 Apr 2017 02:29:01 +0000</pubDate>
      <link>https://forem.com/bhaskar_vk/data-scientists-and-software-engineering</link>
      <guid>https://forem.com/bhaskar_vk/data-scientists-and-software-engineering</guid>
      <description>

&lt;p&gt;&lt;em&gt;Originally published on my &lt;a&gt;personal blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Coding != Software Engineering
&lt;/h1&gt;

&lt;p&gt;As has been mentioned ad nauseam: Any one can code. What has not been said enough is that there is a lot more to coding than merely assembling a set of instructions in a programming language of your choice to make the machine do what you want. Not as catchy as 'Any one can code!', is it?&lt;/p&gt;

&lt;p&gt;As a professional software developer turned data scientist, I feel compelled to share some software engineering wisdom with my fellow data scientist who may have followed a non coding heavy path. If you are an academic researcher turned data scientist, or perhaps a data analyst used to point-and-click GUI tools, or excel (the horror!), then learning and being able to code in a programming language can be a liberating, exhilarating, but also a very scary experience. But fear no more. This post and the follow up posts in this series are just for professionals like you. This series will introduce you and encourage you to explore software engineering in more detail, in order to become proficient in writing good code no matter the programming language.&lt;/p&gt;

&lt;h1&gt;
  
  
  So What is Software Engineering?
&lt;/h1&gt;

&lt;p&gt;Instead of referencing a formal definition which you can easily look up using Google, let me tell you what I think the practice of software engineering aims to accomplish. Writing more or less working code is the easy part. What software engineering aims to accomplish is making the code portable, concise, relatively bug free, secure, performant within given constraints, and reusable, with limited man-power and budget. And believe me, this is not as easy as you might think it is, nor is this process a natural extension of the practice of coding. By that I mean that you can't learn software engineering by coding more and more, let alone master it. Proper software engineering is an art+science on to it self, of which coding skills are an important but nonetheless only a small piece.&lt;/p&gt;

&lt;p&gt;The reason I chose to explain software engineering this way, is because, the term software engineering is in itself somewhat controversial and debated. So instead of drowning you in the controversy about the term, I present my understanding of the intent behind software engineering. But be forewarned that this is one person's opinion so take it for what it's worth.&lt;/p&gt;

&lt;h1&gt;
  
  
  So Why Must Data Scientists Care?
&lt;/h1&gt;

&lt;p&gt;For many a reasons. As I mentioned previously more and more data analysis is now done in code rather than point-and-click GUI tools. This places the added burden of learning how to code on an data analyst / researcher who may not have had exposure to coding before. Even if you had taken a programming language class before, it was mostly to teach you the syntax of the programming language rather than teach you about software engineering.&lt;/p&gt;

&lt;p&gt;The implications of the above are they you may write code that works but it may have all sorts of issues. It may not be portable on account of using non-portable APIs/Libraries. It may not be optimized/concise and as a result non performant at scale. It may have a large surface area for bugs and security vulnerabilities. It may not be maintainable in the long run, and hence prevent you from reproducing your results in the future. Given all this, I would go as far as to argue that if you care about the veracity and reproducibility of your research/analysis then you absolutely must care about software engineering.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cliff Notes for Software Engineering
&lt;/h1&gt;

&lt;p&gt;I must warn you this page is only meant to get you started on software engineering, and not tell you all that there is about it. Even then, following most of my advice below will make you a better coder (ahem software engineer).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a basic understanding of how computer systems work. The hardware, the software (including OS/Kernel), the network, the Internet. &lt;strong&gt;This will go a long way, I promise&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Try and pick up at least 2 or 3 programming languages. Broaden your repertoire. &lt;/li&gt;
&lt;li&gt;Learn about various programming paradigms like imperative, object-oriented, functional etc.&lt;/li&gt;
&lt;li&gt;Many a modern languages don't strictly fall under a single paradigm. Form a habit of recognizing which features adhere to which paradigms.&lt;/li&gt;
&lt;li&gt;Embrace each programing language's idiosyncrasies rather that fight them. If in doubt always remember that people lot smarter than you put hours into developing the language/API/library you are using.&lt;/li&gt;
&lt;li&gt;Have a good understanding of the &lt;strong&gt;standard library&lt;/strong&gt; of a programming language. It will prevent you from inefficiently duplicating functionality that was at your disposal from the get go. &lt;/li&gt;
&lt;li&gt;In addition to the standard library research a bit on some leading 3rd party libraries/APIs available. Someone always has the problem solved before you. Your skill lies in finding it rather than duplicating it.&lt;/li&gt;
&lt;li&gt;Start picking up on how to distinguish efficient vs inefficient code. Efficiency can defined in terms of performance, conciseness, resource consumption etc.&lt;/li&gt;
&lt;li&gt;Teach yourself the principles of &lt;strong&gt;application security&lt;/strong&gt; and secure coding. Not being a full time software developer doesn't alleviate you from writing secure code.&lt;/li&gt;
&lt;li&gt;Think beyond your immediate use case. Think of use cases in future or use cases by users other than yourself. "It suffices my needs" is a narrow mindset.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write less code and more comments&lt;/strong&gt;. Think of that someone who has to read your code six months or an year from now. Even if that someone is you, I can tell you from experience that reading properly commented code can do wonders to lower your stress levels.&lt;/li&gt;
&lt;li&gt;Be critical of your coding abilities rather than being confident about them. Let that imposter syndrome be your motivation to improve.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automate your testing&lt;/strong&gt;. Be it unit tests or integration tests, take out the human as much as possible from the equation.&lt;/li&gt;
&lt;li&gt;Learn about &lt;strong&gt;software delivery pipelines&lt;/strong&gt;. Continuous integration (CI), automated deployments, devops are not just buzzwords. They play a critical part in your overall product development.&lt;/li&gt;
&lt;li&gt;Familiarize yourself with distributed computing, cloud environments, virtualization and container technologies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last four ones are special and deserve to be separated out from the rest.&lt;br&gt;
Always follow them no matter how big/small your program/script is, and how much you are pressed for time. Excuse the shouting because they are that much important.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;NEVER CODE WITHOUT A VERSION CONTROL SYSTEM, PREFERABLY GIT&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DON'T HARD CODE STRINGS, NUMBERS, FILE/DIRECTORY NAMES EVER!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ALWAYS METICULOUSLY DOCUMENT YOUR "CLEVER" HACKS. ALWAYS!&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally... &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DON'T BLINDLY COPY CODE FROM STACK OVERFLOW&lt;/strong&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Anything More?
&lt;/h1&gt;

&lt;p&gt;Yes! A lot more. Over the course of this series I will expand on each of my bullet points in a separate blog post that will deep dive in to the point. In the mean time feel free to look up software engineering, the controversy around it. If you have any comments to share find me on Twitter (link at the bottom).&lt;/p&gt;


</description>
      <category>datascience</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Setup OSX for R</title>
      <dc:creator>Bhaskar Karambelkar</dc:creator>
      <pubDate>Fri, 20 Jan 2017 01:44:23 +0000</pubDate>
      <link>https://forem.com/bhaskar_vk/setup-osx-for-r</link>
      <guid>https://forem.com/bhaskar_vk/setup-osx-for-r</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally Published on my &lt;a href="https://www.karambelkar.info/2017/01/setup-osx-for-r/"&gt;Personal Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a rather details documentation of my OSX setup for R usage using homebrew. You can get away with a lot less than what I have installed below, but this is fairly comprehensive and I have also given some steps to verify installation of various packages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Github API Token
&lt;/h3&gt;

&lt;p&gt;Get a github account and setup an API token as described &lt;a href="https://help.github.com/articles/creating-an-access-token-for-command-line-use/"&gt;here&lt;/a&gt;. This helps you avoid hitting Github API limits when using homebrew.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export HOMEBREW_GITHUB_API_TOKEN="your_new_token"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile
&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Homebrew and tap some taps
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/bin/ruby &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
brew analytics off &lt;span class="c"&gt;# full on paranoid mode&lt;/span&gt;
brew tap caskroom/cask &lt;span class="c"&gt;# GUI apps&lt;/span&gt;
brew tap caskroom/fonts &lt;span class="c"&gt;# fonts&lt;/span&gt;
brew tap homebrew/science
brew tap homebrew/completions
brew tap homebrew/services
brew tap homebrew/versions
brew tap osgeo/osgeo4mac &lt;span class="c"&gt;# If you need Geospatial stuff&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Bash
&lt;/h3&gt;

&lt;p&gt;Install Bash and verify&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;bash bash-completion2
/usr/local/bin/bash &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU bash, version 4.3.46(1)-release (x86_64-apple-darwin15.5.0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Setup bash along with some utility functions. Primarily we setup &lt;code&gt;brewPkg&lt;/code&gt; bash function which will not only install homebrew packages but also log the output for debugging purposes if so desired.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'echo "/usr/local/bin/bash" &amp;gt;&amp;gt; /etc/shells'&lt;/span&gt;

&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/Library/Logs/Homebrew/&lt;span class="nv"&gt;$USER&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'
if [ -f $(brew --prefix)/share/bash-completion/bash_completion ]; then
  . $(brew --prefix)/share/bash-completion/bash_completion
fi

brewPkg() {
  pkg=$1
  shift
  (
    brew install ${pkg} $*  2&amp;gt;&amp;amp;1 |
        tee $HOME/Library/Logs/Homebrew/$USER/${pkg}-$(date +"%F_%H%M").txt
  )
}

brewSrcPkg() {
  pkg=$1
  shift
  (
    brew install --build-from-source  ${pkg} $*  2&amp;gt;&amp;amp;1 |
        tee $HOME/Library/Logs/Homebrew/$USER/${pkg}-$(date +"%F_%H%M").txt
  )
}

brewSrcPkgWgcc() {
  pkg=$1
  shift
  (
    export CC=gcc-6
    export CXX=g++-6
    export HOMEBREW_CC=gcc-6
    export HOMEBREW_CXX=g++-6
    brew install --build-from-source  ${pkg} $*  2&amp;gt;&amp;amp;1 |
        tee $HOME/Library/Logs/Homebrew/$USER/${pkg}-$(date +"%F_%H%M").txt
  )
}

'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;  ~/.bash_profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Load the new bash shell, so we can use all the auto-complete goodies. Or simply close and restart the Terminal App.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/local/bin/bash &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GCC Compiler and Autotools
&lt;/h3&gt;

&lt;p&gt;Install gcc, without multilib so that &lt;a href="http://stackoverflow.com/questions/29057437/compile-openmp-programs-with-gcc-compiler-on-os-x-yosemite"&gt;OpenMP works&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg gcc &lt;span class="nt"&gt;--without-multilib&lt;/span&gt;
/usr/local/bin/gcc-6 &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc-6 (Homebrew gcc 6.1.0 --without-multilib) 6.1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/local/bin/gfortran &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU Fortran (Homebrew gcc 6.1.0 --without-multilib) 6.1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Setup aliases for homebrew's gcc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /usr/local/bin
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; gcov-6 gcov
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; gcc-6 gcc
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; g++-6 g++
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; cpp-6 cpp
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; c++-6 c++
&lt;span class="nb"&gt;cd&lt;/span&gt; -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Install ccache to speed up compilation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg ccache
/usr/local/bin/ccache &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ccache version 3.2.7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Install autotools, pkg-config, and cmake&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg cmake pkg-config autoconf automake
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Let's make sure OpenMP is working as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; omp-test.c &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;"
#include &amp;lt;omp.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
int main() {
    #pragma omp parallel
    printf("Hello from thread %d, nthreads %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;", omp_get_thread_num(), omp_get_num_threads());
}
&lt;/span&gt;&lt;span class="no"&gt;END
&lt;/span&gt;gcc-6 &lt;span class="nt"&gt;-fopenmp&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; omp-test omp-test.c 
./omp-test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;You should see something similar but not exactly the same.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 4, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 5, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 7, nthreads 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Misc libs
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg freetype fontconfig  pixman gettext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SSL/SSH Libs
&lt;/h3&gt;

&lt;p&gt;Setup and verify openssl and libressl.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg  openssl
/usr/local/opt/openssl/bin/openssl version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OpenSSL 1.0.2h  3 May 2016
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg  libressl
/usr/local/opt/libressl/bin/openssl version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LibreSSL 2.3.6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg libssh2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  wget and curl
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg wget
/usr/local/bin/wget &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU Wget 1.18 built on darwin15.6.0.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg curl
/usr/local/opt/curl/bin/curl-config &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libcurl 7.50.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  GPG
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg gpg2 &lt;span class="nt"&gt;--with-readline&lt;/span&gt;
/usr/local/bin/gpg2 &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg (GnuPG) 2.0.30
libgcrypt 1.7.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg gpgme
/usr/local/bin/gpgme-config &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1.6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Java
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;java
java &lt;span class="nt"&gt;-version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  X-server
&lt;/h3&gt;

&lt;p&gt;We need an X-Server. This takes a lot of time so be patient.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;xquartz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;

&lt;p&gt;Install python2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg python
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--upgrade&lt;/span&gt; pip setuptools
/usr/local/bin/python &lt;span class="nt"&gt;-V&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python 2.7.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Install Python3&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg python3
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--upgrade&lt;/span&gt; pip setuptools wheel
/usr/local/bin/python3 &lt;span class="nt"&gt;-V&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python 3.5.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Git
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg git &lt;span class="nt"&gt;--with-blk-sha1&lt;/span&gt; &lt;span class="nt"&gt;--with-gettext&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-pcre&lt;/span&gt; &lt;span class="nt"&gt;--with-persistent-https&lt;/span&gt;
/usr/local/bin/git &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git version 2.9.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Boost libs w/ dependencies
&lt;/h3&gt;

&lt;p&gt;Install icu4c library for Unicode and globalization&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg icu4c
/usr/local/opt/icu4c/bin/icu-config &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;57.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Install libxml2, libiconv, and libxslt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg libxml2 libiconv libxslt
brew &lt;span class="nb"&gt;link &lt;/span&gt;libxml2 &lt;span class="nt"&gt;--force&lt;/span&gt;
/usr/local/bin/xml2-config &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.9.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Install boost. Ignore the warning at the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg boost &lt;span class="nt"&gt;--with-icu4c&lt;/span&gt; &lt;span class="nt"&gt;--with-mpi&lt;/span&gt; &lt;span class="nt"&gt;--without-single&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Boost is a beast of a library, so we need some quick programs to test whether it has installed successfully.&lt;br&gt;
Shamelessly copied/adapted from the &lt;a href="https://tabreziqbal.wordpress.com/2006/03/16/how-to-test-c-boost-installation/"&gt;Intertubes&lt;/a&gt;. Ignore the warning messages spewed by the compiler.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; first.cpp &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;
#include&amp;lt;iostream&amp;gt;
#include&amp;lt;boost/any.hpp&amp;gt;
int main()
{
    boost::any a(5);
    a = 1.61803;
    std::cout &amp;lt;&amp;lt; boost::any_cast&amp;lt;double&amp;gt;(a) &amp;lt;&amp;lt; std::endl;
}
&lt;/span&gt;&lt;span class="no"&gt;END
&lt;/span&gt;clang++ &lt;span class="nt"&gt;-o&lt;/span&gt; first first.cpp
./first
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1.61803
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; second.cpp &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;
#include&amp;lt;iostream&amp;gt;
#include &amp;lt;boost/filesystem.hpp&amp;gt;
int main() 
{
    boost::filesystem::path full_path( boost::filesystem::current_path() );
    if ( boost::filesystem::exists( "second.cpp" ) )
    {
        std::cout &amp;lt;&amp;lt; "Found second.cpp file in " &amp;lt;&amp;lt; full_path &amp;lt;&amp;lt; std::endl;
    } else {
        std::cerr &amp;lt;&amp;lt; "Argh!, Something not working" &amp;lt;&amp;lt; std::endl;
        return 1;
    }
}
&lt;/span&gt;&lt;span class="no"&gt;END
&lt;/span&gt;clang++ &lt;span class="nt"&gt;-o&lt;/span&gt; second second.cpp &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-lboost_filesystem-mt&lt;/span&gt; &lt;span class="nt"&gt;-lboost_system-mt&lt;/span&gt;
./second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Found second.cpp file in "/Users/brewmaster"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Latex Support
&lt;/h3&gt;

&lt;p&gt;Take a Coffee break and then some, because this is a huge one.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;mactex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  R
&lt;/h3&gt;

&lt;p&gt;&lt;br&gt;Install libsvg, librsvg, and cairo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg cairo 
brewPkg libsvg
brewPkg librsvg
brewPkg pandoc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Openblas for speedier linear algebra in R.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg openblas &lt;span class="nt"&gt;--with-openmp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Test openblas. Shamelessly copied from &lt;a href="https://github.com/xianyi/OpenBLAS/wiki/User-Manual#code-examples"&gt;Intertubes&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; test-openblas.c &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;"
#include &amp;lt;cblas.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

void main()
{
  int i=0;
  double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};         
  double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};  
  double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5}; 
  cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,
    3,3,2,1,A, 3, B, 3,2,C,3);

  for(i=0; i&amp;lt;9; i++)
    printf("%lf ", C[i]);
  printf("&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;");
}
&lt;/span&gt;&lt;span class="no"&gt;END

&lt;/span&gt;clang &lt;span class="nt"&gt;-L&lt;/span&gt;/usr/local/opt/openblas/lib &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-I&lt;/span&gt;/usr/local/opt/openblas/include &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-lopenblas&lt;/span&gt; &lt;span class="nt"&gt;-lpthread&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; test-openblas test-openblas.c

./test-openblas 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;11.000000 -9.000000 5.000000 -9.000000 21.000000 -1.000000 5.000000 -1.000000 3.000000 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Eigen and Armadillo for Rcpp and v8 for &lt;a href="https://github.com/jeroenooms/V8"&gt;R+v8&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg eigen
brewPkg armadillo &lt;span class="nt"&gt;--with-hdf5&lt;/span&gt;
brewPkg v8-315
brew &lt;span class="nb"&gt;link &lt;/span&gt;v8-315 &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Test Armadillo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /usr/local/opt/armadillo/examples/
clang++   &lt;span class="nt"&gt;-O2&lt;/span&gt;   &lt;span class="nt"&gt;-o&lt;/span&gt; example1  example1.cpp  &lt;span class="nt"&gt;-larmadillo&lt;/span&gt; &lt;span class="nt"&gt;-framework&lt;/span&gt; Accelerate
./example1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;You should see something like below and lot more.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Armadillo version: 7.200.2 (Plutocratic Climate Change Denialist)
A.n_rows: 2
A.n_cols: 3
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Test v8&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'quit()'&lt;/span&gt; | v8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V8 version 3.15.11.18 [sample shell]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;Finally install R itself, and also setup R to use Apple's &lt;code&gt;clang&lt;/code&gt; compiler. We can also setup R to use &lt;code&gt;gcc&lt;/code&gt; compiler to take advantage of &lt;code&gt;openmp&lt;/code&gt; support, but I've noticed that not all R packages compile correctly when using GCC.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg r &lt;span class="nt"&gt;--with-openblas&lt;/span&gt; &lt;span class="nt"&gt;--with-pango&lt;/span&gt;
&lt;span class="c"&gt;# for rJava to work.&lt;/span&gt;
R CMD javareconf &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nv"&gt;JAVA_CPPFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;-I&lt;/span&gt;/System/Library/Frameworks/JavaVM.framework/Headers

&lt;span class="c"&gt;# Setup $HOME/.r/Makevars file to properly link against homebrew packages.&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.r
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.r/Makevars &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;
CC=ccache clang
CXX=ccache clang++
SHLIB_CXXLD=ccache clang++
FC=gfortran-6
F77=gfortran-6
MAKE=make -j8
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig
PKG_LIBS += -L/usr/local/opt/icu4c/lib -L/usr/local/lib
&lt;/span&gt;&lt;span class="no"&gt;END


&lt;/span&gt;&lt;span class="c"&gt;# Also setup a R_LIBS_USER directory to install R packages locally.&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/Library/R/3.x/library
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.Renviron &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;
export R_LIBS_USER=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/Library/R/3.x/library
&lt;/span&gt;&lt;span class="no"&gt;END

&lt;/span&gt;&lt;span class="c"&gt;# add same stuff to .bash_profile&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.Renviron &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GIS Stuff
&lt;/h3&gt;

&lt;p&gt;Mostly PostGIS + Geo libs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg postgresql
brewPkg geos
brewPkg proj
brewPkg gdal2 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-armadillo&lt;/span&gt; &lt;span class="nt"&gt;--with-complete&lt;/span&gt; &lt;span class="nt"&gt;--with-libkml&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-opencl&lt;/span&gt; &lt;span class="nt"&gt;--with-postgresql&lt;/span&gt; &lt;span class="nt"&gt;--with-unsupported&lt;/span&gt;
brewPkg postgis &lt;span class="nt"&gt;--with-gui&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Other Programming Languages
&lt;/h3&gt;

&lt;p&gt;Some other programming languages I use occasionally.&lt;/p&gt;

&lt;h4&gt;
  
  
  Node.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg node
brewPkg phantomjs casperjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Scala
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;scala
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  golang
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;golang
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="sh"&gt;
export GOPATH=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="sh"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$GOPATH&lt;/span&gt;&lt;span class="sh"&gt;/bin
export PATH=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="sh"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$GOROOT&lt;/span&gt;&lt;span class="sh"&gt;/bin
&lt;/span&gt;&lt;span class="no"&gt;END
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Other Interesting Stuff
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brewPkg imagemagick &lt;span class="nt"&gt;--with-fontconfig&lt;/span&gt; &lt;span class="nt"&gt;--with-ghostscript&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-librsvg&lt;/span&gt; &lt;span class="nt"&gt;--with-pango&lt;/span&gt; &lt;span class="nt"&gt;--with-webp&lt;/span&gt;
brewPkg vim &lt;span class="nt"&gt;--with-python3&lt;/span&gt; &lt;span class="nt"&gt;--with-client-server&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-lua&lt;/span&gt; &lt;span class="nt"&gt;--with-luajit&lt;/span&gt; &lt;span class="nt"&gt;--with-override-system-vi&lt;/span&gt;

brewPkg macvim &lt;span class="nt"&gt;--with-python3&lt;/span&gt; &lt;span class="nt"&gt;--with-client-server&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--with-lua&lt;/span&gt; &lt;span class="nt"&gt;--with-luajit&lt;/span&gt; &lt;span class="nt"&gt;--with-override-system-vim&lt;/span&gt;

brewPkg jq &lt;span class="c"&gt;# json processing&lt;/span&gt;

brew cask &lt;span class="nb"&gt;install &lt;/span&gt;font-hack font-fira-code &lt;span class="c"&gt;#extra fonts&lt;/span&gt;

brewPkg mlpack &lt;span class="c"&gt;# Fast Machine Learning&lt;/span&gt;
brewPkg protobuf &lt;span class="nt"&gt;--devel&lt;/span&gt; &lt;span class="c"&gt;# Google's Protocol Buffer Library&lt;/span&gt;
brewPkg gsl &lt;span class="c"&gt;# GNU Scientific Library&lt;/span&gt;
brewPkg libyaml &lt;span class="c"&gt;# YAML Support&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GUI Apps
&lt;/h3&gt;

&lt;p&gt;Apps related to Securing your Mac.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;blockblock knockknock &lt;span class="se"&gt;\&lt;/span&gt;
    dhs taskexplorer kextviewr
brew cask &lt;span class="nb"&gt;install &lt;/span&gt;suspicious-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Quicklook Plugins for Developers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;qlcolorcode qlstephen qlmarkdown &lt;span class="se"&gt;\&lt;/span&gt;
    quicklook-json qlprettypatch quicklook-csv betterzipql &lt;span class="se"&gt;\&lt;/span&gt;
    qlimagesize webpquicklook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;These are some GUI apps I use. Pick and chose as you like. They are not necessarily related to R or even development.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew cask &lt;span class="nb"&gt;install &lt;/span&gt;google-chrome chrome-devtools firefox iterm2 seil &lt;span class="se"&gt;\&lt;/span&gt;
 slate keepassx free-mind itsycal flux caffeine alfred beardedspice &lt;span class="se"&gt;\&lt;/span&gt;
 macdown mysqlworkbench osxfuse smcfancontrol torbrowser vagrant&lt;span class="se"&gt;\&lt;/span&gt;
 vagrant-manager vlc cog yed slack owncloud 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>r</category>
      <category>rstats</category>
      <category>osx</category>
      <category>homebrew</category>
    </item>
    <item>
      <title>GDAL 2 On Mac with Homebrew</title>
      <dc:creator>Bhaskar Karambelkar</dc:creator>
      <pubDate>Thu, 20 Oct 2016 21:34:35 +0000</pubDate>
      <link>https://forem.com/bhaskar_vk/gdal-2-on-mac-with-homebrew</link>
      <guid>https://forem.com/bhaskar_vk/gdal-2-on-mac-with-homebrew</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on my &lt;a href="https://www.karambelkar.info/2016/10/gdal-2-on-mac-with-homebrew/"&gt;personal blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a small post about upgrading to &lt;a href="https://trac.osgeo.org/gdal/wiki/Release/2.1.3-News"&gt;gdal 2.x&lt;/a&gt; on a Mac using homebrew.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assumptions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You have homebrew installed and setup.&lt;/li&gt;
&lt;li&gt;You already have gdal 1.x installed via homebrew's default 'gdal' formula.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Install gdal 2.x
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Unlink gdal 1.x using&lt;br&gt;&lt;code&gt;brew unlink gdal&lt;/code&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tap into &lt;a href="https://github.com/OSGeo/homebrew-osgeo4mac"&gt;osgeo4mac&lt;/a&gt; &lt;br&gt;&lt;code&gt;brew tap osgeo/osgeo4mac &amp;amp;&amp;amp; brew tap --repair&lt;/code&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install gdal2.&lt;br&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;gdal2 &lt;span class="nt"&gt;--with-armadillo&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--with-complete&lt;/span&gt; &lt;span class="nt"&gt;--with-libkml&lt;/span&gt; &lt;span class="nt"&gt;--with-unsupported&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Link gdal2&lt;br&gt;&lt;code&gt;brew link --force gdal2&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; gdal-config &lt;span class="nt"&gt;--version&lt;/span&gt;
2.1.1

&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; gdal-config &lt;span class="nt"&gt;--libs&lt;/span&gt;
&lt;span class="nt"&gt;-L&lt;/span&gt;/usr/local/Cellar/gdal2/2.1.1/lib &lt;span class="nt"&gt;-lgdal&lt;/span&gt;

&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; gdal-config &lt;span class="nt"&gt;--cflags&lt;/span&gt;
&lt;span class="nt"&gt;-I&lt;/span&gt;/usr/local/Cellar/gdal2/2.1.1/include
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Post Install
&lt;/h2&gt;

&lt;p&gt;If you are using R for geo-spatial stuff, be sure to reinstall the &lt;code&gt;rgdal&lt;/code&gt; library. Also you can now install &lt;a href="https://github.com/edzer/sfr"&gt;sf&lt;/a&gt; in R using &lt;code&gt;devtools::install_github('edzer/sfr')&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>r</category>
      <category>gis</category>
      <category>homebrew</category>
      <category>gdal</category>
    </item>
    <item>
      <title>How to use Twitter’s Search REST API most effectively.</title>
      <dc:creator>Bhaskar Karambelkar</dc:creator>
      <pubDate>Mon, 05 Jan 2015 12:49:00 +0000</pubDate>
      <link>https://forem.com/bhaskar_vk/how-to-use-twitters-search-rest-api-most-effectively</link>
      <guid>https://forem.com/bhaskar_vk/how-to-use-twitters-search-rest-api-most-effectively</guid>
      <description>

</description>
      <category>search</category>
      <category>python</category>
      <category>twitter</category>
      <category>api</category>
    </item>
  </channel>
</rss>
