Skip to content

Instantly share code, notes, and snippets.

View RamiKrispin's full-sized avatar
👻
Focusing

Rami Krispin RamiKrispin

👻
Focusing
View GitHub Profile
@RamiKrispin
RamiKrispin / airflow_dag_ex1.py
Created May 21, 2024 12:47
Example for parsing xcom value with using DockerOperator
from datetime import datetime, timedelta
from airflow.utils.dates import days_ago
from airflow import DAG
from airflow.providers.docker.operators.docker import DockerOperator
from airflow.operators.python import PythonOperator
from docker.types import Mount
import os
@RamiKrispin
RamiKrispin / docker-compose.yml
Created October 19, 2023 05:15
ATSAF Docker Compose
version: "3.9"
services:
rstudio:
image: "rkrispin/atsaf:dev.0.0.0.9000"
ports:
- "8787:8787"
volumes:
- type: "bind"
source: "$ATSAF_DIR"
target: "/home/rstudio"
@RamiKrispin
RamiKrispin / app.R
Created September 25, 2023 03:28
Forecasting Sandbox Example
# Forecasting Sandbox ----
# This is an example for a Shinylive R app
# The app provides a forecasting sandbox for the AirPassengers dataset
# It supports 3 stats forecasting models - Linear Regression, ARIMA, and Holt-Winters
library(shiny)
data(AirPassengers)
# UI ----
ui <- fluidPage(
@RamiKrispin
RamiKrispin / gist:fff84af2622927d82d1dd369d77e3210
Created September 19, 2022 12:26
RStudio_server_docker.sh
#!/bin/bash
# Launching RStuido server on a docker with different settings
# Basic run command to launce rocker container with RStudio Server
docker run -d -p 8787:8787 \
-e USER=rstudio -e PASSWORD=rstudio \
rocker/rstudio:4.2
# Disabling the authentication
@RamiKrispin
RamiKrispin / messages in R.R
Created September 16, 2022 14:14
Examples for printing messages during run time with R
# Print messages with print and cat
print("This is the message I want to print")
cat("This is the message I want to print\n") # Using the \n operator to jump for the next line
# The print command can also print code output
print(data.frame(x = 1:3, y = 4:6))
# Where cat cannot print non text or multiple vector objects
cat(data.frame(x = 1:3, y = 4:6))
@RamiKrispin
RamiKrispin / lm_beta_coefficients.R
Created January 31, 2022 04:32
Calculate the beta coefficients for linear regression
#generate random numbers
set.seed(1234)
x1 <- rnorm(n = 1000, mean = 3, sd = 3)
x2 <- rnorm(n = 1000, mean = 0, sd = 1)
noise <- runif(n = 1000, min = 0, max = 1)
# Set formula
y <- 5 * x1 - 3 * x2 + noise
# Run regression
@RamiKrispin
RamiKrispin / regression_plot.R
Created January 12, 2022 06:13
Regression plot with R-sqr value
# Adding regression line to a plot
set.seed(1234)
# Creating a random dataset
x <- rnorm(n = 1000, mean = 10, sd = 3)
y <- 2 * x + 10 + rnorm(n = 1000, mean = 0, sd = 4)
d <- data.frame(y = y,
x = x)
@RamiKrispin
RamiKrispin / waterfall_plotly.R
Created January 9, 2022 04:51
Creating waterfall chart with plotly
library(plotly)
df <- data.frame(y = c(21, 44, 27, 8),
x = c(100, 200, 150, 250))
df$x_cum <- cumsum(df$x)
df$y_cum <- cumsum(df$y)
df
@RamiKrispin
RamiKrispin / daily_cases_ghana.R
Created January 1, 2022 12:02
Daily new COVID-19 cases in Ghana
# Plotting COVID19 daily new cases in the Ghana
# Using the following libraries:
# coronavirus for data
# plotly for dataviz
# dplyr for data manipulation
library(coronavirus)
library(plotly)
library(dplyr)
df <- refresh_coronavirus_jhu()
@RamiKrispin
RamiKrispin / daily_cases_us.R
Created December 31, 2021 18:09
Plotting Daily New COVID19 Cases in the US
# Plotting COVID19 daily new cases in the US
# Using the following libraries:
# coronavirus for data
# plotly for dataviz
# dplyr for data manipulation
library(coronavirus)
library(plotly)
library(dplyr)
df <- refresh_coronavirus_jhu()