Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

MohamedKari

🏠
Working from home
View GitHub Profile
View wilcoxon.py
# 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 Aug 4, 2021
VolumeButtonEvents.swift
View VolumeButtons.swift
//
// VolumeButtons.swift
// multitouch
//
// Created by Mo Kari on 04.08.21.
//
import Foundation
import SwiftUI
import UIKit
View latex-tools.md
# 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 Jan 23, 2021
UIKit to SwiftUI Delegation with Coordinators and ViewControllers
View steps.md

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 Nov 23, 2020
GitHub Secrets Helper (with support for pushing docker-machine certs)
View gh-secrets.py
"""
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 Nov 22, 2020
Setup VNC on EC2
View vnc-on-ec2.sh
# 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
View sequence_aware_threading.py
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
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
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: 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 \