Skip to content

Instantly share code, notes, and snippets.

@kapulkin
kapulkin / Timer.py
Last active October 12, 2020 21:38
Measuring evaluation time in python
import time
import logging
logger = logging.getLogger(__name__)
class Timer:
def __init__(self, name: str, maxCount = None):
self.name = name
self.time = 0
self.count = 0
@kapulkin
kapulkin / CocoDataset.py
Last active October 7, 2020 22:39
Extracting segmentation masks from coco poly or RLE format into numpy images
import json
import cv2
import os
import random
import numpy as np
from pycocotools import mask as cocoMask
class CocoDataset:
def __init__(self, annotationFilePath: str, imagesDir: str, masksDir: str, shuffle: bool = True):
with open(annotationFilePath, 'r') as annotationFile:
@kapulkin
kapulkin / pyodide.html
Last active March 5, 2021 13:56
Pyodide sandbox: Loading csv file into numpy aray
<html>
<head>
</head>
<input type="file" id="fileInput" onchange="handleFiles(this.files)"/>
<div id="pyodide"/>
<body>
<script type="text/javascript">
self.languagePluginUrl = "/python/"
@kapulkin
kapulkin / Circle.ts
Last active October 28, 2019 02:17
Intersection of ray with rounded box
class Circle {
private x: number
private y: number
private radius: number
/**
* constructor
*/
public constructor(x, y, radius) {
this.x = x
@kapulkin
kapulkin / keybase.md
Created May 8, 2017 16:04
Keybase proof

Keybase proof

I hereby claim:

  • I am kapulkin on github.
  • I am kapulkin (https://keybase.io/kapulkin) on keybase.
  • I have a public key whose fingerprint is 48F5 2435 481B 5C5A 9C96 AF69 3E94 656E C1EB FC6A

To claim this, I am signing this object:

@kapulkin
kapulkin / web-servers.md
Created May 8, 2017 16:00 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000