Skip to content

Instantly share code, notes, and snippets.

View velikodniy's full-sized avatar
:octocat:

Vadim Velicodnii velikodniy

:octocat:
View GitHub Profile
@velikodniy
velikodniy / guess.py
Created October 26, 2012 19:42
Угадайка
#!/usr/bin/env python
# coding: utf-8
data = {'question': 'Это животное?', True: 'кошка', False: 'компьютер'}
def ask(q):
a = raw_input(q)
if a in 'y':
return True
else:
@velikodniy
velikodniy / close_ie.c
Created October 26, 2012 19:56
IE closer
#include <windows.h>
#include <string.h>
const char FILTER[] = "Internet Explorer";
BOOL CALLBACK CloseWindow(HWND h, LPARAM lparam)
{
char buff [256]; // I know, I know...
GetWindowText(h, (LPTSTR)buff, 256);
if(strstr(buff, FILTER) != NULL)
@velikodniy
velikodniy / beep.cpp
Created October 26, 2012 20:37
Beeper (libao)
// g++ -lao -o beep beep.cpp
#include <ao/ao.h>
#include <cmath>
#include <cstdlib>
#define BITS 16
#define CHANNELS 1
#define RATE 22050
#!/bin/bash
# 150% fullscreen
EVEN_UP_CROP=179
ODD_DOWN_CROP=16
#result
SIZE=918x1192
SHIFT=+215+138
@velikodniy
velikodniy / encrypt.sh
Created October 18, 2015 18:35
Encrypt dirs with given prefix (zsh)
#!/bin/zsh
PREFIX=2008
FROM='/media/vadim/Data/Фотографии'
for dir in $FROM/$PREFIX*;
do
echo -n "$dir" ...
dirname=$(basename "$dir")
tar c -C "$FROM" $dirname | gpg -e -r "Vadim Velikodniy" -o "$dirname.tar.gpg";
@velikodniy
velikodniy / pyopencl_example.py
Created December 11, 2015 10:17
PyOpenCL example
import numpy as np
import pyopencl as cl
N = 1000000
a_np = np.random.rand(N).astype(np.float32)
b_np = np.random.rand(N).astype(np.float32)
ctx = cl.create_some_context(answers=['0'])
queue = cl.CommandQueue(ctx)
https://www.linux.org.ru/forum/development/12574505
@velikodniy
velikodniy / Client.java
Created December 4, 2016 15:06
Java client-server
import java.net.*;
import java.io.*;
import java.util.*;
public class Client {
static int port = 5003; // Порт, такой же, как у сервера
static String address = "127.0.0.1"; // Адрес сервера
public static void main(String[] args) {
try {
@velikodniy
velikodniy / sharpness.py
Created May 25, 2018 17:29
Estimate image sharpness
from torch import Tensor
import torch.nn as nn
import torch.nn.functional as F
class Sharpness(nn.Module):
def __init__(self):
super().__init__()
kernel = [[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]]
kernel = Tensor(kernel)
kernel.unsqueeze_(0)
@velikodniy
velikodniy / tinyraytracer.py
Created January 22, 2019 19:10
Very slow ray tracer
import numpy as np
import numba as nb
jit = nb.njit(parallel=True, fastmath=True)
@jit
def v(x):
return np.array(x, dtype=np.float64)