This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.ajax({ | |
| url:"/score/ajax/add_score", | |
| type:"POST", | |
| data:JSON.stringify(params), | |
| contentType: "application/json", | |
| success: function(result) { | |
| if (result) { | |
| alert("저장되었습니다."); | |
| } else { | |
| alert("잠시 후에 시도해주세요."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.ajax({ | |
| url:"/score/ajax/research", | |
| type:"POST", | |
| success: function(result) { | |
| if (result) { | |
| } else { | |
| alert("불러오기 실패"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/databricks/learning-spark/blob/master/files/testweet.json | |
| val tweets = sqlContext.jsonFile("/home/lee/learning-spark/learning-spark/files/testweet.json") | |
| // verify schema | |
| tweets.printSchema() | |
| tweets.schema | |
| // show table | |
| tweets.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json, os | |
| import Proto import Tweet_pb2 as LogDataProto | |
| import protobuf_to_dict import protobuf_to_dict | |
| filename="tweet.log" # proto type | |
| # read protobuf file | |
| f = open(filename, "r") | |
| try: | |
| logfile = LogDataProto.LogDataFile() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.spark.sql.Row | |
| // Seq[org.apache.spark.sql.Row] | |
| data = logData.getSeq[Row](logData.fieldIndex("object")); | |
| val rdd = sc.parallelize(data) | |
| val df = sqlContext.createDataFrame(rdd, data.apply(0).schema) | |
| df.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.spark.sql.functions._ | |
| // DataFrame Column | timestamp_milli | | |
| scala> df.select(col("timestamp_milli")).show() | |
| +---------------+ │starbucks@cluster05:~$ | |
| |timestamp_milli| │starbucks@cluster05:~$ ls | |
| +---------------+ │data Desktop download elephant-bird learning-spark Music projects ScalaPB spark-protobuf Videos | |
| | 1468335081249| │derby.log Documents Downloads hadoop-2.6.3 metastore_db Pictures Public spark-1.6.1-bin-hadoop2.6 Templates | |
| | 1468335081249| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from GooglePlayStore import GooglePlayStore | |
| import CSVFileIO | |
| f = open("/home/banana/package_name.csv") | |
| lines = f.read().split("\n") | |
| results = [] | |
| gps = GooglePlayStore() | |
| for package_name in lines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #-*-encode:utf8-*- | |
| from bs4 import BeautifulSoup | |
| import requests | |
| class GooglePlayStore: | |
| GOOGLE_PLAY_STORE_URL = 'https://play.google.com/store/apps/details?id=' | |
| def __init__(self): | |
| print 'play google stroe' | |
| def get_package_info(self, package_name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import os | |
| def get_csv_writer(filename, rows, delimiter): | |
| with open(filename, 'w') as csvfile: | |
| fieldnames = rows[0].keys() | |
| writer = csv.DictWriter(csvfile, fieldnames=fieldnames, delimiter=delimiter) | |
| writer.writeheader() | |
| for row in rows: | |
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import os | |
| class SingletonType(type): | |
| def __call__(cls, *args, **kwargs): | |
| try: | |
| return cls.__instance | |
| except AttributeError: | |
| cls.__instance = super(SingletonType, cls).__call__(*args, **kwargs) | |
| return cls.__instance |