Skip to content

Instantly share code, notes, and snippets.

Working from home


Working from home
View GitHub Profile
# TODO: refactor for future usage
# TODO: Bonferroni-correct for number of questions
import pandas as pd
import scikit_posthocs as sp
import statsmodels.api as sa
def load_questionnaire():
q = pd.read_csv("questionnaire.csv", delimiter=";")
q = q.melt(id_vars=["Technique", "QuestionId"], value_vars=[f"P{i}" for i in range(1, 13)], var_name="ParticipantId", value_name="Response")
MohamedKari / VolumeButtons.swift
Last active Aug 4, 2021
View VolumeButtons.swift
// VolumeButtons.swift
// multitouch
// Created by Mo Kari on 04.08.21.
import Foundation
import SwiftUI
import UIKit
# Count words
texcount -inc paper.tex

# Get bib-file containing only the used references
bibexport paper

# Show unsused or undefined references
checkcites paper
MohamedKari /
Created Jan 23, 2021
UIKit to SwiftUI Delegation with Coordinators and ViewControllers


  1. Create final class with name UICloudVisionViewController inheriting UIViewController with all the typical (the UI in the name refers to UIKit) which follows the UIKit approach
  2. Create struct with name CloudVisionViewController inheriting from UIViewControllerRepresentable which covers the missing link between SwiftUI and UIKit
  3. To exchange data between UIKit and SwiftUI, add a coordinator class to CloudVisionViewController and return an instance of it in the makeCoordinator func

Reflect changes from UIKit in SwiftUI: Communication is delegate-based. The goal is to call a delegate in the custom UIKit UICloudVisionViewController which updates the parent SwiftUI view 4. Add the changing variable to the SwiftUI ContentView as a state variable: @State private var mostRecentFrame: UIImage? = nil 5. Add the changing variable to the CloudVisionViewController as a @Binding var mostRecentFrame: UIImage? 6. Implement a CloudVisionDelegate protocol and in there a function wit

MohamedKari /
Last active Nov 23, 2020
GitHub Secrets Helper (with support for pushing docker-machine certs)
bash <(curl -S
source .gh-secrets/bin/activate
import os
from base64 import b64encode
import json
MohamedKari /
Last active Nov 22, 2020
Setup VNC on EC2
# bash <(curl -s
sudo apt -y update
sudo apt -y install ubuntu-desktop
sudo apt -y install tightvncserver
sudo apt -y install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
mkdir -p ~/.vnc
cat <<EOF > ~/.vnc/xstartup
import time
import logging
import importlib
from typing import List, Any
from enum import Enum
from collections import deque
from concurrent.futures import ThreadPoolExecutor
from abc import ABC, abstractmethod
import numpy as np
MohamedKari / Makefile
Last active May 28, 2020
CA-signed Certificate Generation with self-generated CA
View Makefile
# args
SAN_FILE = localhost.san
# vars
NAME = $(basename $(SAN_FILE))
ca_key_passphrase = $(shell openssl rand -base64 32)
define ca_conf_template
[ req ]
default_bits = 4096
MohamedKari / Dockerfile
Last active May 22, 2020
CUDA with Python Dockerfile
View Dockerfile
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
SHELL ["/bin/bash", "-c"]
ENV PYENV_ROOT="/.pyenv"
# Install pyenv dependencies & fetch pyenv
# see:
RUN apt-get update && \
apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \