# .R script showing capabilities of sparklyr R package
# Prerequisites before running this R script: 
# Ubuntu 16.04.3 LTS 64-bit, r-base (version 3.4.1 or newer), 
# RStudio 64-bit version, libssl-dev, libcurl4-openssl-dev, libxml2-dev
# New features in sparklyr 0.6:
# https://blog.rstudio.com/2017/07/31/sparklyr-0-6/
# sparklyr cheat sheet: https://github.com/rstudio/cheatsheets/raw/master/source/pdfs/sparklyr.pdf
# dplyr+tidyr: https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf
# sparklyr currently (2017-08-19) only supports Apache Spark version 2.2.0 or older
# Install Spark locally:
sc_version <- "2.2.0"
config <- spark_config()
# number of CPU cores to use:
config$spark.executor.cores <- 6
# amount of RAM to use for Apache Spark executors:
config$spark.executor.memory <- "4G"
# Connect to local version:
sc <- spark_connect (master = "local",
 config = config, version = sc_version)
# Copy data to Spark memory:
import_iris <- sdf_copy_to(sc, iris, "spark_iris", overwrite = TRUE) 
# partition data:
partition_iris <- sdf_partition(import_iris,training=0.5, testing=0.5) 
# Create a hive metadata for each partition:
# Create reference to training data in Spark table
tidy_iris <- tbl(sc,"spark_iris_training") %>% select(Species, Petal_Length, Petal_Width) 
# Spark ML Decision Tree Model
model_iris <- tidy_iris %>% ml_decision_tree(response="Species", features=c("Petal_Length","Petal_Width")) 
# Create reference to test data in Spark table
test_iris <- tbl(sc,"spark_iris_test") 
# Bring predictions data back into R memory for plotting:
pred_iris <- sdf_predict(model_iris, test_iris) %>% collect
pred_iris %>%
 lab=model_iris$model.parameters$labels)) %>%
 ggplot(aes(Petal_Length, Petal_Width, col=lab)) +
sudo apt update
sudo apt install cmake build-essential
sudo apt install checkinstall git
sudo apt remove hashcat
sudo apt build-dep hashcat
sudo rm -rf hashcat/
git clone https://github.com/hashcat/hashcat.git
cd hashcat
git submodule update --init
sudo make
sudo checkinstall
hashcat --version
# hashcat version should be v3.5.0 or newer
# install all dependencies for gifine:
sudo apt update
sudo apt install ffmpeg graphicsmagick gifsicle luarocks
sudo apt install cmake libgirepository1.0-dev build-essential git
sudo apt install libxext-dev checkinstall libimlib2-dev
sudo apt install libimlib2 mesa-common-dev libxrender-dev
sudo apt install libxrandr-dev libglew-dev libglm-dev libglu1-mesa-dev
sudo apt build-dep graphicsmagick
git clone https://github.com/naelstrof/slop.git
cd slop
sudo make
sudo make install
# install gifine:
sudo luarocks install --server=http://luarocks.org/dev gifine
# test with this command: gifine


# linapple (Apple IIe emulator)
sudo apt-get update
sudo apt-get install git unp build-essential checkinstall libopenal-dev 
sudo apt-get install freeglut3-dev gawk libsdl1.2-dev libcurl4-openssl-dev zlib1g-dev libzip-dev
sudo rm -rf apple2
sudo rm -rf linapple
git clone https://github.com/LasDesu/linapple.git
mkdir ~/linapple/disks
cd ~/linapple/src
sudo make
cd ~/linapple
# Get ProDOS User Guide
wget --no-check-certificate  http://www.applelogic.org/files/PRODOSUM.pdf
# Get Apple IIe ROM
wget --no-check-certificate  ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images/apple_iie_rom.zip
wget --no-check-certificate  ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images/077-0018%20Apple%20IIe%20Diagnostic%20Card%20-%20English%20-%20Lower%20ROM%202764.bin
wget --no-check-certificate  ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images/077-0019%20Apple%20IIe%20Diagnostic%20Card%20-%20English%20-%20Upper%20ROM%202764.bin
wget --no-check-certificate  ftp://ftp.apple.asimov.net/pub/apple_II/emulators/rom_images/2764_APPLE-IIe-0341-0162-A_PAL_SWE_FIN.bin
# get newest ProDOS 2.4.1 operating system for Apple IIe (release date: September 2016!)
wget --no-check-certificate https://archive.org/download/ProDOS_2_4_1/ProDOS_2_4_1.dsk
# get Apple II games
wget --no-check-certificate  http://www.virtualapple.org/apple2/Breakout_Chipout_Hi-Res_Breakout.zip
wget --no-check-certificate  http://www.virtualapple.org/apple2/Galaxian.zip
wget --no-check-certificate  http://www.virtualapple.org/apple2/SantaParaviaandFiumaccio.zip
wget --no-check-certificate  http://www.virtualapple.org/apple2/Karateka.zip
unp *.zip
mv *.dsk ~/linapple/disks/
# Press F3 in linapple and navigate to ~/linapple/disks and select the game to load
# Then press CTRL-SHIFT-F2 to restart the linapple emulator and load the game
# how to compile and install newest version of 
# proftpd 
# in Ubuntu 16.04 LTS 64-bit:
sudo apt-get update
sudo apt-get install checkinstall build-essential
sudo apt-get build-dep proftpd-dfsg proftpd-basic 
sudo apt-get purge proftpd-basic
sudo rm -rf proftpd
git clone https://github.com/proftpd/proftpd
cd proftpd
sudo ./configure
sudo make clean
sudo make
sudo checkinstall
# type 3 and hit  to enter 1.3.5b as the software version
apt-cache show proftpd
# Terminal output of 'apt-cache show proftpd' should be similar to this:
# Package: proftpd
# Status: install ok installed
# Priority: extra
# Section: checkinstall
# Installed-Size: 8492
# Maintainer: root
# Architecture: amd64
# Version: 1.3.5b-1
# Provides: proftpd
# Description: Package created with checkinstall 1.6.2
# Description-md5: 556b8d22567101c7733f37ce6557412e
# how to compile and install newest version of 
# picocom (Minimal dumb-terminal emulation program) 
# in Ubuntu 16.04 LTS 64-bit:
sudo apt-get update
sudo apt-get install checkinstall build-essential
sudo apt-get build-dep picocom
sudo apt-get purge picocom
sudo rm -rf picocom
git clone https://github.com/npat-efault/picocom
cd picocom
sudo make clean
sudo make
sudo cp picocom /usr/bin
picocom --help |head -n 2
# the previous command should show picocom version 2.3a or higher
# How to fix SSL "certificate verify failed" error making it impossible to pull data from 'https://rubygems.org/ in Ubuntu 16.04 LTS 64-bit# 
# This bash script will make it possible to use the "sudo gem install <package>" command
# For example: sudo gem install tenancy   will work after running this script
sudo apt-get update
sudo apt-get install ruby
sudo update-ca-certificates
sudo gem sources -r https://rubygems.org/
sudo gem sources -a http://rubygems.org/
sudo gem update --system
sudo gem sources -r http://rubygems.org/
sudo gem sources -a https://rubygems.org/
sudo gem install tenancy