Skip to content

Instantly share code, notes, and snippets.

View lasso1.r
library(lars) #load lars library
# load data from csv file
fullData <- read.csv('/Users/adityanisal/Dropbox/ExtractedResultFiles/CSV/fireplace-mv1.csv')
# display data
fullData
# remove "null" columns (columns with all 0s)
M <- fullData[,colSums(fullData^2) !=0]
M
# Take all columns (features) except the last solutionVector
x <- M[,c(1:8)]
@adini121
adini121 / explore-correlations.r
Created Feb 18, 2016 — forked from stephenturner/explore-correlations.r
Exploring correlations with R using cor.prob and chart.Correlation
View explore-correlations.r
## Correlation matrix with p-values. See http://goo.gl/nahmV for documentation of this function
cor.prob <- function (X, dfr = nrow(X) - 2) {
R <- cor(X, use="pairwise.complete.obs")
above <- row(R) < col(R)
r2 <- R[above]^2
Fstat <- r2 * dfr/(1 - r2)
R[above] <- 1 - pf(Fstat, 1, dfr)
R[row(R) == col(R)] <- NA
R
}
@adini121
adini121 / Useful_mysql_commands.md
Last active Feb 3, 2016
Useful mysql commands
View Useful_mysql_commands.md

##(My)sql commands I encountered throughout my sql-experience

####Basics #####Create database and tables

DROP DATABASE IF EXISTS database_name;

CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@adini121
adini121 / expecting.md
Created Oct 31, 2015 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts
View expecting.md

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@adini121
adini121 / apache_httpd_install.md
Last active Oct 4, 2021
Install Apache server without root privileges : The definitive guide (Linux/Unix only)
View apache_httpd_install.md

A definitive guide for installing Apache-httpd server without root privileges | Only for unix-like systems

During the work of my thesis I had to run php based applications on a linux server where I had no root privileges. Hence I dug up on the web and I present to you

a way to install apache httpd at any desired location.

./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache 
--enable-deflate --enable-expires --enable-headers --enable-usertrack 
--enable-cgi --enable-rewrite --enable-so --enable-vhost-alias  
--with-apr=/home/nisal/apache/httpd-2.4.17/srclib/apr-1.5.2/ --with-apr-util=/home/nisal/apache/httpd-2.4.17/srclib/apr-util-1.5.4/ 
--prefix=/home/nisal/apache/httpd-2.4.17/ 
@adini121
adini121 / Useful_bash_commands.md
Last active Jul 6, 2016
Commands for CLI and bash scripting
View Useful_bash_commands.md

Cleanup after jenkins

	rm -rf $(ls -la | grep -E 'nisal.*slave*' | awk '{print $9}')
	rm -rf $(ls -la | grep -E 'nisal.tmp' | awk '{print $9}')
	rm -rf $(ls -la | grep -E '*nisal*.*._.*' | awk '{print $9}')
	rm -rf $(ls -la | grep -E '*nisal*.*tool*' | awk '{print $9}')
	
	kill $(ps aux | grep -E 'nisal.*java -jar /tmp*' | awk '{print $2}')
	kill $(ps aux | grep -E 'nisal.*slave*' | awk '{print $2}')
	kill $(ps aux | grep -E '/usr/lib/jvm/java.*TomcatInstance*' | awk '{print $2}')
@adini121
adini121 / Useful_git_commands.md
Last active Jan 28, 2016
Useful git commands I encountered throughout my experience with Git
View Useful_git_commands.md

##Git commands I encountered throughout my git-experience

####Best Git practices

  1. Always review what's in the staging area before commiting to make sure you would only add/commit whats intended to be committed -> Saves you from pushing undesired objects to remote.
git status | git diff --cached
  1. Always fetch from remote before working in order to avoid (future) conflicts ####Regular git workflow for creating/adding/committing/pushing new files to (remote) repository
@adini121
adini121 / git_repo_creation.sh
Last active Oct 3, 2015
Create a new repository locally AND add remote too (e.g. create a remote repository at github from local one)
View git_repo_creation.sh
#! /bin/bash
# Description
# Author: Adi
# ChangeLog:
# Date: 29.08.15
repo=$1
git init
@adini121
adini121 / tmux_local_static_install.sh
Last active Oct 13, 2015 — forked from haridsv/tmux_local_static_install.sh
Bash script for installing tmux without root privileges. Simply download, give exec permissions and run.
View tmux_local_static_install.sh
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.0
@adini121
adini121 / gist:ad11c65d03bc5d2370d6
Created Sep 22, 2015 — forked from tonymtz/gist:714e73ccb79e21c4fc9c
Uninstall XQuartz.app from OSX Yosemite
View gist:ad11c65d03bc5d2370d6
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in