Wednesday, December 2, 2015

My most used commands in Mininet

Introduction

A new thing that I learn today is mininet. Mininet is a set of software tools that I can use to simulate computer networks. The tools has build-in topology that that can get a non-sophisticate user like me to get my feet wet within a short time. This beats running into my lab and connecting cables to get my topology.

Mininet has extensive set of document and VM appliances that you can download and start right away. The VM image that I downloaded is based on Ubuntu 12.04. There are a lot of resources that you can use to learn about Ubuntu, VM, and virtualization on the web. I'll skip over these discussion for now, but may come back and talk about it later.

List of commands for Daily use

Mininet is known on the Ubuntu VM appliance as "mn" - its abbreviation *giggle*. Since mininet needs access to resources on the appliance, you will have to run "mn" at an elevated permission. On a Unix system such as Ubuntu you prefix mininet's command with sudo. This is how you start "mininet" once you get into the mininet appliance.
mininet@mininet-vm:~$ sudo mn
Mininet responses with the following output. It creates the default simple network topology.
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
mininet>
In this topology, we have 2 hosts and one switch. These hosts are denoted by h1 and h2. s1 represents the switch in this topology. "Links" are connections between a host and a switch. The link is always a point-to-point - meaning that the link connects between a pair only. The end-point of a link can be either a host, or a switch. These links in this topology shows as:
(h1, s1) (h2, s1)

There are several ways to review your network topology. The one that I use most is net. Here's the example of the output of the command:
mininet> net
c0
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
mininet>

Next time, we will go over other aspect of running the simple topology.

Example of running Java program calling external "jar" file

In this example, my java program is calling Juniper's Netconf.jar to interact with routers running JUNOS.
reia-mba:~/Devel/SRXFlowInfo/bin reia$ java -cp ../lib/Netconf.jar:. getFlowInfo arg0 arg1 arg2

In this example,

  • "reia-mba:~/Devel/SRXFlowInfo/bin reia$ " is the command prompt on my MacBook Air.
  • The next portion of the command is "java" - the name of Java virtual machine.
  • Next up is "-cp", this is called a flag. This particular flag - "cp" is an abbreviation of "CLASS PATH". This flag consumes the next argument - "../lib/Netconf.jar:.", which is the location of "Netconf.jar" Class Library that provided by Juniper.
  • getFlowInfo is the class that we want to execute. It is shown in the directory as getFlowInfo.class. This is the output of Java compiled code. Pretty much an equivalent of a.out, I think. I will have to look this out later on.
    One note about this .class extension. When you want to run the Java program, don't put in the .class extension. You will get an error that the java can not find "main"

Friday, November 27, 2015

Installing Juniper's PyEZ on Mac OS X (Part 1)

My goal is to install Juniper's PyEZ on my Macbook Air so that I can do some work while hanging out with friends. As many of my friends do, we hang out having coffee for awhile and then the topic of discussion usually turns into technical. From than on, if enough people curious, it turns into a mini-hackaton. LOL. I think we spend too much time on this and not enough on non-technical thing. Getting a life is probably is a good thing too *giggle*

As a tools, my 11" MBA is hard to beat. The keyboard is full size - except for the tiny arrow keys on the right. The screen is more than adequate. The battery life is awesome. And it is light. Not as light as the new Macbook, but it is light enough. An at less than $999, it is hard to beat.

Anyway, my note for today is how to install "Juniper's PyEZ" on my Macbook Air. Let spend some time on the PyEZ. This post contains the first part of my installation which covers getting most of the Python library in place. The next blog will continue with the installation.

Juniper's PyEZ

PyEZ is a Python power-shell that you can use to interact with Juniper's routers. It is based on Netconf (see RFC6241) Supposedly it provides a consistent interface to a router such that you can - at least in theory - using a unify program/interface to talk to elements in your multi-vendor network. (commentary... you can see how well it works such that there is another movement to unify further via openconfig.org)

I checked out Juniper's web site and it listed the requirement of installing:

  • Xcode
  • pip
This is simple enough since I always have "Xcode" installed, this gonna be a piece of cake. For "pip", you can see my other blog.

The next step is to install "PyEZ" using "pip install junos-pyez". Unfortunately, this won't work cuz I got an error while compiling it. Here's my error on the screen: (Note the cute ASCII scroll bar, it's so '80s LOL.)

reia-mba:/usr/bin reia$ sudo pip install junos-eznc
Password:
The directory '/Users/reia/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/reia/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting junos-eznc
  Downloading junos-eznc-1.2.3.tar.gz (62kB)
    100% |████████████████████████████████| 65kB 98kB/s 
