##(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;
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)] |
## 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 | |
} |
##(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;
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.
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
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/
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}')
##Git commands I encountered throughout my git-experience
####Best Git practices
git status | git diff --cached
#! /bin/bash | |
# Description | |
# Author: Adi | |
# ChangeLog: | |
# Date: 29.08.15 | |
repo=$1 | |
git init |
#!/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 |
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 |