Skip to content

Instantly share code, notes, and snippets.

View tartakynov's full-sized avatar

Artem Tartakynov tartakynov

View GitHub Profile
@tartakynov
tartakynov / hgp.py
Last active August 29, 2015 14:01
Calculates required number of Hadoop data nodes on first year
from math import ceil
from tabulate import tabulate
GiB = 1024
TiB = 1048576
def main():
"""
Calculates cluster growth plan based on numbers listed below
"""
@tartakynov
tartakynov / hgp_monthly.py
Created May 18, 2014 05:05
Calculates required number of Hadoop data nodes by month
from math import ceil
from tabulate import tabulate
GiB = 1024
TiB = 1048576
def main():
"""
Calculates cluster growth plan based on numbers listed below
"""
@tartakynov
tartakynov / HoltWinters.scala
Created November 9, 2014 16:18
Holt-Winters Forecasting Method in Scala
/*
* Holt-Winters Forecasting Method.
* Written by Artem Tartakynov.
* This particular implementation uses immutable collections and possibly
* creates a lot of work for garbage collector. Please feel free to use or modify it in
* whatever way best works for you.
*
* References:
* Jia Li and Andrew W. Moore. Forecasting Web Page Views: Methods and Observations. 2008.
*/
@tartakynov
tartakynov / fourex.py
Last active March 29, 2024 07:18
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
@tartakynov
tartakynov / parenthesis.py
Created May 7, 2016 07:48
Parenthesis String Parser
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
expression = simple_expression*
simple_expression = str | ( expression )
"""
class Expression:
def __init__(self):
@tartakynov
tartakynov / tokenizer.scala
Created May 7, 2016 13:48
Functional Tokenizer
type Tokenizer = String => Seq[Token]
val tokenizer = new Tokenizer {
override def apply(input: String): Seq[Token] = input.foldRight(Seq("")) {
case (c, acc) if Character.isMirrored(c) => Seq("", c.toString) ++ acc
case (c, acc) => Seq(c + acc.head) ++ acc.tail
}.map(_.trim).filter(_.nonEmpty).map {
str => Token(str, str match {
case "(" | "{" | "[" | "<" => TokenType.LPAREN
case ")" | "}" | "]" | ">" => TokenType.RPAREN
case _ => TokenType.STR
@tartakynov
tartakynov / scalastyle-config.xml
Created June 10, 2016 15:32
Scalastyle Config
<!--
If you wish to turn off checking for a section of code, you can put a comment in the source
before and after the section, with the following syntax:
// scalastyle:off
... // stuff that breaks the styles
// scalastyle:on
You can also disable only one rule, by specifying its rule id, as specified in:
@tartakynov
tartakynov / scalastyle-config.xml
Created June 10, 2016 15:32
Scalastyle Config
<!--
If you wish to turn off checking for a section of code, you can put a comment in the source
before and after the section, with the following syntax:
// scalastyle:off
... // stuff that breaks the styles
// scalastyle:on
You can also disable only one rule, by specifying its rule id, as specified in:
@tartakynov
tartakynov / build.sbt
Created September 5, 2016 06:23
Add public asset with app version (Play Framework)
resourceGenerators in Compile <+= (WebKeys.public in Assets, version).map {
case (dir, v) =>
val file = dir / "version.txt"
val gitCommit = Process("git rev-parse HEAD").lines.head
val content = "version=%s git-commit=%s".format(v, gitCommit)
IO.write(file, content)
Seq(file)
}
@tartakynov
tartakynov / mysql.sh
Last active December 5, 2016 12:24
MySQL Docker
docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d mysql:latest
docker run --name myadmin -d --link mysql:db -p 8888:80 phpmyadmin/phpmyadmin