Skip to content

Instantly share code, notes, and snippets.

View tartakynov's full-sized avatar

Artem Tartakynov tartakynov

View GitHub Profile
docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql/mysql-server:latest
docker run --name myadmin -d -p 8888:80 --link mysql:db phpmyadmin/phpmyadmin
docker run --name rabbitmq -d -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15671:15671 -p 15672:15672 -p 25672:25672 rabbitmq:3-management
@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
@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 / 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 / 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 / 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 / fourex.py
Last active July 15, 2024 16:24
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 / 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 / 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
"""