meshsmith has quit [Remote host closed the connection]
govg has quit [Quit: leaving]
duckpupp1 has quit [Ping timeout: 255 seconds]
xall has quit [Ping timeout: 245 seconds]
Derperperd has joined #ruby
Qwertii has joined #ruby
<Qwertii>
hi
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Qwertii>
Does anyone know how I could use nokogiri to find an element with the attribute itemprop="price"
nankyokusei has joined #ruby
Derperperd has quit [Ping timeout: 264 seconds]
Xentil has quit [Ping timeout: 240 seconds]
Xentil has joined #ruby
alexar has quit [Remote host closed the connection]
kazlock has quit [Quit: This computer has gone to sleep]
nankyokusei has quit [Ping timeout: 245 seconds]
fedruantine has quit [Ping timeout: 248 seconds]
zeroDi has quit [Quit: WeeChat 1.6]
hanmac has quit [Ping timeout: 276 seconds]
yqt has quit [Ping timeout: 240 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
fedruantine has joined #ruby
astrobunny has joined #ruby
d^sh has quit [Ping timeout: 264 seconds]
<al2o3-cr>
Qwertii: what do you have now?
d^sh has joined #ruby
<Qwertii>
I just tried html.css(span[itemprop="price"]) but there were some other issue in my code so I havent been able to check if it works yet
myk267 has joined #ruby
<al2o3-cr>
can you gist your code sample/
alexar has joined #ruby
hanmac has joined #ruby
Guest57401 is now known as ged
ged is now known as Guest51474
<acalycine>
How do you escape spaces in arguments in Python?
<acalycine>
*ruby
<acalycine>
lmao
<acalycine>
I get the error "Main-v3(cricapi).rb:22:in `<main>': uninitialized constant Zealand (NameError)"
<acalycine>
When I try to run a method with these args: "core_summary(New Zealand)"
Rodya_ has joined #ruby
djuber has joined #ruby
<havenwood>
acalycine: Spaces and Constants don't mix. No spaces in Constants, just CamelCase or SCREAMING_SNAKE CASE.
gajus has quit [Quit: Connection closed for inactivity]
<acalycine>
Lol
<acalycine>
How would I convert the input "New Zealand" to a readable input for Ruby?
<acalycine>
Splat or?
<havenwood>
What do you mean by "readable?"
<havenwood>
"New Zealand" #=> ?
<havenwood>
acalycine: What's the desired output ^ above?
<acalycine>
That's basically my question, how can "New Zealand" be readable by Ruby?
<Radar>
?xy
<ruby[bot]>
it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
<acalycine>
"New Zealand" is the () for a method
<Radar>
acalycine: This would work a lot better if you showed us the code that you're using.
<acalycine>
score_summary() now needs '' for some reason
<Radar>
Thank you. Taking a look.
<Radar>
Where did this score url come from?
<Radar>
I thought we were debugging match_list_hash?
<acalycine>
Ah, I'll do that. that's the final output
<acalycine>
in order to get to score_url it needs to get the hash
<Radar>
ok, glhf. I've tried to help but now I need to go do real work.
cyphase has joined #ruby
<acalycine>
Thanks anyway. Just needed to know if there was a way to automatically put '' around the input I get from Discord...
Derperperd has joined #ruby
<Radar>
acalycine: For the love of all that is precious. The input you get from discord already has the quotes around it.
jared_nyc has joined #ruby
<Radar>
acalycine: You can verify this, as I showed before, by doing p team.
<Radar>
I am frustrated because I was trying to help you get to the bottom of what match_list_hash was, and then you show me some completely different code about scores.
<Radar>
Like, what are we even trying to debug here? Are you having difficulty focus? I sure as shit am.
<baweaver>
might want to go back over some basics.
<acalycine>
"Ruby allows you to use the splat operator (*) before a parameter in a block to greedily grab all arguments that aren't already covered by others. This is useful when making a command that takes a text as an argument that might also contain spaces, but you don't want to have to use quotes"
<acalycine>
Is this true?
<baweaver>
for the input the code gives, yes
<baweaver>
which is already a string
<baweaver>
but you literally put in two constants
<acalycine>
Yeah, I can see what you're saying.
<acalycine>
That's an issue (probably not an issue) with the API though, right?
<baweaver>
It's not
<acalycine>
Yep.
<baweaver>
When you input something to slack that's what it's grabbing
<baweaver>
when you put it directly to the code though
StoneCypher has joined #ruby
<acalycine>
Yeah. It's just not very user-friendly to put quotes around "New Zealand" though.
<baweaver>
...
<acalycine>
Why not?
<baweaver>
On line 23 of your program it is required absolutely
<baweaver>
the slack input is already a string
<baweaver>
so putting quotes around that part would be silly
<acalycine>
You mean "score_summary(team='Bangladesh')"
<acalycine>
etc?
<baweaver>
.........
<acalycine>
That was just a test to see if it worked
fedruantine has joined #ruby
<acalycine>
the input comes from
<acalycine>
bot.command :score do |event, team|
<acalycine>
score_summary(team)
<acalycine>
end
<baweaver>
I'm aware of this
<acalycine>
Yes.
<baweaver>
you use a splat on team
<baweaver>
bot.command watches for the command score
<baweaver>
so it sees: score cricket New Zealand
<baweaver>
and assigns that to.....
<acalycine>
an array
<baweaver>
>> event, team = %w(cricket New Zealand); [event, team]
<dminuoso>
FrankD: Most GUI bindings are kind of outdated or the support is meh, or they lack features.
<FrankD>
hell even TCL had Tk!
<dminuoso>
FrankD: In our last project we separated the GUI entirely, developed it in C++ and connected the Ruby logic through an object request broker.
<FrankD>
yeah
<dminuoso>
Made things fucktons easier because you don't get shot in the back by things such as the the GVL
<FrankD>
well my first thought was.. Ruby for IRC Client scripting
<FrankD>
then I was like eh why not write the whole thing in Ruby :P
<dminuoso>
There's official curses bindings
<FrankD>
lol, not looking to remake epic/irssi
<dminuoso>
Im just saying. ;-)
<dminuoso>
FrankD: The main issue with the qtbindings library linked above is that they don't suport qt 5.0 yet..
<FrankD>
ah
<dminuoso>
Which is ultra sad, considering it's 4 years old.
<FrankD>
and no native support for winblows SDKs?
<FrankD>
i dont even know what the windows API is called now :P
<dminuoso>
FrankD: Actually, there is!
<dminuoso>
FrankD: You can call the entire Win32 API natively.
<FrankD>
wrapper for that?
<dminuoso>
Without any gems in fact.
<FrankD>
o.O
<FrankD>
got any links?
<FrankD>
atleast i could write a shim and do a *nix version later
<dminuoso>
FrankD: Oh well, there's a wrapper library to ease things up win32-api
<FrankD>
thats ok, as gross as the api is.. I've worked with Win32 a bit
matrix9180 is now known as matrix9180[away]
* FrankD
shudders
<dminuoso>
Oh interestingly it's more than just an FFI wrapper
<dminuoso>
didn't know
<dminuoso>
Ah well.
<dminuoso>
FrankD: But if you insist you can call it natively from Ruby.
<FrankD>
maybe i should just write it in RoR
<FrankD>
and let the browser draw it
<FrankD>
:P
cibs has quit [Ping timeout: 245 seconds]
<FrankD>
and just use CodeMirror or something to edit/upload client-side code
<FrankD>
or Ace
cibs has joined #ruby
Guest95085 is now known as ged
ged is now known as Guest63187
<FrankD>
dminuoso, how tough was it to implement it your way? C++ core with Ruby bindings?
raul782 has quit [Read error: Connection reset by peer]
<FrankD>
effing Hexchat has Python (bleh) and LUA (BLEH!).. maybe toss some Ruby in dere
govg has quit [Quit: leaving]
raul782 has joined #ruby
tildes has quit [Ping timeout: 248 seconds]
<FrankD>
although i dont really like Hexchat's GUI.. it'd still be nice
<dminuoso>
FrankD: Depending on what you do, it may even be easier to approach this from the other way around. Write the UI and other components in C++, and then embed ruby with the semi-official MRuby
ta has quit [Remote host closed the connection]
<dminuoso>
boost asio is fun ;-)
<FrankD>
screw it, ill write my scripts in plain C
pandaant has joined #ruby
<FrankD>
_without_ libc!
<FrankD>
and just dynamically load objects.
jeyraof has quit [Quit: This computer has gone to sleep]
<dminuoso>
FrankD: You can't write it in plain C without libc.
<dminuoso>
FrankD: Without a libc its not C.
conta has joined #ruby
<FrankD>
uclibc :P
jenrzzz has joined #ruby
<dminuoso>
FrankD: I recommend musl
<dminuoso>
uclibc is dead
<FrankD>
oh is it?
<dminuoso>
Yes.
<dminuoso>
musl is the current state of the art miniature C library
matrix9180[away] is now known as matrix9180
matrix9180 is now known as matrix9180[away]
<dminuoso>
Though even those are real C standard libraries.
<FrankD>
yeah
<FrankD>
the without libc was more of a joke
blaxter has joined #ruby
nankyokusei has joined #ruby
<dminuoso>
FrankD: Point of interest, implementations must provide a so called "freestanding environment", in which only a very small subset of the C library (mostly just types) must be available.
<FrankD>
aye, i do a lot of AVR8 stuff
Snickers has joined #ruby
blaxter has quit [Client Quit]
<dminuoso>
Cool :)
<dminuoso>
FrankD: As a hobby or professionally?
ddrmanxbxfr has quit [Remote host closed the connection]
<FrankD>
dminuoso, hobby
<FrankD>
i got annoyed at hand-testing JFET characteristics by hand
<dminuoso>
You just made me lookup what JFETs are.
<FrankD>
so i whipped up a PCB with a 24-bit ADC and 16-way muxer, SPI to an ATTiny.. which has a shit USI (Universal Serial Interface)
<FrankD>
so I wound up just bitbanging SPI
<FrankD>
yeah you try to match them, Idss and Vpp aka Vgs(off) are two important characteristics
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FrankD>
so I could test 16 at a time that way without flipping a switch to go between Idss/Vpp and then manually writing it in a spreadsheet and tagging the JFET..
nankyokusei has quit [Ping timeout: 264 seconds]
charliesome has joined #ruby
<dminuoso>
SPI, ATTiny, USI, Idss, Vpp, Vgs...
<dminuoso>
You lost me.
<dminuoso>
:S
<FrankD>
spi is a serial communications protocol
<dminuoso>
My understanding of processor stops at the architectural level.
<FrankD>
you send a bit, you receive a bit
<dminuoso>
Oh right.
<FrankD>
1 data line, 1 clock line
cajone has quit [Ping timeout: 258 seconds]
dionysus69 has joined #ruby
<FrankD>
so you shift a bit out an IO line, then you shift a bit in on the same line.. the USI is supposed to make that easy
<dminuoso>
What kind of characteristics are you testing on JFETs?
raul782 has quit [Remote host closed the connection]
<dminuoso>
Their switching speed?
<FrankD>
no
ifctj has quit [Ping timeout: 276 seconds]
<FrankD>
"Pinchoff voltage" and saturation current for Drain to Source (Idss)
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Mortomes|Work has joined #ruby
matrix9180[away] is now known as matrix9180
nofxx has quit [Remote host closed the connection]
Derperperd has quit [Ping timeout: 276 seconds]
nofxx has joined #ruby
charliesome has joined #ruby
<djellemah>
I asked this yesterday, no answer so I'm trying again: I need to parse some yaml with tags (eg !ruby/object:PhusionPassenger::Utils::TeeInput). I've had a go at telling Psych (alternatively Syck) to ignore tags that it can't resolve to classes, and just return them as hashes. Seems the only way to do that is to override various things in Psych (alternatively Syck). Am I missing the obvious way to do this easily?
acalycine has quit [Quit: bye]
cajone has joined #ruby
charliesome has quit [Client Quit]
nankyokusei has joined #ruby
nofxx has quit [Remote host closed the connection]
nofxx has joined #ruby
teclator has joined #ruby
dionysus69 has quit [Ping timeout: 256 seconds]
nankyokusei has quit [Ping timeout: 240 seconds]
xall_ has joined #ruby
xall has quit [Ping timeout: 245 seconds]
SesMan has joined #ruby
sebastia_ has joined #ruby
unreal has quit [Ping timeout: 255 seconds]
unreal has joined #ruby
bigkevmcd has joined #ruby
sebastiansier has quit [Ping timeout: 252 seconds]
pandaant has quit [Remote host closed the connection]
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<djellemah>
mwlang: um hangon that's in Gemfile. Not sure that works in .gemspec files as well.
<kke>
mwlang: i got screwed with the ~> 3.0 earlier, it indeed takes 3.* not 3.0.*.
nowhere_man has joined #ruby
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
<mwlang>
kke: I updated to a newer version of someone’s gem and they added that ~> 3.0 in the last release, breaking code that was previous working for Rails 4.x, so it looks like I’ll send a PR out to fix that.
aredridel has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mwlang>
finally found the actual explanation in Bundler’s docs: Most of the version specifiers, like >= 1.0, are self-explanatory. The specifier ~> has a special meaning, best shown by example. ~> 2.0.3 is identical to >= 2.0.3 and < 2.1. ~> 2.1 is identical to >= 2.1 and < 3.0. ~> 2.2.beta will match prerelease versions like 2.2.beta.12. ~> 0 is identical to >= 0.0 and < 1.0.
jrafanie has joined #ruby
Derperperd has joined #ruby
vali_ has joined #ruby
gnufied has quit [Quit: Leaving]
Mortomes|Work has quit [Ping timeout: 260 seconds]
<z64>
hi all, wondering if someone can point me in the right direction to learn how to do some things concurrently. basically, i have four different calls to make to an API using a library, generated from an #each block. since the API is 'pretty slow', i'd like to make all four calls at once and just wait until each thread is done.
Ropeney has joined #ruby
<z64>
since i've never done this kind of thing before, my google-fu is failing me pretty bad :(
hoov has joined #ruby
JoshS has joined #ruby
nettoweb1 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
flashbang has quit [Quit: ERC (IRC client for Emacs 25.1.1)]
<z64>
alright. i'll play with that a bit. another lib i'm already using depends on concurrent-ruby, i'm thinking i can use Futures that are bundled with it too..
ferr1 has quit [Quit: WeeChat 1.6]
legionas has quit [Quit: Konversation terminated!]
_geoff_ has joined #ruby
Snowy has quit [Remote host closed the connection]
Snowy has joined #ruby
_geoff has quit [Ping timeout: 240 seconds]
bmurt has joined #ruby
ecuanaso has joined #ruby
dionysus69 has quit [Ping timeout: 255 seconds]
tyang__ has joined #ruby
harai_ has joined #ruby
binaryplease has quit [Quit: binaryplease]
djbkd has joined #ruby
Snowy has quit [Ping timeout: 264 seconds]
tyang_ has quit [Ping timeout: 256 seconds]
harai_ has quit [Ping timeout: 264 seconds]
saneax is now known as saneax-_-|AFK
Snowy has joined #ruby
zapata has quit [Ping timeout: 258 seconds]
ta has quit [Remote host closed the connection]
cdg has joined #ruby
chouhoulis has joined #ruby
al2o3-cr has joined #ruby
Silthias has joined #ruby
ianmethyst has joined #ruby
Silthias2 has quit [Ping timeout: 240 seconds]
patarr has quit [Ping timeout: 240 seconds]
LoneHerm_ has joined #ruby
SteenJobs_ has joined #ruby
zapata has joined #ruby
SteenJobs_ has quit [Client Quit]
aufi has quit [Quit: Leaving]
LoneHerm_ has quit [Ping timeout: 245 seconds]
xall_ has joined #ruby
Guest1574 is now known as ged
ged is now known as Guest57620
emilkarl has joined #ruby
vdl has joined #ruby
DevilTiger has joined #ruby
<emilkarl>
How would you timeshift a "weekday" array.. [1,3,5] (mon, wed, fri) lets say I want the same array but 2 days forward [3,5,7] or back [6,1,3]. How would you do that in a nice ruby way?
<Burgestrand>
emilkarl or well, whatever you want it to be really as long as you're consistent ;) days go from 0-6
<emilkarl>
hmm yes but in my case synday is 7 :/
<Burgestrand>
Guess you'll have to adjust the zeroes then :)
UserJosh has joined #ruby
<emilkarl>
yes but with % 7, it is just the zeros that goes wrong?
<emilkarl>
right?
<emilkarl>
0 means 7
Derperperd has joined #ruby
<Burgestrand>
emilkarl Yeah, for you it does
nhhc has quit [Ping timeout: 252 seconds]
<ytti_>
i would make days 0-6 internally
<Burgestrand>
(it's not uncommon for sundays to be 0 in programming environments)
jshjsh has quit [Ping timeout: 240 seconds]
<emilkarl>
no i know
mistym has joined #ruby
mistym has quit [Changing host]
mistym has joined #ruby
<emilkarl>
but I am using something that uses 1 as monday
<emilkarl>
hmm
Xavaier has joined #ruby
opt9 has quit [Quit: Bye bye]
<emilkarl>
I guess I have to figure that out because 0-6 would mean %7 always works
<emilkarl>
that would be much easier
raul782 has joined #ruby
<emilkarl>
i would always do [2,4,6] { |d| ((d-1)-2)%7+1 }
opt9 has joined #ruby
<emilkarl>
hehe
<emilkarl>
or no..because -1 would fail
<emilkarl>
Darn
nettoweb has joined #ruby
Derperperd has quit [Ping timeout: 258 seconds]
icey has joined #ruby
icey has quit [Changing host]
icey has joined #ruby
<Burgestrand>
Just make a second pass and convert all 0s to 7s :)
[reed] has quit [Ping timeout: 240 seconds]
<Burgestrand>
Do `map` again, so to say
<ytti_>
7:44 < emilkarl> i would always do [2,4,6] { |d| ((d-1)-2)%7+1 }
<ytti_>
i think this solution works
<dminuoso>
Burgestrand: I learned that the hard way. I set up my mobile phone anew, setting an alarm clock for the first 5 days without thinking. On friday I was late for a meeting.. quite embarrassing.
<dminuoso>
Burgestrand: Yeah. I'm a little unsure what Google's reasoning behind this is, perhaps the majority of folks views sunday as the first day..
<ytti_>
US views sunday first
<ytti_>
EU views sunday last
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
ytti_: Figures. This is actually reflected in German language as well, since the German word for "wednesdays" is short for "middle of the week"
<ytti_>
from abrahamic religion POV, god rested on last day, whish is saturday (sabbato in greek)
chouhoul_ has joined #ruby
<dminuoso>
Though this is not reflected in any German calendar.
<Burgestrand>
dminuoso I run into this problem every now and then since I prefer to have my interfaces in english, and in my culture sunday is the last day but quite often putting things in english also gives me sunday as first day. :)
<ytti_>
so really, we should be starting work sunday
<dminuoso>
ytti_: Amazing to start the week with.. not working!
<dminuoso>
I love the attitude.
chouhoul_ has quit [Remote host closed the connection]
<dminuoso>
It's almost Italian.
<emilkarl>
Thanks
chouhoul_ has joined #ruby
<Burgestrand>
ytti_ Huh, wow, didn't know saturday translated to the actual sabbath in Greek, that's cool.
<ytti_>
in middle east friday+saturday is weekend
<ytti_>
and work starts sunday
<Burgestrand>
TIL!
<ytti_>
Burgestrand, me neither, until i moved to greek speaking country and saw store opening hours :/
chouhoulis has quit [Ping timeout: 240 seconds]
nhhc has joined #ruby
saslam has joined #ruby
<Burgestrand>
ytti_ hehe
rajat has joined #ruby
Beams has quit [Quit: .]
emilkarl has quit [Quit: emilkarl]
Technodrome has joined #ruby
<catphish>
i'm looking for a way to allow untrusted users to execute very simply code under ruby, the kind of code one might enter into a spreadsheet cell, is there any obvious solution?
gajus has joined #ruby
Beams has joined #ruby
ianmethyst has quit [Quit: WeeChat 1.7]
cajone has quit [Ping timeout: 252 seconds]
pwnd_nsfw` has joined #ruby
gix has quit [Ping timeout: 252 seconds]
nowhere_man has joined #ruby
pwnd_nsfw has quit [Ping timeout: 245 seconds]
gix has joined #ruby
Burgestrand has quit [Quit: Closing time!]
shinnya has joined #ruby
rajat has quit [Ping timeout: 256 seconds]
alxs has quit [Ping timeout: 260 seconds]
douglascorrea has quit [Ping timeout: 258 seconds]
<ytti_>
catphish, $SAFE=4 and eval?
[reed] has joined #ruby
[reed] has joined #ruby
[reed] has quit [Changing host]
<Papierkorb>
catphish: What do you mean, like ruby code? Solution: DON'T
<ytti_>
yeah it might be better to just write some small dsl
<Papierkorb>
catphish: It is really complex to do it correctly. Any sandboxing gem you'll find is a hoax, it's not possible to do it safely in-process. And if you fork() for it, there are so soo sooooo many things to consider
<catphish>
Papierkorb: to clarify, i had rather discounted eval'ing ruby, i was thinking more of a simple interpreted language implemented in ruby
<Papierkorb>
catphish: if all you need are math equations, parse and evaluate them manually, using a proper parser and everything
<Papierkorb>
ytti_: Never *ever* give a user access to an eval-like functionality
<catphish>
but i have not the skills to write the parser, so i was hoping something might exist in the form of a "safe" ready made interpreted language written in ruby
Semtex-h has quit []
shinnya has quit [Ping timeout: 240 seconds]
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
brent__ has joined #ruby
nowhere_man has quit [Remote host closed the connection]
benlieb has joined #ruby
dgarstang has joined #ruby
<dgarstang>
How can I dump a json object without all the quotes being \"escaped\" ?
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb>
dgarstang: dump where? to stdout for debugging purposes?
<dgarstang>
Papierkorb: Yes
<Papierkorb>
dgarstang: I just use the `#display` method for that: foo.to_json.display
<Papierkorb>
Wouldn't use it for anything else
<dgarstang>
i'll give it a try
govg has joined #ruby
<dgarstang>
Papierkorb: Nope. I still get ... "create_instance_tags":"{\"Version\":\"2012-10-17\",\"Statement\":[{
<Papierkorb>
What's your code line?
StoneCypher has quit [Ping timeout: 252 seconds]
mark_66 has quit [Remote host closed the connection]
bweston92 has quit [Quit: Connection closed for inactivity]
<dgarstang>
Papierkorb: inline_policies.to_json.display ... same result
douglascorrea has joined #ruby
<dgarstang>
Ruby.. only language I've seen that implicitly turns a variable into a statement based on a method suffixed at the end. Yeah, that's real clear
<Papierkorb>
...?
<Papierkorb>
display takes `self` and #write's it to STDOUT
<Papierkorb>
It's a really simple method
<dgarstang>
Papierkorb: There's no statement in front of it
s2013 has joined #ruby
<Papierkorb>
..huh?
<dgarstang>
Papierkorb: inline_policies is a variable
<Papierkorb>
`puts` isn't a statement either
<Papierkorb>
it's a normal method
<Papierkorb>
in fact, statements are hard to find in ruby.
unshadow has quit [Ping timeout: 260 seconds]
<dgarstang>
Papierkorb: in any case, the weirdness of ruby still won't print it as a json object
<Papierkorb>
And something is overwriting your display method.
<Papierkorb>
["foo"].to_json.display
<Papierkorb>
Works as intended
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dgarstang>
It's ruby. Of course it is. Thanks anyway.
<apeiros>
"json object"
<Papierkorb>
Giving: ["foo"]=> nil Note that the =>nil is output from pry on my end.
antgel_ has quit [Ping timeout: 276 seconds]
aganov has quit [Remote host closed the connection]
<dgarstang>
I know. I'll just remove all the escapes by hand. That will take about an hour
<Papierkorb>
...
unshadow has joined #ruby
blackmes1 has joined #ruby
<Papierkorb>
Yeah because writing STDOUT.write(asdasd) is really hard as workaround
<Papierkorb>
But please, rage on
<apeiros>
you did notice that they have a string with quotes in them in the json, yes?
<Papierkorb>
And waste your time while blaming ruby
<apeiros>
so no wonder they're escaped…
<dgarstang>
apeiros: No. I have no idea
<Papierkorb>
apeiros: Lol that I didn't see.
ecuanaso has joined #ruby
alxs has joined #ruby
<apeiros>
dgarstang: that much I gathered from your rant :-p
<dgarstang>
Papierkorb: STDOUT.write(inline_policies) = same result
<Papierkorb>
dgarstang: you're putting JSON into JSON. What do you expect? Ruby magically knowing that the string in the object is in fact is another JSON object?
<Papierkorb>
dgarstang: Working as intended. Fix your input.
<Papierkorb>
It's GIGO. Garbage In, Garbage Out.
xall_ has joined #ruby
<dgarstang>
If I'm printing json as json, you'd expect puts inline_policies to work, but it doesn't
despai has joined #ruby
hobodave has joined #ruby
<Papierkorb>
... huh? JSON as JSON?
<dgarstang>
"you're putting JSON into JSON"
alexar has joined #ruby
<apeiros>
Papierkorb: I wish you good luck. I don't think I'd have the patience.
workmad3 has joined #ruby
<Papierkorb>
a JSON serialized object as string into a JSON object dgarstang
<dgarstang>
Ok, well we've tried several methods and none seem to work, so thanks anyway
<Papierkorb>
apeiros: Ah it's entertaining seeing people raging on and blaming ruby for things their shitty input is at fault at
<havenwood>
dgarstang: JSON is a serialization format. You serialize Ruby to a JSON String. It's just a regular String at that point, a String that has JSON in it. If you deserialize your JSON and it has more JSON in it, you're in JSON inception, on level deep. Don't forget to bring a top.
<dgarstang>
havenwood: I would if I could understand it
UserJosh has quit [Ping timeout: 240 seconds]
<havenwood>
dgarstang: So if you have this JSON: "{\"[]\":\"{}\"}"
<havenwood>
dgarstang: And deserialize it, you'll end up with this String: "{\"[]\":\"{}\"}"
<havenwood>
dgarstang: bad paste
<havenwood>
dgarstang: You'll end up with this Hash: {"[]"=>"{}"}
avril14th has quit [Remote host closed the connection]
slappy16 has joined #ruby
<havenwood>
dgarstang: Try it in your REPL (irb or pry)
<havenwood>
dgarstang: What is the key and value in the resulting, deserialized Hash?
<havenwood>
dgarstang: Both JSON!
nettoweb has joined #ruby
<havenwood>
dgarstang: It's serialized more than one level deep. That might be a mistake in your case.
<chrisarcand>
Does anyone know if the Octokit gem is considered threadsafe?
<apeiros>
chrisarcand: does the documentation state that it is threadsafe?
nankyokusei has joined #ruby
UserJosh has joined #ruby
<chrisarcand>
I cannot find any information regarding threadsafety (be it safe or not) about the gem anywhere, hence my asking here. Hoping for someone who's used it who might have experienced issues or not.
<baweaver>
Most Ruby is not written in such a manner
<apeiros>
rule of thumb is: if it is threadsafe, it's documented as such
<baweaver>
so unless explicitly stated it's probably not
<havenwood>
dgarstang: If you go on and deserialize the key and value, the key is an Array and the Value a hash. Just examples, but keep in mind you can serialize to JSON, then serialize the resulting String to JSON again. It's confusing if you do.
<apeiros>
otherwise it's almost certainly not
alexar has quit [Ping timeout: 276 seconds]
<havenwood>
dgarstang: Make any sense?
Guest57620 is now known as ged
<apeiros>
note: that does not mean that it's unusable in a threaded application
<baweaver>
It more of means proceed with caution
ged is now known as Guest16853
<chrisarcand>
Fair. Thanks for the input.
jshjsh has quit [Ping timeout: 256 seconds]
tercenya has quit [Remote host closed the connection]
<havenwood>
dgarstang: Or maybe this is a better example: ''".to_json.to_json.to_json
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alexar has quit [Remote host closed the connection]
alexar has joined #ruby
cdg has quit [Ping timeout: 256 seconds]
mikecmpbll has joined #ruby
alxs has quit [Ping timeout: 255 seconds]
csk has quit [Ping timeout: 276 seconds]
UserJosh is now known as JoshS
splud has joined #ruby
<antoniobeyah>
if I have a directory structure: fruits/<fruit_group>/<fruit_type>/<fruit_name> is there an easy way to generate that in table form?
<baweaver>
define table form
<antoniobeyah>
| fruit group | fruit type | fruit name |
<antoniobeyah>
rows and columns
<baweaver>
There is a potentially easy one
<baweaver>
Look into directory globbing
<apeiros>
antoniobeyah: you can use Dir.glob + String#split
<baweaver>
yep, and split on /
<baweaver>
for the file name
Lord_of_Life has quit [Excess Flood]
milardov_ has quit [Remote host closed the connection]
<antoniobeyah>
cool, are there any libraries that will print a table?
Lord_of_Life has joined #ruby
<antoniobeyah>
from that data
milardovich has joined #ruby
<baweaver>
CSV probably has some stuff
LoneHerm_ has joined #ruby
<antoniobeyah>
thanks, I'll check it out
<apeiros>
if you just want an ascii table - there are gems
<apeiros>
it's not too difficult to do with plain printf, though
pilne has joined #ruby
milardovich has quit [Ping timeout: 240 seconds]
<antoniobeyah>
true, i just didn't want to deal with it ;)
LoneHerm_ has quit [Ping timeout: 240 seconds]
<apeiros>
gem then. I'm sure ruby-toolbox has something for you :)
__Yiota has joined #ruby
nvms has joined #ruby
nvms has quit [Max SendQ exceeded]
gusrub has joined #ruby
nvms has joined #ruby
_djbkd has joined #ruby
whathappens has joined #ruby
nofxx has quit [Remote host closed the connection]
Xeago has quit [Ping timeout: 240 seconds]
nofxx has joined #ruby
nofxx has joined #ruby
nofxx has quit [Changing host]
nvms has quit [Client Quit]
Xeago has joined #ruby
benlieb has joined #ruby
unshadow_ has joined #ruby
Technodrome has joined #ruby
Technodrome has joined #ruby
Technodrome has quit [Changing host]
diego_ has joined #ruby
gusrub has quit []
unshadow has quit [Ping timeout: 255 seconds]
biberu has joined #ruby
milardov_ has joined #ruby
<Fetch>
I'm running into GH-1513 with Ruby 2.4.0. The fix has been committed to trunk, how long and what does the process look like to get that added to the 2.4 branch for 2.4.1?
synthroid has joined #ruby
Guest22916 is now known as rprimus
alphor has quit [Quit: Bye!]
benlieb has quit [Quit: benlieb]
alphor has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
frozengeek__ has joined #ruby
duderonomy has joined #ruby
raul782 has quit [Remote host closed the connection]
nankyokusei has joined #ruby
renchan has quit [Quit: Leaving...]
gusrub has joined #ruby
benlieb has joined #ruby
nankyokusei has quit [Ping timeout: 240 seconds]
gusrub has quit [Client Quit]
benlieb has quit [Client Quit]
__Yiota has joined #ruby
amclain has joined #ruby
gusrub has joined #ruby
tomphp has joined #ruby
gusrub has quit [Client Quit]
dc4 has joined #ruby
harfangk has quit [Ping timeout: 252 seconds]
gusrub has joined #ruby
tolerablyjake has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has quit [Quit: inabit. zz.]
Technodrome has quit [Read error: Connection reset by peer]
milardov_ has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<frewsxcv_old>
Where { and } are delimiters of a block that return an expression
<SpComb>
what do you need the block for?
<frewsxcv_old>
In reality, it's a block that's like 10 lines long
benlieb has quit [Quit: benlieb]
<frewsxcv_old>
So it only executes if @some_variable is false-y
Xav_ has joined #ruby
whathappens has quit [Remote host closed the connection]
<Papierkorb>
frewsxcv_old: You want to memoize the result of an expensive calculation? I suggest moving the block into its own method, so the line becomes a simple `@foo ||= something_expensive`
whathappens has joined #ruby
jackjackdripper has joined #ruby
<frewsxcv_old>
So then the answer is "it's not possible" ?
<Papierkorb>
frewsxcv_old: Hard to tell, could you please give us more context what you'
<frewsxcv_old>
I know ways to get around it, I'm just wondering if Ruby has some way to accomplish what I said
<Papierkorb>
*what you're trying to accomplish=?
<frewsxcv_old>
What other context do you need?
Xavaier has quit [Ping timeout: 240 seconds]
Xav_ is now known as Xavaier
<frewsxcv_old>
In Rust, you can do something like: let x = { some_function(); 5 };
lucz has joined #ruby
nvms has joined #ruby
<frewsxcv_old>
Not that you'd want to with this simple of an example, but all blocks are expressions
whathappens has quit [Read error: Connection reset by peer]
blackwind_123 has quit [Ping timeout: 258 seconds]
nvms has quit [Client Quit]
<Papierkorb>
frewsxcv_old: I don't know Rust, if you're trying to memoize that you called some expensive method already, it won't get much shorter than what you have. Though if you have a 10 line begin ... end block there, I'd still move it into its own method
d^sh has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
blackwind_123 has joined #ruby
<frewsxcv_old>
Darn, that's unfortunate. I don't see the value in creating another method for this, unless it was just a dummy internal function
cdg has quit [Remote host closed the connection]
<frewsxcv_old>
if defined? @some_variable; @some_variable; else; some_expensive_stuff(); end
<frewsxcv_old>
Even that seems nicer than a new method
vnzvg has joined #ruby
Zamyatin has joined #ruby
<Radar>
@some_variable ||= some_expensive_stuff ?
cdg has joined #ruby
<frewsxcv_old>
Actually, it'd be:
<Radar>
oh I see that Papierkorb suggested that already.
<Radar>
frewsxcv_old: You've written ||= in the longest way I know.
alexar has joined #ruby
<frewsxcv_old>
Right, but I want to keep the logic in the method
<Papierkorb>
I'd wager that even a ternary operator would be nicer, though if @some_variable can't be legitimately be nil or false, you should prefer the ||= version
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
flvszch50 has joined #ruby
<Papierkorb>
frewsxcv_old: And the added value of having it in its own method would be to increase readability. As this is (also) personal taste, won't talk you into doing it. I guess you can make a case that if the method really just returns a memoized @some_variable then it's fine
willdrew_ has joined #ruby
willdrew_ has quit [Client Quit]
<Papierkorb>
like `def foo; @foo ||= begin ... end; end`
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<frewsxcv_old>
Oh, begin...end is what I was looking for
workmad3 has joined #ruby
benlieb has joined #ruby
<Papierkorb>
Please note that using begin...end like that could be regarded as a hack frewsxcv_old
nvms has joined #ruby
<frewsxcv_old>
For what reasons?
willdrew has quit [Ping timeout: 240 seconds]
alexar has quit [Ping timeout: 240 seconds]
flvzsch50 has quit [Ping timeout: 256 seconds]
jhack has quit [Quit: jhack]
<baweaver>
begin ... end for cache is not uncommon
strongcode has joined #ruby
<baweaver>
I've seen it done with lambdas as well
alexar has joined #ruby
dgarstang has quit [Ping timeout: 240 seconds]
<baweaver>
the other common way is a memoize decorator: memoized def method_name ... end
chouhoulis has joined #ruby
`tim` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
markholmes has joined #ruby
<frewsxcv_old>
Are there pitfalls with begin...end? I don't see any issues with this
Pumukel has quit [Remote host closed the connection]
Pumukel has joined #ruby
<Papierkorb>
frewsxcv_old: There aren't
workmad3 has quit [Ping timeout: 255 seconds]
jhack has joined #ruby
tvw has joined #ruby
chouhoul_ has quit [Ping timeout: 245 seconds]
MrPunkin has quit [Quit: MrPunkin]
nvms has quit [Quit: This computer has gone to sleep]
alxs has quit [Ping timeout: 255 seconds]
chouhoulis has quit [Ping timeout: 240 seconds]
biberu has quit []
nvms has joined #ruby
sballert has joined #ruby
<James123>
Does anyone know a function that can normalise text e.g. russian / greek etc. characters to latin ones?
polishdub has quit [Quit: Leaving]
sballert has quit [Client Quit]
last_staff has quit [Quit: last_staff]
ecuanaso has joined #ruby
<zenspider>
that sounds like a bad idea... can (should?) you even do that? very little overlap
<apeiros>
James123: the term you have to look for is transliteration
sballert has quit [Remote host closed the connection]
<lucz>
Radar: yeah I saw that, it's how I got to the script, but the mysql bit throws me off, the server is a new server, so would I need to run a mysql backup and restore it onto the server im running the script on?
Guest10208 is now known as ged
sballert has joined #ruby
<lucz>
Radar: and then enter the local mysql authentication?
ged is now known as Guest16921
<Radar>
lucz: I don't know past what I can google.
sballert has quit [Client Quit]
<lucz>
Radar: okay mate, thanks anyways
Lord_of_Life has quit [Excess Flood]
<lucz>
Radar: appreciate the help :)
<Papierkorb>
Radar: OHAYO btw
<Radar>
Papierkorb: OHAYO
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
prawnzy has quit [Remote host closed the connection]
kht has joined #ruby
LoneHerm_ has quit [Ping timeout: 252 seconds]
millerti has joined #ruby
RickHull has joined #ruby
StoneCypher has quit [Ping timeout: 240 seconds]
<RickHull>
what's a good way to interface with some kernel based C structures? for example, how can I determine from ruby whether a kernel timeval struct is a different size on 32 bit vs 64 bit platform?
Lord_of_Life has quit [Excess Flood]
nettoweb has joined #ruby
DoctorMonocular has joined #ruby
<DoctorMonocular>
hey everyone
<RickHull>
or, what the byte length is on "my" platform
Lord_of_Life has joined #ruby
sepp2k has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 258 seconds]
alxs has joined #ruby
<DoctorMonocular>
Weird requirement I'm hoping I can get help with. I solved it in a shitty way, hoping I can do better. I have a string that I want to gsub all vowels out of, and replace them with random numbers, so I use gsub to match a number, and use a block that generates a random number. The problem is that I want all the numbers to be unique within the string, so I need a way to track which replacements have been made
<DoctorMonocular>
already so I don't duplicate any.
blackbombay has joined #ruby
<DoctorMonocular>
The shitty solution I have is to store each random replacement in an array as part of the gsub block, then check at the end if all values in that array are unique. If not I try again, until all values are unique
<DoctorMonocular>
the code is gross and inefficient and confusing, I hate it, even though it technically works
<RickHull>
would you replace e.g. "a" with say 5 the first occurrence and then anything other than 5 (or another number already used) for the second?
<al2o3-cr>
RickHull: can get that information with fiddle, it's in the ruby core
<DoctorMonocular>
RickHull: yes
<RickHull>
doing "random" substitutions while ensuring uniqueness for the generated numbers is an ugly problem
<RickHull>
e.g. GUIDs and UUIDs
NeverTired has joined #ruby
alxs has quit [Ping timeout: 264 seconds]
<RickHull>
DoctorMonocular, if space is important, then you can store which numbers have been used in a bitmap
mikecmpbll has joined #ruby
<RickHull>
but this means lots of bitwise operations to register a newly used number
<RickHull>
al2o3-cr, will check it out, thx
<al2o3-cr>
np
<RickHull>
and you'll want to limit your scope of available numbers
<RickHull>
or you can just store your used numbers as hash keys (or set members)
<RickHull>
DoctorMonocular, a more efficient way to have unpredictable substitutions without collision
<RickHull>
would be to just generate a list of unique numbers ahead of time, and pop the stack as needed
<RickHull>
rather than generate, test for collision, regenerate
<RickHull>
for example, you could shuffle 1..100
Derperperd has quit [Ping timeout: 245 seconds]
<RickHull>
though shuffling itself can be grossly inefficient
<ruby[bot]>
al2o3-cr: # => undefined method `parse_struct_signature' for Fiddle::CParser:Module (NoMethodError) ...check link for more (https://eval.in/722590)
<RickHull>
in this method -- I would be translating the linux files "by hand" into Fiddle commands?
<al2o3-cr>
RickHull: oh yeah
<RickHull>
i was hoping to just read some stuff off the system
<RickHull>
i.e. my running linux system, assuming the source is on the filesystem in a known location
<al2o3-cr>
not possible with fiddle then
<al2o3-cr>
afaik anyway
redhedded1 has joined #ruby
<RickHull>
hmmm
<RickHull>
i would think it does -- that timeval is part of a C library on my system
<RickHull>
fiddle should let me interact with it
benlieb has quit [Quit: benlieb]
FrankD has quit [Ping timeout: 240 seconds]
<al2o3-cr>
not without creating it first
<RickHull>
hm. i know i have to create some stuff like the wrapper