Skip to content

Instantly share code, notes, and snippets.

View josefslerka's full-sized avatar

Josef Šlerka josefslerka

View GitHub Profile
@josefslerka
josefslerka / index.html
Last active December 12, 2015 02:09
MDS Facebook
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>D3 Test</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
.axis path,
.axis line {
fill: none;
@josefslerka
josefslerka / gist:4360941
Created December 22, 2012 20:34
Detekce dominatnich barev
#short version of this GIST https://gist.github.com/3980277
library("ReadImages")
library("reshape")
library("ggplot2")
#detekce dominatnich barev
readImage <- read.jpeg("File5196.jpg")
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)
@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
@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 / 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 / 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
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:3248443
Created August 3, 2012 15:06
Odstraneni RT
if(substring(value,0,3)=="RT ", substring(value,3), value)
value.replace(/^RT @\w+:/,' ')
@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"