Collecting lxml>=3.2.4 (from junos-eznc)
  Downloading lxml-3.5.0.tar.gz (3.8MB)
    100% |████████████████████████████████| 3.8MB 73kB/s 
Collecting ncclient>=0.4.3 (from junos-eznc)
  Downloading ncclient-0.4.6.tar.gz (57kB)
    100% |████████████████████████████████| 61kB 83kB/s 
Collecting paramiko>=1.15.2 (from junos-eznc)
  Downloading paramiko-1.16.0-py2.py3-none-any.whl (169kB)
    100% |████████████████████████████████| 172kB 163kB/s 
Collecting scp>=0.7.0 (from junos-eznc)
  Downloading scp-0.10.2-py2.py3-none-any.whl
Collecting jinja2>=2.7.1 (from junos-eznc)
  Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
    100% |████████████████████████████████| 266kB 113kB/s 
Collecting PyYAML>=3.10 (from junos-eznc)
  Downloading PyYAML-3.11.tar.gz (248kB)
    100% |████████████████████████████████| 249kB 115kB/s 
Collecting netaddr (from junos-eznc)
  Downloading netaddr-0.7.18-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 120kB/s 
Requirement already satisfied (use --upgrade to upgrade): setuptools>0.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from ncclient>=0.4.3->junos-eznc)
Collecting ecdsa>=0.11 (from paramiko>=1.15.2->junos-eznc)
  Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
    100% |████████████████████████████████| 90kB 195kB/s 
Collecting pycrypto!=2.4,>=2.1 (from paramiko>=1.15.2->junos-eznc)
  Downloading pycrypto-2.6.1.tar.gz (446kB)
    100% |████████████████████████████████| 446kB 77kB/s 
Collecting MarkupSafe (from jinja2>=2.7.1->junos-eznc)
  Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: lxml, ecdsa, pycrypto, paramiko, ncclient, scp, MarkupSafe, jinja2, PyYAML, netaddr, junos-eznc
  Running setup.py install for lxml
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-3YToOU/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-QXJfAy-record/install-record.txt --single-version-externally-managed --compile:
    Building lxml version 3.5.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-intel-2.7
    creating build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/builder.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/cssselect.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/sax.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.macosx-10.11-intel-2.7/lxml
    creating build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    creating build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron
    copying src/lxml/lxml.etree.h -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/rng
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.macosx-10.11-intel-2.7
    creating build/temp.macosx-10.11-intel-2.7/src
    creating build/temp.macosx-10.11-intel-2.7/src/lxml
    cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -Isrc/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.11-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
    In file included from src/lxml/lxml.etree.c:323:
    src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
    #include "libxml/xmlversion.h"
             ^
    1 error generated.
    Compile failed: command 'cc' failed with exit status 1
    creating tmp
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitzzAQot.c -o tmp/xmlXPathInitzzAQot.o
    /tmp/xmlXPathInitzzAQot.c:1:10: fatal error: 'libxml/xpath.h' file not found
    #include "libxml/xpath.h"
             ^
    1 error generated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    Perhaps try: xcode-select --install
    *********************************************************************************
    error: command 'cc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-3YToOU/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-QXJfAy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-3YToOU/lxml
reia-mba:/usr/bin reia$

Unfortunately, after all these works, it is not enough. The problem is that "easy_install" can't file libxml version number. Ok, it is a good practice to make sure you have the right thing install, but wow, how come it doesn't work?

A little more googling and I found out that there is actually a better instruction on how to install the PyEZ. I found it on Juniper's github page -

https://github.com/Juniper/py-junos-eznc/blob/master/INSTALL-OSX.md
I probably can be shameless and copy the content here. However, I don't feel like doing this today. LOL. So may be when I don't have anything better to do I'll do that.
Anyway, you follow the instruction on that page and you should be able to install your PyEZ. I haven't finished the installation, yet. So I'm sure I will post more stuffs in a couple of days.

Later Loves.

ReiA

Installing "pip" on Mac OSX

Why "pip" on my MBA?

I always tell people how much I'm very fond of my 11" MacBook Air (MBA), it comes with a number of useful tools. For development platform, I usually use tools on my Ubuntu desktop running as a virtual machine on my 15" MacBook Pro (MBP). But since I have an old MBP, it is supper heavy and I don't want to lug it around all day, especially on the weekend where I want to go hang out with friends. So my alternative is to use either my lighter weight 11", or an Acer 720 Chromebook when going around town. For a day that I have a couple of hours of free time, I think my MBA win the day. I can actually do some development work connecting back to my lab to test my code and etc... all by using my MBA. I have tried the CB but unfortunately, we don't have any VPN option for CB, it is rather unfortunate since the CB is actually pretty nice.

