Skip to content

Instantly share code, notes, and snippets.

@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",
@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 / 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 / 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 / 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 / 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 / Refresh Tables in SQL Endpoint.py
Created May 7, 2025 07:16 — forked from MarkPryceMaherMSFT/Refresh Tables in SQL Endpoint.py
Code to refresh the tables in the SQL Endpoint, after they have been updated in the lakehouse. Cut and paste this code into a cell in a notebook
########################################################################################################
# Sample script to call the syncronisation between the Fabric Lakehouse and the SQL Endpoint
#
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# This script is a workaround until the documented API is released: https://learn.microsoft.com/en-us/fabric/release-plan/data-warehouse#refresh-sql-analytics-endpoint-rest-api
#
#sempy version 0.4.0 or higher
!pip install semantic-link --q
import json