Skip to content

Instantly share code, notes, and snippets.

View josefslerka's full-sized avatar

Josef Šlerka josefslerka

View GitHub Profile
@josefslerka
josefslerka / gist:2709927
Created May 16, 2012 12:21
GREL pro YouTube API
https://gdata.youtube.com/feeds/api/videos/zpe4T0lXZcE?v=2&alt=json
value.parseJson()["entry"]["yt$statistics"]["viewCount"]
value.parseJson()["entry"]["yt$rating"]["numLikes"]
value.parseJson()["entry"]["yt$rating"]["numDislikes"]
value.parseJson()["entry"]["author"][0]["name"]["$t"]
value.parseJson()["entry"]["author"][0]["uri"]["$t"]
value.parseJson()["entry"]["author"][0]["yt$userId"]["$t"]
@josefslerka
josefslerka / gist:2837367
Created May 30, 2012 16:20
Google Refine Template for Scrapping Facebook Fan Pages
[
{
"op": "core/column-addition-by-fetching-urls",
"description": "Create column Facebook at index 2 by fetching URLs based on column URL using expression grel:value",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"newColumnName": "Facebook",
"columnInsertIndex": 2,
@josefslerka
josefslerka / gist:3025485
Created June 30, 2012 20:57
Clean NodeXL twitter list
[
{
"op": "core/column-removal",
"description": "Remove column Visual Properties",
"columnName": "Visual Properties"
},
{
"op": "core/column-removal",
"description": "Remove column Column2",
"columnName": "Column2"
@josefslerka
josefslerka / gist:3248443
Created August 3, 2012 15:06
Odstraneni RT
if(substring(value,0,3)=="RT ", substring(value,3), value)
value.replace(/^RT @\w+:/,' ')
Pocet shares na Twitteru
http://urls.api.twitter.com/1/urls/count.json?url=
Pocet shares na LinkedInu
http://www.linkedin.com/countserv/count/share?url=http://www.klaboseni.cz&format=json
Pocet shares na Facebooku
http://graph.facebook.com/?id=http://www.klaboseni.cz
@josefslerka
josefslerka / gist:3769046
Created September 23, 2012 06:06
The Internet - source code
require 'tweetstream'
require "serialport"
TweetStream.configure do |config|
config.consumer_key = 'xxxx'
config.consumer_secret = 'xxxx'
config.oauth_token = 'xxxx'
config.oauth_token_secret = 'xxxx'
config.auth_method = :oauth
end
@josefslerka
josefslerka / dh7.R
Last active October 13, 2015 05:48
Digital Humanities 7
library(tm)
library(textcat)
library(tm)
library(tau)
library(openNLP)
inspect(havel[1:2])
havel[[1]] #pristup ke konkretnimu dokumentu
@josefslerka
josefslerka / ncd.R
Created December 1, 2012 19:39
Normalized Compression Distance
# Normalized Compression Distance
# http://en.wikipedia.org/wiki/Normalized_Compression_Distance
# Quick and dirty implementation
ncd <- function(file1, file2) {
both <- ""
file1 <- toString(file1)
file2 <- toString(file2)
comp1 <- memCompress(file1, type=c(c("bzip2")))
@josefslerka
josefslerka / gist:4195326
Created December 3, 2012 14:23
Digital Humanities 8 - Text mining
#
#
# https://sites.google.com/site/genbiovis/code/network
#
# natazeni knihovny
library(tm)
# nacteni korpusu
tbl <- read.csv("kv.csv", header=TRUE)
tbl <- subset(tbl, select = -X )
d <- dist(tbl)
fit <- cmdscale(d,eig=TRUE, k=2)
nazev <- c("Fischer", "Sobotka", "Franz", "Roithová", "Fischerová", "Dientsbier", "Schwarzenberg","Zeman")
x <- fit$points[,1]*(-1)
y <- fit$points[,2]
plot(x, y, xlab="levice - pravice", ylab="konzervativni - liberalni",
main="Podobnost kandidátů podle postojů", type="n", ylim=c(-6,6), xlim=c(-6,6))
text(x, y, labels = nazev)