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.SparkSession | |
object SparkWordCount extends App { | |
val spark = SparkSession.builder | |
.master("local[*]") | |
.appName("Spark Word Count") | |
.getOrCreate() | |
val lines = spark.sparkContext.parallelize( |
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
name := "SparkScalaTest" | |
version := "1.0" | |
scalaVersion := "2.11.12" | |
libraryDependencies ++= Seq( | |
"org.apache.spark" %% "spark-core" % "2.3.2", | |
"org.apache.spark" %% "spark-sql" % "2.3.2" | |
) |
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
db.allPosts.aggregate([ | |
{$group: {_id: "$user.id", tags: {$addToSet: "$tags"}}}, | |
{$unwind: "$tags"}, | |
{$unwind: "$tags"}, | |
{$group: {_id: "$_id", tags: {$addToSet: "$tags"}}}, | |
{$out: "tags"} | |
]) |
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 requests import get, Session, adapters | |
def getInstaPosts(latitude, longitude, distance, minTimestamp, maxTimestamp, count): | |
params = { | |
'lat': latitude, | |
'lng': longitude, | |
'distance': distance, # radius of requested area | |
'min_timestamp': str(minTimestamp), #start date | |
'max_timestamp': str(maxTimestamp), #end date | |
'count': COUNT, # number of posts(100 max) |
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
db.allPosts.aggregate([ | |
{$group: {_id: "$user.id"}}, | |
{$out: "users"} | |
]); |
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
def getFollowers(userId, nextCursor): | |
params = { | |
'cursor': nextCursor, | |
'access_token': INSTAGRAM_ACCESS_TOKEN | |
} | |
session = Session() | |
session.mount("https://", adapters.HTTPAdapter(max_retries=50)) | |
response = session.get("https://api.instagram.com/v1/users/" + userId + "/followed-by", params = params, verify = True) | |
OlderNewer