Skip to content

Instantly share code, notes, and snippets.

@gusy
gusy / generate_dashboards.py
Last active October 5, 2017 10:14
This generates a dashboard per region based on a template dashboard. Outputs json to standard output
from datadog import initialize, api
import json
TEMPLATE_DASHBOARD_ID = 227470
options = {
'api_key': '**',
'app_key': '**'
}
@gusy
gusy / generate_dashboards
Created October 5, 2017 10:13
This generates a dashboard per region based on a template dashboard
from datadog import initialize, api
import json
TEMPLATE_DASHBOARD_ID = 227470
options = {
'api_key': '**',
'app_key': '**'
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gusy
gusy / marvel-net.R
Created April 28, 2014 17:00
Extract marvel social network from bipartite graph
library(igraph)
###wget http://exposedata.com/marvel/data/hero-network.csv && mv hero-networks.csv source.csv
a<-read.table("~/marvel-class/source.csv",sep=",",stringsAsFactors=F)
a$V2<-paste(a$V2, "comic book")
g<-simplify(graph.data.frame(a,directed=T))
#names<-V(g)$name
#g<-remove.vertex.attribute(g,"name")
#gb<-graph.bipartite(types=x,edges=c(t(get.edges(g,E(g)))))
x<-degree(g,mode="in")>0
library(RJSONIO)
library(ggplot2)
oo<-fromJSON("http://pregel.mat.upm.es/ErdosN500MC100.json")
data<-do.call(rbind,lapply(1:100,function(i){
return(cbind(names(oo)[i],1:length(oo[[i]]),unlist(oo[[i]])))
}))
mode(data)<-"numeric"
df<-data.frame(data)
@gusy
gusy / web-to-podcast.php
Created June 6, 2012 15:26
scrapping cope output podcast
<?php
$checkin_url='http://eurocopa.cope.es/Eurocopa2012/eurocope/audios/especial-eurocopa';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $checkin_url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
$result=curl_exec($ch);
#echo $result;
@gusy
gusy / add-rel.py
Created June 4, 2012 04:08
add relationship
import sys,codecs
'''
format input sender recieverid #emails
format output relationship;#emails_AtoB;#emails_BtoA
'''
f=file("/dev/stdin")
for line in f:
line=line.split(";");
from=line[0]
to=line[1]
@gusy
gusy / extract-network-from-log.py
Created June 4, 2012 01:13
Mono-core python dict based script
import sys,codecs
'''
format emiter receiver contacts
example: 5767599 242682935 4
'''
links={}
i=0
f=file("/dev/stdin")