Skip to content

Instantly share code, notes, and snippets.

View tukachev's full-sized avatar

Yurij Tukachev tukachev

View GitHub Profile
@tukachev
tukachev / jwst_status.R
Last active January 10, 2022 19:49
Параметры полёта телескопа "Джеймс Уэбб"
library(tidyverse)
library(jsonlite)
library(png)
library(glue)
library(ragg)
library(here)
library(showtext)
library(ggdark)
library(ggtext)
@tukachev
tukachev / gmail_send_sms
Created September 30, 2021 23:50
emal2sms
gmail.send <- function(username, password, emailto, sub, msg)
{
frommailuser <- paste(username,"@gmail.com", sep='')
com1 <- paste("sendEmail -f", frommailuser, "-t", emailto, "-o message-charset=utf-8 -u")
com2 <- "-m "
com3 <- paste("-o message-format=text -s smtp.gmail.com -o tls=yes -xu", username, "-xp", password)
system(paste(com1, sub, com2, msg, com3))
}
@tukachev
tukachev / ru_tiled_map.R
Created July 24, 2018 17:33
Плиточная карта РФ
library(geofacet)
library(ggplot2)
mygrid <- data.frame(
row = c(1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8,
8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11),
col = c(1, 5, 18, 19, 4, 10, 1, 12, 17, 18, 3, 4, 5, 9, 10, 15, 12, 13, 8, 9,
10, 17, 18, 20, 1, 3, 14, 15, 16, 4, 5, 6, 7, 12, 13, 7, 8, 9, 10, 17,
14, 15, 16, 3, 4, 5, 6, 12, 7, 8, 9, 10, 18, 13, 14, 15, 16, 3, 4, 5,
#!/usr/bin/Rscript
# Пакеты
library("httr")
library("XML")
library("stringr")
library("ggplot2")
library("telegram")
library("RCurl")
library("httr")
library("Cairo")
# Функция-парсер протокола репертуарной решетки из программы
# KELLY (В.И. Похилько, Н.Н. Страхов) Автор: Юрий Тукачев
# yurij.tukachev@gmail.com
importKellyGrid <- function(file, dir = NULL, encode = "UTF-8") {
# Необходимые пакеты
require(stringr)
require(OpenRepGrid)
require(tcltk)
if (!is.null(dir))
p.disagreement <- function(data) {
n <- ncol(data)
m <- matrix(0, n, n)
rownames(m) <- names(data)
colnames(m) <- names(data)
for (i in 1:n) {
for (j in i:n) {
m[i, j] <- mean(data[, i] != data[, j])
}
}
@tukachev
tukachev / clipboard.R
Last active April 10, 2016 17:27
clipboard in linux: copy&paste
# only works in linux
# Install xclip first
# $ sudo apt-get install xclip
# write to clipboard
wclip <- function(x, sep="\t", row.names=FALSE, col.names=TRUE){
con <- pipe("xclip -selection clipboard -i", open="w")
write.table(x, con, sep=sep, row.names=row.names, col.names=col.names)
close(con)
}
cowsay <- function(x) {
system(paste0("cowsay ", "'", x, "'"))
}
cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.")
#> cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.")
# _____________________________________
#/ Вечная загадка мира — это его \
@tukachev
tukachev / pdf2txt.R
Created October 13, 2015 20:29
pdf2txt
dest <- "~/pdf"
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
sapply(myfiles, FUN = function(i){
file.rename(from = i, to = paste0(dirname(i), "/", gsub(" ", "", basename(i))))
})
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
lapply(myfiles, function(i) system(paste('"pdftotext" -layout', paste0('"', i, '"')), wait = FALSE) )
@tukachev
tukachev / rpa.R
Created August 6, 2014 17:38
McCrae's rpa (r profile agreement): calc&plot
# McCrae's rpa (r profile agreement): calc&plot :)
rpa <- function(p1, p2){
if (length(p1) != length(p2))
stop("'p1' and 'p2' must have the same length")
k <- length(p1)
pr1 <- (p1 - 5.5)/2
pr2 <- (p2 - 5.5)/2
sumM.sq <- sum(((pr1 + pr2)/2)^2)
sumd.sq <- sum((pr1 - pr2)^2)
ipa <- (k + 2*sumM.sq - sumd.sq) / sqrt(10*k)