Skip to content

Instantly share code, notes, and snippets.

View MohamedKari's full-sized avatar

MohamedKari

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
MohamedKari / VolumeButtons.swift
Last active August 4, 2021 19:39
VolumeButtonEvents.swift
//
// VolumeButtons.swift
// multitouch
//
// Created by Mo Kari on 04.08.21.
//
import Foundation
import SwiftUI
import UIKit
@MohamedKari
MohamedKari / latex-tools.md
Last active July 29, 2021 13:53
latex-tools
# Count words
texcount -inc paper.tex

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

# Show unsused or undefined references
checkcites paper
@MohamedKari
MohamedKari / steps.md
Created January 23, 2021 13:44
UIKit to SwiftUI Delegation with Coordinators and ViewControllers

Preliminaries

  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
MohamedKari / gh-secrets.py
Last active November 23, 2020 22:37
GitHub Secrets Helper (with support for pushing docker-machine certs)
"""
Installation:
```
bash <(curl -S https://gist.githubusercontent.com/MohamedKari/d6a2a7a6cdfe5aee32a6c8eefd6029be/raw/gh-secrets.sh)
source .gh-secrets/bin/activate
```
"""
import os
from base64 import b64encode
import json
@MohamedKari
MohamedKari / vnc-on-ec2.sh
Last active November 22, 2020 12:35
Setup VNC on EC2
# bash <(curl -s https://gist.githubusercontent.com/MohamedKari/9d3982f70849f273d51a3c86126ddb41/raw/c827f74257f847f352b1f489fc970381cec626db)
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
@MohamedKari
MohamedKari / sequence_aware_threading.py
Created August 21, 2020 18:29
Sequence-Aware Threading
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
__pycache__
@MohamedKari
MohamedKari / Makefile
Last active May 28, 2020 19:52
CA-signed Certificate Generation with self-generated CA
# 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
MohamedKari / Dockerfile
Last active May 22, 2020 10:30
CUDA with Python Dockerfile
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
SHELL ["/bin/bash", "-c"]
ENV PYENV_ROOT="/.pyenv"
# Install pyenv dependencies & fetch pyenv
# see: https://github.com/pyenv/pyenv/wiki/common-build-problems
RUN apt-get update && \
apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \