Posted in Bioinformatics, Data Science, Neurology, R Language

Installing and Using R lanuage in Ubuntu


The World of Tomorrow
We are surrounded by data and tools that collects it. Every time you perform a web search on bing or use Google map to find a location; you are generating data. Those able to analyze data and extract knowledge that enables informed decision-making will be at a advantage. It is reminiscent of when software usage and basic computer skills went from a “convenience” to an “mandatory.”

Before we start changing the world with Data analysis/Data Science; first things first, lets get a basic tool for analyzing data up and running. Let’s pretend Microsoft Excel never came your mind. R language is the tool I will focus on in this blog. It is both a programming language and platform for data science.

Install on non-Linux Platforms
This blog will focus only on Linux and the command line installation (I am a Microsoft guy fighting hard to get away from GUI-addiction.) If you like an alternative means, check out this URL, select a country in it and follow the instructions:
https://cran.r-project.org/mirrors.html

For example, for United States, an image from Berkeley, select: https://cran.cnr.berkeley.edu.

Installation on Ubuntu

  1. Open a command line
  2. Run command to update Linux (optional but recommended):
    sudo apt-get update
  3. Run command to install R Language:
    sudo apt-get install r-base

Running R Language
In command line, run this (its case sensitive):
R

Hello, World test
Here is a Hello, world test:

  1. To save a variable with a value, type:
    x <- "Hello, world"
  2. To print out the saved variable’s value, type:
    print(x)

To Close R Language Command Prompt
In command line, run this command (ts case sensitive):
q()o

Installing R Studio
The command line version is suitable for basic R language operations. However, for more real-world analysis, it would be better to use an IDE like R Studio

To begin installing R Studio, go to:
https://www.rstudio.com/products/rstudio/download/

Search for the word “Ubuntu” on the page above and make sure you select the appropriate version that matches the bit (32 or 64) of your machine. Clicking on this will download a file for installation. Double click on the downloaded file and the Ubuntu Software Center will come up (if not, bring it up.) Follow the instructions.

You should be ready to use it, if you followed the steps in the blog loyally. Have fun.

Posted in Uncategorized

ChicagoVeg’s restaurant application updated (January 23rd 2015)


