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 / server.R
Created April 2, 2021 18:01 — forked from garrettgman/server.R
A shiny app that helps you explore stock returns (by way of yahoo finance and quantmod)
library(shiny)
library(quantmod)
library(VGAM)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# acquiring data
dataInput <- reactive({
if (input$get == 0)
@Patrikios
Patrikios / main.go
Last active February 20, 2022 21:58
Gist on type checking in go
package main
// Sources:
// 1. https://go.dev/tour/methods/15
// 2. https://go.dev/tour/methods/16
// 3. https://stackoverflow.com/questions/6996704/how-to-check-variable-type-at-runtime-in-go-language
// 4. https://go.dev/tour/methods/9
// Notions
// concrete types like int, float64, string etc
@Patrikios
Patrikios / function_parameter_pasing.jl
Created February 20, 2022 22:01
Passing by reference an passing by value in julialang
#= assignment of a function to a new name
- is shallow copy of a function
- in programming parlance: done by reference
=#
f(x) = 2x
g = f
g #f (generic function with 1 method)
g(2) #4
f(x) = 4x
@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"));
@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 / 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 / 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 / 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 / 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 / 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: