Skip to content

Instantly share code, notes, and snippets.

View walteryu's full-sized avatar

walteryu walteryu

View GitHub Profile
@walteryu
walteryu / random-user.js
Created March 23, 2016 07:05
DWA-15, P3: jQuery Form Validation Script
// jQuery script for validating user input
$(document).ready(function () {
$('#random-user').append("Form submitted successfully!");
$('#random-user').validate({
// initialize jquery validation plugin
rules: {
count: {
required: true
},
@walteryu
walteryu / hw3_p3.sh
Last active October 8, 2018 15:22
hw3_p3.sh
#!/bin/bash
# Download MySQL connector, store in working folder then unpack for use:
tar zxvf mysql-connector-java-5.1.31.tar.gz
# Call PySpark with MySQL connector:
pyspark --driver-class-path mysql-connector-java-5.1.47-bin.jar
@walteryu
walteryu / hw3_p3.py
Last active October 8, 2018 15:21
hw3_p3.py
# CSCI E-63 HW3 - Problem 3
# Author: Walter Yu
# Description: PySpark script to connect to MySQL database, register table and display row count.
# Create context and connect to MySQL:
sqlContext= SQLContext(sc)
dfm = sqlc.read.format("jdbc").option("url","jdbc:mysql://localhost/retail_db").option("driver","com.mysql.jdbc.Driver").option("dbtable","departments").option("user","xxxxx").option("password","xxxxx").load()
# Verify schema, create view and display row count:
dfm.printSchema()
@walteryu
walteryu / hw3_py2.py
Last active September 29, 2018 03:54
hw3_p2.py
'''
Author: Walter Yu
Course: CSCI E-63, Fall 2018
Assignment: HW3, Problem 2
References:
Slide 46 & 47, Lecture 3 Notes
SparkContext Tutorial:https://www.tutorialspoint.com/pyspark/pyspark_sparkcontext.htm
'''
from pyspark import SparkContext, SparkConf
from pyspark.sql import SQLContext, Row, SparkSession
@walteryu
walteryu / hw4_p1.sh
Created October 8, 2018 15:20
hw4_p1.sh
#!/bin/bash
# CSCI E63 HW4 - Walter Yu, Fall 2018
# Script commands to complete HW4
# P1 - Compress data file for trasnfer into VM:
tar -zcvf retail-data.tar.gz ../e63-hw4-data-oreilly/data/retail-data
# P1 - Extract data file within VM:
tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
@walteryu
walteryu / hw5.sql
Last active October 9, 2018 17:55
hw5.sql
/*
CSCI E63 HW5 - Walter Yu, Fall 2018
Script commands to complete HW5
*/
-- Q1: Create tables:
create table stations(
stations_id int(11) ,
name varchar(64) ,
latitude decimal(11) ,
@walteryu
walteryu / hw5_p1.sh
Created October 8, 2018 19:07
hw5_p1.sh
#!/bin/bash
# CSCI E63 HW5 - Walter Yu, Fall 2018
# Script commands to complete HW5
# P1 - Compress data file for trasnfer into VM:
tar -zcvf retail-data.tar.gz ../e63-hw4-data-oreilly/data/retail-data
# P1 - Extract data file within VM:
tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
@walteryu
walteryu / network-count.py
Created October 22, 2018 16:17
HW7 Script
from pyspark.sql import SparkSession
from pyspark.sql.functions import explode
from pyspark.sql.functions import split
spark = SparkSession.builder.appName("StructuredNetworkWordCount").getOrCreate()
lines = spark.readStream.format("socket").option("host", "localhost") \
.option("port", 9999).load()
# Split the lines into words