ChicagoVeg is a non-profit organization in Chicago, whose goal is to promote veganism, vegetarians and raw veganism in Chicagoland. The organization has updated its restaurant application (http://www.chicagoveg.com/restaurants/). The primary goal of the update was to improve users’ mobile experience. Some changes made were:

– Fixed issue with map getting out of bounds on mobile and tablet
– Added warning message for users using IE 8 and lower (Google only supports IE 9 and above so the restaurant app is forced to too)
– Corrected issue in mobile where direction overflowed
– Added ability for users to post information about the site on social media
– Enlarged filtering options (e.g. Name | Distance in Restaurant list) to improve visibility and click-ability in mobile
– Fixed issue with mobile where address boxes was getting misaligned

Posted in Uncategorized

Reminder on how to Perform Basic Git operations on Github-code (using command lines)


This blog is a summary of a way of setting up an environment to use git and checking in code. It assumes you have used a form of source control. If you are a total newbie to programming, try this first – https://try.github.io/levels/1/challenges/1
This blog uses an application called restaurant listing application (https://github.com/ChicagoVeg/restaurantList) for demonstration purposes. Change references to this to suit your needs.

Pre-requisites

  1. Download git: http://git-scm.com/download
  2. Create a repository in github. Go to your github page and click on the Repository-button.

Steps Up Environment

        1. Create a directory on your local drive, where you want the code.
        2. Go to PowerShell or Command Prompt or some other command line application that supports git; and go to the directory from Step #1
        3. In the prompt, type in (to set up directory to be a local git repo):
          git init
        4. Get the code (you will find the URL in the github page, under “HTTPS clone URL”, on the right-hand-side):
          git remote add origin https://github.com/ChicagoVeg/restaurantList.git
        5. Create a master branch
          git checkout -t -b master origin/master
        6. Track changes
          git branch --set-upstream-to=origin/master

Notes

        • If you get an issue where a path name is too long, run this command:
          git config --system core.longpaths true
        • If you get an error where there is no tracking information (means you skipped this step above), run this:
          git branch --set-upstream master origin/master

Checking in Code

      1. Get the code onto your local repo. Reminder, git is about each user having their local repo (for your own changes) and everyone sharing a group-repo (cumulative code one or more people shared)
        git pull
      2. Tracking untracked files (Adding new files to your local repo)
        To untracked files (files not already in github) to the commit package, use this:
        git add .
        Note: This add all untracked files. If you want to add specific files, adjust ths. See this for more more information: https://www.kernel.org/pub/software/scm/git/docs/git-add.html.
      3. Here is a way of committing changes to your local repo:
        git commit -am "This is some comment Fixed #4"Note: (1)This will NOT check in the code to the main repository for others to use. It commits it to your local, which you can later check in for others to use. The push command does the check in and that will be discusses later. (2)This is unnecessary if you have no newly added files. (3)In “-am”, the ‘a’ stands adds all changes while the ‘m’ is for commenting. This is not appropriate if you do not want to add all recent changes to your local repository. Use a different option for commit as suites your needs. (4)The “#4” in the commit associated the check-in to an issue number. It can be left out the comment if you are not associating the commit to an issue. Although I advise to always associate check-ins to something.
      4. To submit code from your local repo to the shared repo, use this command:
        git push
        Note: This pulls from your local repository and pushed it to github.

A tutorial with less verbose than this can be found here: http://davidgiard.com/2016/01/30/MyCommonGitCommands.aspx

Posted in JavaScript

Reminder on how to get up and going with bower.js


This is a reminder of how to get up and running with Bower.js. It is intended for people have used it before but just need a quick refresher.

Installing Bower
Step 1: Download node.js (you may likely have it installed already)

Step 2: Install it (globally preferred, locally if you must)
npm install bower -g

Step 3: Create bower.json file using bower itself:
bower init

Step 4 (Optional): Change where bower is stored from bower_component to anything you want. For example, to use js/lib:

1st: creat file called: “.bowerrc”
2nd: The file above should have content like:


{
"directory": "js/lib"
}

The only thing you change is “js/lib” if that is not where you want to store your packages

Maintaining packages
Updating a package and update the bower config file(e.g. lodash)
bower install lodash --save

Uninstall a package
bower uninstall lodash

To get specific version
bower install lodash#2.2.1

check for available versions
bower info lodash

update all packages
bower update

Posted in Uncategorized

Here is a quick reminder on how to use LESS, one of the many CSS precompliers:

Variables: As they are in porgramming languages

@greenColor: #00FF00;
@font-family: Georgia

.makeItGreen {

background-color: @greenColor;
font-family: @font-family;
}

Mixin: For style sheet/rules reuse

@greenColor: #00FF00;
@font-family: Georgia

.makeItGreen {
background-color: @greenColor;
font-family: @font-family;
}
.greatGreenStyle {
.makeItGreen; // here is the reuse
}

Reusing rules from a different file

@import “element.less”

.makeItRound{
.round(1px);
}

Note: This has to be in the same location as the less file in question

Nesting

nav {
width: 200px;
height: 100px;
li {                                                      /* nested */
width: 100px;
background-color: green;
a {                                              /* second nested-level: nav li a */
color: lime;
}
}
}

Nesting with pseudo class

a {
font-family: Georgia;
&.hover {
color: green;
}
}

Note: & refers to the current rule
Arithmetic

@height: 200px

div {
height: @height * 2;
}

Note: Similar principle applies to other arithmetic operations

Posted in JavaScript

Getting up and Going with Grunt.js


Quickly Getting up with Grunt.js (may not be very helpful for newbies)
This post will quickly show you how to get up and going with Grunt.js from a command prompt. It uses the JSHINT contrib as an example. The tutorial goes quickly, so it may not be the best way to learn if you are completely new to Grunt.js . A PluralSight video may be more helpful. For others, it can serve a reference just in case you forgot how to set it up and do not need a 101-tutorial.

It does NOT show you how to use it in Visual Studio. A post on that is forthcoming.

Why use Grunt.js?
Grunt.js is used to automate the running of task running; on node.js. Examples of task could be- Validate HTML, run JSHINT on JavaScript, compile LESS to CSS, compile TypeScript to JavaScript and many others task. It takes away the gruntwork of cutting and pasting a JavaScript file in jshint.com, linting in it, and then cutting and pasting it back into your solution.

How do I Get Started
Step 1: Go to node.js and install node.js. Note, it may already be installed for you if you are using Linux

Step 2: Open up a command prompt

Step 3: Install Grunt CLI globally via this command:
npm install -g grunt-cli

Step 4: In the folder where you want to run grunt, create a file name package.json and have this configuration (customize it to your needs)

{
"name": "AnAwesomeProject",
"description": "Some Awesome Project",
"version": "0.1.0-alpha",
"license": "MIT",
"author": "Kermit the Frog",
"contributors": [
{
"name": "Kermit the Frog",
"email": "fakeEmail@fakeEmail.com"
},
{
"name": "Michael Jackson",
"email": "ms@mjj5550.mjj"
}
],
"devDependencies": {
}
}

Step 5: Create a file called gruntfile.js and have this in it (customize to your liking):

'use strict';

module.exports = function(grunt) {
grunt.initConfig({
pkg: grun.file.readJSON(‘package.json’)
});

grunt.loadNpmTaks(”);
}

Step 6: install grunt itself locally with this command:
npm install grunt --save-dev

Step 7: At this point, you are ready to have task to run. Let’s start with a simple one. Run this command (note, -save-dev will update the package.json file for you):
npm install grunt-contrib-jshint --save-dev

Step 8: Update the gruntfile.js to be something like this:
'use strict';

module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON(‘package.json’),
jshint: {
options: {
},
files: [‘./Scripts/ *.js’]
}

});

grunt.loadNpmTasks(‘grunt-contrib-jshint’);

grunt.registerTask(‘default’, [‘jshint’]);
}

Step 9: Open the command prompt and this:
grunt

Step 10: Observe the message in the commmand prompt

Additional options for the package.json file can be found here: http://browsenpm.org/package.json
Additional node packages can be found at: http://gruntjs.com/plugins

A tutorial can be found at: http://gruntjs.com/ and PluralSight has a video on the topic.