critique welcome
Nov. 11th, 2018 09:03 pmSlapped it together for the oncoming Scale by the Bay conference.
good stuff on medium
Sep. 3rd, 2018 08:17 pmНу просто надо было комп забрать, ну.
А обратно приехал в шестом часу; зашел в КМарт, купил мочалку, скребок для душа, и еще, не знаю как описать, губку для мытья ванны, ну там не губка а типа тоже мочалка. Вот.
Дома мы планировали идти погулять, но погода опять шепчет, мол, дождик скоро. Так я пошел вычистил фильтрацию пруда; там столько бактерий развелось, ужас. Кошка все мне помогала, ходила со мной туда-сюда, серьезная такая. Только что в воду не лезла. И все время что-то говорит. Жаль, я ее акцента не понимаю.
А, ну так-то главная развлекуха - это Akka Streams. Прогресс зафигачил хрен знает куда; и удобная такая вещь.
Например, вопрос - а как мне в акке файл в вебсервере послать на запрос? Ответ - стримами. Сорс - файл, синк - httpResponse. Привинтили - и готово; никаких байтов, никаких буферов, закрытий файлов, всей этой хрени. Все сделано уже до нас.
Я единственно что написал метод
>>>
, чтобы типа ставить точку в конце. Ну и K
-комбинатор, я вообще не понимаю, как люди без него программируют.def K[T, U](t: => T) = (any: U) => t implicit class MyFuture[T](f: Future[T]) { def >>>(op: T => Unit): Unit = f.onComplete(_.foreach(op)) }
Вот в этом кусочеке я соединяю последовательно несколько фьючерсов, потом в конце закрываю лавочку.
def f4: Future[Done] = { val all = FileIO.fromPath(factorialPath) val numbersBS = all.via(Framing.delimiter(ByteString("\n"), Int.MaxValue)) val numbers = numbersBS map (_.utf8String) numbers.runWith(Sink.foreach(s => println(s"<<$s>>"))) } (f1 flatMap K(f2) flatMap K(f3) flatMap K(f4)) >>> K(system.terminate())
Здесь
f4
читает файл, режет его на строки, и выдает на консоль каждую строку.Ну это к примеру.
Причем, похоже, что flatMap тут у меня зря, надо соединять будет не фьючерсы, а элементы потока.
Ну я просто типа балуюсь еще пока.
Scala Future[T] notes
Apr. 4th, 2018 04:53 pmtf: Future[T] =...
, and two functions, f: T => U
and g: U => V
We can produce
vf: Future[V] = tf map f map g
- same as vf: Future[V] = tf map (f andThen g)
Now, having
fp: PartialFunction[T, U]
and gp: PartialFunction[U, V]
,we can run
tf1: Future[T] = tf andThen fp andThen gp
- these partial functions will be called on the value that tf produces, with no outside effect - only side effects happen. "composition" waits for fp
before calling gp
.yet another future operation, onComplete, works like this: having
f: Try[T] => U
, the call tf onComplete f
will call f
even if the future ended with an error; the result of tf onComplete f
is of type Unit
.Also, if your function
f
produces a Future
, you will need to use flatMap
.scala posiciones en Màlaga
Jan. 22nd, 2018 03:21 pm
En la actualidad tenemos abierto dos procesos uno para Data Architec y otro para Technical Architec
Condiciones de la oferta:
.- Competitive Salary
PTG Benefits + relocation covered
Benefit Band | Notice Period | Private Health | Holiday | Sick Pay Entitlement | On Target Bonus | Relocation (Optional) |
PTG Professional / Technical
| 3 months |
Whole family (premium coverage) | 25 plus public holidays | 14 wks full / 14 wks ½ pay after 5 years
| 30% cash | Yes |
из таксистов в программисты
Dec. 26th, 2017 10:49 am"what do scala programmers think about c#
Dec. 7th, 2017 03:10 pmI don’t think I’m entitled to speak for all Scala programmers, but I know some.
So, in general, C# is pretty nice. But it’s so ancient. First, it’s not community supported. You cannot expect somebody coming up with C#Z, or Cats#, or Spark# - Microsoft is an obstacle to doing anything good for the community, I guess. I may be wrong.
And the language, of course, it’s awkward, compared to Scala (and, more and more, compared to Java, too).
It would be nice to hear other opinions, so I’m reposting it on twitter.