Skip to content

Instantly share code, notes, and snippets.

View Patrikios's full-sized avatar
🎯
carpe diem

Patrik Patrikios

🎯
carpe diem
View GitHub Profile
@Patrikios
Patrikios / powershell.ps1
Last active April 29, 2023 11:51
poweshel alias function to delete and add new value to path
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 ";"
@Patrikios
Patrikios / pipable_chatgGPT_commands.R
Last active April 16, 2023 11:36
chatGPT interactions, as well to help you generate and evaluate code
# 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")
@Patrikios
Patrikios / App1.R
Last active April 16, 2023 11:10
R Shiny modal outputs render on input change strategies (previously rendered plot on input change visible VS plot render does not show previoous plot)
# 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(
@Patrikios
Patrikios / conditions.R
Last active March 10, 2023 07:15
implements custom R conditions (like errors, warnings, messages) as found in 1st Edition of Hadley's Advanced R book
# 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:
@Patrikios
Patrikios / multithreading.jl
Last active September 20, 2022 15:42
Overview of the parallelism/concurrent/distributed framework of julia in a nutshell
# 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
=#
@Patrikios
Patrikios / Dockerfile
Last active September 20, 2022 15:42
Building a shinyproxy Dockerfile based on rhub/r-minimal for R shiny app
# 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
@Patrikios
Patrikios / generator_expressions_study.jl
Last active September 19, 2022 15:24
GEnerator Expressions in julialang
# 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])
@Patrikios
Patrikios / pairs_study.jl
Last active September 19, 2022 13:12
julia pairs data structure
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)
@Patrikios
Patrikios / sync.md
Created September 13, 2022 15:44 — forked from xin053/sync.md
[go sync] go sync #go #sync

sync.WaitGroup

package main

import (
	"log"
	"math/rand"
	"sync"
	"time"
@Patrikios
Patrikios / DataFrames_Study.jl
Created September 13, 2022 14:49
A short excourse on the DataFrames.jl API
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"));