Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue synchronize #1312
vijendra singh
@viju0731_twitter
Okay
Ólafur Páll Geirsson
@olafurpg
@viju0731_twitter java.text.SimpleDateFormat can be used to parse dates from strings https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
java.util.concurrent.TimeUnit can be used to convert between ms/s/days/... https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html
For example
@ java.util.concurrent.TimeUnit.DAYS.toSeconds(7)
res2: Long = 604800L

@ 7 * 24 * 60 * 60
res3: Int = 604800
Vasily Kirichenko
@vasily-kirichenko
What's the simplest way to serialize any object to json? Say, I have a java library which provides a complex type with lots of properties like getTitle, getDetails.getPrice, etc. I need to store it's representation in the DB, without any need to deserialize it later.
Dominic Egger
@GrafBlutwurst
probably write it to a caseclass and use json lib of your choice. that'll decouple serialization from any and all java weirdness you might encounter.
that'd require to write a function from the java thing to your caseclass but that might prove much safer than e. g. using reflection (depending on the pieces of java)
vijendra singh
@viju0731_twitter
@olafurpg Thanks for input
if i have my date string val sTime= "2018-10-15"
how do i convert it into unix timestamp
Vasily Kirichenko
@vasily-kirichenko
@GrafBlutwurst it's a lot of work :( In .NET any json lib can do it automatically (via reflection).
Dominic Egger
@GrafBlutwurst
well you could do the same here. i just shy away from it because it can be very hard to get right (nullness, non serializable fields etc)
you could use any java reflection based json lib and it'll probably work. as for scala, many json libs work by deriving a decoder/encoder at compiletime using the case class definition. it pretty robust due to it failing at compile time rather than runtimw if something is not encodable, like a socket
Li Haoyi
@lihaoyi
if you never need to deserialize your data later, | /dev/null is high-performance web-scale json serialization :P
if you want java-style serialization of java objects and you still need to deserialize them later somehow, java libraries like jackson work great
"great"
Vasily Kirichenko
@vasily-kirichenko
ok, thanks, will try jackson. The data is needed to look at "raw data" in case of accidents or to spot a bug.
Peter Aaser
@PeterAaser
Anyone here that can help mo out with some very basic parsing questions?
Vasily Kirichenko
@vasily-kirichenko
image.png
any hope to make it compilable?
Or I need an Error intermediate case class?
Basile Baranetskyy
@bbb3
@vasily-kirichenko two catch independants does not work?
Peter Aaser
@PeterAaser
T: TotalFailure
me_irl
Dominic Egger
@GrafBlutwurst
@PeterAaser shoot
Christopher Davenport
@ChristopherDavenport
@PeterAaser what are you using?
Peter Aaser
@PeterAaser
Atto
It's all rather basic
I want to parse RISC-V ops
They look like this:
Dominic Egger
@GrafBlutwurst
welp I don't know atto. but I'll still be a rubberduck
Peter Aaser
@PeterAaser
    addi    sp,sp,-32
    sw    ra,28(sp)
    sw    s0,24(sp)
    addi    s0,sp,32
    li    a5,2
    sb    a5,-17(s0)
    lbu    a5,-17(s0)
    mv    a0,a5
    call    isRMS
    mv    a5,a0
    beqz    a5,.L9
lol, pretty colorful
Basile Baranetskyy
@bbb3
I mean two cases:
case MyFirstException(e, ) => println(e)
case MySecondException(e,
)=> println(e)
Peter Aaser
@PeterAaser
I'm pretty much 100% green when it comes to parsing, but here's what I've thought so far
First, instructions don't rely on each other, which is good
one exception is labels, but I handle that in a later pass
Christopher Davenport
@ChristopherDavenport
Ok. I follow so far.
Peter Aaser
@PeterAaser
so I should first make a parser for the opcode (mv, li, beqz et al) which then decides how I should parse the remaining part of the OP
So some function String => Parser[AsmOP]
Here's where I'm getting out of my depth though
In this case a label is a valid AsmOP
Christopher Davenport
@ChristopherDavenport
That would just be flatMap.
Peter Aaser
@PeterAaser
yeah, true
I guess I need a lookuptable for ops
String => Option[?? Parser[OP?]]
Christopher Davenport
@ChristopherDavenport
Or a typeclass for extraction.
Peter Aaser
@PeterAaser
question marks added for confusion pinpointing
Christopher Davenport
@ChristopherDavenport
Also parse it as an option/either, not option of a parser.
As the latter is less compositional.