Skip to content

Instantly share code, notes, and snippets.

View wolterlw's full-sized avatar
🇺🇦

Volodymyr wolterlw

🇺🇦
View GitHub Profile
@wolterlw
wolterlw / count_people.sql
Last active June 9, 2017 21:23
beautiful SQL function to count people on position
CREATE OR REPLACE FUNCTION count_max_on_pos(date1 DATE, date2 DATE, id_pos INTEGER) RETURNS INTEGER AS $$
-- date1, date2 - limits of the time interval
-- id_pos - id of the position we examine
DECLARE num_people_array INTEGER ARRAY;
DECLARE max_on_pos INTEGER := 0;
DECLARE curr_on_pos INTEGER := 0;
DECLARE i INTEGER;
BEGIN
SELECT ARRAY(SELECT coalesce(num_pos,0) - coalesce(num_neg,0) FROM
from keras.models import Sequential
model = Sequential()
@wolterlw
wolterlw / torch_dataset.py
Created June 13, 2018 12:47
PyTorch dataset template
class CustomDataset(torch.utils.data.Dataset):
def __init__(self):
# TODO
# 1. Initialize file paths or a list of file names.
pass
def __getitem__(self, index):
# TODO
# 1. Read one data from file (e.g. using numpy.fromfile, PIL.Image.open).
# 2. Preprocess the data (e.g. torchvision.Transform).
# 3. Return a data pair (e.g. image and label).
@wolterlw
wolterlw / add_sublime_shortcut.py
Created September 10, 2018 16:18 — forked from dshulchevskiy/add_sublime_shortcut.py
Sublime shortcut for jupyter notebook
"""
Sublime shortcuts for jupyter notebook
"""
from jupyter_core.paths import jupyter_config_dir
import os
custom_js_path = os.path.join(jupyter_config_dir(), 'custom', 'custom.js')
custom_path = os.path.join(jupyter_config_dir(), 'custom')
@wolterlw
wolterlw / pytorch_template.py
Created January 10, 2019 23:23
PyTorch_Template
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision.datasets.mnist import MNIST
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
import visdom
from collections import OrderedDict
class LeNet5(nn.Module):
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
@wolterlw
wolterlw / shell_stuff.sh
Created January 18, 2019 00:42
Shell stuff
#to match the word between foo and bar use:
$ grep -oP '(?<=foo )\w+(?= bar)' test.txt
@wolterlw
wolterlw / tg_notify.sh
Last active January 18, 2019 04:29
Minimal bash script to push messages to telegram via bot API
#!/bin/bash
# 1. create a bot using @BotFather
# 2. create a public channel, add the bot as it's administrator
# 3. fill in the required information below
# 4. do a test run. In the response there will be a chat_id, which is a bunch of numbers
# now it's possible to make the channel private and use chat_id instead of the public name
bot_token=#YOUR_BOT_TOKEN
chat_id=#UR_CHANNEL_ID
api_call="https://api.telegram.org/bot$bot_token/sendMessage"
@wolterlw
wolterlw / tf_changes.diff
Created September 18, 2019 04:33
Changes made to the tensorflow source to enable custom operations
diff --git a/tensorflow/lite/kernels/internal/BUILD b/tensorflow/lite/kernels/internal/BUILD
index 4be3226938..6bc39a7194 100644
--- a/tensorflow/lite/kernels/internal/BUILD
+++ b/tensorflow/lite/kernels/internal/BUILD
@@ -37,6 +37,18 @@ NEON_FLAGS_IF_APPLICABLE = select({
],
})
+cc_library(
+ name = "common",
@wolterlw
wolterlw / hand_ssh_anchors.cpp
Created September 20, 2019 19:10
c++ program to get anchors needed for hand detection
/*
parameter JSON
{
"num_layers": 5,
"min_scale": 0.1171875,
"max_scale": 0.75,
"input_size_height": 256,
"input_size_width": 256,
"anchor_offset_x": 0.5,
"anchor_offset_y": 0.5,