Anyway, I think I digress... as usual. Today, I just want to make a note that on the Mac OS X, I can use easy_install to install pip.

What is "easy_install"

Looking at /usr/bin/easy_install, I found out that it is a python script writing to simplify installation of Python's component. If you know Python, it is pretty simple to read and understand. So why wait... go there an cat it. *giggle*

Screen scrape of pip installation

Here is my screen scrape of the session. It is very simple - as long as you have an ability to "sudo" or being an "administrator" on your Mac.

reia-mba:~ reia$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 7.1.2
Downloading https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917710196
Processing pip-7.1.2.tar.gz
Writing /tmp/easy_install-DqikW9/pip-7.1.2/setup.cfg
Running pip-7.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-DqikW9/pip-7.1.2/egg-dist-tmp-sI6Tr4
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
Adding pip 7.1.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
reia-mba:~

Untile next time... Muach!!!!

Monday, September 14, 2015

Setup Virtual LAMP Server - Install VirtualBox

In this module...

In my previous blog post, we talked about creating our own virtual LAMP server for the purpose of not only having a contained web development but also a way to learn how to manage our own servers. In this blog post, we are looking at the first step which is to install a virtualization software on your host laptop.

For the virtualization software, I pick VirtualBox (or VBox) cuz it is free. You can beat its price here. I have been using VBox for a couple of years now - on both MacOSX host and Windows host with very good results. I don't even remember having any problem with any of the host systems. So it gets high vote of confidence from me.

The current software version is VirtualBox 5.0. I have version 5.0.4 running on my MacBook Pro, and version 4.3.30 running on my MacBook Air that I use when travelling. They work great. Either version would be fine.

There are also tons of information about virtualization on VirtualBox Wiki page. I also found very interesting information, especially for beginner. You can take a look at the First chapter of VBox Manual.

Getting the VirtualBox software

VirtualBox software is available at https://www.VirtualBox.org/wiki/Download.

On the download page, you have choices of your host operating system or (host OS). This is the version of OS that you run on your laptop. For example, I have a MacBook running OSX, I would pick "VirtualBox 5.0.4 for OS X host amd64". The "amd64" bit tells you that the software is for a 64-bit OS - most of the newer OS are 64-bit nowaday.

Once you click on the appropriate link for your host, the software starts downloading. VBox version 5.0.4 for OSX is about 90Mbytes. So it is rather small by today's standard. Below the host OS, there is a link to "VirtualBox Extension package". The extension pack is really great if you want to connect your USB ports to the virtual host. We don't really need the extension pack for our virtual LAMP. But you can download and install it, if you want.

VirtualBox installation

When you click on the link to download, the software package is downloaded into your "Download" folder. On my Macbook, it is usually under ~/Downloads directory.

In this example, I have two version of VirtualBox that I downloaded.

