Skip to content

Instantly share code, notes, and snippets.

$.ajax({
url:"/score/ajax/add_score",
type:"POST",
data:JSON.stringify(params),
contentType: "application/json",
success: function(result) {
if (result) {
alert("저장되었습니다.");
} else {
alert("잠시 후에 시도해주세요.");
$.ajax({
url:"/score/ajax/research",
type:"POST",
success: function(result) {
if (result) {
} else {
alert("불러오기 실패");
}
}
// 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()
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()
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()
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|
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:
#-*-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):
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:
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