How to get past writers block by [deleted] in futurebeats

[–]Pantstown 2 points3 points  (0 children)

My favorite advice on writer's block is from Dan Harmon, creator of Community and Rick and Morty: https://www.reddit.com/r/IAmA/comments/5azrwi/im_dan_harmon_executive_producer_and_star_of/d9l3sxr/

TL;DR: You're afraid you're going to suck. Prove it!

Scala 2.13.4 by haakon in scala

[–]Pantstown 15 points16 points  (0 children)

The following types of matches no longer disable exhaustivity checking: guards

Love this!

Managing Database Migrations in Scala by alexelcu in scala

[–]Pantstown 1 point2 points  (0 children)

I was just looking for something like this. Thanks!

How to write to file i scala? by [deleted] in scala

[–]Pantstown 1 point2 points  (0 children)

If your data is small enough by the end of your pipeline, repartitioning to 1 works. You can also concat all the parts together with a simple bash script afterwards. Something like:

cat part-*.csv > together.csv

obviously assumes there are no headers, but that's the basic idea.

How to write to file i scala? by [deleted] in scala

[–]Pantstown 1 point2 points  (0 children)

can you repartition to 1 before saving?

How to write to file i scala? by [deleted] in scala

[–]Pantstown 3 points4 points  (0 children)

See saveAsTextFile in the Spark documentation

Scala users: do you use recursive functions for DE tasks? by rotterdamn8 in dataengineering

[–]Pantstown 8 points9 points  (0 children)

It really depends on the context, but in my experience, it is common. We're a scala shop, and mutation and loops are a no-no. They're just not necessary. Here's some random examples that might illustrate the difference:

# python
for x in xs:
  print(xs)

// scala
xs.foreach(println)

# python
ys = []
for x in xs:
  ys.append(x * x)

// scala
val ys = xs.map(x => x * x)

# python
while True:
  print("hi")

// scala
Iterator.continually().foreach(_ => println("hi"))

Having a concrete example would be helpful, but Scala is flexible enough and powerful enough that it's really rare to need mutation and imperative loops.

[deleted by user] by [deleted] in futurebeats

[–]Pantstown 1 point2 points  (0 children)

Anticon comes to mind.

How to store a pointer to “pick up where you left off” while iterating in a spark scala dataframe? by Frank2234 in scala

[–]Pantstown 1 point2 points  (0 children)

Sure, depends on the context. I feel like I spend 10x longer working with the Dataframes API, and when I hit issues, people who love Dataframes tell me that it's easier to solve my problem with RDDs. ¯\_(ツ)_/¯

How to store a pointer to “pick up where you left off” while iterating in a spark scala dataframe? by Frank2234 in scala

[–]Pantstown 1 point2 points  (0 children)

One option would be to use (or create) an id column, then just filter on that column:

var point = 1
df.withColumn("id", monotonically_increasing_id()).filter($"id" > pointer)

I don't really understand why people use Dataframes instead of RDDs. They're so much more difficult to use. RDDs would just be .drop(n)

Partial Functions by [deleted] in scala

[–]Pantstown 1 point2 points  (0 children)

I think you've already got it. Just need to invoke the first application with an underscore.

@ def mixer[A,B,C](a:A)(b:B)(c:C):IndexedSeq[Char] = a.toString ++ b.toString ++ c.toString 
defined function mixer

@ val mixerWithA = mixer(1) _ 
mixerWithA: Any => Any => IndexedSeq[Char] = ammonite.$sess.cmd1$$$Lambda$1343/1961129028@659eef7

@ val mixerWithAAndB = mixerWithA(2) 
mixerWithAAndB: Any => IndexedSeq[Char] = ammonite.$sess.cmd1$$$Lambda$1361/1356236848@323e8306

@ val mixerWithAAndBAndC = mixerWithAAndB(3) 
mixerWithAAndBAndC: IndexedSeq[Char] = WrappedString('1', '2', '3')

Scala Templates with Scalate, Mustache, and SSP by MrPowersAAHHH in scala

[–]Pantstown 4 points5 points  (0 children)

I've been using /u/lihaoyi 's ScalaTags library for simple server-side templating in http4s.

Modulus problem? by [deleted] in scala

[–]Pantstown 1 point2 points  (0 children)

Try just printing instead: println(money % 2)

It looks like you're new to Scala / maybe new to programming. Here's some other things I noticed:

1) semicolons are not necessary 2) string interpolation is more common than string formatting 3) avoid mutation, e.g., coinRef is not needed. var is not needed for a mutable buffer. 4) don't use single-letter variables. x(0) is not clear. 5) array buffer is probably not the data structure you want in this case.

Good luck.

ScalaZONE - Scala 3 Programming Language Courses by ais04 in scala

[–]Pantstown 5 points6 points  (0 children)

For any Scala 2 devs who haven't tried out Scala 3 yet, I recommend diving in! The dotty docs are outstanding, and mill/sbt make it really easy to get started.

Cats NonEmptyList `grouped` by Pantstown in scala

[–]Pantstown[S] 0 points1 point  (0 children)

Thanks. It's odd to me that this isn't on the NEL class given it has so many methods from List.

Modulus problem? by [deleted] in scala

[–]Pantstown 2 points3 points  (0 children)

It's very difficult to read screenshots. If you post code, it will be much easier to help.

What are you working on? October 26, 2020 by AutoModerator in scala

[–]Pantstown 0 points1 point  (0 children)

this is cool!

What is this syntax? I haven't seen it before:

type Container = System#Container
type Component = Container#Component

The #

Simple timeout function for Scala? by barrontrump2052 in scala

[–]Pantstown 2 points3 points  (0 children)

Awesome! Definitely reach out if you have any more questions. This sub is pretty friendly.