Skip to content

Instantly share code, notes, and snippets.

View tukachev's full-sized avatar

Yurij Tukachev tukachev

View GitHub Profile
@alexeilutay
alexeilutay / transliterator.R
Last active December 20, 2021 00:06
Transliterator from Russian to English
# A function for transliteration inspired by https://gist.github.com/tukachev/7550665 but way too faster
translit2 <- function(text){
transliterations <- data.frame(
lat = c("A","B","V","G","D","E","YO","ZH","Z","I","J","K","L","M","N",
"O","P","R","S","T","U","F","KH","C","CH","SH","SHCH","''","Y","'","E'","YU","YA",
"a","b","v","g","d","e","yo","zh","z","i","j","k","l","m","n","o","p","r",
"s","t","u","f","kh","c","ch","sh","shch","''","y","'","e'","yu","ya"),
rus = c("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П",
"Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я",
@memoryfull
memoryfull / amplitude_time_density_example.R
Created February 23, 2017 17:49
An example of seewave::acoustat amplitude density calculation
# Install dependencies
#install.packages(c("fftw","tuneR","rgl","rpanel", "seewave"), repos="http://cran.at.r-project.org/")
# for Fast Fourier transform (fftw) to work, install
# the fftw lib (e.g. brew install fftw)
# Load libraries
library(data.table)
library(tuneR)
library(seewave)
read.gspreadsheet <- function(key) {
require(RCurl)
myCsv <- getURL(paste("https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=",
key, "&single=true&gid=0&output=csv", sep = ""),
.encoding = "UTF8")
read.table(textConnection(myCsv), header = T, sep = ",", stringsAsFactors = FALSE)
}
@tukachev
tukachev / rpa.R
Last active August 29, 2015 13:56
# McCrae's rpa (r profile agreement)
rpa <- function(p1,p2){
if (length(p1) != length(p2))
stop("'p1' and 'p2' must have the same length")
k <- length(p1)
sumM.sq <- sum(((p1 + p2)/2)^2)
sumd.sq <- sum((p1 - p2)^2)
ipa <- (k + 2*sumM.sq - sumd.sq) / sqrt(10*k)
rpa <- ipa / sqrt(k - 2 + ipa^2)
return(rpa)
@JoesDataDiner
JoesDataDiner / GetOfficeMetadata.R
Created June 10, 2013 22:32
Extracting Microsoft Office metadata using R
library(XML)
#use R's inbuilt unzip function, knowing that the required metadata is in docProps/core.xml
doc = xmlInternalTreeParse(unzip('test.docx','docProps/core.xml'))
#define the namespace
ns=c('dc'= 'http://purl.org/dc/elements/1.1/')
#extract the author using xpath query
author = xmlValue(getNodeSet(doc, '/*/dc:creator', namespaces=ns)[[1]])