Skip to content

Instantly share code, notes, and snippets.

View nizhib's full-sized avatar

Evgeny Nizhibitsky nizhib

  • London, United Kingdom
  • 01:45 (UTC +01:00)
View GitHub Profile
@nizhib
nizhib / critical.go
Created December 14, 2022 09:43
Synchronizing workers with critical parts
package main
import (
"log"
"math/rand"
"os"
"os/signal"
"sync"
"time"
)
@nizhib
nizhib / mono.css
Created September 5, 2021 11:27
Monospaced
.highlight > pre > span,
.highlight > tbody > tr > td,
.highlight > table > tbody > tr > td,
.highlight > table > tbody > tr > td > span,
.jp-InputPrompt, .jp-OutputPrompt,
.CodeMirror-linenumber,
.preview > span,
.preview > span > span,
.line-number,
@nizhib
nizhib / tunnel@.service
Created June 19, 2021 10:45
SSH Tunnel Service
[Unit]
Description=Keeps the ssh tunnel to %i open
After=network.target
[Service]
User=nizhib
Environment="AUTOSSH_PORT=0"
Environment="AUTOSSH_LOGFILE=/tmp/tunnel.%i.log"
Environment="AUTOSSH_PIDFILE=/tmp/tunnel.%i.pid"
Environment="SSH_OPTIONS=-o 'ServerAliveInterval=60' -o 'ServerAliveCountMax=3'"
@nizhib
nizhib / sota.py
Last active June 19, 2021 10:41
Multi-Image Data Prefetcher
class DataPrefetcher:
def __init__(self, loader, num_images=1, num_labels=1):
self.loader = iter(loader)
self.num_images = num_images
self.num_labels = num_labels
self.num_others = 1
self.stream = torch.cuda.Stream()
self.mean = (
torch.tensor([0.485 * 255, 0.456 * 255, 0.406 * 255])
@nizhib
nizhib / pytorch.org.css
Created October 2, 2018 09:47
Pytorch.org stylesheet
*, a {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-weight: 400;
}
h1, h2, h3, h4, h5, h6,
.blog .main-content-wrapper h4 a {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-weight: 700;
}
@nizhib
nizhib / parallel.py
Last active December 3, 2019 17:48
Parallel model+criterion for pytorch
import threading
import torch
from torch.nn.modules import Module
from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
from torch.nn.parallel.replicate import replicate
from torch.nn.parallel.parallel_apply import parallel_apply
__all__ = ['DataParallelModel', 'DataParallelCriterion']
@nizhib
nizhib / unet.py
Created March 2, 2018 15:09
U-Net from Topcoder Abnormality Detection
__author__ = "nizhib"
import torch
from torch import nn
from torch.autograd import Variable
def conv3x3(in_channels, out_channels, dilation=1):
return nn.Conv2d(in_channels, out_channels, 3, padding=dilation, dilation=dilation)
@nizhib
nizhib / pipeline.py
Last active October 7, 2020 13:36
Multiprocess Pipeline
import multiprocessing
import os
class MultiprocessPipeline(object):
"""
pipeline = MultiprocessPipeline(foo)
pipeline.start()
for a, b, c in something:
pipeline.put((a, b, c))