Skip to content

Instantly share code, notes, and snippets.

Konstantin Tretyakov konstantint

Block or report user

Report or block konstantint

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View to_sign_or_not_to_sign.cpp
// https://nauka.leprosorium.ru/comments/2349993/
#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
long long f(int x) {
if (x < 0) return 0;
@konstantint
konstantint / dsw-3.sql
Created Dec 2, 2018
The Data Science Workflow blogpost, snippet 3
View dsw-3.sql
with _BehaviourFeatures as (
... inline the view definition ...
),
_ProfileFeatures as (
... inline the view definition ...
),
_ModelInputs as (
... concatenate the feature columns ...
)
select
@konstantint
konstantint / dsw-2.sql
Created Dec 2, 2018
The Data Science Workflow post, snippet 2
View dsw-2.sql
select
s.Key
v1.AverageTimeSpent,
v1.NumberOfClicks,
v2.Country
v3.Purchase as Target
from vw_TrainSample s
left join vw_BehaviourFeatures v1 on v1.Key = s.Key
left join vw_ProfileFeatures v2 on v2.Key = s.Key
left join vw_TargetFeatures v3 on v3.Key = s.Key
@konstantint
konstantint / dsw-1.py
Created Dec 2, 2018
The Data Science Workflow blogpost, code snippet 1
View dsw-1.py
import sqlalchemy as sa
import pandas as pd
e = sa.create_engine("sqlite:///raw_data.sqlite")
pd.read_csv("raw_data.csv").to_sql("raw_data", e)
View ovpn_setup.sh
# Executable transcript of https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04
sudo apt update
sudo apt install -y openvpn easy-rsa python
make-cadir ~/openvpn-ca
cd ~/openvpn-ca
cat <<EOT >> vars
# New values
export KEY_COUNTRY="EE"
export KEY_PROVINCE="Some Province"
@konstantint
konstantint / Program.cs
Last active Mar 21, 2018
A program for adding ten numbers
View Program.cs
// Source code for the post:
// https://www.quora.com/Can-you-write-a-program-for-adding-10-numbers/answer/Konstantin-Tretyakov
// http://fouryears.eu/2018/03/17/a-program-for-adding-10-numbers/
//
// Runs with the following config.xml:
// <Config>
// <InputProvider class="Enterprise.NumberSequenceProvider"/>
// <OutputConsumer class="Enterprise.PeanoNumberPrinter"/>
// <Solution class="Enterprise.TenNumberAddingSolution">
// <Strategy class="Enterprise.AdditionStrategy"/>
@konstantint
konstantint / fig5.py
Created Mar 6, 2018
Secrets of Spring Motion - Figure 5
View fig5.py
# Figure 5 from http://fouryears.eu/2016/11/17/the-secrets-of-spring-motion/
# Intended to be run from a Jupyter notebook cell
%pylab inline
g = 9.18
k = 2.0 * 8
L = 1.0
m = 1.0/9
@konstantint
konstantint / earlystopping_mnist.py
Last active Jan 7, 2018
Early Stopping Experiment with MNIST
View earlystopping_mnist.py
# Early Stopping Experiment with MNIST
# http://fouryears.eu/2017/12/05/the-mystery-of-early-stopping/
#
# Code adapted from: https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py
# By: Konstantin Tretyakov
# License: MIT
import keras
from keras.datasets import mnist
from keras.models import Sequential
View paul_and_simon_sort.py
# "Paul-and-Simon sort"
# http://fouryears.eu/2017/07/25/sorting-in-linear-time/
# http://www-wjp.cs.uni-saarland.de/publikationen/PS80.pdf
#
# Copyright 2017, Konstantin Tretyakov
# License: MIT
from math import log2, ceil
def paul_and_simon_sort(a):
View LeprosoriumLiveSoundNotifier.js
function LiveWatcher(watch_posts, watch_users) {
var self = this;
var _oldListener;
function newListener(d) {
var el = document.createElement('div');
el.innerHTML = JSON.parse(d.data).data;
var post_id = parseInt(el.childNodes[0].getAttribute("data-post_id"));
var user_login = el.childNodes[0].getAttribute("data-user_login");
You can’t perform that action at this time.