Skip to content

Instantly share code, notes, and snippets.

View randyzwitch's full-sized avatar

Randy Zwitch randyzwitch

View GitHub Profile
@randyzwitch
randyzwitch / search-tweets.jl
Created December 8, 2014 01:42
#Julialang tweets - Twitter.jl
julia_tweets = get_search_tweets("#julialang")
@randyzwitch
randyzwitch / hello-world.jl
Created December 8, 2014 01:26
Hello, World - Twitter.jl
post_status_update("Hello, World!")
@randyzwitch
randyzwitch / twitter-julia-authentication.jl
Last active August 29, 2015 14:10
Twitter.jl Authentication
using Twitter
apikey = "q8Qw7WJTVP..."
apisecret = "FIichPpGJxiOssN..."
accesstoken = "98689850-v0zZNr..."
accesstokensecret = "w7bDg9K0c493T..."
twitterauth(apikey,
apisecret,
accesstoken,
REQUEST:
{
"reportDescription":{
"dateFrom":"2013-01-01",
"dateTo":"2013-11-16",
"reportSuiteID":"",
"segment_id":"53c059aee4b07cd3c4332163",
"metrics":[
{
"id":"bouncerate"
@randyzwitch
randyzwitch / macros-twitter.jl
Created November 23, 2014 04:00
Update: Macros in Julia for code refactoring
macro endpoint(name, path)
quote
function $(esc(name))(; options=Dict{String, String}())
r = get_oauth($"https://api.twitter.com/1.1/$path", options)
return r.status == 200 ? JSON.parse(r.data) : r
end
end
end
@endpoint get_help_configuration "help/configuration.json"
@randyzwitch
randyzwitch / meta-twitter.jl
Last active August 29, 2015 14:09
Metaprogramming in Julia
funcname = (:get_help_configuration, :get_help_languages, :get_help_privacy, :get_help_tos, :get_application_rate_limit_status)
endpoint = ("help/configuration.json", "help/languages.json", "help/privacy.json", "help/tos.json", "application/rate_limit_status.json")
for (func, endp) in zip(funcname, endpoint)
@eval function ($func)(; options=Dict{String, String}())
r = get_oauth($"https://api.twitter.com/1.1/$endp", options)
return r.status == 200 ? JSON.parse(r.data) : r
@randyzwitch
randyzwitch / redundant-twitter.jl
Created November 17, 2014 20:11
Redundant Julia code
#############################################################
#
# Help section Functions for Twitter API
#
#############################################################
function get_help_configuration(; options=Dict{String, String}())
r = get_oauth("https://api.twitter.com/1.1/help/configuration.json", options)
@randyzwitch
randyzwitch / aa-ggplot2.R
Created November 7, 2014 02:08
Adobe Analytics Anomaly Detection ggplot
#Plot data using ggplot2
library(ggplot2)
#Calculate points crossing UCL or LCL
pageviews_w_forecast$outliers <-
ifelse(pageviews_w_forecast$pageviews > pageviews_w_forecast$upperBound.pageviews, pageviews_w_forecast$pageviews,
ifelse(pageviews_w_forecast$pageviews < pageviews_w_forecast$lowerBound.pageviews, pageviews_w_forecast$pageviews, NA))
#Add LCL and UCL labels
LCL <- vector(mode = "character", nrow(pageviews_w_forecast))
@randyzwitch
randyzwitch / breakout-5.R
Created November 6, 2014 22:17
BreakoutDetection - Min Size change
res <- breakout(formatted_df, min.size=5, method='multi', beta=.001, degree=1, plot=TRUE)
res$plot
@randyzwitch
randyzwitch / breakoutdetection-default.R
Created November 6, 2014 21:30
BreakoutDetection - Default example
res <- breakout(formatted_df, min.size=24, method='multi', beta=.001, degree=1, plot=TRUE)
res$plot