Skip to content

Instantly share code, notes, and snippets.

View alekseyl1992's full-sized avatar

Leontiev Aleksey alekseyl1992

  • MailRu Group
  • Moscow
View GitHub Profile
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
xs = np.arange(-100, 100, 0.1)
ys = np.sin(xs)
n = 75
def mcloren(x):
@alekseyl1992
alekseyl1992 / lab.py
Created November 2, 2016 21:05
lab.py
def get_area(matrix, start_row, start_col):
max_area = 0
height = 0
prev_line_width = 0
for j in range(start_row, len(matrix)):
row = matrix[start_row]
height += 1
current_line_width = 0
@alekseyl1992
alekseyl1992 / my_shared_ptr_no_heap.cc
Created September 3, 2016 15:56
my_shared_ptr_no_heap.cc
#include <iostream>
#include <memory>
#include <string>
#include <vector>
template <typename T>
class my_shared_ptr {
public:
my_shared_ptr(T* raw_ptr)
: raw_ptr_(raw_ptr),
@alekseyl1992
alekseyl1992 / my_shared_ptr.cc
Last active September 3, 2016 15:52
my_shared_ptr.cc
#include <iostream>
#include <memory>
#include <string>
#include <vector>
template <typename T>
class my_shared_ptr {
public:
my_shared_ptr(T* raw_ptr)
: raw_ptr_(raw_ptr),
Index url score score_delta uid time_delta speed date
0 52790 /start_game: 0 0 57519da4fa2950be58e0645c 0.000 0.000000 2016-06-03T15:11:11.049Z
1 52258 /update_score: 0 0 57519da4fa2950be58e0645c 125.641 0.000000 2016-06-03T15:11:30.408Z
2 52266 /start_game: 0 0 57519da4fa2950be58e0645c 0.000 0.000000 2016-06-03T15:11:53.763Z
3 52799 /update_score: 1 1 57519da4fa2950be58e0645c 33.096 0.030215 2016-06-03T15:12:03.504Z
4 52801 /update_score: 1 0 57519da4fa2950be58e0645c 1.593 0.000000 2016-06-03T15:12:05.097Z
5 52804 /update_score: 2 1 57519da4fa2950be58e0645c 18.421 0.054286 2016-06-03T15:12:23.518Z
6 52276 /update_score: 3 1 57519da4fa2950be58e0645c 9.985 0.100150 2016-06-03T15:12:33.503Z
@alekseyl1992
alekseyl1992 / spark_mnist_mlp.py
Created February 14, 2016 16:53
Apache Spark. Training MLP on MNIST
from __future__ import print_function
from pyspark import SparkContext, SparkConf
from pyspark.mllib.linalg import DenseVector, VectorUDT
from pyspark.sql import SQLContext
from pyspark.ml.classification import MultilayerPerceptronClassifier
from pyspark.ml.evaluation import MulticlassClassificationEvaluator
from pyspark.sql.types import StructType, StructField, StringType, DoubleType, ArrayType
@alekseyl1992
alekseyl1992 / spark_perf_test.py
Created January 20, 2016 12:51
Spark Perf test
import random
def sample(p):
x, y = random.random(), random.random()
return 1 if x*x + y*y < 1 else 0
def run(sc, num_samples):
count = sc.parallelize(xrange(0, num_samples)).map(sample) \
.reduce(lambda a, b: a + b)
print "Pi is roughly %f" % (4.0 * count / num_samples)
@alekseyl1992
alekseyl1992 / two_phase_virtual_invocation.cpp
Created November 12, 2015 09:18
Two phase C++ virtual invocation
#include <exception>
#include <stdexcept>
#include <string>
class NotImplementedException : public std::runtime_error {
public:
NotImplementedException(const std::string& str)
: std::runtime_error(str) {
}
@alekseyl1992
alekseyl1992 / go_tcp_server.go
Last active September 3, 2015 11:57
Go TCP server
package main
import (
"fmt"
"net"
"os"
)
const (
CONN_HOST = "localhost"
using Generation = std::vector<Genome>;
constexpr int buildingSize = 100;
Genome createGenome() {
Genome genome;
int currentFloor = 0;
do {