The rest of the article will show a step by step of installing VirtualBox.

  • Next step is to install the software. Double click the "VirtualBox-5.0.4-102546-OSX.dmg" icon. The app will open a new window which will tell you how to install.
  • When you double click the "VirtualBox.pkg" icon, another dialog box shows up. This step, the software will check to make sure that your laptop could run the software.
    Click Continue
  • Another dialog box advice of how much disk space it will use. Click Install to go ahead with the installation.
  • Once again, you hit Install. OSX will ask you for your administrative password. Input your password and click Install Software
    If everything is good, you will see a couple more updates to the install dialog box.
    ... and finally, a message say "The installation was successful.
  • And we are done... So easy, I know right?

    We will go through running VirtualBox for the first time next time. We will also go over installing a Ubuntu server. See you next time.

  • Saturday, September 12, 2015

    Set up a LAMP server for Web Development - Intro

    What is this about?

    A lot of people like to learn more about Web development. But not everyone has access to a web server. And let's face it, having your own web server running on your laptop is nice, isn't it? What more is that you are also learning to manage a Linux/Ubuntu server. Double bonus!!!!

    Today I will talk about setting up a LAMP (Linux+Apache+MySQL+PHP) environment running as a virtual machine on your laptop. Since I have a MacBook Pro, this article will focus on the MacBook. The same procedure works for MacBook Air too.
    There are a number of virtualization products you can use on a Mac. My favorites are VMWare Fusion from VMWare, and VirtualBox from Oracle. Since VirtualBox is FREE, we will be using VirtualBox in this article.

    What do you need?

    • A laptop, obviously. Any laptop with multiple cores CPU and at least 4G bytes of memory would works. The LAMP server, surprisingly, does not need a lot of memory to run. 512M or even 256M is enough for a server without GUI. I am using a mid-2012 MacBook Pro with i7 and 16G. It is way overkill and not necessary. I also have a 11" Macbook Air with 4G mem and it is working fine.
    • A Virtualization software such as VirtualBox, or VMWare
    • Ubuntu 32-bit or 64-bit server software in ISO format

    In the next blog post, I'll go through the steps that I put these thing together.

    Friday, March 13, 2015

    Adventure in R

    What's up?

    I am taking a class on Coursera.org called - "The Data Scientist's Toolbox" teaches online by Jeef Leek, Brian Caffo, and Roger D. Peng.  Part of the class is to teach you how to use git, github, R, and R's packages

    Rcurl package requires "curl-config".
    This means that we need to do:
    • sudo apt-get install curl
    • sudo apt-get install libcurl4-gnutls-dev

    "mermaid" - OMG!!!!!

    Ok, so I am really excited to have found mermaid- the software. LOL.
    I was looking for a tool that I can generate a chart. It started off with markdown and I ended up running into mermaid.

    mermaid is written in JavaScript, so you will need to have node.js installed on your lappy. Come to think of it, I haven't write an article about node.js, yet. I will do it later. *giggle*

    NOTE: I found out later that mermaid requires Phantom.js and not node.js. I need to rewrite this section. One thing for sure, all of these require npm. Yeah, more stuffs to write about...

    Installing mermaid

    Installing mermaid is pretty simple, but only if you have node installed. So if you don't have node go ahead and install it on your puter.
    The following is a script of me installing mermaid on my beloved Macbook Pro.

    [reia-mbp15:~] reia% sudo npm install -g mermaid
    Password:
    
    > contextify@0.1.13 install /usr/local/lib/node_modules/mermaid/node_modules/d3/node_modules/jsdom/node_modules/contextify
    > node-gyp rebuild
    
    gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/reia/.node-gyp/0.10.33"
    gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mermaid/node_modules/d3/node_modules/jsdom/node_modules/contextify/.node-gyp"
      CXX(target) Release/obj.target/contextify/src/contextify.o
      SOLINK_MODULE(target) Release/contextify.node
      SOLINK_MODULE(target) Release/contextify.node: Finished
    /usr/local/bin/mermaid -> /usr/local/lib/node_modules/mermaid/bin/mermaid.js
    mermaid@0.4.0 /usr/local/lib/node_modules/mermaid
    ├── which@1.0.9
    ├── minimist@1.1.1
    ├── he@0.5.0
    ├── semver@4.3.1
    ├── mkdirp@0.5.0 (minimist@0.0.8)
    ├── moment@2.9.0
    ├── chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
    ├── dagre-d3@0.3.3 (graphlib@1.0.1, dagre@0.6.4, lodash@2.4.1)
    └── d3@3.4.13 (jsdom@1.0.0)
    [reia-mbp15:~] reia% 
    

    How do I run "mermaid"?

    After the installation, I tried to run it but it failed.... *sad face*.

    [reia-mbp15:~] reia% mermaid
    mermaid: Command not found.
    
    It turns out that I didn't have "/usr/local/bin" in my PATH, silly me. LOL.
    Using absolute path fix that issue, for now.
    Note to self, add /usr/local/bin/ into the .cshrc
    [reia-mbp15:~] reia% /usr/local/bin/mermaid
    
    You had errors in your syntax. Use --help for further information.
    You must specify at least one source file.
    Cannot find phantomjs in your PATH. If phantomjs is installed
    you may need to specify its path manually with the '-e' option.
    Run this executable with '--help' or view the README for more
    details.
    [reia-mbp15:~] reia% /usr/local/bin/mermaid --help
    
    Usage: mermaid [options] ...
    
    file    The mermaid description file to be rendered
    
    Options:
      -s --svg             Output SVG instead of PNG (experimental)
      -p --png             If SVG was selected, and you also want PNG, set this flag
      -o --outputDir       Directory to save files, will be created automatically, defaults to `cwd`
      -e --phantomPath     Specify the path to the phantomjs executable
      -t --css             Specify the path to a CSS file to be included when processing output
      -c --sequenceConfig  Specify the path to the file with the configuration to be applied in the sequence diagram
      -h --help            Show this message
      -v --verbose         Show logging
      --version            Print version and quit
    [reia-mbp15:~] reia%
    

    Example

    you can find a lot of example of mermaid at http://knsv.github.io/mermaid/. Here's just a short one:

    sequenceDiagram
    Customer ->> HelpDesk: Case Open
    Note right of HelpDesk: SR open via CRM
    if there is no known PR
    Then HelpDesk open a new PR HelpDesk->> ACE: Create a new PR Note right of ACE: Update the PR
    and change PR status to
    "info"