Fork me on GitHub
#off-topic
<
2017-10-30
>
fellshard01:10:20

Scala has explicit rules for it iirc, depending on which symbol a given operator starts or ends with

fellshard01:10:29

Which seems kinda hellish to me

qqq02:10:17

Anyone here live in an RV by choice? I'd like to DM you about programming from an RV / doing remote work.

eggsyntax23:10:28

I used to, although it wasn't a going-places RV, more just an inexpensive form of tiny/alternative housing.

seancorfield04:10:13

@qqq Surely that's just a matter of having a reasonably high bandwidth 'net connection on the road?

seancorfield04:10:37

Or at least, regular places/times where you can get online with high bandwidth?

Sebastian12:10:48

Hi everybody

jmayaalv16:10:27

is anybody using Ergodox with emacs ? trying to find inspiration for my configuration.

jjttjj17:10:57

maybe a dumb programming question, but if you're dealing with epoch days (days since unix epoch) is it an ok programming practice to do normal arithmetic for adding days or should I stick to using real date apis (in this case java.time). in other words, if i need an epoch day that's 45 days from today can I just add 45 to the current epoch day or should i convert to LocalDate and use LocalDate/plusDays to add days (I'm leaning towards the latter, more involved method)

dpsutton17:10:56

do you care about leap days sneaking into the computation?

dpsutton17:10:23

ie, if you forgot about feb 29 sometimes would it be fatal to your logic?

jjttjj17:10:40

would leap year already be accounted for with epoch-days though? like if feb 28th is epoch-day 10,000 on a leap year and i add 2, wouldn't I still get march 1st as epoch day 10,002?

jjttjj17:10:15

(i guess the confusingness of all these edge cases is a good reason to just stick to date-specific arithmetic)

dpsutton17:10:35

if you know that when you are getting the date for that day that the february of that year had 29 days

chris17:10:39

use a date lib

chris17:10:55

what happens when a day doesn't have 86,400 seconds, for example

chris17:10:01

(or whatever it is)

jjttjj17:10:11

gotcha will do, thanks

borkdude19:10:17

xslt question: how can I introduce a scope like, from here I select foo and then I can do <xsl:value-of select="bar"> for <foo><bar></bar></foo>, so I don’t have to write foo/bar?

borkdude19:10:31

I used a for-each

noisesmith19:10:46

which for-each is that? d’oh, of course, you mean the xsl:for-each in xslt

chris19:10:21

so <xsl:value-of select="../bar">

chris19:10:55

actually, nevermind, I misunderstood the question

chris20:10:07

does selecting bar in that context not work?

chris20:10:14

it seems to me like it would work

borkdude20:10:36

> does selecting bar in that context not work? how would I do that without for-each? I basically want for-each but for a single element

chris20:10:20

do you have a sample of your xml file and the ideal output? I don't really understand what you're asking for (which is likely because of my unfamiliarity with xslts and not your lack of explanation)

borkdude20:10:29

well, the real output is a bit involved, but never mind, for-each works 😉

borkdude20:10:54

I had this structure:

<foo>
<bar><baz><inner1><elt1>1</elt1><elt2>1</elt2></inner1></baz></bar>
<bar><baz><inner2><elt1>2</elt1><elt2>2</elt2></inner2></baz></bar>
</foo>
where I had to select either inner1 or inner2 and then the same things under that:
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
      <xsl:for-each select="foo/bar/baz">
        <xsl:for-each select="inner1|inner2">
        <tr>
          <td><xsl:value-of select="elt1"/></td>
          <td><xsl:value-of select="elt2"/></td>
        </tr>
     </xsl:for-each>
      </xsl:for-each>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
I guess for-each does exactly what I want and the fact that it can select multiple or just one doesn’t matter

mobileink18:10:47

the xsltish way to do it is to use additional templates instead of for-each.

flowthing19:10:19

Yep, you'll definitely want to do something like this instead of using xsl:for-each:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates select="foo/bar/baz/*"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="inner1 | inner2">
    <tr>
      <td>
        <xsl:value-of select="elt1"/>
      </td>
      <td>
        <xsl:value-of select="elt2"/>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>

flowthing19:10:03

Or <xsl:apply-templates select="foo/bar/baz/inner1 | foo/bar/baz/inner2"/> if you want to be more explicit.

mobileink19:10:25

yeah. i forget the default rules but you could take it all the way to template match="elt1" etc.

mobileink19:10:39

so you don't need select.

mobileink19:10:17

<xsl:template match="elt1"> <td> <xsl:apply-templates/> </td> </xsl:template> etc.

borkdude19:10:59

Yeah, cool, but these elements are not namespaced, so this could easily lead to name clashes I think?

mobileink20:10:52

sure, but xsl handles namespaces very well. easy to namespace them if need be.

mobileink20:10:02

anyway, same applies to using for-each, select, etc. you're namespaced or you're not. i recommend always using namespaces, it's easy.

flowthing06:11:52

You can also use a more specific match pattern, like <xsl:template match="foo/bar/baz/inner1"/>.