havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.3, 2.5.5, 2.7.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
Technodrome has joined #ruby
<ellcs> >># 1 + 1
<ruby[bot]> ellcs: # => nil (https://eval.in/1119455)
<ellcs> >> 1 + 1
<ruby[bot]> ellcs: # => 2 (https://eval.in/1119456)
<ellcs> #{asdf}
<ellcs> >> #{asdf}
<ruby[bot]> ellcs: # => nil (https://eval.in/1119457)
rprimus has quit [Remote host closed the connection]
<ellcs> can someone explain why this is not an error?
<ellcs> >> #{asdf}
<leftylink> I now found that even raising in other ways would result in the same
<leftylink> &>> "#{1 / 0}"
<rubydoc> stderr: -e:2:in `/': divided by 0 (ZeroDivisionError) (https://carc.in/#/r/75l0)
ebbflowgo has joined #ruby
<leftylink> note that #{asdf} is not a string interpolation if it's not in a string.
<al2o3-cr> ellcs: it's a comment
znz_jp has quit [Quit: kill -QUIT $$]
znz_jp has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
cadeskywalker has quit [Ping timeout: 244 seconds]
cadeskywalker has joined #ruby
ebbflowgo has quit [Quit: ebbflowgo]
fphilipe_ has joined #ruby
gix has quit [Ping timeout: 248 seconds]
fphilipe has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
SeepingN has joined #ruby
tranch has joined #ruby
fphilipe has quit [Ping timeout: 248 seconds]
AJA4350 has joined #ruby
Jello_Raptor has quit [Remote host closed the connection]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
tranch has quit [Quit: tranch]
codefriar has joined #ruby
Jello_Raptor has joined #ruby
agent_white has joined #ruby
uplime is now known as ^
leitz has quit [Quit: Leaving]
tranch has joined #ruby
agent_white has quit [Ping timeout: 272 seconds]
agent_white has joined #ruby
ebbflowgo has joined #ruby
ebbflowgo has quit [Quit: ebbflowgo]
ebbflowgo has joined #ruby
ebbflowgo has quit [Client Quit]
ebbflowgo has joined #ruby
ebbflowgo has quit [Client Quit]
yokel has quit [Read error: Connection reset by peer]
exmortus has joined #ruby
yokel has joined #ruby
staticx has quit [Ping timeout: 272 seconds]
<brool> why is sinatra's docs trash
<havenwood> brool: [W]hy [are] [S]inatra's docs trash?
<havenwood> brool: Writing is hard, I guess?
<brool> 2hadr
agent_white has quit [Quit: bbl]
fphilipe has joined #ruby
<havenwood> brool: Having Sinatra trouble?
<brool> not really, i'm just lamenting that i wasn't able to find a good cohesive rundown of the API and have to read through sections of the manual like the README or the config settings page and hope it has what i'm looking for
<havenwood> brool: You might give Roda or Hanami a try. Those are both great options along the same lines that are coded well and well documented.
ogres has joined #ruby
<havenwood> brool: Roda is more directly inspired by Sinatra.
AJA4350 has quit [Remote host closed the connection]
<havenwood> There're fewer books and such about Roda, since it's newer - but the code is easier to review.
<brool> interesting, will google
<havenwood> brool: http://roda.jeremyevans.net/
<havenwood> brool: Roda adds a routing tree and thread-safe cache on top of basic Rack functionality. That's provided by this one file: https://github.com/jeremyevans/roda/blob/master/lib/roda.rb
<havenwood> brool: Then you can cherry pick plugins to add additional functionality that you need to compose your framework. These are the base plugins: https://github.com/jeremyevans/roda/tree/master/lib/roda/plugins
<havenwood> brool: That's it!
<havenwood> It's very nicely done.
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
codefriar has joined #ruby
codefriar has quit [Client Quit]
fphilipe has quit [Ping timeout: 272 seconds]
ebbflowgo has joined #ruby
Alison`8 has quit [Quit: Leaving]
ebbflowgo has quit [Client Quit]
ebbflowgo has joined #ruby
ebbflowgo has quit [Client Quit]
Alison`8 has joined #ruby
redlegion has quit [Quit: The Lounge - https://thelounge.chat]
ellcs has quit [Ping timeout: 252 seconds]
redlegion has joined #ruby
Alison`8 has quit [Quit: Leaving]
Alison`8 has joined #ruby
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
ellcs has joined #ruby
ebbflowgo has joined #ruby
ebbflowgo has quit [Quit: ebbflowgo]
podlech has joined #ruby
ebbflowgo has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Pixi_ has quit [Quit: Pixi_]
Xiti has joined #ruby
podlech has quit [Quit: WeeChat 2.5-dev]
brool has quit [Ping timeout: 252 seconds]
zapata has quit [Quit: WeeChat 2.5]
fphilipe has joined #ruby
queip has quit [Ping timeout: 245 seconds]
ebbflowgo has quit [Quit: ebbflowgo]
queip has joined #ruby
dellavg_ has joined #ruby
crankharder has quit [Quit: leaving]
crankharder has joined #ruby
fphilipe has quit [Ping timeout: 245 seconds]
crankharder has quit [Client Quit]
ogres has quit [Quit: Connection closed for inactivity]
tranch has quit [Quit: tranch]
agrecascino has quit [Ping timeout: 245 seconds]
crankharder has joined #ruby
fphilipe has joined #ruby
agrecascino has joined #ruby
crankharder has quit [Remote host closed the connection]
fphilipe has quit [Ping timeout: 268 seconds]
crankharder has joined #ruby
crankharder has quit [Ping timeout: 268 seconds]
<ellcs> al2o3-cr: lol
rippa has joined #ruby
amrx has joined #ruby
dellavg_ has quit [Ping timeout: 272 seconds]
crankharder has joined #ruby
crankharder has quit [Client Quit]
crankharder has joined #ruby
SegFaultAX has quit [Quit: ZNC - http://znc.in]
SolarAquarion has quit [Ping timeout: 252 seconds]
ropeney has quit [Ping timeout: 252 seconds]
ropeney has joined #ruby
lord4163 has quit [Excess Flood]
ellcs has quit [Ping timeout: 264 seconds]
uranoss has quit [Quit: Connection closed for inactivity]
lord4163 has joined #ruby
fphilipe has joined #ruby
tranch has joined #ruby
conta has joined #ruby
Alison`8 has quit [Quit: Leaving]
Alison`8 has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Xiti has quit [Ping timeout: 244 seconds]
tranch has quit [Quit: tranch]
Xiti has joined #ruby
esrse has joined #ruby
ellcs has joined #ruby
xco has joined #ruby
tranch has joined #ruby
kyrylo has joined #ruby
sauvin has joined #ruby
sauvin has quit [Max SendQ exceeded]
Inline has quit [Quit: Leaving]
sauvin has joined #ruby
amrx has quit []
m_antis has quit [Quit: m_antis]
conta has quit [Ping timeout: 258 seconds]
Furai has quit [Quit: WeeChat 2.5]
Furai has joined #ruby
conta has joined #ruby
sandstrom has joined #ruby
hiroaki has quit [Ping timeout: 245 seconds]
fphilipe has quit [Ping timeout: 252 seconds]
vondruch has joined #ruby
exmortus has quit [Remote host closed the connection]
kyrylo has quit [Quit: Textual IRC Client: www.textualapp.com]
exmortus has joined #ruby
kyrylo has joined #ruby
coreyja has quit [Read error: Connection reset by peer]
supergeek[m] has quit [Read error: Connection reset by peer]
neovalis[m] has quit [Write error: Connection reset by peer]
turt2live has quit [Write error: Connection reset by peer]
sepp2k has quit [Remote host closed the connection]
aecepoglu[m] has quit [Write error: Connection reset by peer]
bastilian has quit [Read error: Connection reset by peer]
fphilipe has joined #ruby
mayurvpatil has joined #ruby
irdr has quit [Remote host closed the connection]
irdr has joined #ruby
ropeney_ has joined #ruby
Seance[m] has quit [Ping timeout: 264 seconds]
ropeney has quit [Ping timeout: 248 seconds]
yokel has quit [Read error: Connection reset by peer]
DriesS has joined #ruby
<DriesS> Hi, I want to get out the sum of the requestCount keys, how can I do this? https://gist.github.com/DriesS/166166d49af0c21031da0bfdbd644c99
yokel has joined #ruby
aupadhye has joined #ruby
mayurvpatil has quit [Ping timeout: 268 seconds]
mayurvpatil has joined #ruby
schne1der has joined #ruby
<leftylink> &ri Enumerable#sum # would probably be helpful in this task.
<rubydoc> https://ruby-doc.org/core-2.6/Enumerable.html#method-i-sum, # would probably be helpful in this task.
TomyWork has joined #ruby
amrx has joined #ruby
deepreds1 has joined #ruby
turt2live has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
mayurvpatil has joined #ruby
jefffrails35 has joined #ruby
jefffrails35 has quit [Client Quit]
DriesS has quit [Quit: DriesS]
sandstrom has quit [Quit: My computer has gone to sleep.]
conta has quit [Ping timeout: 252 seconds]
deepreds1 has quit [Ping timeout: 264 seconds]
mikecmpbll has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mayurvpatil has quit [Ping timeout: 268 seconds]
mayurvpatil has joined #ruby
sandstrom has joined #ruby
mn3m has joined #ruby
amrx has quit []
mayurvpatil has quit [Quit: This computer has gone to sleep]
deepreds1 has joined #ruby
queip has quit [Ping timeout: 252 seconds]
mayurvpatil has joined #ruby
queip has joined #ruby
powerbit has joined #ruby
mn3m has quit [Ping timeout: 258 seconds]
ur5us has joined #ruby
nonamme has joined #ruby
ur5us has quit [Ping timeout: 276 seconds]
aecepoglu[m] has joined #ruby
code_zombie has quit [Quit: Leaving]
Alison`8 has quit [Quit: Leaving]
themsay has quit [Ping timeout: 246 seconds]
conta has joined #ruby
conta has quit [Remote host closed the connection]
conta has joined #ruby
Alison`8 has joined #ruby
_whitelogger has joined #ruby
doodlebug has joined #ruby
themsay has joined #ruby
amrx has joined #ruby
Technodrome has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
mayurvpatil has joined #ruby
tranch has left #ruby [#ruby]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
conta has quit [Ping timeout: 268 seconds]
queip has quit [Ping timeout: 248 seconds]
mn3m has joined #ruby
conta has joined #ruby
themsay has quit [Read error: Connection reset by peer]
themsay has joined #ruby
mn3m has quit [Ping timeout: 248 seconds]
dionysus69 has quit [Ping timeout: 248 seconds]
queip has joined #ruby
NL3limin4t0r_afk is now known as NL3limin4t0r
doodlebug has quit [Ping timeout: 272 seconds]
agent_white has joined #ruby
leitz has joined #ruby
Swyper has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
Swyper has quit [Remote host closed the connection]
fritzroy15 has joined #ruby
doodlebug has joined #ruby
queip has quit [Ping timeout: 246 seconds]
<fritzroy15> hello, I'm trying to integrate the datadog apm into a ruby app ( coded by someone else ); if I run "ruby app.rb" it runs just fine on port 4567 and the traces get sent; however, if I do rackup app.rb, it works just fine on port 9292, but the traces no longer get sent; whats the difference?
mayurvpatil has joined #ruby
queip has joined #ruby
reber has joined #ruby
esrse has quit [Ping timeout: 272 seconds]
agent_white has quit [Quit: brb]
<fritzroy15> anybody alive in here? :)
aupadhye has quit [Ping timeout: 276 seconds]
<leitz> Alive, yes. Smart, not so much...
<leitz> Speaking for myself, anyway.
<leitz> Sounds like there's two different configs, based on the different ports. Is the trace another piece of the config that's different?
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4350 has joined #ruby
<fritzroy15> leitz hah, nobody is particularily smart on a friday
<fritzroy15> where would these configs be?
nonamme has quit [Quit: WeeChat 1.9.1]
<fritzroy15> ( mind you I'm a devops, not a dev, so go easy on me )
mayurvpatil has quit [Quit: This computer has gone to sleep]
aupadhye has joined #ruby
<fritzroy15> i tried grepping for 9292 to try and find something
<fritzroy15> but nothing came up, just a bunch of declarations, nothing like 'port=9292' in any config
nonamme has joined #ruby
Makku has joined #ruby
<Makku> Hi could anyone tell any 5 most important and notable changes in latest ruby
<Makku> What is the type of GC used
<Makku> What is the compiler used
haxx0r has quit [Ping timeout: 252 seconds]
<ytti> when is this work due?
noobineer has quit [Ping timeout: 276 seconds]
conta has quit [Ping timeout: 258 seconds]
ur5us has joined #ruby
ur5us has quit [Ping timeout: 250 seconds]
noobineer has joined #ruby
ebbflowgo has joined #ruby
Inline has joined #ruby
<al2o3-cr> &>> 192.step(0, -8).each_with_object('') { |b, s| s << (529835950419149496931706216147869793156292345183471361352057 >> b & 0xff) }
<rubydoc> # => "Thank Crunchy it's Friday" (https://carc.in/#/r/75mg)
BH23 has joined #ruby
jcalla has joined #ruby
codefriar has joined #ruby
queip has quit [Ping timeout: 246 seconds]
BH23 has quit [Ping timeout: 272 seconds]
Josse has joined #ruby
queip has joined #ruby
deepreds1 has quit [Ping timeout: 272 seconds]
aupadhye has quit [Ping timeout: 264 seconds]
Inline has quit [Ping timeout: 252 seconds]
Esa_ has joined #ruby
ebbflowgo has quit [Quit: ebbflowgo]
aupadhye has joined #ruby
rolandasb has joined #ruby
<balo> oooops sorry, wrong channel
queip has quit [Ping timeout: 258 seconds]
<balo> not advertisement, i promise :) but friday feeling is going strong already
<tweaks> al2o3-cr: heh
queip has joined #ruby
rippa has quit [Ping timeout: 258 seconds]
rolandasb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rapture has joined #ruby
rippa has joined #ruby
haxx0r has joined #ruby
orbyt_ has joined #ruby
krawchyk has joined #ruby
dviola has joined #ruby
theta8 has joined #ruby
<theta8> Anyone here use Watir? I'm working on a script and was trying to pass the browser window object to a method for re-use but it does not work. I'm curious what the scope issue is.
GodFather has joined #ruby
theta8 has quit [Quit: leaving]
joast has quit [Quit: Leaving.]
GodFather has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
doodlebug has quit [Ping timeout: 245 seconds]
ur5us has quit [Ping timeout: 276 seconds]
<NL3limin4t0r> Makku: The most notable changes are most often the new introduced features. Like Kernel#then, endless ranges, Enumerable#chain (or Enumerable#+) and the composition operator (<< and >> for Proc and Method).
<NL3limin4t0r> ^ Introduced in 2.6.0
tdy has quit [Remote host closed the connection]
sandstrom has quit [Remote host closed the connection]
dellavg_ has joined #ruby
chalkmonster has joined #ruby
<havenwood> Makku: Are you wondering about the differences between 2.5 and 2.6 of something broader?
TomyWork has quit [Remote host closed the connection]
Technodrome has joined #ruby
joast has joined #ruby
nonamme has quit [Remote host closed the connection]
<leitz> Important changes depends on your perspective. A lot of the stuff that's coming in is beyond me to understand or use, thus not important. Except that my #ruby friends think it is, so it is.
<leitz> As long as we're avoiding a JVM and keep moving away from $< type stuff, I'm pretty pleased.
<leitz> Though I do get tempted by Go now and again...
fphilipe has quit [Ping timeout: 268 seconds]
<NL3limin4t0r> "in latest ruby" so I assumed the latest version
dhollinger has joined #ruby
NL3limin4t0r is now known as NL3limin4t0r_afk
rprimus has joined #ruby
reber has quit [Remote host closed the connection]
chalkmonster has quit [Quit: WeeChat 2.5]
_whitelogger has joined #ruby
Inline has joined #ruby
dviola has quit [Quit: WeeChat 2.5]
fritzroy15 has quit [Remote host closed the connection]
dviola has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
aupadhye has quit [Quit: Leaving]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
dhollinger has quit [Quit: dhollinger]
manakanapa has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has quit [Quit: WeeChat 2.5]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
dviola has joined #ruby
orbyt_ has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
cthulchu_ has joined #ruby
chalkmonster has joined #ruby
yokel has quit [Remote host closed the connection]
yokel has joined #ruby
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> i need to build a ledger for accounting (deposits, trades, withdrawals etc). obviously i need to avoid all the rounding issues that `float` has. can i use `t.decimal(precision: 16, scale: 6)` and i'm save with rounding errors?
<haxx0r> ah, rails question :eyeroll:
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
pavelz has joined #ruby
<pavelz> hi i want to do: c,b = a.match(/(\d+),(\d+)/) but i get result only in the first var
<pavelz> and i doing something wrong
<leftylink> &ri String#match # as I recall, it only returns MatchData. If you want to extract items from the match data, try sending the MatchData the appropriate message that allows it to do so
<rubydoc> https://ruby-doc.org/core-2.6/String.html#method-i-match, # as I recall, it only returns MatchData. If you want to extract items from the match data, try sending the MatchData the appropriate message that allows it...
<leftylink> I am going purely off of memory, but perhaps it's something like
<leftylink> &ri MatchData#groups
<rubydoc> Found no entry that matches class MatchData instance method groups
<pavelz> neat.
<haxx0r> pavelz, isn't c an array?
<pavelz> captures seems to provied the result
<leftylink> oh, I see I was wrong and it was not groups.
<pavelz> hi i want to do: c,b = a.match(/(\d+),(\d+)/).caputres
<haxx0r> isn't it .flatten?
<leftylink> that is good that someone had a better memory than I did
<chalkmonster> haxx0r: there's gems with built in money classes for this sort of thing
<haxx0r> yeah, i know the money gem. but i feel it's not the best for a crypto exchange platform
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<chalkmonster> well, ultimately you'll either have to use that or roll your own Money class
<chalkmonster> that said, I have seen people use float for money in production and get away with it
<chalkmonster> mainly because the investors didn't know they'd hired incompetents
<chalkmonster> these are nodejs rockstars so, what'll you do
<chalkmonster> *shrug*
mikecmpbll has quit [Quit: inabit. zz.]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
comet23 has joined #ruby
<comet23> i don't understand how this type of recursion works
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<phaul> show an example of a recursion that's clear and we can try explaining how this is the same/different. Or tell us a bit more about what's confusing about this example.
<phaul> general rule : it doesn't really matter what it does, what matters is that it gets down to base case, so it terminates..
<haxx0r> it's counting down all the way and at the end it's counting together
<haxx0r> def lucas_number(n)
<haxx0r> then you see what it does internally
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> do it this way and you see how it's counting down with recursion
<haxx0r> and if you wanna see how deep the recursion goes, i'll show you how to do that
<comet23> phaul: i thought it ends at the last evaluation
<comet23> what i mean by that is
<comet23> lucas_number(n) will always equal 1 unless the input is 2
<comet23> i mean lucas_number(n - 1)
<comet23> so the way i think it works is not the way it actually works
<comet23> because lucas_number(n - 1) == 1 and lucas_number(n - 2) == 1 the answer should be 1 + 1 = 2
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
dhollinger has joined #ruby
<phaul> recursive expressions can go down to the base case and then bubble results using the return value of one level deeper in the summation of the one level up. That's basically how this works but Im not sure if my explanation helps..
<phaul> so it will reach lucas(1), and lucas(2) but then they will be added at lucas(3) and so on
<phaul> another way to look at this algorithm is: first you go all the way down in two binary trees where each node splits in two and then as subtrees with only two leafs are termintaing they become new leafs.
cthu| has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<phaul> if these explanations don't help then apologies, it's kind of hard to explain stuff over irc, and much easier too draw on a whiteboard
cthu| has quit [Max SendQ exceeded]
cthu| has joined #ruby
<leftylink> counterexample to the statement "because lucas_number(n - 1) == 1 and lucas_number(n - 2) == 1 the answer should be 1 + 1 = 2". no, see lucas(2). by line 4, lucas(2) is lucas(1) + lucas(0). by line 3, lucas(1) is 1. by line 2, lucas(0) is 2. therefore, lucas(2) is 2 + 1, which is 3. which is not 2
cthulchu_ has quit [Ping timeout: 268 seconds]
ebbflowgo has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
sauvin has quit [Ping timeout: 252 seconds]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
falconfox has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
orbyt_ has quit [Quit: Textual IRC Client: www.textualapp.com]
cthulchu_ has joined #ruby
queip has quit [Ping timeout: 244 seconds]
cthu| has quit [Ping timeout: 246 seconds]
leitz has quit [Quit: Leaving]
ur5us has joined #ruby
queip has joined #ruby
reaVer has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 276 seconds]
conta1 has joined #ruby
codefriar has quit [Ping timeout: 246 seconds]
conta1 has quit [Quit: conta1]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
queip has quit [Ping timeout: 268 seconds]
queip has joined #ruby
krawchyk has quit [Quit: krawchyk]
Hess has joined #ruby
Hess has quit [Client Quit]
<haxx0r> i want to generate generate unique identifiers like `AGBBL3W-ZKPXXL-JZFYWR` or `TAN5OL-RTLX2-4ELIEV` or `OPDTA6-VNN3X-E62FSR`. is there any possibility to do it based on a seed like the current processortime, so i don't need to recheck my database that thisn thing is unique, instead i can just trust that the seed will give me unique things?
codefriar has joined #ruby
yokel has quit [Read error: Connection reset by peer]
mniip has quit [Ping timeout: 608 seconds]
<leftylink> well you made me read https://www.callicoder.com/distributed-unique-id-sequence-number-generator/ . so thanks for stimulating learning with that question
yokel has joined #ruby
<leftylink> (well I just searched "unique id generation" on some search engine and got that article)
nonamme has joined #ruby
segy has quit [Ping timeout: 246 seconds]
<haxx0r> and now we do it how in ruby? :D
<havenwood> &>> require 'securerandom'; SecureRandom.uuid
<havenwood> haxx0r: ^
<rubydoc> # => "4dc0c0cc-c4c2-4b68-abb4-44ccca164cfa" (https://carc.in/#/r/75n4)
<haxx0r> that's not helping since it's horrible to index in database
<haxx0r> it's too big
<havenwood> haxx0r: That makes a fine UUID, for most DBs. ¯\_(ツ)_/¯
<havenwood> haxx0r: What DB?
<haxx0r> mysql. but you wanna make 25,000,000 records or more with huge uuids?
<havenwood> Yes.
<havenwood> These are unique. You can use fewer characters or smaller sets but you'll start to threaten collision.
<havenwood> haxx0r: That doesn't seem like a problem. I'd advise 25 million uuids.
<haxx0r> i need customers to tell me the numbers, i dont want them to tell me so many characters. hence just 12 or 15 digits
<havenwood> For customer-read numbers, you might want to consider Base58.
dellavg_ has quit [Ping timeout: 245 seconds]
<havenwood> It's intentionally readable.
segy has joined #ruby
<havenwood> haxx0r: Here's my implementation of Base58 in Ruby: https://gist.github.com/havenwood/3b5a973626f6f0081beb78d6866215ab
<havenwood> haxx0r: In any case, you can make your own uuid however you'd like. Check SecureRandom methods.
<haxx0r> i'll build my own generator right now as a rails style plugin
<haxx0r> has_identifier
<adam12> acts_as_identifier ... couldn't help myself.
<havenwood> haxx0r: There a private method #choose on SecureRandom that you could use here.
<havenwood> &>> SecureRandom.send(:choose, [*?1..?9, *?a..?k, *?m..?z, *?A..?H, *?J..?N, *?P..?Z], 20).gsub(/(.{5})(?=.)/, '\1-\2')
<rubydoc> stderr: -e:2:in `<main>': uninitialized constant SecureRandom (NameError) (https://carc.in/#/r/75nu)
<havenwood> &>> require 'securerandom'; SecureRandom.send(:choose, [*?1..?9, *?a..?k, *?m..?z, *?A..?H, *?J..?N, *?P..?Z], 20).gsub(/(.{5})(?=.)/, '\1-\2')
<rubydoc> # => "znShW-8Umsw-VSyeu-yZnQb" (https://carc.in/#/r/75nw)
<havenwood> haxx0r: That ^, for example, is Base58 characters - 20 of them, separated every 5 by a dash.
<adam12> That choose method is neat. I wonder if it would be better off exposed.
<havenwood> These chars tend to be easy for people to correctly identify.
<havenwood> adam12: I do think it should be. :)
kyrylo has joined #ruby
segy has quit [Ping timeout: 272 seconds]
plujon has joined #ruby
kyrylo has quit [Client Quit]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<adam12> havenwood: Spend any time with Steep? I think you had been checking out Ruby types recently.
<havenwood> adam12: Yes, I've tried Steep on a few projects now. It's not ready for primetime but it seems really promising for useful analysis. I wonder about shipping the stdlib with Steep support out of the box.
<havenwood> I'd love to support Soutaro's work. Maybe more to say on that later.
<adam12> havenwood: Yeah. Sorbet is DOA for me since I develop on FreeBSD but Steep seems to be chugging along nicely without too much ceremony.
<adam12> It's language server support might be a bigger win. Trying to onboard newer devs who are used to auto-complete, etc. has been a huge challenge as of late.
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
chalkmonster has quit [Quit: WeeChat 2.5]
AJA4350 has quit [Ping timeout: 244 seconds]
AJA4350 has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
orbyt_ has joined #ruby
r3m has quit [Remote host closed the connection]
r3m has joined #ruby
orbyt_ has quit [Ping timeout: 248 seconds]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
chalkmonster has joined #ruby
bjpenn has joined #ruby
<bjpenn> is it frowned upon to wrap an entire methods implemention within an foo = ...; bar = ...; if bar && foo ...<method implementation>... end
cd has quit [Remote host closed the connection]
<bjpenn> let me rephrase
<bjpenn> the entire method is like `def foobar; <what i typed above>; end`
<bjpenn> seem to be getting rubocop errors to use a guard clause
<haxx0r> how to get the prefix?
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> class Bla; has_identifier("RE")
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
tdy has joined #ruby
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
teej has joined #ruby
Technodrome has joined #ruby
<havenwood> haxx0r: What did you end up going with for a UUID?
<haxx0r> the one i pasted
<haxx0r> but prefix isn't working
<haxx0r> i think i do the whole concern thing wrong
segy has joined #ruby
<havenwood> haxx0r: I'd expect a ton of collisions with 16 uppercase characters.
<haxx0r> why tho
<haxx0r> can i feed a seed to create random stuff?
<havenwood> haxx0r: There are only so many combinations and that's a small set with relatively few characters. We should look at the maths.
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> 3x 5^26
<havenwood> Also, birthday paradox.
<haxx0r> well, kraken.com uses same model
<havenwood> There are 25 million, you're adding one more.
<havenwood> haxx0r: I'm just suggesting you use something actually unique or account for collision. I don't know what kraken is.
<haxx0r> 5**26
<haxx0r> 3x
<haxx0r> so i have
<haxx0r> Prefix 1490116119384765625-1490116119384765625-1490116119384765625
<haxx0r> i'm not sure about collision. but the universe is big i think
<havenwood> haxx0r: the universe is bigger than 26
<haxx0r> isn't it
<haxx0r> 3**5**26 ?
<haxx0r> i mean, just 3**5**10
<haxx0r> i personally would say it's safe to use and practically it won't ever create collusions, but i also didn't study science nor am i good at math
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> allright, that code works perfect
jcalla has quit [Remote host closed the connection]
Fernando-Basso has joined #ruby
<haxx0r> but fair enough, lets bring numbers inside.
<haxx0r> then we are safe with collisions?
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<leftylink> might as well write the code to calculate it now, then we can use it in all future situations where we need to calcuate
<leftylink> oh
<leftylink> I though the code was wrong because it kept giving me 23 and I thought the right answer is 30
<leftylink> but it looks like 23 is actually the right anwer??????
<leftylink> &>> universe = n = d = 365; (2..).find { |i| n *= (universe + 1 - i); d *= universe; Rational(n, d) <= Rational(1, 2) }
<rubydoc> # => 23 (https://carc.in/#/r/75nz)
<leftylink> everyting I did there correct?
<leftylink> ok cool
<haxx0r> Array.new(i){ [*'0'..'9',*'A'..'Z'].sample }.join
<haxx0r> &>> Array.new(i){ [*'0'..'9',*'A'..'Z'].sample }.join
<haxx0r> &>>Array.new(i){ [*'0'..'9',*'A'..'Z'].sample }.join
<rubydoc> stderr: -e:2:in `<main>': undefined local variable or method `i' for main:Object (NameError) (https://carc.in/#/r/75o1)
<rubydoc> stderr: -e:2:in `<main>': undefined local variable or method `i' for main:Object (NameError) (https://carc.in/#/r/75o0)
<haxx0r> &>> Array.new(10){ [*'0'..'9',*'A'..'Z'].sample }.join
<rubydoc> # => "3D2M7Q7DL7" (https://carc.in/#/r/75o2)
<leftylink> so uh in this case we do 26 ** 16 as the universe size, right?
doodlebug has joined #ruby
<leftylink> &>> universe = n = d = 26 ** 16; (2..).find { |i| n *= (universe + 1 - i); d *= universe; Rational(n, d) <= Rational(1, 2) }
doodlebug has quit [Excess Flood]
<havenwood> haxx0r: Sample doesn't choose repeated characters, which substantially limits the options.
<havenwood> haxx0r: The SecureRandom#choose method I showed does.
<rubydoc> stderr: playpen: timeout triggered! (https://carc.in/#/r/75o3)
<leftylink> OH NOOOOOOOOOOO
<al2o3-cr> i've got more cash the 26 ** 16 ;P
<al2o3-cr> *than
nonamme has quit [Quit: WeeChat 1.9.1]
* al2o3-cr wishes ;)
<al2o3-cr> &>> [*1..26].repeated_permutation(16).size == 26 ** 16
<rubydoc> # => true (https://carc.in/#/r/75o4)
<haxx0r> *?a..?k, *?m..?z,
<haxx0r> so you exclude some chars?
<haxx0r> h I O are missing?
<haxx0r> [*?1..?9, *?a..?k, *?m..?z, *?A..?H, *?J..?N, *?P..?Z]
<al2o3-cr> haxx0r: otherwise it'll be not base58
<haxx0r> i dont need base58
<haxx0r> ah
<haxx0r> because people too stupid to differ I i l
<havenwood> haxx0r: Yeah, customers reading it wrong is a big problem.
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<havenwood> haxx0r: 0 vs O, etc
<havenwood> (depending on the font)
<haxx0r> TIL what base58 is
* haxx0r putsa photo of havenwood over his door
<havenwood> If I had a penny for everyone with my photo over their door...
<al2o3-cr> haxx0r: 1 kudos point
<haxx0r> so then i don't need to check on validity anymore because i can assume zero collision, ya?
<havenwood> haxx0r: i'd highly recommend at least validating
<havenwood> if you knew you'd not collide, you could skip it
<havenwood> a one in 25-million bug can be super frustrating, since it's hard to reproduce
<haxx0r> yea but that means always 1 extra mysql query.
<haxx0r> if it's 1 in 25 million that is ok. record won't be created then. i can live with that
<havenwood> how long does it take to check a cached index for a collision?
<al2o3-cr> &>> [*?1..?9, *?a..?z, *?A..?Z] - [*?1..?9, *?a..?k, *?m..?z, *?A..?H, *?J..?N, *?P..?Z]
<rubydoc> # => ["l", "I", "O"] (https://carc.in/#/r/75o5)
<haxx0r> good question
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<haxx0r> i'll go sleep
<haxx0r> thanks so far
<haxx0r> have a good nite
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
Josse has quit [Quit: Connection closed for inactivity]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<leftylink> well.
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
<leftylink> https://en.wikipedia.org/wiki/Birthday_problem#Approximations has told me there are formulae. I don't know how some of them were gotten. maybe I should read the linked papers
<leftylink> maybe another day...........
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
doodlebug has joined #ruby
doodlebug has quit [Excess Flood]
AJA4350 has quit [Ping timeout: 246 seconds]
<al2o3-cr> havenwood: can you link me that config.ru you posted please?
<al2o3-cr> havenwood: thank you
<havenwood> al2o3-cr: previous revision has the inline plugin - that edit presumes the gem
ruby[bot] has quit [Remote host closed the connection]
<al2o3-cr> ah, ok
ruby[bot] has joined #ruby
<havenwood> minus the I
dhollinger has quit [Quit: dhollinger]
<al2o3-cr> appreciated havenwood thanks
<havenwood> np!
<al2o3-cr> havenwood: that's awesome
<al2o3-cr> so each connection it remembers it's state
<al2o3-cr> per a process bases
<al2o3-cr> i get it
<havenwood> al2o3-cr: yes, a Fiber holds the state and can be suspended and resumed
xco has quit [Quit: xco]
<havenwood> al2o3-cr: so it's a tiny stack and you can have a plethora
DTZUZO has joined #ruby
<al2o3-cr> i never really delve into much but the language itself. i should really because there are really good projects about :)
<havenwood> al2o3-cr: ioquatix has also done a bunch of work on native assembly implementation of fibers that's already been merged and this PR for a lightweight fiber selector that I'd love to see merged: https://github.com/ruby/ruby/pull/1870
<havenwood> al2o3-cr: It's neat that the async projects can be used now and support HTTP/2.
<al2o3-cr> havenwood: nice :) yes, the future of ruby looks promising indeed
<havenwood> it does!
<havenwood> And then with guilds and other engines we can do parallel computation as well.
<havenwood> Hundreds of thousands or millions of async connections with parallel computation available is a great story to tell.
<al2o3-cr> havenwood: who is it that is working on guilds can't remember off the top of my head?
<havenwood> al2o3-cr: Koichi Sasada
<havenwood> (the author of YARV)
<al2o3-cr> ah, yes. watching the rubygaigi about guilds and he was saying something about a complete redesign of the ffi implentation
<al2o3-cr> honestly, i'm excited about ruby 3!
<al2o3-cr> one sec
themsay has quit [Ping timeout: 272 seconds]
Norrin has joined #ruby
<al2o3-cr> guilds was a different video
ebbflowgo has left #ruby [#ruby]
shirak has joined #ruby
xco has joined #ruby
xco has quit [Quit: xco]
xco has joined #ruby
schne1der has quit [Ping timeout: 252 seconds]
ammar has quit [Quit: Lost terminal]
canton7 has quit [Quit: ZNC - http://znc.in]
Spitfire has quit [Ping timeout: 245 seconds]
xco has quit [Quit: xco]
canton7 has joined #ruby
falconfox has quit [Ping timeout: 245 seconds]
bjpenn has quit [Read error: Connection reset by peer]
Arahael has left #ruby ["WeeChat 2.2"]
orbyt_ has joined #ruby
houhoulis has joined #ruby
queip has quit [Ping timeout: 272 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Fernando-Basso has quit [Remote host closed the connection]
queip has joined #ruby
AJA4350 has joined #ruby