Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
@IronistM
IronistM / 0_reuse_code.js
Created November 10, 2013 22:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
LOAD
if(age<16, 'Under 16',
if(age>65, 'Over 65',
text(16+(Div(age-16,10)*10)) & ' - ' & text(25+(Div(age-16,10)*10)))) as age_group
// in this case we want to load a 10% sampling set of the data
data:
LOAD ….<your fields>…
FROM <your QVD file>
WHERE ceil(rand() * 100) <= 10; // or: rand() <= 0.1
// SAMPLE n LOAD is much faster but allocates the memory of the full data set during the LOAD
// Where rand() <= n allocates only the memory of the smaller result set which could be crucial with Big Data..
#Plot data using ggplot2
library(ggplot2)
#Combine year/month/day together into POSIX
pageviews_w_forecast$date <- ISOdate(pageviews_w_forecast$year, pageviews_w_forecast$month, pageviews_w_forecast$day)
#Convert columns to numeric
pageviews_w_forecast$pageviews <- as.numeric(pageviews_w_forecast$pageviews)
pageviews_w_forecast$pageviews_upper <- as.numeric(pageviews_w_forecast$pageviews_upper)
pageviews_w_forecast$pageviews_lower <- as.numeric(pageviews_w_forecast$pageviews_lower)
ip2Int <- function(ip){
split <- as.numeric(strsplit(ip, "\\.")[[1]])
out <- (split[1] * 256^3) + (split[2] * 256^2) + (split[3] * 256) + (split[4])
return(out)
}
int2Ip <- function(int){
split <- NULL
split[1] <- as.integer(int/256^3)
var https = require('https'),
key = 'key',
url = 'http://www.igvita.com/',
strategy = 'desktop';
https.get({
host: 'www.googleapis.com',
path: '/pagespeedonline/v1/runPagespeed?url=' + encodeURIComponent(url) +
'&key='+key+'&strategy='+strategy
}, function(res) {
###############################################
##
## Attempt no 2 at building a shiny web app
## for AB Testing use - using global.R
##
## global.R - loading and defining variables for the global environment
##
###############################################
# Pallette used in some charts as a general indicator color for better or worse that the control group