Skip to content

Instantly share code, notes, and snippets.

@svenhofstede-zz
svenhofstede-zz / inlet.js
Last active August 29, 2015 14:11
Hover_over_coloring_grid
var canvas = d3.select("svg");
var width = 500;
var height = 500;
var amount = 10;
var data = [];
var intervalW = width/amount;
var intervalH = height/amount;
for (i=0;i<amount;i++){
@svenhofstede-zz
svenhofstede-zz / inlet.js
Last active August 29, 2015 14:11
Hover_grid_color_bg
var canvas = d3.select("svg");
var width = 500;
var height = 500;
var amount = 12;
var data = [];
var intervalW = width/amount;
var intervalH = height/amount;
for (i=0;i<amount;i++){
@svenhofstede-zz
svenhofstede-zz / inlet.js
Last active August 29, 2015 14:11
Random_circle_example
var svg = d3.select("svg")
var circle = svg.append("circle")
circle.attr("cx",500)
.attr("cy",300)
.attr("r",87)
.attr("fill","#ff6575")
.attr("stroke","#606060")
.attr("stroke-width",35)
@svenhofstede-zz
svenhofstede-zz / inlet.js
Last active August 29, 2015 14:11
Block_drop_down_stacking
//Click on a column to drop down a block. Stack by dropping down multiple blocks in the same column.
//You can change the width, height and the amount of columns below.
var width = 500;
var height = 500;
var amount = 10;
var data = [];
@svenhofstede-zz
svenhofstede-zz / r_code_snippets
Last active August 29, 2015 14:19
R_code_snippets
# Read csv file
dfName = read.csv("file.csv")
# READ CSV FILE WITH DATATYPE DEFINED FOR A CERTAIN COLUMN s
dfName <- read.csv("file.csv",colClasses=c("date"="Date"))
# WRITE CSV FILE
write.csv(dfName, file="file.csv")
for (i in 1:nrow(air)){
distance <- 999
lat_air <- air[i,"Latitude"]
long_air <- air[i,"Longitude"]
for(j in 1:nrow(subway)){
dist <- earth.dist(long_air,lat_air,subway[j,"Longitude"],subway[j,"Latitude"])
if(dist < distance){
distance <- dist
}
@svenhofstede-zz
svenhofstede-zz / spark_dataframe_persistance.scala
Last active December 16, 2015 15:05
spark_dataframe_persistance
// Spark version 1.3.0
import org.apache.spark.storage.StorageLevel
// Given a query
val initial_query = "SELECT * FROM snow_stg.sc_cat_item"
// For all the 4 tries below, the dataframe does not get persisted and no entries in the Storage tab of the Spark UI
// Try 1
val cmdb_rel_ci = sqlContext.sql(initial_query)
@svenhofstede-zz
svenhofstede-zz / coordinator_with_id_parameter.xml
Last active May 4, 2016 11:06
Get the ID of a Coordinator in a Oozie workflow
<coordinator-app
name="demo_coordinator"
frequency="360"
start="2100-12-31T23:59Z"
end="2100-12-31T23:59Z"
timezone="EST"
xmlns="uri:oozie:coordinator:0.2"
>
<controls>
<execution>FIFO</execution>
..
<action name="demo">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>demo.bash</exec>
<argument>${COORDINATOR_ID}</argument>
<file>demo.bash#demo.bash</file>
</shell>
# requirements: install python packages
# importing all required packages, pandas, numpy, matplotlib, seaborn, requests,...
import pandas as pd
import numpy as np
import requests
import seaborn as sb
import matplotlib.pyplot as plt
import os
import scrapy