Skip to content

Instantly share code, notes, and snippets.

View mgnisia's full-sized avatar

Moritz Gnisia mgnisia

View GitHub Profile
# Creating Function to write Email as EML File to Disk
def save_message(message_admin, request, queryset):
i = 0
for message in queryset.all():
eml_content = message.get_email_object().as_bytes()
file_name = f"some_file_path/{message.subject}_{i}.eml"
print(file_name)
with open(file_name, "wb") as outfile:
outfile.write(eml_content)
i += 1
@mgnisia
mgnisia / Sum_Expansion.py
Created June 4, 2019 09:21
Sympy Sum Expansion Example
from sympy import *
init_printing()
i, j = symbols('i j', cls=Idx)
b = IndexedBase('b')
c = IndexedBase('c')
alpha = IndexedBase('alpha')
Sum(b[i]*alpha[i,j]*c[j], (i, 1, 3), (j, 1,3)).doit()
@mgnisia
mgnisia / Setup_Precice_OpenFOAM.Dockerfile
Last active June 4, 2019 09:22
Dockerfile for preCICE, OpenFOAM and the preCICE openFOAM Adapater
# Selecting the Operating System
FROM ubuntu:18.04
# Updating
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install wget git gnupg gnupg2 gnupg1 software-properties-common vim
RUN sh -c "wget -qO - http://dl.openfoam.org/gpg.key | apt-key add -"
# Setup OpenFoam
RUN add-apt-repository http://dl.openfoam.org/ubuntu
RUN apt-get update
RUN apt-get -y install openfoam5
@mgnisia
mgnisia / Dockerfile
Last active September 26, 2019 08:58
Dockerfile for gcc compiler with simple fish prompt and mpi
FROM nlknguyen/alpine-mpich
FROM gcc
# Update the containers to install fish
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y fish vim
# Install PNG Library
RUN wget https://download.savannah.nongnu.org/releases/pngpp/png++-0.2.9.tar.gz
@mgnisia
mgnisia / md_table.fish
Created November 27, 2019 12:01
Create Markdown table in fish per function
function md_table
set header "| header | header |\n| ------ | ------ |\n"
for i in *.cpp;
set -a header "| $i | |\n";
end;
printf "$header";
end
@mgnisia
mgnisia / Dockerfile
Created January 6, 2020 12:38
MPI Dockerfile, used for running Gitlab CI
FROM gcc
# Install MPI
ENV MPI_VERSION 3.3.1
RUN wget http://www.mpich.org/static/downloads/${MPI_VERSION}/mpich-${MPI_VERSION}.tar.gz &&\
tar xfz mpich-${MPI_VERSION}.tar.gz &&\
cd mpich-${MPI_VERSION} &&\
./configure &&\
make -j 4 &&\
make -j 4 install
@mgnisia
mgnisia / Dockerfile
Created January 16, 2020 18:04
Dockerfile for gcc with mpi, python3, numpy and pandas, Application: CI testing of MPI code
FROM gcc
# Install MPI
ENV MPI_VERSION 3.3.1
RUN wget http://www.mpich.org/static/downloads/${MPI_VERSION}/mpich-${MPI_VERSION}.tar.gz &&\
tar xfz mpich-${MPI_VERSION}.tar.gz &&\
cd mpich-${MPI_VERSION} &&\
./configure &&\
make -j 4 &&\
make -j 4 install
@mgnisia
mgnisia / BoundaryConditions.py
Created June 4, 2020 09:36 — forked from ilciavo/BoundaryConditions.py
Poisson and Heat Equation with boundary conditions
#poisson solver
#u_xx = b(x)
%matplotlib inline
from __future__ import division
import numpy as np
from numpy import cos, sin, zeros, pi
from numpy.linalg import solve, norm
import matplotlib.pyplot as plt
from matplotlib import rcParams
@mgnisia
mgnisia / ravel_index.h
Created September 23, 2020 17:56
Transform 1D Index Notation to 3D Index notation in C++ / CPP
template<typename T>
std::array<T,3> index_3D(T index, T size) {
T x = index % size;
T tmp = (index - x) / size;
T y = tmp % size;
T z = (tmp - y) / size;
return std::array<T,3>{z,y,x};
}
@mgnisia
mgnisia / print_tensor.py
Created October 6, 2020 08:42
Printing of three dimensional tensor
# Assumption tensor == np.array
def print_tensor(tensor):
for i3 in range(0, tensor.shape[0]):
for i1 in range(0, tensor.shape[2]):
string_line = ""
for i2 in range(0, tensor.shape[1]):
string_line += " {:3.2f} ".format(tensor[i3][i2][i1])
print(string_line)
print("------------------------------------")