Skip to content

Instantly share code, notes, and snippets.

@bshishov
bshishov / Viewport.cs
Last active October 28, 2023 18:36
Unity Editor utility to add clippable pan&zoom area to EditorWindow in UGUI
// Copyright 2023 Boris Shishov (github: @bshishov)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial
// portions of the Software.
import time
import subprocess
import json
from contextlib import contextmanager
MYSTEM_BINARY = 'mystem.exe'
MYSTEM_ARGS = '--input-format json --fixlist fixlist.txt --format json -gi -d -c'
@bshishov
bshishov / hashcode2020.py
Created February 21, 2020 14:15
hashcode2020
from typing import List, Set, Dict, NamedTuple
import multiprocessing
import random
class Book(NamedTuple):
id: int
score: int
@bshishov
bshishov / SimpleDecal.shader
Last active April 28, 2021 09:29
Unity3D simple screen-space decal shader. Does not support lighting. Works with LWRP. Just create a material with this shader and assign it to a cube (also disable shadows and collider). Thats it you've got a working decals.
Shader "Custom/SimpleDecal"
{
Properties {
_MainTex ("Main Texture", 2D) = "white" {}
[HDR]_Color ("Color", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags { "RenderType"= "Transparent" "Queue" = "Transparent" }
Pass
@bshishov
bshishov / forecasting_metrics.py
Last active April 20, 2024 04:29
Python Numpy functions for most common forecasting metrics
import numpy as np
EPSILON = 1e-10
def _error(actual: np.ndarray, predicted: np.ndarray):
""" Simple error """
return actual - predicted
@bshishov
bshishov / mcts.py
Created January 24, 2018 00:21
Monte Carlo Tree Search
import numpy as np
from typing import List, Tuple
from alpha_chess_zero import settings
from alpha_chess_zero.game_model import GameModel
class MCTSNode(object):
def __init__(self, state):
self.state = state
@bshishov
bshishov / OutliersCorrection.ipynb
Last active February 28, 2017 11:34
Image outliers correction with numpy.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bshishov
bshishov / ndarray_test.ipynb
Last active February 13, 2017 22:53
Numpy test of array (R,) and (R,1)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bshishov
bshishov / speech.py
Created February 7, 2017 11:42
Fundamental frequency estimation using cepsrtal analysis
import time
import matplotlib.pyplot as plt
import wave
import numpy as np
# Mapping for numpy arrays
types = {1: np.int8, 2: np.int16, 4: np.int32}
# Open the wave file
@bshishov
bshishov / wget-wiki.sh
Last active November 15, 2021 19:39
WGET recursive download of a mediawiki website with authorization
#!/bin/bash
WIKI_URL=___ # with trailing slash
WIKI_USERNAME=___
WIKI_PASSWORD=___
WIKI_DUMP_DIR=./dump
WIKI_DUMP_DIR_LOGIN=${WIKI_DUMP_DIR}/login
WIKI_LOGIN_PAGE="index.php?title=Служебная:Вход"
#WIKI_START_PAGE="index.php?title=Содержание"
WIKI_START_PAGE="index.php/Содержание"