Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. I'm new to using Ruby and this tickled me pink

I'm new to using Ruby and this tickled me pink

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
68 Posts 47 Posters 2 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R [email protected]

    timedelta marks time in days, seconds, and microseconds. It doesn't take leap years into account because the concept of years is irrelevant to timedelta. If you need to account for leap years, you need a different API.

    R This user is from outside of this forum
    R This user is from outside of this forum
    [email protected]
    wrote last edited by
    #54

    You can subtract two dates and get the exact time difference.

    1 Reply Last reply
    0
    • cm0002@lemmy.worldC [email protected]
      This post did not contain any content.
      U This user is from outside of this forum
      U This user is from outside of this forum
      [email protected]
      wrote last edited by
      #55

      I miss Ruby DSLs so much. Python is bland. It's on purpose, I know and even appreciate it.

      Yet I feel like Ruby syntax magic compared to Python blandness is like comparing a steaming plate of beautiful aromatic curry to plain rice.

      1 Reply Last reply
      3
      • A [email protected]

        Python is more system agnostic though.

        V This user is from outside of this forum
        V This user is from outside of this forum
        [email protected]
        wrote last edited by
        #56

        Lucky for me I control all the machines I write scripts for. So far...

        1 Reply Last reply
        0
        • E [email protected]

          LLM is saying this is a feature of Rails and not particularly Ruby.

          I was surprised Python didn’t have a years parameter but learned about

          relativedelta(years=10)

          noxypaws@pawb.socialN This user is from outside of this forum
          noxypaws@pawb.socialN This user is from outside of this forum
          [email protected]
          wrote last edited by
          #57

          LLM is saying...

          Stop. Nothing at all past those three words is worth a damn.

          E 1 Reply Last reply
          0
          • noxypaws@pawb.socialN [email protected]

            LLM is saying...

            Stop. Nothing at all past those three words is worth a damn.

            E This user is from outside of this forum
            E This user is from outside of this forum
            [email protected]
            wrote last edited by
            #58

            What is the purpose of this comment.

            noxypaws@pawb.socialN 1 Reply Last reply
            0
            • R [email protected]

              Obligatory Tom Scott video

              alaknar@sopuli.xyzA This user is from outside of this forum
              alaknar@sopuli.xyzA This user is from outside of this forum
              [email protected]
              wrote last edited by
              #59

              This is exactly why I love PowerShell.

              Need the [DateTime] object from 10 years ago? No biggie, just chuck (Get-Date).AddYears(-10) down your console.

              Need it in a specific timezone? That one's trickier, but since PowerShell can do .Net, run this:

              $TargetDateTime = (Get-Date).AddYears(-10)
              $TargetTimeZone = "India Standard Time"
              $tz = [TimeZoneInfo]::FindSystemTimeZoneById($TargetTimeZone)
              $utcOffset = $tz.GetUtcOffset($TargetDateTime)
              [DateTimeOffset]::new($TargetDateTime.Ticks, $utcOffset)
              

              And you get a DateTimeOffset object, which is this beauty:

              DateTime           : 25/08/2015 23:15:14
              UtcDateTime        : 25/08/2015 17:45:14
              LocalDateTime      : 25/08/2015 19:45:14
              Date               : 25/08/2015 00:00:00
              Day                : 25
              DayOfWeek          : Tuesday
              DayOfYear          : 237
              Hour               : 23
              Millisecond        : 421
              Microsecond        : 428
              Nanosecond         : 600
              Minute             : 15
              Month              : 8
              Offset             : 05:30:00
              TotalOffsetMinutes : 330
              Second             : 14
              Ticks              : 635761413144214286
              UtcTicks           : 635761215144214286
              TimeOfDay          : 23:15:14.4214286
              Year               : 2015
              

              DateTime is the time in your target timezone, UtcDateTime is, well, the UTC time, and LocalDateTime is the time on host you ran the commands on.

              1 Reply Last reply
              0
              • E [email protected]

                What is the purpose of this comment.

                noxypaws@pawb.socialN This user is from outside of this forum
                noxypaws@pawb.socialN This user is from outside of this forum
                [email protected]
                wrote last edited by
                #60

                You didn't seem to be ashamed of admitting to asking an LLM a question as if it was helpful, wise, or respectable for you to have done. You should be.

                E 1 Reply Last reply
                0
                • noxypaws@pawb.socialN [email protected]

                  You didn't seem to be ashamed of admitting to asking an LLM a question as if it was helpful, wise, or respectable for you to have done. You should be.

                  E This user is from outside of this forum
                  E This user is from outside of this forum
                  [email protected]
                  wrote last edited by
                  #61

                  This is a poor perspective to have on things towards a stranger on the internet. I hope you’re just having a bad day and that things get better.

                  1 Reply Last reply
                  0
                  • M [email protected]

                    People still use ruby?

                    sinthesis@lemmy.todayS This user is from outside of this forum
                    sinthesis@lemmy.todayS This user is from outside of this forum
                    [email protected]
                    wrote last edited by
                    #62

                    You probably use it everyday and didn't know it https://github.blog/engineering/architecture-optimization/building-github-with-ruby-and-rails/

                    M 1 Reply Last reply
                    1
                    • cm0002@lemmy.worldC [email protected]
                      This post did not contain any content.
                      A This user is from outside of this forum
                      A This user is from outside of this forum
                      [email protected]
                      wrote last edited by [email protected]
                      #63

                      There's two of these threads?! Well ok here's the same comment.

                      10.years.ago
                      On.a.cold.dark.night
                      There.was.someone.killed
                      'Neath.the.town.hall.lights
                      There.were.few.at.the.scene
                      Though.they.all.agreed
                      That.the.slayer.who.ran
                      Looked.a.lot.like.me
                      
                      1 Reply Last reply
                      0
                      • supervisor194@lemmy.worldS [email protected]

                        ahahaha oh come on, the comment was clearly a joke. To be honest, I'd be far more interested in gothly serious sam on the left.

                        A This user is from outside of this forum
                        A This user is from outside of this forum
                        [email protected]
                        wrote last edited by [email protected]
                        #64

                        Can't see the comment but judging by the uname you're right, that's Frank Reynolds' fake name from It's Always Sunny, Mantis Toboggan M.D. lmao. I'd wager 95% of what that person says is at least intended to be a joke/satirical/etc.

                        1 Reply Last reply
                        1
                        • W [email protected]

                          The comparison is somewhat awkward, because the rails example presumably produces a date, while the python one is referring to an interval of time.
                          Just from the meme it's not obvious which was the actual intended use, so labeling either as inaccurate requires us to make assumptions.

                          Personally, the concept of "10 years ago" is a bit nebulous to me. If today is February 29th, is ten years ago March 1st? Doesn't seem right. Or particularly useful.

                          N This user is from outside of this forum
                          N This user is from outside of this forum
                          [email protected]
                          wrote last edited by
                          #65

                          Ruby should add 10.years.ago.today

                          1 Reply Last reply
                          0
                          • R [email protected]

                            timedelta marks time in days, seconds, and microseconds. It doesn't take leap years into account because the concept of years is irrelevant to timedelta. If you need to account for leap years, you need a different API.

                            N This user is from outside of this forum
                            N This user is from outside of this forum
                            [email protected]
                            wrote last edited by
                            #66

                            365.25*10 would at least get you closer.

                            1 Reply Last reply
                            0
                            • M [email protected]

                              Yeah its a rails only thing. Rubys biggest issue is its much too intelligent for its own good. Its implicit rather than pythons explicit. Most of the time. That and it's hard to find out where Ruby starts and rails ends.

                              That being said I made a ton of good money on rails back about 15 or so years ago. Still excellent for starting out.

                              T This user is from outside of this forum
                              T This user is from outside of this forum
                              [email protected]
                              wrote last edited by
                              #67

                              Ruby’s biggest issue is rails. Ruby is such a beautiful and highly functional language and yet everyone’s experience with it is rails’ horrific metaprogramming magic. I’ve had numerous people tell me they hate Ruby, and yet when I dig deeper I find out that they don’t actually understand where Ruby ends and rails starts and all of their problems lies on rails side. The majority of people I’ve shown that have come to actually like Ruby where they hated it before.

                              1 Reply Last reply
                              0
                              • sinthesis@lemmy.todayS [email protected]

                                You probably use it everyday and didn't know it https://github.blog/engineering/architecture-optimization/building-github-with-ruby-and-rails/

                                M This user is from outside of this forum
                                M This user is from outside of this forum
                                [email protected]
                                wrote last edited by
                                #68

                                That explains a lot about how GitHub works… or doesn’t.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups