Skip to content

Instantly share code, notes, and snippets.

View Sibirtsev's full-sized avatar
💭
C++

Alexey Sibirtsev Sibirtsev

💭
C++
View GitHub Profile
@Sibirtsev
Sibirtsev / i3.conf
Last active August 29, 2015 14:21 — forked from diyan/i3.conf
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@Sibirtsev
Sibirtsev / output
Last active June 14, 2016 02:57
Interpolation matrix of numbers with mean values
$ php scale.php
[5 x 5]
13.00 11.00 13.00 15.00 10.00
12.00 10.00 15.00 11.00 13.00
10.00 15.00 10.00 12.00 14.00
15.00 11.00 13.00 11.00 14.00
15.00 13.00 15.00 12.00 0.00
@Sibirtsev
Sibirtsev / quantile.sql
Last active September 5, 2016 05:00
Median in MySQL
SET @rownum := -1;
SET @quantile := 0.5;
SELECT
AVG(t.field)
FROM
(
SELECT
@rownum := @rownum + 1 AS rownum,
table.field AS field
@Sibirtsev
Sibirtsev / percentile.sh
Created August 18, 2016 04:54 — forked from lewisd32/percentile.sh
Calculate percentile in bash
#!/bin/bash
# stdin should be integers, one per line.
percentile=$1
tmp="$(tempfile)"
total=$(sort -n | tee "$tmp" | wc -l)
# (n + 99) / 100 with integers is effectively ceil(n/100) with floats
count=$(((total * percentile + 99) / 100))
head -n $count "$tmp" | tail -n 1
rm "$tmp"
@Sibirtsev
Sibirtsev / pop.py
Created September 5, 2016 04:59
Count non-zero bits
def pop(x):
x = int(x)
x -= ((x >> 1) & int('0x55555555', 16))
x = (x & int('0x33333333', 16)) + ((x >> 2) & int('0x33333333', 16))
x = (x + (x >> 4)) & int('0x0F0F0F0F', 16)
x += (x >> 8)
x += (x >> 16)
return x & int('0x0000003F', 16)
x = int('0b10111100011000110111110111111', 2)
@Sibirtsev
Sibirtsev / vector.py
Created September 15, 2016 03:24 — forked from rldotai/vector.py
Pure Python Vector class
"""
A simple implementation of vectors in Python modelled after tuples, but having
altered some of the operations to be closer to vector arithmetic.
It targets Python 3.5+ in order to support __matmul__, allowing for dot
products, which I have heard are important in linear algebra.
We check for whether it is operating on a number in order to implement
broadcasting; otherwise it performs the operations elementwise.
We also use `zip_longest` because it performs an implicit check for sequences
of unequal length; it pads the iteration with `None`, which will raise an error

###Полезные ссылки:

Сам по себе модуль хорошо документирован.

###Описание Word2Vec - штука, принимающая на вход массив из предложений(являющихся массивом из слов) и возвращающая некий объект. Этот некий объект реализует интерфейс dict, где ключами являются слова. И несколько методов, о которых расскажу дальше.

@Sibirtsev
Sibirtsev / Caffe Ubuntu 15.10.md
Created October 25, 2016 09:42 — forked from wangruohui/Caffe Ubuntu 15.10.md
Compile and run Caffe on Ubuntu 15.10

Ubuntu 15.10 have been released for a couple of days. It is a bleeding-edge system coming with Linux kernel 4.2 and GCC 5. However, compiling and running Caffe on this new system is no longer as smooth as on earlier versions. I have done some research related to this issue and finally find a way out. I summarize it here in this short tutorial and I hope more people and enjoy this new system without breaking their works.

Install NVIDIA Driver

The latest NVIDIA driver is officially included in Ubuntu 15.10 repositories. One can install it directly via apt-get.

sudo apt-get install nvidia-352-updates nvidia-modprobe

The nvidia-modprobe utility is used to load NVIDIA kernel modules and create NVIDIA character device files automatically everytime your machine boots up.

Reboot your machine and verify everything works by issuing nvidia-smi or running deviceQuery in CUDA samples.

@Sibirtsev
Sibirtsev / bash_prompt.sh
Created November 30, 2016 11:17 — forked from insin/bash_prompt.sh
Set color bash prompt according to active virtualenv, git branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});