cosmicz has quit [Quit: This computer has gone to sleep]
dviola has quit [Ping timeout: 240 seconds]
dviola has joined #ruby
dviola has quit [Changing host]
dviola has joined #ruby
astrobunny has joined #ruby
kimbernator has joined #ruby
nacsurte_ has quit [Ping timeout: 260 seconds]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
gusrub has joined #ruby
bvcosta has quit [Ping timeout: 264 seconds]
<kimbernator>
I'm just beginning to learn Ruby (and programming in general), and I'm working with opening and closing files right now and something is confusing me: Typically I'd declare a variable as an IO object for a file by doing "var = open(file)" then read from it by running var.read, finally closing it with a var.close (cont.)
<kimbernator>
but
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<kimbernator>
by accident I tried "data = open(file).read" and it assigned the contents of the file to the "data" variable
<kimbernator>
Whether or not that's good form, I'm not sure if that file is supposed to be closed or if it was automatically
<kimbernator>
Because there's no longer an object to run a .close on
<kimbernator>
Does that make sense?
lacuna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has quit [Quit: Ex-Chat]
GodFather has joined #ruby
<kimbernator>
So I guess the question is this: if I don't create an IO object for a file, but rather run an operation like .read on the open operation itself, does that keep the file open?
QualityAddict has joined #ruby
<kimbernator>
Maybe I'm yelling into the wind haha
t-recx has quit [Quit: t-recx]
gizmore has joined #ruby
nobitanobi has quit [Remote host closed the connection]
r3QuiEm_cL has joined #ruby
gizmore|2 has quit [Ping timeout: 246 seconds]
<matthewd>
kimbernator: open returns a File object. That's what you're calling read on, either way.
<matthewd>
If you don't close it, it gets left open*
r3QuiEm_cL has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<kimbernator>
I am 95% sure that makes sense to me, but the issue that arises using the syntax I did is that I have no method of closing that file anymore
<matthewd>
* until it gets automatically closed later, but it's generally bad form to rely on that
<kimbernator>
Unless I do and I'm just not aware of it
<matthewd>
Correct. So you probably don't want to do that.
r3QuiEm_cL has joined #ruby
<kimbernator>
Huh, so it's just a solid way to take up a bunch of memory without a method to reclaim it other than gc
<matthewd>
Just like `file = open(..); content = file.read; file = nil`... and now you can't close it.
<kimbernator>
Oh wow
<kimbernator>
Not a lot of hand-holding huh
<matthewd>
I'm not sure what you mean
<matthewd>
`file` is a variable that points to an object. If you point it elsewhere, it no longer points to that object.
<kimbernator>
I guess it was more a reaction to the logic as a whole, regardless of language
<kimbernator>
Like I said, programming isn't something I'm entirely familiar with
<kimbernator>
I'm okay with scripting in bash/powershell, but neither of those would present this issue
_aeris_ has quit [Ping timeout: 248 seconds]
<kimbernator>
Hey, thanks for the help
The_Schmidt_ has left #ruby ["Leaving"]
<kimbernator>
Really appreciate it
<teatime>
kimbernator: some languages like python and perl6 have a feature/syntax that lets you do something cool here
<matthewd>
GC will take care of it in time... it's just unwise to rely on it because it's consuming an fd, for example
lacuna has joined #ruby
<matthewd>
You "should" be using a block, though: then the problem goes away
<teatime>
nice, didn't know you could do the same thing in Ruby
_aeris_ has joined #ruby
<matthewd>
If you're really just reading a file, though, File.read(filename) is simpler again
r3QuiEm_cL has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
r3QuiEm_cL has joined #ruby
r3QuiEm_cL has quit [Client Quit]
benlieb has joined #ruby
nexii has joined #ruby
mim1k has joined #ruby
<kimbernator>
Right, and after a couple minutes of research that was what I ended up using
<nexii>
hello. I was wondering if anyone else is having timeouts when trying to install gems
<kimbernator>
I just wanted to understand how ruby was dealing with my questionable syntax
<nexii>
I can't even seem to install bundler
jenrzzz has quit [Ping timeout: 240 seconds]
<matthewd>
kimbernator: So, I think it's important to emphasize that calling methods on objects (and chains of methods on objects from methods on objects ..) is a very ordinary and reasonable thing to do
<matthewd>
kimbernator: The only time it becomes less reasonable is if you need to call multiple methods on the same object
marxarelli|afk is now known as marxarelli
marxarelli is now known as marxarelli|afk
<matthewd>
(as you did with read + close)
<kimbernator>
At that point I'd want to do "var = open(file); operation ; operation ; var.close", right?
<kimbernator>
Just want to make sure I get your drift
<matthewd>
In bash terms, you can build as many things as you like into a pipeline, but if you want to send the output of one command into two other separate commands, you're gonna need to store it in a variable
mim1k has quit [Ping timeout: 260 seconds]
A124 has quit [Ping timeout: 240 seconds]
<matthewd>
(or use a tempfile, because that's a normal thing to do in a shell) (or use tee, which is just getting complicated)
<matthewd>
Right.
<kimbernator>
I'm so smart
enterprisey has joined #ruby
<kimbernator>
brb applying for a senior developer role
<nexii>
does anyone have any advice on how to get past the timeout errors when running gem install?
<matthewd>
nexii: I'd investigate it as a network issue ¯\_(ツ)_/¯
charliesome has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
A124 has joined #ruby
<nexii>
matthewd: I thought maybe that was the case, but then I get this error in different networks
d^sh has joined #ruby
mtkd has quit [Ping timeout: 240 seconds]
<kimbernator>
Side note: pretty rad that I can hop on to an IRC and get help from one of the members of the rails core team
jordanm has joined #ruby
mtkd has joined #ruby
lxnr has joined #ruby
nofxx has joined #ruby
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
lxnr has quit [Ping timeout: 255 seconds]
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nexii>
I just noticed that the issue might be related to my os since my other computer on the same network, which runs OSX, runs bundle just fine whereas the computer that it doesn't work with runs xenial ubuntu
<kimbernator>
matthewd: I'm reading the documentation on using a block for File.open(). You're right, it's a bit more elegant than what I'm doing. Good call!
nexii has quit [Remote host closed the connection]
nofxx has quit [Remote host closed the connection]
<matthewd>
It's also the more rubyish approach: blocks turn up everywhere
noobineer has joined #ruby
<kimbernator>
Again, thanks for the advice buddy. Have a good one!
kimbernator has quit [Quit: Leaving]
lacuna has joined #ruby
baroquebobcat has joined #ruby
jameser has joined #ruby
gusrub has quit [Remote host closed the connection]
knight33 has joined #ruby
skweek has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
someuser has quit [Ping timeout: 248 seconds]
Slinky_Pete has joined #ruby
lacuna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gusrub has joined #ruby
quobo has quit [Quit: Connection closed for inactivity]
VladGh has quit [Ping timeout: 240 seconds]
ujjain- has quit [Changing host]
ujjain- has joined #ruby
lacuna has joined #ruby
Slinky_Pete has quit [Ping timeout: 248 seconds]
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
mkali has joined #ruby
__Yiota has joined #ruby
skweek has joined #ruby
baroquebobcat has quit [Quit: baroquebobcat]
VladGh has joined #ruby
kn-928 has joined #ruby
lacuna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lxnr has joined #ruby
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
aihwh has joined #ruby
runescape07rsps has quit [Quit: Leaving]
orbyt_ has joined #ruby
lxnr has quit [Ping timeout: 255 seconds]
enterprisey has quit [Quit: Leaving]
Cohedrin_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FahmeF has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nofxx has joined #ruby
anisha has joined #ruby
QualityAddict has quit [Quit: Leaving]
troys_ is now known as troys
FahmeF has quit [Ping timeout: 240 seconds]
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
runescape07rsps has joined #ruby
nofxx has quit [Remote host closed the connection]
ta_ has joined #ruby
nofxx has joined #ruby
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
ta_ has quit [Ping timeout: 248 seconds]
dviola has quit [Quit: WeeChat 1.9]
chouhoulis has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
cschneid has joined #ruby
nobitanobi has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
cschneid has quit [Ping timeout: 255 seconds]
ascarter has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Alina-malina has quit [Changing host]
Alina-malina has joined #ruby
nertzy has quit [Ping timeout: 264 seconds]
bambanx has joined #ruby
baroquebobcat has joined #ruby
npgm has quit [Quit: Connection closed for inactivity]
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
e2021 has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
aleandros has joined #ruby
mim1k has joined #ruby
gusrub has quit [Remote host closed the connection]
benlieb has quit [Ping timeout: 260 seconds]
GodFather has quit [Ping timeout: 248 seconds]
skweek has quit [Ping timeout: 240 seconds]
coderphive has quit [Quit: coderphive]
Fezzler has joined #ruby
mim1k has quit [Ping timeout: 248 seconds]
zacts has quit [Quit: WeeChat 1.9]
Fezzler has quit [Client Quit]
sarbs has joined #ruby
lxnr has joined #ruby
nobitanobi has quit [Remote host closed the connection]
lxnr has quit [Ping timeout: 255 seconds]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kn-928 has quit [Ping timeout: 240 seconds]
Slinky_Pete has joined #ruby
P1ro has quit [Remote host closed the connection]
skweek has joined #ruby
Slinky_Pete has quit [Ping timeout: 248 seconds]
skweek has quit [Ping timeout: 260 seconds]
troys is now known as troys_
ascarter has joined #ruby
bambanx has quit [Quit: Leaving]
gusrub has joined #ruby
ta_ has joined #ruby
Keltia has quit [Read error: Connection reset by peer]
Keltia has joined #ruby
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ryandevilla has joined #ruby
ovaltine1 has quit [Ping timeout: 240 seconds]
mim1k has joined #ruby
ascarter has joined #ruby
ryandevilla has quit [Ping timeout: 240 seconds]
gusrub_ has joined #ruby
gusrub has quit [Ping timeout: 260 seconds]
mim1k has quit [Ping timeout: 248 seconds]
live has joined #ruby
live has quit [Quit: Leaving]
kapil___ has quit [Quit: Connection closed for inactivity]
lektrik has joined #ruby
sarbs has quit [Read error: Connection reset by peer]
aleandros has quit [Quit: aleandros]
howdoi has joined #ruby
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guardianx has joined #ruby
e2021 has quit [Remote host closed the connection]
nacsurte has joined #ruby
e2021 has joined #ruby
twillkens has quit [Quit: Lost terminal]
baroquebobcat has quit [Quit: baroquebobcat]
gusrub_ has quit [Remote host closed the connection]
gusrub has joined #ruby
nacsurte has quit [Ping timeout: 240 seconds]
troys_ is now known as troys
cagomez has joined #ruby
govg has joined #ruby
cagomez has quit [Ping timeout: 255 seconds]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
danieli has quit [Ping timeout: 248 seconds]
Bock has joined #ruby
rabajaj has joined #ruby
gusrub has quit [Remote host closed the connection]
gusrub has joined #ruby
im0nde has joined #ruby
danieli has joined #ruby
im0nde is now known as asd460
danieli has quit [Changing host]
danieli has joined #ruby
asd460 has quit [Client Quit]
troys has quit [Quit: Bye]
anisha has quit [Quit: This computer has gone to sleep]
kn-928 has joined #ruby
im0nde has joined #ruby
ta_ has quit [Remote host closed the connection]
kn-928 has quit [Ping timeout: 240 seconds]
Dimik has quit [Ping timeout: 240 seconds]
e2021 has quit [Read error: Connection reset by peer]
e2021 has joined #ruby
kapil___ has joined #ruby
clouts has joined #ruby
djbkd has joined #ruby
kluge has quit [Ping timeout: 252 seconds]
ruby-lang446 has quit [Ping timeout: 260 seconds]
spheric has quit [Ping timeout: 248 seconds]
ur5us has quit [Remote host closed the connection]
guardianx has quit []
alex`` has joined #ruby
mbr has quit [Ping timeout: 255 seconds]
mbr has joined #ruby
jinie has quit [Ping timeout: 260 seconds]
jinie has joined #ruby
onegoal has joined #ruby
ledestin has joined #ruby
gusrub has quit [Remote host closed the connection]
ana_ has joined #ruby
shime has joined #ruby
kwd has joined #ruby
im0nde has quit [Quit: im0nde]
conta has joined #ruby
nobody has joined #ruby
nobody has quit [Remote host closed the connection]
djbkd has quit [Remote host closed the connection]
djbkd has joined #ruby
kwd has quit [Quit: kwd]
djbkd has quit [Ping timeout: 264 seconds]
onegoal has quit [Ping timeout: 260 seconds]
balazs_ has quit [Ping timeout: 240 seconds]
KevinSjoberg has joined #ruby
lxnr has joined #ruby
cadillac_ has quit [Ping timeout: 240 seconds]
shime has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
guardianx has joined #ruby
cadillac_ has joined #ruby
jamesaxl has joined #ruby
Mon_Ouie has quit [Ping timeout: 252 seconds]
ta_ has joined #ruby
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
KevinSjoberg has joined #ruby
ana_ has quit [Quit: Leaving]
TomyWork has joined #ruby
guardianx has quit []
ana_ has joined #ruby
quobo has joined #ruby
runescape07rsps has quit [Quit: Leaving]
cagomez has joined #ruby
Burgestrand has joined #ruby
cagomez has quit [Ping timeout: 260 seconds]
mark_66 has joined #ruby
jaruga has joined #ruby
claudiuinberlin has joined #ruby
claudiuinberlin has quit [Client Quit]
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has quit [Quit: WeeChat 1.9]
KevinSjoberg has joined #ruby
guille-moe has joined #ruby
ur5us has joined #ruby
kn-928 has joined #ruby
lexruee has quit [Ping timeout: 248 seconds]
lexruee has joined #ruby
kn-928 has quit [Ping timeout: 248 seconds]
dextrey has joined #ruby
yeticry_ has quit [Read error: Connection reset by peer]
yeticry has joined #ruby
A124 has quit [Ping timeout: 240 seconds]
e2021 has quit [Remote host closed the connection]
e2021 has joined #ruby
cagomez has joined #ruby
claudiuinberlin has joined #ruby
A124 has joined #ruby
Mon_Ouie has joined #ruby
e2021 has quit [Read error: Connection reset by peer]
e2021 has joined #ruby
Silthias has joined #ruby
im0nde has joined #ruby
Silthias1 has joined #ruby
cagomez has quit [Ping timeout: 260 seconds]
maum has joined #ruby
<maum>
I got an error: strip!': invalid byte sequence in EUC-KR
<maum>
how can I fix this problem?
dionysus69 has joined #ruby
Silthias has quit [Ping timeout: 260 seconds]
babykosh has joined #ruby
<tobiasvl>
maum: can you gist the whole stacktrace?
iamayam has quit [Ping timeout: 255 seconds]
iamayam has joined #ruby
babykosh has quit [Quit: babykosh]
mochiyoda_ has quit [Ping timeout: 255 seconds]
dextrey has quit [Ping timeout: 255 seconds]
mochiyoda_ has joined #ruby
figuresofstick has joined #ruby
alex`` has joined #ruby
imode has quit [Ping timeout: 255 seconds]
kapil___ has quit [Quit: Connection closed for inactivity]
mim1k has joined #ruby
bronson has quit [Remote host closed the connection]
cagomez has joined #ruby
justthisguy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cagomez has quit [Ping timeout: 252 seconds]
KeyJoo has joined #ruby
abrcdbr has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shime has joined #ruby
claudiuinberlin has joined #ruby
claudiuinberlin has quit [Client Quit]
bruno- has joined #ruby
mikecmpbll has joined #ruby
marr has joined #ruby
claudiuinberlin has joined #ruby
Ishido has quit [Quit: Roads? Where We're Going We Don't Need Roads.]
Ishido has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
maum: by treating encoding with respect.
<dminuoso>
maum: Clearly your string has codepoints that are not valid in EUC-KR
<maum>
ㅗㅡ
<maum>
hm
<dminuoso>
maum: So you're probably trying to mojibake your string. Figure out the correct encoding.
<dminuoso>
maum: And where does the string come from?
<dminuoso>
Is it a literal in the same file?
cfjk has joined #ruby
<maum>
it is same file and I am not sure which string is the problem
<maum>
the file was working fine before
ana_ has joined #ruby
belmoussaoui___ has joined #ruby
<dminuoso>
maum: Is that a yes or no to my question?
tcopeland has quit [Quit: tcopeland]
<maum>
yes
belmoussaoui has quit [Ping timeout: 264 seconds]
<dminuoso>
maum: The stack trace will tell you where its coming from, so you can identify the exact string.
FahmeF has joined #ruby
<dminuoso>
It's quite possible that your editor considered the file to be some other encoding (say UTF8), saved characters using UTF8 codepoints - but ruby interprets those codepoints as EUC-KR
<dminuoso>
So I'd say look into the encoding of your editor.
KeyJoo has quit [Read error: Connection reset by peer]
<maum>
the string is 'Dong C. Liu and Jorge Nocedal. 1989. On the limited memory large scale optimization. Mathema tical Programming, 45:503?528.'
<dminuoso>
maum: What is your text editors encoding?
bruce_lee has joined #ruby
<maum>
how can I check it ? I am using vi editor
<dminuoso>
maum: `:set encoding`
aihwh has quit [Quit: Leaving.]
<maum>
I tried :set encoding=utf-8 in vi
<maum>
but it still same
<dminuoso>
maum: ...
<dminuoso>
maum: That's the problem to begin with perhaps?
<maum>
you mean the problem is the vi encoding?
<dminuoso>
maum: Yes. vi is saving the file using encoding "utf-8", and Ruby then interprets that file as encoding "euc-kr"
<dminuoso>
mojibake complete.
<maum>
:set encoding=euc-kr ?
<maum>
hm,... also same
<dminuoso>
maum: Well if the characters are already in the buffer Im not sure what would happen.
<maum>
ok, thanks for your help!
<TomyWork>
has anyone here ever made a totally custom Thin backend?
<TomyWork>
i'm confused about start/stop/connect/disconnect
<TomyWork>
basically what i want to do is have a custom backend that takes a single connection and exits
<TomyWork>
and that connection should be fed from stdin/out
<TomyWork>
instead of a socket
GeorgesLeYeti has joined #ruby
<GeorgesLeYeti>
Hi
<GeorgesLeYeti>
I have a array of values and I want to return an array of uniq value of this array but order by the number of occurency
cagomez has joined #ruby
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
raynold has quit [Quit: Connection closed for inactivity]
bronson has joined #ruby
bruno- has joined #ruby
gregf_ has joined #ruby
lxsameer has joined #ruby
ShalokShalom_ has joined #ruby
bronson has quit [Ping timeout: 240 seconds]
Slinky_Pete has joined #ruby
ShalokShalom has quit [Ping timeout: 240 seconds]
ShalokShalom_ is now known as ShalokShalom
lxsameer has quit [Ping timeout: 248 seconds]
Slinky_Pete has quit [Ping timeout: 240 seconds]
GodFather has joined #ruby
<TomyWork>
i want to control what exactly ends up on stdout, so my first two lines in the script are "$actual_stdout = $stdout" and "$stdout = $stderr". why/how does the Thin web server still output to stdout?
<dminuoso>
TomyWork: $stdout is just a variable pointing at an object.
<dminuoso>
TomyWork: and thin probablz doesn't use that variable?
<elomatreb>
STDOUT is the default value of $stdout, nothing stops them from just using it directly
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jamesaxl has quit [Ping timeout: 260 seconds]
fmartingr has quit [Quit: Connection closed for inactivity]
bronson has joined #ruby
Slinky_Pete has joined #ruby
bronson has quit [Ping timeout: 246 seconds]
Slinky_Pete has quit [Ping timeout: 240 seconds]
figures_ has joined #ruby
figuresofstick has quit [Ping timeout: 248 seconds]
alex`` has joined #ruby
<dminuoso>
Cork: didn't we have this discussion yesterday?
<Cork>
no
<dminuoso>
Weird, just had this topic this week.
<Cork>
haven't touch this kind of problem in at least 8 months >_>
jlebrech has joined #ruby
<Cork>
this is an old script i'm trying to fix a bug in :)
<dminuoso>
Cork: fork the process through some mechanism server side, install a local sighandler for SIGINT and translate it into sending SIGTERM to the fork'ed process.
<Cork>
i think i have a fairly clean solution and it looks like it works
<jlebrech>
anyone try ubuntu subsystem on windows? my colleague is trying to run middleman on windows 10 and i suggested that would be a better course to take than installing ruby directly on windows
<Cork>
i basically store the different ssh sessions in a global hash and on trap("INT") i loop them and run .shutdown! on them
<Cork>
it seams to work, not completely through testing yet though
tcopeland has quit [Quit: tcopeland]
kn-928 has joined #ruby
<dminuoso>
Cork: Assuming SSH terminates a child process immediately that sounds sane.
<dminuoso>
(or rather, Im not sure how SSH server exactly executes things)
<Cork>
ya, that is still what i'm trying to test
<Cork>
first level looks like it always works, it is child processes i have left
eblip has joined #ruby
eb0t has quit [Ping timeout: 246 seconds]
ShekharReddy has joined #ruby
kn-928 has quit [Ping timeout: 240 seconds]
tcopeland has joined #ruby
Ishido has quit [Ping timeout: 240 seconds]
madhatter has quit [Remote host closed the connection]
Ishido has joined #ruby
tcopeland has quit [Client Quit]
shime has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
naprimer has joined #ruby
tvw has quit [Ping timeout: 240 seconds]
knight33 has joined #ruby
tvw has joined #ruby
charliesome has joined #ruby
dextrey has joined #ruby
cagomez has joined #ruby
madhatter has joined #ruby
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ldnunes has joined #ruby
e2021 has quit [Remote host closed the connection]
Mon_Ouie has quit [Ping timeout: 240 seconds]
e2021 has joined #ruby
Mon_Ouie has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
cagomez has quit [Ping timeout: 240 seconds]
kn-928 has joined #ruby
dionysus69 has joined #ruby
claudiuinberlin has joined #ruby
savoir-faire has left #ruby [#ruby]
synthroid has joined #ruby
GeorgesLeYeti has quit [Quit: Leaving]
figures_ is now known as figuresofstick
Slinky_Pete has joined #ruby
kn-928 has quit [Ping timeout: 248 seconds]
Slinky_Pete has quit [Ping timeout: 248 seconds]
runescape07rsps has quit [Ping timeout: 240 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gnufied has quit [Quit: Leaving]
jaruga has quit [Quit: jaruga]
claudiuinberlin has joined #ruby
harfangk has quit [Quit: No Ping reply in 180 seconds.]
my123 has quit [Read error: Connection reset by peer]
tcopeland has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gnufied has joined #ruby
harfangk has joined #ruby
jaruga has joined #ruby
e2021 has quit [Remote host closed the connection]
e2021 has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
my123 has joined #ruby
my123 has quit [Changing host]
my123 has joined #ruby
stamina has quit [Quit: WeeChat 1.9]
bmurt has joined #ruby
InfinityFye has quit [Ping timeout: 240 seconds]
jaruga has quit [Ping timeout: 255 seconds]
claudiuinberlin has joined #ruby
InfinityFye has joined #ruby
jaruga has joined #ruby
sekmo has joined #ruby
dionysus69 has quit [Remote host closed the connection]
FahmeF has quit [Remote host closed the connection]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darix has quit [Quit: may the packets be with you...]
<pavelz>
hello. i am working on some project and can
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<pavelz>
cant't figure out why bundler does not include gems from git repos in the search path
<elomatreb>
Are they in a group you didn't install/require? You should probably show your Gemfile
claudiuinberlin has joined #ruby
dextrey has quit [Ping timeout: 255 seconds]
someuser has joined #ruby
balazs_ has joined #ruby
GodFather has joined #ruby
aagdbl[m] has quit [Ping timeout: 240 seconds]
M107262[m] has quit [Ping timeout: 240 seconds]
aidalgol has quit [Ping timeout: 240 seconds]
Orbixx[m] has quit [Ping timeout: 240 seconds]
tcopeland has joined #ruby
bronson has joined #ruby
<pavelz>
how can I check what stuff will be included in an app? i used bundler exec ruby -e 'puts $:
tcopeland has quit [Client Quit]
<pavelz>
is that wrong?
shime has joined #ruby
bokayio has quit [Ping timeout: 240 seconds]
DLSteve has joined #ruby
kua[m] has quit [Ping timeout: 240 seconds]
roshanavand has quit [Quit: Leaving]
velu_aon[m] has quit [Ping timeout: 246 seconds]
haylon has quit [Ping timeout: 246 seconds]
dtcristo has quit [Ping timeout: 246 seconds]
Tagami[m] has quit [Ping timeout: 246 seconds]
dman[m] has quit [Ping timeout: 246 seconds]
KevinMGranger has quit [Ping timeout: 246 seconds]
jonjits[m] has quit [Ping timeout: 246 seconds]
watzon has quit [Ping timeout: 246 seconds]
aviraldg has quit [Ping timeout: 255 seconds]
Hanma[m] has quit [Ping timeout: 255 seconds]
gokul_mr[m] has quit [Ping timeout: 264 seconds]
yana[m] has quit [Ping timeout: 264 seconds]
torarne has quit [Ping timeout: 264 seconds]
turt2live has quit [Ping timeout: 255 seconds]
lasenna[m] has quit [Ping timeout: 276 seconds]
Matt[m]1 has quit [Ping timeout: 276 seconds]
cgfbee has quit [Ping timeout: 240 seconds]
tcopeland has joined #ruby
Giphy[m] has quit [Ping timeout: 276 seconds]
Silthias1 has quit [Ping timeout: 255 seconds]
bokayio has joined #ruby
bronson has quit [Ping timeout: 248 seconds]
chmuri has quit [Ping timeout: 240 seconds]
cgfbee has joined #ruby
apparition has quit [Quit: Bye]
tcopeland has quit [Quit: tcopeland]
Silthias has joined #ruby
chmurifree has joined #ruby
tcopeland has joined #ruby
<TomyWork>
Cork dont pin me down on it, but I think your first-level processes will get a SIGHUP. do they deal with that?
chouhoulis has joined #ruby
Silthias1 has joined #ruby
tcopeland has quit [Client Quit]
<Cork>
TomyWork: ya
Silthias has quit [Ping timeout: 240 seconds]
<TomyWork>
what do you mean "ya"?
<pavelz>
elomatreb: oh its something different ) there are two files each define a class and class that is inheriting from one defined in other file is not defined.
<pavelz>
a head scratcher.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dextrey has joined #ruby
phinxy has joined #ruby
phinxy has left #ruby [#ruby]
claudiuinberlin has joined #ruby
<pavelz>
is there a reason a class might be undefined even if the file defining it is right there?
<TomyWork>
btw, i dont know what you mean by your question. are you looking for a way to throw warnings/errors whenever someone uses eval somewhere? are you looking for a clean migration path?
<TomyWork>
or something else entirely?
armyriad has joined #ruby
rabajaj has quit [Quit: Leaving]
mson has quit [Quit: Connection closed for inactivity]
eckhardt has joined #ruby
FahmeF has joined #ruby
belmoussaoui___ has quit [Quit: belmoussaoui___]
<baweaver>
module Kernel; def eval(*a) raise 'lol no' end end
<matthewd>
Even if you want to keep the hash, '=' is a bit shorter than 'with_object'
* baweaver
keeps looking for a dirty regex / sprintf hack
<baweaver>
I don't think it'd be shorter than that though
<sagax>
ruby can do this ['a','b','c'].zip(['1','2','3']) => [["a", "1"], ["b", "2"], ["c", "3"]] but how to do "zip" like this? (['a','b','c'],['1','2','3']).zip() with native
mim1k has quit [Ping timeout: 255 seconds]
KevinSjoberg has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Chuck_>
I'm just trying to see what versions of ruby I'm using.
<havenwood>
Chuck_: I'm trying to see what your Ruby command actually is.
<havenwood>
Chuck_: Do you get the expected result for?: command -V ruby
<Chuck_>
It showed this: zsh: no matches found: check?:
<havenwood>
command -V ruby
<havenwood>
Chuck_: just that ^
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Chuck_>
zsh: command not found: -V
<havenwood>
Chuck_: The part to run is `command -V ruby`.
<havenwood>
This whole line:
<havenwood>
command -V ruby
<havenwood>
The command is `command` with the `-V` flag and `ruby` as an argument.
baroquebobcat has joined #ruby
<Chuck_>
ruby is an alias for /usr/bin/open -a /Applications/RubyMine.app/
jinie has quit [Ping timeout: 248 seconds]
runescape07rsps has joined #ruby
<havenwood>
Chuck_: That's why ^
<havenwood>
Chuck_: You've defined an alias for Ruby that actually opens your RubyMine app.
jinie has joined #ruby
<Chuck_>
i use rvm list and it showed all the versions with the asterisk and => for the current version being used but that command for checking ruby version is not working for me.
<havenwood>
Chuck_: Check our .zshrc for an: alias ruby="/usr/bin/open -a /Applications/RubyMine.app/"
<havenwood>
and delete that line
<Chuck_>
i see
<havenwood>
Chuck_: You've aliased the `ruby` command to opening your Ruby IDE. That's probably not a good idea.
<havenwood>
Chuck_: I'd strongly recommend deleting that alias.
charliesome has joined #ruby
Terens has quit [Ping timeout: 240 seconds]
<havenwood>
Chuck_: Maybe instead do an `alias -s rb="open -a /Applications/RubyMine.app"` so it opens Ruby files in your IDE if you "run" them directly like: >> example.rb
ledestin has joined #ruby
<havenwood>
Or just pick an alias name other than "ruby".
<Chuck_>
Thank you so much, havenwood! I got that to work now.
<havenwood>
I'd definitely consider that name reserved for the lang's binary.
<havenwood>
Chuck_: You're welcome!
elsevero has quit [Ping timeout: 248 seconds]
elsevero has joined #ruby
ShekharReddy has quit [Quit: Connection closed for inactivity]
conta1 has joined #ruby
nb_bez_______ has quit [Quit: Connection closed for inactivity]
anisha has quit [Quit: This computer has gone to sleep]
conta1 has quit [Ping timeout: 246 seconds]
runescape07rsps has quit [Quit: Leaving]
lxsameer has joined #ruby
Chuck_ has quit [Remote host closed the connection]
snockerton has joined #ruby
knight33 has joined #ruby
FahmeF has joined #ruby
Silthias has joined #ruby
cdg has joined #ruby
guille-moe has quit [Ping timeout: 240 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Bock has quit [Ping timeout: 240 seconds]
cdg has quit [Ping timeout: 240 seconds]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
belmoussaoui has joined #ruby
cdg has joined #ruby
xall has quit [Quit: xall]
charliesome has joined #ruby
hahuang65 has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #ruby
Chuck_ has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Slinky_Pete has joined #ruby
FahmeF has quit [Remote host closed the connection]
selim has quit [Ping timeout: 240 seconds]
ryandevilla has quit [Quit: WeeChat 1.7]
cdg has quit [Ping timeout: 260 seconds]
uZiel has quit [Ping timeout: 248 seconds]
charliesome has quit [Ping timeout: 240 seconds]
SHyx0rmZ has joined #ruby
selim has joined #ruby
jamesaxl has joined #ruby
charliesome has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jinie has quit [Ping timeout: 240 seconds]
jinie has joined #ruby
Burgestrand has joined #ruby
afromank_ has quit []
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
balazs_ has quit [Ping timeout: 255 seconds]
charliesome has quit [Ping timeout: 248 seconds]
charliesome has joined #ruby
<pavelz>
i have a problem with this project when i try to start the app there is an error says that class is undefined while it is clearly right there. Could a loading order of some sort cause one of the files in the directory cause it not to load
<pavelz>
?
jgjorgji has joined #ruby
phaul has joined #ruby
cadillac_ has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jgjorgji>
what's the best way to tar up a ruby program so i don't have to install development tools on servers?
Slinky_Pete has quit [Remote host closed the connection]
<elomatreb>
pavelz: You need to explicitely require files you need, Ruby doesn't do autoloading
<pavelz>
i guess this is them some sort of bundler/rails fault then
<elomatreb>
Rails does do some limited autoloading however
cadillac_ has joined #ruby
bronson has joined #ruby
balazs_ has joined #ruby
orbyt_ has quit [Client Quit]
KevinSjoberg has joined #ruby
hahuang65 has joined #ruby
eckhardt has joined #ruby
bronson has quit [Ping timeout: 255 seconds]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #ruby
LastWhisper____ has quit [Client Quit]
lxnr has quit [Ping timeout: 240 seconds]
LastWhisper____ has joined #ruby
Dimik has joined #ruby
mikecmpbll has joined #ruby
hahuang65 has quit [Ping timeout: 255 seconds]
lacuna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
cschnei__ has joined #ruby
RedNifre has joined #ruby
<RedNifre>
Hi. Any recommendation regarding writing tests?
knight33 has joined #ruby
mtkd has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<elomatreb>
RedNifre: Do it? :P
<RedNifre>
The Book has a chapter about it and goes with 'test/unit' from the standard library. Is that the way to go or are there significantly better libraries out there that I should use instead?
<Papierkorb>
`rspec` is also pretty popular. If it's better depends on your taste
<RedNifre>
Oh, I think I heard about that one. Wasn't there a project that used rspec to specify the language but Matz didn't support it so it was abandoned and Ruby is now basically specified by what MRI does each release?
<dminuoso>
RedNifre, be careful to test your own code and not someone elses.
mtkd has joined #ruby
<RedNifre>
dminuoso I still haven't gotten around figuring out gems and serious project setups (the standard library is still enough for my tiny projects) so there's no risk for encountering other people's code anyway ;)
<Papierkorb>
Just get into writing tests. What you use doesn't matter much for that. There are many things to think about, but honestly, just get doing it and learn along the way.
hahuang65 has joined #ruby
<dminuoso>
RedNifre, for example I see a lot of rails projects doing idiotic things like it { should belong_to(:blah) }
<RedNifre>
Oh, I already write tests in other languages, I was asking about the technical side in Ruby (which library etc.)
<Papierkorb>
RedNifre: Just be on the look-out when you got a bit comfortable with it for improvements and best-practices
<RedNifre>
Well, I try to mostly write pure functions so testing doesn't get too complicated (No need to create complex mocks if all you have is functions and data)
<elomatreb>
dminuoso: I actually like doing that, I accidentally forgot to set up the reverse association on a model multiple times which was only caught by such a test
<dminuoso>
elomatreb, I've just frequently seen tests that just try to assert that the "thing in rails you are using" really does what its supposed to.
biberu has quit []
hahuang65 has quit [Ping timeout: 248 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
preyalone has joined #ruby
maryo_ has quit [Quit: Leaving]
Slinky_Pete has joined #ruby
ddffg has joined #ruby
Burgestrand has quit [Quit: Closing time!]
synthroid has joined #ruby
Slinky_Pete has quit [Ping timeout: 240 seconds]
voker57 has quit [Ping timeout: 255 seconds]
voker57 has joined #ruby
voker57 has quit [Changing host]
voker57 has joined #ruby
r3QuiEm_cL has joined #ruby
roonsauce has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
kn-928 has joined #ruby
dviola has joined #ruby
ta_ has joined #ruby
snockerton has quit [Quit: Leaving.]
kn-928 has quit [Ping timeout: 248 seconds]
orbyt_ has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
Slinky_Pete has joined #ruby
al2o3-cr has quit [Ping timeout: 252 seconds]
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jaruga has quit [Quit: jaruga]
nacsurte_ has joined #ruby
sagax has quit [Remote host closed the connection]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
KevinSjoberg has joined #ruby
nacsurte_ has quit [Read error: Connection reset by peer]
Chuck_ has quit [Remote host closed the connection]
bmurt has joined #ruby
nacsurte has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
bronson has joined #ruby
<RedNifre>
If I have a byte string, how do I pick three consecutive bytes and join them into a number? e.g. turn 01 00 00 into the number 65536?
<RedNifre>
do I have to_i all of them, shift and add? Or is there a simpler way?
<matthewd>
I don't know of a built-in thing that'll take three bytes... I guess I might do "\x00#{the_three_bytes}".unpack("N")
<Papierkorb>
24bit integers are whacko anyway. You could use unpack but I don't see much reason, as now you have to add the NUL byte at the right place (endianess)
bronson has quit [Ping timeout: 246 seconds]
lacuna has joined #ruby
<Papierkorb>
You can get around that by unpacking a 16bit and a 8bit integer, and then shifting those. But that's not shorter than just manually shifting it right away
<Papierkorb>
Makes it also a bit clearer which endianess you're using there
<RedNifre>
Well, the unpack variant looks nicer than (bstring[start].to_i << 16) + (bstring[start+1].to_i << 8) + bstring[start+2].to_i
cdg has joined #ruby
<matthewd>
`bstring[start, 3].bytes.inject(0) {|l,r| l * 256 + r }` ?
FahmeF has joined #ruby
knight33 has joined #ruby
duracrisis is now known as bob
<RedNifre>
Interesting, but isn't "\x00#{bstring[start, 3]}".unpack("N") clearer? (Assuming the reader knows what N means)
bob is now known as Guest61719
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<matthewd>
To me, yes -- especially given that unpack is much clearer for other (e.g. 16bit) values
lxnr has joined #ruby
<matthewd>
The byte-wrangling isn't terrible in its own right, but it'd stand out horribly against unpacks elsewhere... and byte-wrangling for things that are trivially unpackable seems silly
<RedNifre>
is there a variant of unpack that returns the first result instead of an array?
<matthewd>
Ruby 2.4 added String#unpack1
<RedNifre>
hey wait... I can pick both numbers in one step if I do "Nn", huh?
<matthewd>
Yes
<RedNifre>
(I have one 3 byte number followed by a 2 byte number)
<RedNifre>
excellent
Chuck_ has joined #ruby
<matthewd>
I'd also consider using IO#read(n) instead of reading the whole thing then trying to slice strings back out, FWIW
troulouliou_div2 has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
troulouliou_div2 has joined #ruby
troulouliou_div2 has quit [Changing host]
<RedNifre>
I thought about that but it's easier for testing if I have a function where I pass a byte string as a parameter and get the parsed object back instead of having the function read the file by itself.
FahmeF has quit [Read error: Connection reset by peer]
<RedNifre>
It's now offset, size = "\x00#{bstring[start,5]}".unpack("Nn") , not too shabby.
<matthewd>
That's what StringIO is for
<RedNifre>
Okay, I'll look it up.
hahuang65 has joined #ruby
<RedNifre>
I'm not convinced. My usecase involves small files (couple kB, maybe 1MB max) so I'll probably stick with the less efficient but easier to understand approach.
Chuck_ has quit [Ping timeout: 240 seconds]
graft has quit [Ping timeout: 246 seconds]
cdg_ has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cdg has quit [Ping timeout: 252 seconds]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
r3QuiEm_cL has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
knight33 has joined #ruby
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troulouliou_div2 has quit [Quit: Leaving]
SteenJobs_ has quit [Quit: SteenJobs_]
Guest61719 is now known as duracrisis
dionysus69 has quit [Ping timeout: 248 seconds]
KevinSjoberg has joined #ruby
charliesome has joined #ruby
Ltem has quit [Quit: Leaving]
s1kx has joined #ruby
goyox86 has joined #ruby
d5sx43 has joined #ruby
d5sx43 has quit [Client Quit]
graft has joined #ruby
jazzinimal has joined #ruby
eckhardt has joined #ruby
<RedNifre>
The "encoding" of a String is basically just a tag attached to it, right? (I'm asking because "\xff".encoding returns UTF-8, even though that string isn't valid UTF-8)
KevinSjoberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<matthewd>
Yes
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jordanm has quit [Ping timeout: 240 seconds]
<apeiros>
RedNifre: additionally, that tag influences what certain operations do
goyox86 has left #ruby [#ruby]
<RedNifre>
so strings are always byte arrays and if i want a UTF-16 string it will be either BE or LE I guess?
synthroid has quit []
lxsameer has quit [Quit: WeeChat 1.7]
goyox86 has joined #ruby
<apeiros>
yes
<RedNifre>
i see
<apeiros>
utf specifies how characters map to bytes
<apeiros>
unicode specifies how characters map to codepoints
KevinSjoberg has joined #ruby
<RedNifre>
no, uft specifies how codepoints map to differently sized bit vectors.
<RedNifre>
E.g. in Java, a String is UTF-16 but you don't have to worry about the endianess inside the language since a char is 16 bit, not 2 x 8 bits.
<apeiros>
bit vectors, huh? tell me, what size are those bit vectors?
wogi has quit [Ping timeout: 252 seconds]
<RedNifre>
depends, 16 bit in java, 32 in go, 8 in the file system?
<apeiros>
then you're not really having utf-16. you have unicode. you have codepoints.
<RedNifre>
no, you can't have a codepoint outside of the BMP in java. you have UTF-16.
<apeiros>
look, you can call a byte an 8bit vector. ain't no real difference.
<RedNifre>
E.g. if you put one gothic letter into a string the string has a length of 2.
<apeiros>
that'd be an implementation limitation.
<apeiros>
there's no utf-16 without an endianness.
ur5us has joined #ruby
<RedNifre>
Why do you believe that?
enterprisey has joined #ruby
<RedNifre>
you can put UTF-16 in an int array without worrying about endianess.
KevinSjoberg has quit [Ping timeout: 240 seconds]
<apeiros>
as said, then you have unicode.
<apeiros>
the thing you put into an array are codepoints.
<RedNifre>
no, if you put UTF-32 into an int array you could call it unicode.
<apeiros>
*shrug* ok. if you want to believe that.
<RedNifre>
Say you put 10FFFF in an array position you might call it unicode, but you are not allowed to use 10FFFF in UTF-16
__Yiota has joined #ruby
<apeiros>
how do you write that "utf-16 int array" to disk?
<RedNifre>
In either big or little endian?
<apeiros>
oh really?
<apeiros>
and how do you write it to memory other than disk?
bmurt has joined #ruby
<RedNifre>
Sure, the UTF-16 in a file will have endianess (because files are made out of bytes), but the array in RAM isn't concerned with endianess.
alex`` has quit [Ping timeout: 240 seconds]
<apeiros>
because endians don't exist in ram? only in hard drives?
ur5us has quit [Ping timeout: 248 seconds]
jenrzzz_ has joined #ruby
wogi has joined #ruby
<RedNifre>
On a 64 bit CPU you can read RAM in chunks of 8, 16, 32 or 64 bit. I guess it's usually little endian these days. So I would infact read and write them to RAM in units of 16 bits without worrying about the endianess.
AnoHito has quit [Read error: Connection reset by peer]
<apeiros>
anyway, as said, the purpose of utf is to map codepoints to bytes. you can believe that or think you know better. IDC. got real stuff to do :)
AnoHito has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
FastJack has joined #ruby
<RedNifre>
Then I choose to believe that I know better and believe that only UTF-8 is about mapping codepoints to sequences of bytes. But I agree that it's probably not worth it to continue the discussion.
Paraxial has quit [Remote host closed the connection]
FastJack_ has quit [Read error: Connection reset by peer]
Paraxial has joined #ruby
roonsauce has quit [Remote host closed the connection]
roonsauce has joined #ruby
<dminuoso>
apeiros, do you have the keyword "encoding" on highlight?
<apeiros>
lol, no
<apeiros>
and honestly by now I think I should ignore the topic.
<dminuoso>
Too frustrating?
<apeiros>
yupp
roonsauce has quit [Ping timeout: 240 seconds]
troys_ is now known as troys
ldnunes has quit [Quit: Leaving]
Azure has quit [Ping timeout: 240 seconds]
belmoussaoui has quit [Read error: Connection reset by peer]
FahmeF has joined #ruby
kn-928 has joined #ruby
<imode>
is it safe to truncate a securerandom UUID after being encoded in base36?
<apeiros>
your computer won't explode if you do it
<imode>
given. but I'm looking to generate 10-digit base-36 IDs.
<imode>
I'm debating between urlsafe_base64 and truncating a UUID.
<apeiros>
well, a type 4 uuid has 122 bits of entropy
belmoussaoui_ has joined #ruby
[Butch] has quit [Quit: I'm out . . .]
<apeiros>
10 digits of base 36 translates to roughly 1/5th of that
<imode>
yeah, I got that too.. maybe I'm just better off throwing random base64 at people.
<apeiros>
it also means you can't restore the original uuid from the base36
<apeiros>
why'd that be better?
<imode>
the keys have to be short.
<imode>
and urlsafe_base64 has a larger alphabet.
<apeiros>
ok. but that's not an answer to the question.
<apeiros>
ok. so why don't you translate the uuid to base64?
<imode>
I considered it, but I'm wondering what the benefit would be.
<imode>
(we're talking about ruby's securerandom, I assume.)
<apeiros>
yes. I did not randomly introduce a new type of uuid.
jordanm has joined #ruby
jazzinimal has quit [Ping timeout: 260 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
millerti has joined #ruby
<imode>
also, the base64 representation of the UUID would be longer than 10 digits.
<apeiros>
the "your computer won't explode" was a hint at you not specifying what "safe" means in your context. just to clarify.
bmurt has joined #ruby
<imode>
I'm good. nevermind.
enterprisey has quit [Ping timeout: 248 seconds]
<apeiros>
ok
<apeiros>
oh, fun, I accidentally my math. 10 digits of base36 is only 1/1454234566226315313152th the entropy of 122bits.
ddffg has quit [Quit: Leaving]
<imode>
I just went with a random URL-safe base64 string and went with 12 characters. that gives me 72 bits.
oleo has quit [Quit: irc client terminated!]
Exagone313 has quit [Quit: see ya!]
<apeiros>
if you want to calculate the risk of collision, the uuid entry of wikipedia iirc has the basic math formula for that in it.
<apeiros>
if that's what you're concerned about RE "safe"
<imode>
pretty much. though the number of possible keys with this method pretty much exceeds what I'm going to be doing. :P
<imode>
thanks though.
<apeiros>
I did find it rather difficult to attach a meaning to the probabilities, though. if you e.g. expect to generate 1mio IDs, is a 0.01% probability of collision low enough?
<apeiros>
the number of keys can be misleading re collision probability.
d10n-work has quit [Quit: Connection closed for inactivity]
brw has quit [Ping timeout: 248 seconds]
<apeiros>
f.ex., you only need 23 people to have a 50% chance of two people having their birthday on the same date (excluding the year)
jenrzzz_ has quit [Ping timeout: 240 seconds]
<apeiros>
iirc…
<havenwood>
the birthday paradox
<apeiros>
yupp
<havenwood>
70 people for 99.9%
<havenwood>
100 people for six nines.
<apeiros>
yeah, it grows surprisingly quick
am55 has quit [Read error: Connection reset by peer]
<apeiros>
imode: anyway, unless you're beyond millions of keys, you'll probably be fine with 72 bit of entropy :)
goyox86___ has joined #ruby
<imode>
apeiros: yeeeah. :P
<imode>
worst case we introduce some extra digits. :P
<apeiros>
if it's stored in a db, just have a unique constraint.
enterprisey has joined #ruby
<imode>
we're throwing them into redis, but also presenting them to users to share.
<imode>
and embedding them in URLs + shortening them.
<imode>
I think 'll stick with base64 though, as 12 digits is enough for our first tests.
<imode>
thanks though! that's an interesting and short demonstration.
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
<matthewd>
If you're actually using Rails, you might want has_secure_token, which is backed by that method. But otherwise, it, or the argument^Wdiscussion in the relevant PRs, might be informative.
<apeiros>
matthewd: interesting implementation :D
<imode>
it definitely is, looking at it now.
<imode>
re: the argument/discussion. :P
r3QuiEm_cL has joined #ruby
mim1k has joined #ruby
<apeiros>
` - ["0", "O", "I", "l"]` - I have something similar in an alnum ID generator for our company
<matthewd>
apeiros: Hmm. I think I just assumed that working with even a smallish bigint would be slower... not sure we ever benchmarked that
roonsauce has quit [Remote host closed the connection]
<apeiros>
I benched it with larger Ns, it degrades quickly.
Guest19798 has quit [Changing host]
Guest19798 has joined #ruby
Guest19798 is now known as Nicmavr
<RedNifre>
How do I check if a file is run directly or in a require_relative? (I want to write tests for a tiny script, but the test starts the stript when I require it)
<apeiros>
if $0 == __FILE__
<apeiros>
though, best to just explicitly separate executables and libraries
<RedNifre>
good point, I'll separate them. Thanks.
jenrzzz has quit [Ping timeout: 260 seconds]
<RedNifre>
But what exactly does "if $0 == __FILE__" mean? Does $0 contain the name of the file that was started first and is __FILE__ a constant that refers to the name of the file where it's referenced? Are those just strings with filenames or File objects? Will they be equal if I have identically named files in separate folders?
<apeiros>
yes. strings. no.
<apeiros>
it's not perfectly reliable since both $0 and __FILE__ can be manipulated. but it's good enough.
<matthewd>
Technically __FILE__ is a string, not a constant
* matthewd
channels dminuoso
<apeiros>
if anything other than a string literal at all, __FILE__ would be a local variable or method
<apeiros>
_ is not uppercase ;-)
* apeiros
never really bothered to look up as what the ruby parser actually treats it
<apeiros>
(it's not registered as lvar, method or constant)
<RedNifre>
In irb __FILE__ is "(irb)" and $0 is "irb". Does that distinction mean anything?
FrostCandy has quit []
jenrzzz has joined #ruby
<apeiros>
you're not in a file
<matthewd>
apeiros: It does get directly inlined as a literal
<apeiros>
matthewd: great. so my intuit was right :)
<apeiros>
though, I think that wouldn't actually rule it out of being a keyword. I mean nothing stops ruby from inlining the value a keyword evaluates to.
<apeiros>
meh
<apeiros>
who cares
<apeiros>
it's a string. it's magic. rest is implementation details.
Bhootrk_ has joined #ruby
bronson has quit [Ping timeout: 248 seconds]
sagax has joined #ruby
<banisterfiend>
apeiros wassup swiss face 9000
<apeiros>
me, despite wanting to be in bed. slow backups. fuck em.
<apeiros>
and what's up in your region of the world?
<apeiros>
where the heck are you nowadays anyway? haven't seen you here in ages!