Skip to content

Instantly share code, notes, and snippets.

View privateOmega's full-sized avatar
🎮
Focusing

Kiran Mathew Mohan privateOmega

🎮
Focusing
  • Hinge Health
  • Bangalore, India
  • 17:37 (UTC +05:30)
View GitHub Profile
@privateOmega
privateOmega / stacktrace.py
Created April 27, 2022 07:51
python3 stacktrace
import traceback
print(''.join(traceback.format_exception(etype=type(error), value=error, tb=error.__traceback__)))
@privateOmega
privateOmega / react-rbac.tsx
Created April 25, 2022 22:52
Simple RBAC implementation for React
import React, { createContext, useContext, useState } from "react"
export type Permission = string
interface IPermissionContextType {
isAllowedTo: (permission: Permission) => boolean
}
const PermissionContext = createContext<IPermissionContextType>({
isAllowedTo: () => false,
@privateOmega
privateOmega / clamav-install.sh
Last active April 1, 2022 06:43
clamav setup ubuntu
sudo apt install clamav clamav-daemon
sudo systemctl enable clamav-daemon
sudo systemctl start clamav-daemon
sudo nano /etc/systemd/system/clamdscan-home.service
# copy following content into it
[Unit]
Description=ClamAV virus scan
Requires=clam-daemon.service
@privateOmega
privateOmega / clamav-install.sh
Last active March 31, 2022 11:49
clamav setup centos
If epel-release is available
sudo yum install epel-release
else
sudo amazon-linux-extras install epel
sudo yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd
sudo freshclam
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '%b'
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='%F{blue}%n%F{yellow}@%F{green}${PWD/#$HOME/~} %F{red}(${vcs_info_msg_0_}) %F{yellow}$%F{reset_color} '
[alias]
st = status -sb
a = add .
co = checkout
cob = checkout -b
last = log -1 head
cane = commit --amend --no-edit
lo = log --oneline -n 10
pr = pull --rebase --prune
cm = commit -m
(
TEST_VAR,
) = [
dict(os.environ)[k]
for k in (
"TEST_VAR",
)
]
@privateOmega
privateOmega / build-opencv.sh
Created February 28, 2022 12:15
Build open-cv with contrib modules with python3 support
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y build-essential
sudo apt-get install -y cmake git unzip pkg-config make libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtbb-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libavutil-dev libavfilter-dev libavresample-dev
mkdir -p venv/opencv
sudo apt-get install python3-dev
python3 -m venv venv/opencv/
source venv/opencv/bin/activate
pip install numpy
git clone --depth=1 https://github.com/opencv/opencv.git opencv
@privateOmega
privateOmega / dcmanonymize.sh
Created February 15, 2022 05:01 — forked from jdoepfert/dcmanonymize.sh
simple dicom anonymization with dcmtk
# Patient's Name. Patient ID birth date series UID. series UID Institution Name Institution Address Accession Number physician operator sop UID other pat ids study id Image Comments
dcmodify -ie -gin -nb -ea "(0010,0010)" -ea "(0010,0020)" -ea "(0010,0030)" -ea "(0020,000E)" -ea "(0020,000D)" -ea "(0008,0080)" -ea "(0008,0081)" -ea "(0008,0050)" -ea "(0008,0090)" -ea "(0008,1070)" -ea "(0008,1155)" -ea "(0010,1000)" -ea "(0020,0010)" -ea "(0020,4000)" *.dcm
@privateOmega
privateOmega / Task 4
Created December 8, 2021 06:21 — forked from Esperanzq/Task 4
Write a wrapper for the os.walk() function that returns a generator. The generator should give me all the files (and only files, excluding directories!) with their absolute path.
import os
import pprint
def get_all_files(path, min_size_kb=None):
for root, dirs, files in os.walk(path):
for file_ in files:
path = os.path.abspath(os.path.join(root, file_))
size = (os.path.getsize(path)) // 1024
if size >= min_size_kb: