Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
public class TopologicalSort {
public static final int WHITE = 0;
public static final int GRAY = 1;
public static final int BLACK = 2;
private static void dfs(int v, List<List<Integer>> edges, int[] colors, List<Integer> queue) {
colors[v] = GRAY;
List<Integer> list = edges.get(v);
apt update && \
apt install -y zsh tmux && \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended && \
chsh -s $(which zsh)
package ru.gordinmitya;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner scanner = new Scanner(new File("asd.txt"));
scanner.close();
@gordinmitya
gordinmitya / MNN_benchmark.md
Created November 8, 2019 10:20
alibaba/mnn benchmark

Benchmarking model described in Real-time Portrait Segmentation on Smartphones by Prisma on MNN framework.

Mi 9T Pto; Snapdragon 855

Forward type: **Vulkan** thread=4** precision=2
--------> Benchmarking... loop = 8
Resize error for batchnorm/mul_1, code=2
[ - ] mdepth.mnn                  max =  276.845ms  min =  274.095ms  avg =  275.366ms
Vulkan don't support for 151, type=ReLU, Special case
/* ----------------------------------------------------------
СМЕНИТЬ НА СВОЙ!
---------------------------------------------------------- */
package ru.gordinmitya;
import java.util.Arrays;
class Animal {
String name;
void say() { }
@gordinmitya
gordinmitya / server_selector.py
Last active October 1, 2019 12:35
Simple python socket chat. One thread for all clients via selectors. Use telnet to join.
import types
import socket
import selectors
from threading import Thread
clients = []
# helper function to remove client from the list by name
@gordinmitya
gordinmitya / server_threads.py
Last active October 1, 2019 12:36
Simple python socket chat. One thread per client. Use telnet to join.
import socket
from threading import Thread
clients = []
# Thread to listen one particular client
class ClientListener(Thread):
def __init__(self, name: str, sock: socket.socket):
@gordinmitya
gordinmitya / nginx.conf
Created September 16, 2019 19:42
Lab4 Nginx configuration: serve static files, proxy other requests to python application.
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
location ~ \.(ico|png|jpg) {
root /www/media;
}
location / {
@gordinmitya
gordinmitya / download_thread.py
Last active September 17, 2019 10:12
distributed systems: lab 2
class DownloadThread(Thread):
def __init__(self, url):
super().__init__()
self.url = url
def run(self):
handle = urllib.request.urlopen(self.url)
fname = os.path.basename(self.url)
with open(fname, "wb") as f_handler:
@gordinmitya
gordinmitya / CalcActivity.java
Created May 29, 2019 09:50
Пример задания обработчика нажатия нескольким кнопкам. Калькулятор.
private View.OnClickListener numberClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button0:
// обработка нажатия на 0
break;
// остальные кнопки …
}
}