Skip to content

Instantly share code, notes, and snippets.

@jankuc
jankuc / keyVault_connection_API.json
Created February 11, 2020 15:30
keyVault_connection_API.json
{
"properties": {
"name": "keyvault",
"connectionParameters": {
"vaultName": {
"type": "string",
"uiDefinition": {
"displayName": "Vault name",
"description": "Name of the vault",
"tooltip": "Provide name of the vault",
@jankuc
jankuc / load_or_install_packages.R
Last active January 24, 2019 10:09
R Function which tries to load packages and installs those packages that are not installed already.
#' Load or install packages
#'
#' It tries to install the specified packages multiple (deafault is 10) times.
#'
#' @param packages character vector of packages which should be loaded or installed if they are not already.
#' @param recursive_depth Argument that is used for selecting how many times the installation should be tried.
#' Defaults to 10. Not intended to be changed.
#'
#' @return
#' @export
@jankuc
jankuc / parallel_example_in_r.r
Created September 12, 2018 08:25
Parallel computation in R usable on windows machines with SOCKS parallelization.
library(parallel)
# detect number of compute cores
num_cores <- detectCores()
# register the cluster
cl <- makeCluster(num_cores)
# load libraries on all nodes in cluster
clusterEvalQ(cl, library(data.table))
@jankuc
jankuc / format_and_mount_new_disk.sh
Created September 8, 2018 12:25
Format new harddrive to ext4 filesystem and mount for use in linux
#!/bin/sh
# Check which device you want to work with
fdisk -l
# Format it with ext4 journaling filesystem. It has sufficiently low number of writes, so it is ok to use with SSDs.
mkfs.ext4 /dev/sda
# Create directory where the new disk will be mounted
mkdir /mnt/evo
# Mount the new disk to the newly created directory
mount /dev/sda /mnt/evo/
# Check the available space on the newly mounted disk
@jankuc
jankuc / messure_time.R
Created August 31, 2018 06:59
How to meassure execution time in R
library(lubridate)
t1 <- Sys.time()
# DO STUFF
t2 <- Sys.time()
time_diff <- difftime(t2, t1, units = 'secs')
duration_str <- hms::as.hms(round(time_diff, 3))
@jankuc
jankuc / Post_to_slack_from_R.R
Last active August 10, 2018 13:20
Gist showing how to post message from R to slack channel
library(jsonlite)
library(httr)
library(R6)
library(curl)
# Create Slack configuration object
slack_conf <- list(
incoming_webhook = "",
icon_url = "http://breakingapis.org/assets/vis/logo_cran.png",
bot_username = "R notification",