Skip to content

Instantly share code, notes, and snippets.

Avatar

Yurij Tukachev tukachev

View GitHub Profile
View doomsday_clock.R
library(rvest)
library(ggplot2)
library(stringr)
url <- "https://ru.wikipedia.org/wiki/Часы_Судного_дня"
df <- url %>%
read_html(url) %>%
html_node("table") %>%
html_table()
# Небольшие преобразования:
@tukachev
tukachev / jwst_status.R
Last active Jan 10, 2022
Параметры полёта телескопа "Джеймс Уэбб"
View jwst_status.R
library(tidyverse)
library(jsonlite)
library(png)
library(glue)
library(ragg)
library(here)
library(showtext)
library(ggdark)
library(ggtext)
View gmail_send_sms
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 Jul 24, 2018
Плиточная карта РФ
View ru_tiled_map.R
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,
View REmoTelegramBot.R
#!/usr/bin/Rscript
# Пакеты
library("httr")
library("XML")
library("stringr")
library("ggplot2")
library("telegram")
library("RCurl")
library("httr")
library("Cairo")
View importKellyGrid.R
# Функция-парсер протокола репертуарной решетки из программы
# KELLY (В.И. Похилько, Н.Н. Страхов) Автор: Юрий Тукачев
# yurij.tukachev@gmail.com
importKellyGrid <- function(file, dir = NULL, encode = "UTF-8") {
# Необходимые пакеты
require(stringr)
require(OpenRepGrid)
require(tcltk)
if (!is.null(dir))
View metafor.R
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 Apr 10, 2016
clipboard in linux: copy&paste
View clipboard.R
# 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)
}
View cowsay.R
cowsay <- function(x) {
system(paste0("cowsay ", "'", x, "'"))
}
cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.")
#> cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.")
# _____________________________________
#/ Вечная загадка мира — это его \
View pdf2txt.R
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) )