Skip to content

Language

gabx edited this page Dec 12, 2016 · 11 revisions

Language

Node.js

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

  • install node.js package and its package manager, npm package

Configuration

Package manager

Node.js packages are managed by npm.

Installation

  • Systemwide Package are installed with the following command # npm -g install packageName . Packages will thus be installed in the /usr/lib/node_modules/npm directory.

  • User mode In user mode, npm installs by default the package in the current directory under node_modules and executables under node_modules/.bin. We will store all packages in the same place using the environment variable npm_config_prefix. Add these line in:

/etc/profile.d/custom-profile.sh
-------------------------------
export npm_config_prefix=/${CODE}/nodejs/modules/npm
export PATH=${PATH}:${CODE}/nodejs/modules/npm/bin

To install package locally, run $ npm install packageName

Upgrade

# npm update -g packageName
  • update all
# npm update -g

Go

Install go package. Then, we need to export the $GOPATH environment variable for code. This will be the storage/development/language/go directory. Edit the etc/profile.d/custom-profile.sh.

Run go env to check.

Ruby

Package manager

  • upgrade all
$ gem update
# gem update --system

By default, when running gem, gems are installed per-user (into ~/.gem/ruby/), instead of system-wide (into /usr/lib/ruby/gems/). This is considered the best way to manage gems, because otherwise they might interfere with gems installed by dnf.

To initialize your environment, run the following commands:

$ gem install bundler
$ bundle init
Writing new Gemfile to ~/Gemfile

By default, Bundler installs gems system-wide, which is contrary to the behaviour of gem itself. To correct this, a line has been added in /etc/profile.d/custom-profile.sh:

export GEM_HOME=$(ruby -e 'print Gem.user_dir')

List your environment variables (below example is for user gitlab):

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.6
  - RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-linux]
  - INSTALLATION DIRECTORY: /storage/gitlab/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /storage/gitlab/bin
  - SPEC CACHE DIRECTORY: /storage/gitlab/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /storage/gitlab/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /bin
     - /usr/bin
     - /usr/local/sbin
     - /usr/sbin

For more gem commands, please run:

$ gem help command

Perl

If no other indication is given, Perl system modules will be installed in /usr/local/bin.

Python

R

R package has been built with intel MKL and compiler. As there is no such built package for Fedora, one R-intel is build from a .spec file. See the build section of the .spec file for options.

configuration

There is no system wide Rprofile.site. R system library is in the default /usr/lib64/R/library folder. All user specific variables and settings are stored in the two files: ~/.config/r/Renviron and ~/.config/r/Rprofile.r.

~/.config/r/Renviron
------------------------
R_HOME_USER=/storage/development/language/r
R_LIBS_USER=${R_HOME_USER}/library
R_LIBS=${R_LIBS_USER}:${R_HOME}/library
R_HISTFILE=${R_HOME_USER}/R.Rhistory
R_HELPER=$HOME/.config/r/helper
R_HISTSIZE=5000
XDG_HOME_CONFIG=$HOME/.config
~/.config/r/Rprofile.R
-------------------------
require(utils, quietly = TRUE)

#------------ Customize prompt --------------
if(interactive()){
        options(prompt=paste(paste (Sys.info () [c ("user", "nodename")], collapse="@"),"[R] "))
}

#------------ Helpers ----------
#' TODO : best approach is to build a package
#' helper directory is defined in Renviron
#' http://stackoverflow.com/questions/26118622/r-user-defined-functions-in-new-environment
#' http://stackoverflow.com/questions/1266279/how-to-organize-large-r-programs
#' Each helper function is an element of .helperEnv
# .helperEnv <- new.env(parent = baseenv())


.helperEnv <- attach(NULL, name = 'helperEnv')


#------------ First function--------------
.First <- function() {
        if(interactive()){
                cat("Welcome back", Sys.getenv("USER"),"\nworking directory is:", getwd(),'\n')
        }
        sapply(list.files(file.path(path.expand(Sys.getenv('R_HOME_USER')),
                                    'helper'),full.names = T), source, .helperEnv)
}

#------------ Last function--------------
.Last <- function(){

        if(interactive()) try(savehistory("/home/poisonivy/.config/r/R.Rhistory"))
        file.append("/home/poisonivy/.config/r/R.Rhistory_old","/home/poisonivy/.config/r/R.Rhistory")
        file.rename("/home/poisonivy/.config/r/R.Rhistory_old","/home/poisonivy/.config/r/R.Rhistory")
        cat('Goodbye', Sys.info()["user"], date(),'\n')
        # write current environment to a file

}

#------------ Options ----------------------
## > utils::str(options()) : list options||style: name=value##
# Setting 'scipen=10' effectively forces R to never use scientific notation to express very small or large numbers
options(
        digits = 12,
        scipen = 10,
        show.signif.stars = FALSE,
        stringsAsFactors = FALSE,
        # error = quote(dump.frames("${R_HOME_USER}/testdump", TRUE)),
        repos=list(CRAN="http://mran.revolutionanalytics.com"),
#       defaultPackages = c('datasets','utils','grDevices','graphics','stats','methods','pryr','data.table','readr'),
        browserNLdisabled = TRUE,
        deparse.max.lines = 2,
        editor = 'vim',
        pager = 'vimrpager'
)


# ----------- Session info ---------
# retrive user info
.thisUser <- paste(c(Sys.info()["user"], '@', Sys.info()["nodename"]), collapse="")
.thisMachine <- paste(Sys.info()[c ("sysname", "machine", 'release')],
                      collapse=".")
.thisR <- sessionInfo()[[1]]$version.string


# ----------- Load silently packages in interactive sessions -------
#suppressWarnings(suppressPackageStartupMessages(
#    library(dplyr)))  
suppressWarnings(suppressPackageStartupMessages(
    library(ggplot2)))
suppressWarnings(suppressPackageStartupMessages(
    library(devtools)))
suppressWarnings(suppressPackageStartupMessages(
    library(setwidth)))
suppressWarnings(suppressPackageStartupMessages(
    library(data.table)))
suppressWarnings(suppressPackageStartupMessages(
    library(slackr)))
suppressWarnings(suppressPackageStartupMessages(
    library(tidyr)))
# ----------- Last ---------------------
message("\n*** Successfully loaded .Rprofile ***\n")

littler

littler provides a simplified command line to R. This allows direct execution of commands.

install littler

install littler using the R cran package:

R> install.packages('littler')

configure

The binary r has been installed in $R_LIBS_USER/littler/bin. Create symbolic link to /usr/local/bin/r and alias in zsh cconfig as r is a built-in command in zsh.

run

Example of small script to upgrade R packages outside any R session:

#!/usr/bin/env r
#
# a simple example to update packages
# parameters are easily adjustable

repos <- "http://cran.us.r-project.org"

lib.loc <- "/storage/development/language/r/library"

update.packages(repos=repos, ask=FALSE, lib.loc=lib.loc)

Performance tuning

https://www.r-bloggers.com/r-benchmark-for-high-performance-analytics-and-computing-i/

PHP

Dependency manager for PHP

# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer
  • composer update This command will update dependencies set in the composer.json file
$ su
# composer update

Ressources

R: From Json to table

R and MongoDb

Clone this wiki locally