package main
import (
"log"
"math/rand"
"sync"
"time"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Alias delp Remove-EnvironmentPath | |
function Remove-EnvironmentPath { | |
$toRemove = ($args -join " ").TrimEnd("\") | |
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User") | |
$changedUserPath = $userPath.Split(";") | | |
ForEach-Object { $_.TrimEnd("\").Trim() } | | |
Where-Object { $_ -ne $toRemove } | |
$changedUserPath = $changedUserPath -Join ";" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# an example of using package 'chatgpt' to help you generate pipaeble code | |
# I used here code that I have seen on twitter | |
# however I cannot locate it anymore, no pun intended, will update the sources once I found it | |
# my package loader (installs packages if they are not installed) | |
if (!require(attachee)) { | |
if (!require(devtools)) { | |
install.packages(devtools) | |
} else { | |
install_github("patrikios/attachee") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This app.R demonstrates how R Shiny rerenders a unique output id | |
# the previously renred plot is initially visible, afterwards changed | |
# that is how shiny is designed to work | |
library(shiny) | |
library(ggplot2) | |
app <- shinyApp( | |
ui = fluidPage( | |
selectInput( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ressources: | |
# - https://github.com/r-hub/r-minimal | |
# - https://hosting.analythium.io/best-practices-for-r-with-docker/ | |
# NOTE | |
# does not support Cairo or x11 add hoc, hence renderPlot will not work, renderPlotly und JS backends are working fine | |
# TEST and DEBUG | |
# - build: sudo docker build --build-arg http_proxy=x --build-arg https_proxy=x -t shiny_app_alpine . | |
# - run: sudo docker run -it -p 3899:3838 -v /home/xyz/:/home/xyz/ shiny_app_alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generator Expressions | |
# - comprehensions can also be written without the enclosing square brackets, producing an object known as a generator | |
# - can be iterated to produce values on demand, instead of allocating an array and storing them in advance | |
# - Generators are implemented via inner functions. | |
# - simple example | |
(1/n^2 for n=1:1000) | |
# - collect | |
collect(1/n^2 for n=1:1000) | |
# - the following expression sums a series without allocating memory | |
map(tuple, (1/(i+j) for i=1:2, j=1:2), [1 3; 2 4]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a_tuple = (1, 2) | |
a_pair = 1 => 2 | |
a_tuple != a_pair | |
# true | |
# The elements are stored in the fields first and second | |
a_pair.first | |
# 1 | |
a_pair.second | |
# 1 | |
typeof(a_pair) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DataFrames | |
# create a data.frame (simple) | |
df = DataFrame(A=1:4, B=["M", "N", "O", "P"]) | |
df[!, :A] # no copy | |
df[:, :A] # copy is returned | |
# create a data.frame (row by row - not performant, as DataFrames are like in R built columnwise) | |
df2 = DataFrame(A=Int[], B=String[]) | |
push!(df2, (1, "M")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOCUMENTATION | |
# | |
# Sources: http://adv-r.had.co.nz/Exceptions-Debugging.html & https://adv-r.hadley.nz/conditions.html | |
# | |
# - all conditions inherit from abstract class 'condition' | |
# - conditions are being signalled from functions | |
# - R conditions system was inpsired by Common Lisp | |
# | |
# | |
# Ressources: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multithreaded programming in Julia | |
#= | |
Julia supports multiple types of parallelism | |
- SIMD (handled by the compiler) -> for instance the package StaticArrays.jl, short static vectors incline to encourage SIMD operations, a further reason why the package is so efficient | |
- Threads with shared memory (this documents touches upon this point) | |
- Distributed (multi-mode, not sharing memory) | |
- GPUs | |
=# |
NewerOlder