Dmitry Kulikov kulikov

View example.py
1 2 3
l = ["1", "32", "hello", "3", "my 43"]
 
return [int(_) for _ in filter(lambda _: _.isdigit(), l)]
View es-scroll.scala
1 2 3 4 5 6 7 8 9 10
val timeout = new TimeValue(600000)
 
val requestBuilder = client
.prepareSearch(index)
.setTypes(indexType)
.setSize(size.getOrElse(5000))
.setScroll(timeout)
.setSearchType(SearchType.SCAN)
 
query foreach requestBuilder.setQuery
View jackson.scala
1 2 3 4 5 6 7 8 9
package com.digsolab.euler.util.format
 
import org.scalatest.FlatSpec
import org.scalatest.matchers.MustMatchers
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonInclude.Include
 
 
case class Person(name: String, age: Int)
View .zshrc
1 2 3 4 5 6 7 8 9
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
 
plugins=(osx brew git sbt bower)
 
source $ZSH/oh-my-zsh.sh
 
 
PROMPT='%{$fg[yellow]%}➤%{$fg_bold[green]%}%p %{$fg[cyan]%}%c $ % %{$reset_color%}'
View nsq-ansible.yaml
1 2 3 4 5 6 7 8 9
---
- name: install supervisord
apt: pkg=supervisor state=present
 
- name: add nsq group
group: name=nsq
 
- name: add nsq user
user: name=nsq group=nsq
View seriesFutures.scala
1 2 3 4 5 6 7 8 9 10
 
def series(items: List[Int]) {
if (items.nonEmpty) {
Future {
doHeavyWork(items.head)
} onComplete {
case res =>
// handler results
series(items.tail)
}
View ScaleFactor.scala
1 2 3 4 5 6 7 8 9 10
object ScaleFactor {
 
val T1MicroSpeed = 10.0
 
def calcNeedInstances(avgSpeed: Int, queueSize: Int): Int = {
val taskPerHour = avgSpeed * 3600
val maxInstances = math.ceil(avgSpeed / T1MicroSpeed)
 
queueSize / taskPerHour.toDouble match {
case h if h < 1 math.ceil(maxInstances * h).toInt
View suffix-preffix.scala
1 2 3 4 5 6 7 8 9 10
object Solution extends App {
 
val bf = Array.newBuilder[String]
 
(1 to Console.readLine().toInt)
.map(_ => Console.readLine())
.foreach(s => println(calc(s)))
 
@annotation.tailrec
def sum(n: Int, res: Int = 0): Int = if (n <= 0) res else sum(n - 1, res + n)
View nsq.conf
1 2 3 4 5 6 7 8 9 10
[program:nsqlookupd]
command=/usr/local/nsq/bin/nsqlookupd --http-address="10.36.206.254:4161" --tcp-address="10.36.206.254:4160"
process_name=%(program_name)s
numprocs=1
directory=/usr/local/nsq
user=ubuntu
stdout_logfile=/var/log/nsq/nsqlookupd.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=5
redirect_stderr=true
View winners.scala
1 2 3 4 5 6 7 8 9 10
case class MC(ids: List[Int], matchType: String = "one")
 
def weight(mcType: String) = 1
 
val values = List(MC(List(1, 2, 3, 4, 5)), MC(List(3, 4, 5, 3, 6)), MC(List(3, 1, 5, 2, 3)))
 
val winners = values.foldLeft(collection.mutable.Map.empty[Int, Int])({ (acc, mc)
mc.ids foreach (id acc.update(id, acc.getOrElse(id, 0) + weight(mc.matchType)))
acc
}).foldLeft(collection.immutable.TreeMap.empty[Int, Int]) { case (best, (id, weight))
Something went wrong with that request. Please try again.