ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
roshanavand has quit [Ping timeout: 260 seconds]
dviola has quit [Quit: WeeChat 3.3]
ur5us has quit [Ping timeout: 264 seconds]
goldfish has joined #ruby
goldfish has quit [Ping timeout: 264 seconds]
crankharder has joined #ruby
crankharder has quit [Ping timeout: 260 seconds]
reset has quit [Quit: reset]
<nakilon>
is there a simpler way to do this? require "open-uri"; (Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5") ? Kernel : URI).open(
reset has joined #ruby
crankharder has joined #ruby
crankharder has quit [Ping timeout: 245 seconds]
markong has joined #ruby
quazimodo has quit [Quit: leaving]
<adam12>
nakilon: What's the change to `open` that you're trying to work around?
waagrr has quit [*.net *.split]
nakilon has quit [*.net *.split]
wmoxam has quit [*.net *.split]
gcd has quit [*.net *.split]
jhass|off has quit [*.net *.split]
joast has quit [*.net *.split]
phenom has quit [*.net *.split]
gfawcett has quit [*.net *.split]
belak has quit [*.net *.split]
ged has quit [*.net *.split]
MachinShin__ has quit [*.net *.split]
peer has quit [*.net *.split]
Pixi has quit [*.net *.split]
marahin has quit [*.net *.split]
tv- has quit [*.net *.split]
dannyAAM has quit [*.net *.split]
_axx has quit [*.net *.split]
Cork has quit [*.net *.split]
jhass|off has joined #ruby
Pixi has joined #ruby
gfawcett has joined #ruby
Cork has joined #ruby
gcd has joined #ruby
joast has joined #ruby
ged has joined #ruby
phenom has joined #ruby
wmoxam has joined #ruby
peer has joined #ruby
MachinShin__ has joined #ruby
belak has joined #ruby
marahin has joined #ruby
waagrr has joined #ruby
nakilon has joined #ruby
tv- has joined #ruby
dannyAAM has joined #ruby
_axx has joined #ruby
motherr has joined #ruby
danjo3 has joined #ruby
phryk_ has joined #ruby
ollysmith_ has joined #ruby
Artea- has joined #ruby
Andrew_ has joined #ruby
vigumnov has joined #ruby
teclator_ has joined #ruby
pookie has joined #ruby
Garo__ has joined #ruby
ox1eef_ has joined #ruby
finstern1s has joined #ruby
jmcgnh_ has joined #ruby
peder_ has joined #ruby
ua_ has quit [*.net *.split]
teclator has quit [*.net *.split]
jmcgnh has quit [*.net *.split]
victori has quit [*.net *.split]
cAMP has quit [*.net *.split]
olspookishmagus has quit [*.net *.split]
phryk has quit [*.net *.split]
peder has quit [*.net *.split]
Garo_ has quit [*.net *.split]
AndrewYu has quit [*.net *.split]
lipoqil has quit [*.net *.split]
Artea has quit [*.net *.split]
ollysmith has quit [*.net *.split]
danjo has quit [*.net *.split]
finsternis has quit [*.net *.split]
jidar has quit [*.net *.split]
cAMP_ has joined #ruby
ox1eef has quit [*.net *.split]
danjo3 is now known as danjo
lipoqil_ has joined #ruby
peder_ is now known as peder
jmcgnh_ is now known as jmcgnh
ringo__ has joined #ruby
ua_ has joined #ruby
jidar has joined #ruby
<ringo__>
is bitwise not in rb still ~ ? I tried to use it but it makes my output negative. ~0 yields -1 while ~1 yeilds -2. Im confused https://tio.run/##KypNqvz/v0BBw9BAU68kP75Yw0iTC8itQ@L//w8A
kaleido has quit [Ping timeout: 244 seconds]
crankharder has joined #ruby
donofrio has joined #ruby
crankharder has quit [Ping timeout: 264 seconds]
phryk_ is now known as phryk
<donofrio>
mornin all if I wanted to update a index.html with hostname what would be in the erb? I have so far only "im <%= node['hostname'] %>" but that doesn't update the index file that my nginx server it rendering?
roshanavand has joined #ruby
roshanavand has quit [Remote host closed the connection]
<nakilon>
ringo__ I would say it's .to_s who is doing something wrong; the bitwise negation should change the sign actually
<nakilon>
because sign is one of the bits
roshanavand has joined #ruby
<ccooke>
I think the main issue is that to_s(2) doesn't know what sort of binary representation you want, and therefore can't produce a signed binary output.
<ccooke>
You would need to convert to a specific form (32-bit signed int, for instance)
Artea- is now known as Artea
<ccooke>
>> [ 20 ].pack('s').unpack('B*')
<ccooke>
bah.
<ccooke>
but try that, and try [ ~20 ].pack('s').unpack('B*')
<ccooke>
Basically, normal negative integers in binary require a fixed bit width, because otherwise they are indistinguishable from a positive number with a higher bit width
donofrio has quit [Ping timeout: 260 seconds]
<ccooke>
and the .to_s(2) form does not specify bits
quazimodo has joined #ruby
<ringo__>
I see. Well even if I skip to_s, it still doesn't work the way I would expect it to. Taking very trivial example is flipping 0 and 1
<quazimodo>
anyone have an idea on how I can package up my ruby program to distribute for osx
<ringo__>
Intuitively NOT 0 == 1 and NOT 1 == 0
<quazimodo>
snap packages on linux make life so easy...
<quazimodo>
ringo__: NOT'ing numbers feels weird
<quazimodo>
NOT 0 means anything but 0
<ringo__>
yeah you're right
<quazimodo>
i'm rarely wrong
<ringo__>
lol
<ringo__>
well, even if I work on bytes and do ~0x0
<quazimodo>
i took the wrong woman, she wont argue with me
<quazimodo>
so, sometimes wrong
<ringo__>
sorry, ~0b0
<ringo__>
it still yields -1 :shrug:
<ccooke>
ringo__: it should
<ringo__>
mario's confused
<ccooke>
bitwise not is not the same thing as a logical not. It's not negating the entire object, it's flipping each bit in turn
donofrio has joined #ruby
<ringo__>
and because it's flipping each bit on int32, it flips "more than I would like to" and thus I end up with negative number?
<ccooke>
if you flip the bits on a signed integer, you will *always* get a negative number.
<ccooke>
because you will flip the MSB, which is taken as a sign bit
<sagax>
how to convert "true" to true?
<sagax>
with native of ruby methods
<ccooke>
sagax: How are you getting 'true' as a string?
<ccooke>
(Where does it come from?)
<ccooke>
ringo__: if ~ is flipping more bits than you want it to, then you do not want to use a bitwise not. you want to use some other thing. What is it you actually need to *do*?
<sagax>
ccooke: from database, nosql
<ccooke>
sagax: that means you are probably storing it as a string in your database. Most databases (sql and nosql) have native methods of storing boolean values. Check your schema and the code that writes to the database and fix it so that you are storing the correct value
<ringo__>
ccooke: I'm doing a coding puzzle where I will need to do solve lots of logic gates so at some point I will have to flip 0's and 1's
<ringo__>
s/do solve/resolve/
<sagax>
ccooke: redis not have boolean type
<sagax>
my question not about databases
roshanavand_ has joined #ruby
<sagax>
i have string "true" and i think - how i can got boolean True with right way
<ringo__>
ccooke: although I will be working *only* with 0's and 1's so I could work on a bit, not 32b, if I could
<ccooke>
sagax: `value == 'true'` will return true or false, if that's what you need.
roshanavand has quit [Ping timeout: 268 seconds]
<ccooke>
ringo__: that won't work, really, because bitwise not is an operator on presumed signed integers
<ringo__>
:<
<ccooke>
ringo__: what you need is to use booleans - true and false - and then you can use !value to negate them
<ccooke>
remember, 0 and 1 are just conventional shorthands for true and false when dealing with logic gates
crankharder has joined #ruby
<ringo__>
yeah, well, sigh
<ccooke>
(or you could argue that everything is shorthand for "high voltage" and "Low voltage" if you want to get existentialist about it...)
<ringo__>
I can't make ruby treat my 0 or 1 as a bit and not int32?
<ccooke>
ringo__: I mean... there are a ton of ways you can do it, but they're not as "clean" as using real booleans
<ringo__>
i see
<ringo__>
well, looks like booleans work with (& | ^), but not ~, instead I'll use !
<ccooke>
sagax: yeah, if you're using redis it is limited. You *can* use booleans in it in a way (you can use SETBIT and GETBIT to set and get individual bit offsets in a key, which will return you a 0 or 1. But that's not as readable.
<sagax>
ok, thanks, will looking for about typecasting from redis driver
<ccooke>
I would probably still use the SETBIT and GETBIT for this, since it's less fragile
<nakilon>
I gemified my thing for the terminal session interface and came up with this name https://github.com/Nakilon/shelenium -- included the helloworld example and a primitive bot that plays roguelike
darkxploit has quit [Ping timeout: 260 seconds]
quazimodo has quit [Ping timeout: 260 seconds]
Inline has joined #ruby
Andrew_ is now known as AndrewYu
motherr has quit [Quit: motherr]
yossarian has quit [Ping timeout: 264 seconds]
yossarian has joined #ruby
yossarian has quit [Changing host]
yossarian has joined #ruby
Pixi has quit [Quit: Leaving]
Pixi has joined #ruby
Inline has quit [Ping timeout: 264 seconds]
_ht has joined #ruby
RougeR has joined #ruby
mewfree[m] has quit [Quit: You have been kicked for being idle]
roshanavand_ has quit [Ping timeout: 264 seconds]
kaleido has joined #ruby
Tuor has joined #ruby
aesthetikx has quit [Ping timeout: 252 seconds]
___nick___ has joined #ruby
<sagax>
we have TrueClass and FalseClass, but how i can declare just BooleanClass? (right way)
<havenwood>
sagax: There isn't a boolean class in Ruby. You can create one but the "right way" depends on what you're doing.
<sagax>
to declare methods for casting string to another type