Skip to content

Instantly share code, notes, and snippets.

View vsimko's full-sized avatar
💭
building stuff

Viliam Simko vsimko

💭
building stuff
View GitHub Profile
library(lsa)
# create some sample data in temp dir
td = tempfile()
dir.create(td)
write(c("dog", "cat", "mouse"), file = paste(td, "D1", sep = "/"))
write(c("ham", "mouse", "sushi"), file = paste(td, "D2", sep = "/"))
write(c("dog", "pet", "pet"), file = paste(td, "D3", sep = "/"))
data(stopwords_en)
library(SparkR)
library(sparklyr)
library(dplyr)
# use specific version of spark/hadoop
sc <- spark_connect("local", version = "2.0.2", hadoop_version = "2.7")
# assuming comma-separated input
spark_read_csv(
sc, "bmw", "~/SOC.csv",
# convert ";" to ","
tr ";" "," < input.csv > output.csv
# list of columns with associated numbers
head -1 commadata.csv | tr ',' '\n' | nl
# project columns 1,2,163-174 into a new file
cut -d',' -f 1,2,163-174 commadata.csv > SOC.csv
# random subsample of 100 rows (not tested)
\usepackage[outerbars,xcolor]{changebar} % due to \cbcolor, \cbstart ... \cbend
\setlength{\changebarwidth}{3pt}
\setlength{\changebarsep}{20pt}
\definecolor{ChangebarColor}{rgb}{0.75,0.85,0.95}
\cbcolor{ChangebarColor}
% ==============================================================================
% Marking the changebark using a margin note
% ==============================================================================
# if (!require('devtools')) install.packages('devtools')
# devtools::install_github('apache/spark@v2.0.2', subdir='R/pkg')
library(SparkR)
library(sparklyr)
library(dplyr)
# use specific version of spark/hadoop
sc <- spark_connect("local", version = "2.0.2", hadoop_version = "2.7")
## Load the library after installing GMP
library(gmp)
library(raster)
plot_tupper <- function(k) {
## The tupper's formula
tupper = function(x, y, k){
z1 <- as.bigz(y + k)
z2 <- as.bigq(z1/17)
library(raster)
# global config
INPUT_FNAME <- "/home/vlx/Work/biggis/data-julian/Auto150_georef.tif"
BAND <- 1
AGGREG_FACT <- 150
AGGREG_FUNC <- mean
# here comes the code
@vsimko
vsimko / scala-test-example.scala
Created October 7, 2016 12:34
example of a test in scala
// taken from: http://www.scalatest.org/user_guide/selecting_a_style
class TVSetSpec extends FeatureSpec with GivenWhenThen {
info("As a TV set owner")
info("I want to be able to turn the TV on and off")
info("So I can watch TV when I want")
info("And save energy when I'm not watching TV")
feature("TV power button") {
scenario("User presses power button when TV is off") {