JeanCarloMachado has quit [Ping timeout: 268 seconds]
romeoh_ has joined #ruby
JeanCarloMachado has joined #ruby
cschneid_ has joined #ruby
electrostat has quit [Quit: uwotm8]
tristanp has quit [Ping timeout: 258 seconds]
romeoh has quit [Ping timeout: 240 seconds]
electrostat has joined #ruby
t-recx has quit [Read error: Connection reset by peer]
Azure has joined #ruby
feelx has quit []
rhyselsmore has joined #ruby
nankyokusei has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
ovaltine1 is now known as ovaltine
JeanCarloMachado has quit [Ping timeout: 255 seconds]
spheric_ has quit [Ping timeout: 258 seconds]
JeanCarloMachado has joined #ruby
spheric has joined #ruby
nankyokusei has quit [Ping timeout: 260 seconds]
spheric has quit [Client Quit]
xco has quit [Quit: xco]
spheric has joined #ruby
xco has joined #ruby
xco has quit [Client Quit]
esObe_ has quit [Remote host closed the connection]
xco has joined #ruby
xco has quit [Client Quit]
xco has joined #ruby
xco has quit [Client Quit]
xco has joined #ruby
xco has quit [Client Quit]
xco has joined #ruby
xco has quit [Client Quit]
ddffg has quit [Ping timeout: 255 seconds]
xco has joined #ruby
xco has quit [Client Quit]
spheric has quit [Ping timeout: 260 seconds]
JeanCarloMachado has quit [Ping timeout: 260 seconds]
xco has joined #ruby
xco has quit [Client Quit]
JeanCarloMachado has joined #ruby
romeoh_ has quit [Remote host closed the connection]
xco has joined #ruby
xco has quit [Client Quit]
duderonomy has joined #ruby
|RicharD| has quit [Quit: Sto andando via]
patr0clus has quit [Quit: tempusfugit]
patr0clus has joined #ruby
patr0clus has quit [Max SendQ exceeded]
houhoulis has quit [Remote host closed the connection]
cfec0b8d has quit [Ping timeout: 260 seconds]
JeanCarloMachado has quit [Ping timeout: 260 seconds]
XZIST has joined #ruby
jameser has joined #ruby
JeanCarloMachado has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
apparition has joined #ruby
d^sh has joined #ruby
Pumukel has joined #ruby
skade_ has joined #ruby
wethu has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
latemus has joined #ruby
JeanCarloMachado has quit [Ping timeout: 260 seconds]
<wethu>
Hi, trying to find an answer with google, however not sure how to word this, what exactly is this: `def Foo(bar); Foo.new(bar); end; Foo("bar") returns an instance of Foo, init'd with "bar" but what is Foo(bar) ? a `method` or `constant_method` ?
<elomatreb>
Although if you want a method like that for a module you wrote yourself it's generally considered good practice not to monkeypatch the global namespace, but rather use the #[] method on your module instead
<elomatreb>
Uh, .[]. So if you wrote "MyFancyLibrary", it'd be called as MyFancyLibrary[some_object_to_convert]
enterprisey has quit [Remote host closed the connection]
northfurr has quit [Quit: northfurr]
JeanCarloMachado has joined #ruby
romeoh has joined #ruby
jcao219 has quit [Ping timeout: 260 seconds]
cschneid_ has quit [Remote host closed the connection]
KeyJoo has quit [Remote host closed the connection]
enterprisey has joined #ruby
apparition has quit [Changing host]
apparition has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
KnownSyntax has quit [Ping timeout: 268 seconds]
esObe_ has joined #ruby
<wethu>
Thanks again for that, i was distracted with real work just now. Very interesting :)
KnownSyntax has joined #ruby
KnownSyntax has joined #ruby
KnownSyntax has quit [Changing host]
JeanCarloMachado has quit [Ping timeout: 260 seconds]
cschneid_ has joined #ruby
esObe_ has quit [Read error: No route to host]
<newrubycoder>
anyone got some win32 experience? i need ruby to press keys for me
esObe_ has joined #ruby
hutch34 has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
esObe_ has quit [Ping timeout: 240 seconds]
pifon has quit [Quit: Connection closed for inactivity]
enterprisey has quit [Ping timeout: 260 seconds]
JeanCarloMachado has joined #ruby
romeoh_ has joined #ruby
gizmore|2 has joined #ruby
charliesome has joined #ruby
romeoh has quit [Ping timeout: 240 seconds]
gizmore has quit [Ping timeout: 240 seconds]
spiette has quit [Ping timeout: 260 seconds]
enterprisey has joined #ruby
JeanCarloMachado has quit [Ping timeout: 240 seconds]
JeanCarloMachado has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
libastral has quit [Ping timeout: 258 seconds]
gusrub has joined #ruby
libastral has joined #ruby
xaxisx has joined #ruby
spheric has joined #ruby
xaxisx has quit [Client Quit]
xaxisx has joined #ruby
coderphive has quit [Quit: coderphive]
skade_ has joined #ruby
spheric_ has joined #ruby
spheric has quit [Ping timeout: 246 seconds]
antgel has quit [Ping timeout: 260 seconds]
gusrub has quit [Remote host closed the connection]
skade_ has quit [Ping timeout: 240 seconds]
PorcoRex has joined #ruby
<PorcoRex>
Good evening.
porfa has quit [Quit: porfa]
<newrubycoder>
yo
northfurr has joined #ruby
cschneid_ has quit [Remote host closed the connection]
nankyokusei has joined #ruby
aglorei has joined #ruby
jcao219 has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
nankyokusei has quit [Ping timeout: 260 seconds]
porfa has joined #ruby
romeoh_ has quit [Remote host closed the connection]
JeanCarloMachado has quit [Ping timeout: 240 seconds]
t-recx has joined #ruby
hutch34 has joined #ruby
esObe_ has joined #ruby
yzra has quit [Quit: yzra]
aupadhye has joined #ruby
esObe_ has quit [Ping timeout: 260 seconds]
astrobunny has joined #ruby
porfa has quit [Quit: porfa]
quobo has quit [Quit: Connection closed for inactivity]
bkxd has quit [Ping timeout: 260 seconds]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bkxd has joined #ruby
rkazak has joined #ruby
jenrzzz has joined #ruby
c_nick has joined #ruby
<c_nick>
Do i need the TCL/TK Bindings when i install Ruby ?
<c_nick>
I am trying to understand why do we need it or what is it
<elomatreb>
It's a graphics library. Unless you're using it somewhere you probably don't really need it
BTRE has quit [Quit: Leaving]
<c_nick>
Sqlite3 on ruby 2.3.3 WIndows, so safe for me to ignore that option
__Yiota has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
hutch34 has quit [Ping timeout: 260 seconds]
rkazak has quit [Quit: Sleep.....ing....]
Pumukel has joined #ruby
djbkd_ has joined #ruby
charliesome has quit [Read error: Connection reset by peer]
guardianJ has quit [Remote host closed the connection]
guardianJ has joined #ruby
hutch34 has joined #ruby
Guest96 has quit [Remote host closed the connection]
hutch34 has quit [Ping timeout: 260 seconds]
xall has quit [Quit: xall]
Guest96 has joined #ruby
xall has joined #ruby
xall_ has joined #ruby
hndk has quit [Quit: Leaving]
cfec0b8d has joined #ruby
xall has quit [Ping timeout: 260 seconds]
Guest96 has quit [Remote host closed the connection]
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
Guest96 has joined #ruby
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
guardianJ has quit [Read error: Connection reset by peer]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
xall_ has quit [Quit: xall_]
guardianJ has joined #ruby
roamingdog has joined #ruby
xall has joined #ruby
roamingdog has quit [Remote host closed the connection]
tristanp has joined #ruby
enterprisey has joined #ruby
esObe_ has joined #ruby
northfurr has quit [Quit: northfurr]
aupadhye has joined #ruby
esObe_ has quit [Ping timeout: 264 seconds]
aupadhye has quit [Client Quit]
bernd27 has quit [Remote host closed the connection]
xall_ has joined #ruby
xall has quit [Ping timeout: 260 seconds]
xall has joined #ruby
guardianJ has quit [Remote host closed the connection]
djbkd has quit [Quit: Leaving...]
xall_ has quit [Ping timeout: 260 seconds]
<dminuoso>
!goodmorning
aupadhye has joined #ruby
aupadhye has quit [Client Quit]
tildes has quit [Ping timeout: 258 seconds]
Blobson has quit [Ping timeout: 240 seconds]
djbkd has joined #ruby
yogg-saron has joined #ruby
patarr has joined #ruby
anisha has joined #ruby
Pumukel has joined #ruby
patarr has quit [Ping timeout: 255 seconds]
xall_ has joined #ruby
Ishido has joined #ruby
xall has quit [Ping timeout: 255 seconds]
Pumukel has quit [Ping timeout: 240 seconds]
jcao219 has joined #ruby
bigkevmcd has joined #ruby
bigkevmcd has quit [*.net *.split]
yogg-saron has quit [*.net *.split]
skade_ has quit [*.net *.split]
bkxd has quit [*.net *.split]
pifon has quit [*.net *.split]
d^sh has quit [*.net *.split]
ben__ has quit [*.net *.split]
infernix has quit [*.net *.split]
yo61 has quit [*.net *.split]
swills has quit [*.net *.split]
Guest37310 has quit [*.net *.split]
minimalism has quit [*.net *.split]
HashNuke has quit [*.net *.split]
hayden___ has quit [*.net *.split]
zenspider[m] has quit [*.net *.split]
dman[m] has quit [*.net *.split]
hayden___ has joined #ruby
swills has joined #ruby
Guest37310 has joined #ruby
hayden___ has quit [Changing host]
hayden___ has joined #ruby
bkxd has joined #ruby
ben__ has joined #ruby
minimalism has joined #ruby
d^sh has joined #ruby
pifon has joined #ruby
yo61 has joined #ruby
User458764 has joined #ruby
Mortomes|Work has joined #ruby
zenspider[m] has joined #ruby
dman[m] has joined #ruby
oleo has quit [Quit: irc client terminated!]
xall_ has quit [Ping timeout: 255 seconds]
infernix has joined #ruby
tim_ has joined #ruby
nankyokusei has joined #ruby
tim_ has left #ruby [#ruby]
nankyokusei has quit [Ping timeout: 258 seconds]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
esObe_ has joined #ruby
bweston92 has quit [Quit: Connection closed for inactivity]
esObe_ has quit [Ping timeout: 240 seconds]
ThePortWhisperer has joined #ruby
<ThePortWhisperer>
hello
<ThePortWhisperer>
i have a large framework that runs on ruby 2.3 on my box
<ThePortWhisperer>
theres another app that requires 2.4 (jekyll) and last time I installed it things seemed to go haywire with the versions stepping on each other
<ThePortWhisperer>
is there some way to install this other ruby version while keeping everything segregated properly
<Radar>
ThePortWhisperer: yes
<Radar>
ThePortWhisperer: use chruby + ruby-install
<Radar>
ThePortWhisperer: what OS are you on?
<ThePortWhisperer>
kali linux
loveablelobster has joined #ruby
andrzejku has joined #ruby
TomyWork has joined #ruby
andikr has joined #ruby
xall_ has joined #ruby
bigkevmcd has joined #ruby
jgnagy has quit [Remote host closed the connection]
ddffg has joined #ruby
Pumukel has joined #ruby
unshadow has joined #ruby
spheric has joined #ruby
xenops has joined #ruby
<dminuoso>
ThePortWhisperer: So the real solution is to actually keep them entirely separate.
<dminuoso>
ThePortWhisperer: If you however must share a physical server, look into chruby. Be sure to have the shell set the correct chruby for each
bronson has quit [Remote host closed the connection]
Pumukel has quit [Ping timeout: 255 seconds]
<ThePortWhisperer>
dminuoso, interesting.
<ThePortWhisperer>
i guess i can fire up another VM that is used only for jekyll
<ThePortWhisperer>
i had to go through hell and high water to recover last time so if the only way to safely avoid that is to put jekyll on another box i'll take the step
TomyWork has quit [Remote host closed the connection]
User458764 has joined #ruby
Puffball has quit [Remote host closed the connection]
djbkd has quit [Remote host closed the connection]
Puffball has joined #ruby
jackrandom has joined #ruby
last_staff has joined #ruby
Guest96 has quit [Remote host closed the connection]
skade_ has joined #ruby
Guest96 has joined #ruby
mark_66 has joined #ruby
<dminuoso>
ThePortWhisperer: Im a big fan of completely isolating apps. Here we dockerize everything.
<dminuoso>
It avoids such issues entirely.
<ThePortWhisperer>
i see. i dont know docker at all yet
Burgestrand has joined #ruby
<ThePortWhisperer>
so if i dockerize the jekyll install it should avoid breaking my other app
<dminuoso>
ThePortWhisperer: A docker container is very much like a VM. Except a VM virtualizes the hardware, whereas docker virtualizes the operating system.
<dminuoso>
ThePortWhisperer: Im not saying you should use it, but you should definitely explore it to know what it's all about.
charliesome has joined #ruby
Bish has quit [Quit: leaving]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
charliesome has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
charliesome has joined #ruby
Pumukel has joined #ruby
esObe_ has joined #ruby
patientj has joined #ruby
mim1k has joined #ruby
mim1k has quit [Ping timeout: 246 seconds]
esObe_ has quit [Ping timeout: 268 seconds]
blackmesa has joined #ruby
toretore has joined #ruby
patientj has left #ruby [#ruby]
Burgestrand has quit [Quit: Closing time!]
roshanavand has joined #ruby
xco has joined #ruby
User458764 has joined #ruby
Burgestrand has joined #ruby
jamesaxl has joined #ruby
<Seenox>
Hello everyone. Sorry if this is a very simple question, but how can I add " in a puts? for example puts ""Hello""?
<Burgestrand>
Seenox you can either escape it by putting a \ before it, or change the quotes so that you don't use " to surround your string
<Burgestrand>
Seenox for what purpose do you need the quotes?
<Burgestrand>
Seenox I'm thinking if it's mean to make the output machine-readable there might be a better way
Ishido has quit [Ping timeout: 240 seconds]
patarr has joined #ruby
<Seenox>
Burgestrand: My script outputs something like this for the "hosts" : [{"Name"=>"git"}, {"Name"=>"ntp"}, {"Name"=>"synfacts"}]
<Seenox>
Burgestrand: Then I need to read all the "Name" values, add " before everyone of them and add ", at the end of it and then use it for another purpose.
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
xco has left #ruby [#ruby]
<Burgestrand>
Seenox you want e.g.: "git", "ntp", "synfacts"
<Seenox>
without space after ,
<Seenox>
Also add another, at the end of it.
Ishido has joined #ruby
<Burgestrand>
Seenox what about if there's a backslash in any of the names?
<Burgestrand>
Seenox or a comma in one of the names?
<Seenox>
Burgestrand: You mean from the source arrays? It won't be any in them, they are puppet classes names.
<Burgestrand>
Seenox I'm fishing for if you're actually trying to output CSV, or this slightly arbitrary format you're describing :)
<Seenox>
Burgestrand: If you look at the output, it is missing a starting " and also an ending ",
<Burgestrand>
Seenox I think you might be making a mistake, but here's your gun: https://eval.in/789279
<Burgestrand>
Seenox if you need a comma at the end you can add it :)
gizmore|2 has quit [Ping timeout: 260 seconds]
<Seenox>
Burgestrand: Can you please explain what mistake I am making here?
HashNuke has joined #ruby
<Burgestrand>
Seenox usually trying to massage output into some arbitrary unknown but unforgiving format for parsing via machine somewhere else is riddled with weird edge-cases you tend to forget about, that'd be solved by using a known format and a known serializer for it!
binaryplease has joined #ruby
gizmore|2 has joined #ruby
<Burgestrand>
Seenox e.g. people that write/read their own CSV reader/writer without using a well-tested one, and end up making a mess :)
<Seenox>
Burgestrand: Hmm, I can't understand you. You mean the output is a mess?
<Burgestrand>
Seenox no. CSV for example is a text format where you separate values into columns and rows, like an excel sheet.
<Seenox>
Burgestrand: to explain a little bit more about it, the script should have a variable like this and then we add our own name at the end of it to use it like this: hammer hostgroup update --title MANUALLYADDEDTITLE --puppet-classes "THEOUTPUTWEHAVE","MANUALLYADDEDNAME"
<Burgestrand>
Seenox ah, so your intent is to use the output in a shell command?
<Seenox>
Burgestrand: Exactly.
<Seenox>
Burgestrand: Am I still making a mess here or I am good to go?
<Burgestrand>
Seenox I'm sure you're aware that shell commands can be a bit finnicky with special characters, e.g. $, '. If you're a 100% sure that your names won't be interpreted by the shell in some weird way then you're good to go.
sepp2k has joined #ruby
<Seenox>
Burgestrand: I think in this particular thing, it will be ok.
<Burgestrand>
Seenox I can almost see it, `hammer hostgroup update --title "Oh no" --puppet-classes "${rm -rf /}","git"
<Seenox>
Burgestrand: Can you please explain what exactly \ did in that puts?
<Burgestrand>
Seenox :)
<Seenox>
Burgestrand: so I can use \ "," to it and it will add the ending comma?
<Seenox>
Burgestrand: Since the data coming from another command in a json format, I think it will be safe to use it like that, or maybe I am lost here.
<Burgestrand>
Seenox if you have a puppet class with the name "${rm -rf /}" you could be in some trouble :)
<Seenox>
Burgestrand: That's true... How to avoid such a thing in general?
<Burgestrand>
Seenox ideally you'd output it in a format tailored for the next usage
nankyokusei has joined #ruby
<Burgestrand>
Seenox e.g. ruby has a module called `shellwords` that's meant to make strings safely passable to bash
gizmore|2 has quit [Ping timeout: 240 seconds]
<Seenox>
Burgestrand: For example before the last step, I put it through shelljoin?
<Burgestrand>
Seenox yeah, it might be that shelljoin is not good for you here since it splits the values by space, and hammer might require commas, but you could pass each name through shellescape
<Seenox>
Burgestrand: I can still call the name key and get the values without removing the IDs, right?
<Burgestrand>
Seenox yup, `hosts.map { … }` retrieves the name only, so no need to filter out the ID.
<Seenox>
Burgestrand: Great!
nadir has quit [Quit: Connection closed for inactivity]
<Burgestrand>
Seenox additionally, if you do: `puppet_classes = pcnames + [puppetclass_name]`, then you can manipulate your class names only once and not worry about the trailing comma
swarm has joined #ruby
lxsameer has joined #ruby
pandaant has joined #ruby
<swarm>
Anyone want to make some cash? I have a quickish programming problem I need help with, and I'm willing to pay someone $200 to solve it.
xall_ has joined #ruby
<dgs_>
no, but i'd like to see the problem regardless
<Seenox>
Burgestrand: What would be the difference in my case? Isn't it same?
<Burgestrand>
Seenox similar, but not the same, it'd allow you to remove that `+ ","` from line #7 and only use `#{puppetclass_names}` (notice plural) instead of `#{pcnames}#{puppetclass_name}` at the final line
blackmesa has quit [Ping timeout: 240 seconds]
<Seenox>
Burgestrand: ah I missed that "s".
<Burgestrand>
Seenox and thus you'd only have a single list of names to pass on, instead of one list and then a lonesome value that you need to tack on to the end :)
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<Seenox>
Burgestrand: Perfect. thanks for the tip.
<Burgestrand>
Seenox also, a final tip that might not be relevant depending on the environment you're in, `Kernel.exec` in Ruby can take multiple parameters for shell commands, which makes it safer than trying to build a command string that you then pass to the shell, downside is that it doesn't return the output as text.
Ishido has quit [Read error: Connection reset by peer]
<Burgestrand>
Seenox e.g. `exec("/usr/bin/hammer", "update", "--title", hostgroup_title, "--puppet-classes", puppet_class_names)`
<Burgestrand>
Seenox also takes care of escaping if you have any nasty characters in the command
<Burgestrand>
I guess it makes sense that ruby bot does not allow exec, oh well :)
<Seenox>
Burgestrand: lol
<Seenox>
Burgestrand: The downside is it doesn't return the output as text, what is the advantage?
mfaeh has joined #ruby
<Seenox>
Burgestrand: I had another case in my script that I had to end it with 2>/dev/null
<Burgestrand>
Seenox safer, the string is not interpreted by the shell so the horror scenario of a pcname with `${rm -rf /}` is not an issue
<mfaeh>
join *pug
<Burgestrand>
Seenox there are ways to retrieve stdout/stderr but it's slightly more cumbersome than what you have when you execute your %x[command] :)
<Seenox>
Burgestrand: So in this case, I could use exec instead and avoid 2>/dev/null?
meinside has joined #ruby
<Burgestrand>
Seenox oh, sorry, it's not exec, I mean `system` (`exec` replaces the calling process with the called process)
<Burgestrand>
Seenox same thing here though, not quite, because `system` returns a true/false if the command exited with success or not, and not the output of the command
arup_r has quit [Remote host closed the connection]
<Seenox>
Burgestrand: Also using system, I can't do the same thing with for example in this case "hammer"?
<Burgestrand>
Seenox no, because `hosts = …` you expect that `hosts` has the parsed output of hammer, but if you use system then it just returns true/false, not the output.
<Seenox>
Burgestrand: I see. So in my case it wouldn't be correct.
<Seenox>
Burgestrand: True or false, as in if the command exists or not?
<Burgestrand>
Seenox true/false as in command exit status
<Seenox>
Burgestrand: What if the program outputs a text regardless of success or fail?
jgnagy has joined #ruby
<Burgestrand>
Seenox return value is exit status only, e.g. 0 == true, anything else == false.
<Seenox>
Burgestrand: Got it.
marr has joined #ruby
jgnagy has quit [Ping timeout: 260 seconds]
bronson has joined #ruby
rhyselsmore has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
DaveTaboola has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bronson has quit [Ping timeout: 240 seconds]
sepp2k has quit [Quit: Leaving.]
<swarm>
dgs_: what did you think of the problem?
itarato has joined #ruby
rhyselsmore has joined #ruby
tvw has joined #ruby
jackjackdripper has joined #ruby
<dgs_>
hmm
<dgs_>
seems like a home problem?
<dgs_>
*home work
<dgs_>
i'd work out the html to draw that table by hand (or text editor)
jenrzzz has joined #ruby
<swarm>
sorta, but i'm not in school. but learning it.
<dgs_>
then just do that select and iterate over it building similar html
<dgs_>
obviously need basic css to give it the same colors/borders etc
jackjackdripper1 has joined #ruby
<swarm>
the html/css/js part is no issue for me. it's the logic of building the tree and iterating through it... it seems inefficient
marr has quit [Ping timeout: 260 seconds]
jackjackdripper1 has quit [Read error: Connection reset by peer]
roamingdog has joined #ruby
jackjackdripper2 has joined #ruby
ledestin has joined #ruby
bubble1994 has joined #ruby
jackjackdripper has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
jackjackdripper2 has quit [Read error: Connection reset by peer]
jackjackdripper has joined #ruby
astrobunny has quit [Remote host closed the connection]
roamingdog has quit [Ping timeout: 240 seconds]
govg has quit [Ping timeout: 268 seconds]
<dgs_>
what are you using to pull out the data? in active record it would be something like
<ineb>
i have a design question. I have a singleton object in my App and basically all other Objects need access to that object. So what are good design approaches here? Make that singleton global and have all other objects access it. Or make every constructor take that singleton object? Or use inheritance, mixins?
armyriad has joined #ruby
ishahnaz has joined #ruby
nadir has joined #ruby
Guest96 has quit [Remote host closed the connection]
Guest96 has joined #ruby
<paulgafton>
ineb: have the singleton instance static, and the rest of the objects access it as Class.SINGLETON
jackrandom has quit [Remote host closed the connection]
A124 has quit [Ping timeout: 255 seconds]
houhoulis has joined #ruby
dangerousdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chouhoulis has joined #ruby
newrubycoder has joined #ruby
hutch34 has joined #ruby
dangerousdave has joined #ruby
houhoulis has quit [Ping timeout: 246 seconds]
nankyokusei has joined #ruby
<dminuoso>
ineb: The solution is to avoid singletons in the first place.
<dminuoso>
ineb: They are usually a strong code smell.
XZIST has joined #ruby
<dminuoso>
Singletons imply global access. Global access means you cant reason about code flow and how state can evolve over the lifetime of your application.
<dminuoso>
(Read-only singletons, or special singletons that dont impact your application such as loggers are fine however)
<canton7>
ineb, creating singletons through DI means that your classes are still testable, which is a big plus
<ineb>
so what are your suggestions?
t-recx has joined #ruby
<canton7>
constructor injection
<canton7>
if you're modelling something of which there is only 1, then a singleton makes sense. One example is the configuration management for your application
<ineb>
in my case, it is an access token
<canton7>
the smell with singletons is that they're traditionally done using static instances, which ihurts testability
<ineb>
every class needs it to do useful things
<canton7>
I'd be more likely to write a class which encapsulates the API the access token is used for, hide the access token inside that class, then inject a singleton instance of that class into whatever needs it
nankyokusei has quit [Ping timeout: 272 seconds]
marr has joined #ruby
A124 has joined #ruby
<ineb>
yes, iam encapsulating it, but we can talk about a token here for the sake of simplicity
TomyWork has joined #ruby
<canton7>
well, I would never inject a token, but I would inject a class which encapsulates an API (and the token is an implementation detail of that class)
<canton7>
so it *does* matter
cronolio has joined #ruby
khronos has joined #ruby
Blobson has joined #ruby
<cronolio>
there have someone expirience with rbot and rss plugin ?
northfurr has joined #ruby
Blobson has quit [Client Quit]
dangerousdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
interki has joined #ruby
interki has quit [Client Quit]
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roamingdog has joined #ruby
<randomswede>
If i want to 301 redirect a ruby app to a new domain, whats the best way to do this? Is rack-rewrite gem a viable option? Or should i do this at the load balancer level?
jphase_ has quit [Remote host closed the connection]
starmix has joined #ruby
<ineb>
no singletons involved
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jphase has joined #ruby
rhyselsmore has quit [Client Quit]
milardovich has joined #ruby
latemus has quit [Ping timeout: 240 seconds]
<canton7>
ineb, that's called property injection (and you might well have done 'service.authentication = whatever', rather than that oddly-named method :P)
<canton7>
ineb, the issue with that is that the service needs the authentication to be present in order to function, but you can end up in a state where it isn't present, if you don't set that property
<canton7>
so it's preferable to pass it as a ctor parameter
jphase has quit [Ping timeout: 272 seconds]
<canton7>
also like I said, I'll pass around an API service, not the token itself
chouhoulis has quit [Remote host closed the connection]
Pumukel has quit [Remote host closed the connection]
<canton7>
ineb, (and if you pass that same Auth instance to multiple services, it is effectively a singleton)
randomswede has quit [Ping timeout: 272 seconds]
cfec0b8d has joined #ruby
<ineb>
canton7: i dont understand what you mean by 'API service' in that context. You are talking about something like TokenManager or whatever?
<canton7>
presumably your access token is to access an API of some sort?
ramortegui has joined #ruby
<ineb>
that is correct, but there is no API service to that. this it what i want to write
<canton7>
right, so I'd write a class which represents the API, and which owns the token
PatrikasZvaigzde has quit [Ping timeout: 255 seconds]
<canton7>
that's the only class which owns the token
nowhereman has quit [Ping timeout: 240 seconds]
<ineb>
i understand
nowhereman has joined #ruby
<ineb>
i think iam all set now
<ineb>
thanks
jameser has joined #ruby
conta has joined #ruby
kke_ is now known as kke
dangerousdave has joined #ruby
jgnagy has joined #ruby
jgnagy has quit [Ping timeout: 240 seconds]
swarm has quit [Quit: Page closed]
claw has quit [Ping timeout: 264 seconds]
stupidsenpai has joined #ruby
stupidsenpai has quit [Client Quit]
gnufied has joined #ruby
bronson has joined #ruby
fmcgeough has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has joined #ruby
d10n-work has quit [Quit: Connection closed for inactivity]
haylon has joined #ruby
Ellimist has joined #ruby
bronson has quit [Ping timeout: 260 seconds]
randomguy has joined #ruby
dangerousdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nhhc has joined #ruby
conta has quit [Remote host closed the connection]
conta has joined #ruby
gabrielgizotti has joined #ruby
jackrandom has quit [Ping timeout: 272 seconds]
bernd27 has joined #ruby
randomguy is now known as randomswede
gabrielgizotti has quit [Client Quit]
aupadhye has quit [Quit: Leaving]
pandaant has quit [Remote host closed the connection]
BSAlb has joined #ruby
DLSteve has joined #ruby
blackmesa has quit [Ping timeout: 272 seconds]
DLSteve has quit [Client Quit]
DLSteve has joined #ruby
BSaboia has quit [Ping timeout: 264 seconds]
wethu has quit [Quit: This computer has gone to sleep]
shaman42 has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
randomswede has quit [Ping timeout: 255 seconds]
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
eindoofus has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
eindoofus has quit [Client Quit]
vali has quit [Quit: vali]
patarr has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
petruff has quit [Ping timeout: 272 seconds]
shinnya has joined #ruby
romank has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jameser has joined #ruby
aupadhye has joined #ruby
milardovich has quit [Remote host closed the connection]
JeanCarloMachado has quit [Ping timeout: 260 seconds]
JeanCarloMachado has joined #ruby
Pumukel has joined #ruby
AlexRussia_ has quit [Ping timeout: 272 seconds]
millerti has joined #ruby
romank has joined #ruby
govg has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dangerousdave has joined #ruby
Burgestrand has quit [Quit: Closing time!]
milardovich has joined #ruby
gchristensen has joined #ruby
chouhoulis has joined #ruby
dangerousdave has quit [Client Quit]
<gchristensen>
Hi, is it possible to tell pry to turn off the nice features and act like more like irb? ie: disable color and paging
<gchristensen>
preferably via environment variablesl
jphase has joined #ruby
ben_____ has joined #ruby
ben__ has quit [Ping timeout: 255 seconds]
theunraveler has joined #ruby
jrafanie has joined #ruby
milardovich has quit [Ping timeout: 272 seconds]
AlexRussia_ has joined #ruby
<Papierkorb>
gchristensen: why not use irb in that case?
fusta has joined #ruby
conta has quit [Ping timeout: 272 seconds]
<kspencer>
if you were to initialize a OpenStruct with a layered dictionary, would it convert every layer
<morfin>
hm
<kspencer>
s/dictionary/hash/
<Papierkorb>
kspencer: No
<morfin>
can i somehow avoid having different Gemfile.lock for FreeBSD and Linux?
<gchristensen>
Papierkorb: I have a 3rd party program that I'm calling that drops me in to a pry session as an "API"
<gchristensen>
so I'm trying to use expect to drive it
<Papierkorb>
kspencer: You can either 1) not use OpenStruct and use #dig instead if that's enough or 2) use the `recursive-open-struct` gem which does what you want
DeeJayh has quit [Read error: Connection reset by peer]
<morfin>
I got suggestion to add this http://paste.ubuntu.com/24536971/ to Gemfile but i will have different lock files for FreeBSD and Linux
<Papierkorb>
kspencer: Well, of course, or you can build the open structs yourself too
<morfin>
that sounds bad because i work in Git and don't want to ignore Gemfile.lock
<kegster>
I have a restful api that let's me run custom scripts, but everytime i run a function in the script, i need to check to make sure it doesn't error out, as only 1 script function can touch the db at a time-- so basically i need to wrap each function with something that checks the output to make sure it's not an error (json format)-- and keep retrying until it can get a valid response
<kegster>
is this even possible?
blackmesa has joined #ruby
[Butch] has joined #ruby
heftig has joined #ruby
johnson[m] has joined #ruby
M107262[m] has joined #ruby
Giphy[m] has joined #ruby
KevinMGranger has joined #ruby
voltai[m] has joined #ruby
jakebriggs[m] has joined #ruby
aviraldg has joined #ruby
Tagami[m] has joined #ruby
daveyboi[m] has joined #ruby
travisr has joined #ruby
thulsa_legume[m] has joined #ruby
dman[m] has joined #ruby
zenspider[m] has joined #ruby
jonjits[m] has joined #ruby
el_ocho[m] has joined #ruby
testnick[m] has joined #ruby
velu_aon[m] has joined #ruby
<kegster>
basically, i know it's an error only if there's some data in my json object
<baweaver>
What have you tried?
jackjackdripper has quit [Read error: Connection reset by peer]
<kegster>
i've tried begin rescue ensure, etc
jackjackdripper has joined #ruby
<kegster>
but i am not sure how to catch it based on the json output
<baweaver>
that'll only work if there's a raised exception
marxarelli has joined #ruby
<baweaver>
you can always use conditional branches y'know `if condition`
mrsolo has quit []
<baweaver>
like if json[:error]
<kegster>
baweaver, so i guess i need to see if the "error" is throwing an exception OR if it's just json output huh
mrsolo has joined #ruby
<kegster>
sounds to me like it may actually be raising an exception, bc my code dies
<baweaver>
Got a stack trace?
<baweaver>
?gist
<ruby[bot]>
https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
<kegster>
too much to explain what i mean by that, bc this is such a niche
<baweaver>
throw it up there and it might be easier to trace
<kegster>
unfortunately no. i'm writing jruby for a scripting api for a 3rd party engine
<kegster>
there is no "console"
<kegster>
i have to manage my output, but if i get an error, it just dies on me lol
<kegster>
so looks like ill need to do some trial/error ---
<kegster>
can i jsut do begin, rescue, end, or do i need a resuce => something
bronson has quit [Remote host closed the connection]
JeanCarloMachado has joined #ruby
hobodave has joined #ruby
<canton7>
you add something to the built-in String class, yeah
<canton7>
it's called money-patching
<elomatreb>
Classes are never "finished" in Ruby, you can open and add or redefine them at any point
nhhc has joined #ruby
<cseder>
canton7 is this what is called a mixin?
<canton7>
no
<cseder>
But I don't declare that I'm extending anything, so if I just "add" to the String class, how come I don't have to mention that I do and create overridden functions from String
<cseder>
It just magically gives String a frequency counter function?
rkazak has quit [Quit: Sleep.....ing....]
<ljarvis>
cseder: yes, it's not really magic though because you wrote it inside the String class explicitly
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ljarvis>
that's just how re-opening classes in Ruby works
lxsameer has quit [Quit: WeeChat 1.7]
<cseder>
ljarvis so if this adds functionality to a class, what is it called if it's not a "mixin"?
<ljarvis>
cseder: it's called monkey-patching, as canton7 pointed out
conta2 has quit [Quit: conta2]
<llua>
he forgot the k
<cseder>
ah, ok, didn't see it, didn't tag my name
<ljarvis>
cseder: mixins are basically just modules. You "mix in" behaviour
<cseder>
so is this a common way of extending classes in Ruby or is it a better way?
<ljarvis>
you generally shouldn't monkey-patch core ruby classes
<cseder>
ljarvis right
<ljarvis>
but, if you want to extend the String class, that's generally how you would do it, yes
<cseder>
monkey-patching sounds like something one should avoid...
yo61 has quit []
yo61 has joined #ruby
<baweaver>
yep
<ljarvis>
it's helpful sometimes, you should generally approach it with caution, though
<baweaver>
^
tildes has quit [Ping timeout: 246 seconds]
pankaj has quit [Ping timeout: 240 seconds]
jphase has quit [Remote host closed the connection]
jphase has joined #ruby
AlexRussia_ has joined #ruby
Fridtjof has quit [Ping timeout: 258 seconds]
jphase_ has joined #ruby
jphase has quit [Read error: Connection reset by peer]
xall_ has quit [Ping timeout: 255 seconds]
gusrub has quit [Remote host closed the connection]
gusrub has joined #ruby
Fridtjof has joined #ruby
sija has joined #ruby
haylon has joined #ruby
pankaj has joined #ruby
gusrub has quit [Ping timeout: 264 seconds]
sija has quit [Client Quit]
haylon has quit [Remote host closed the connection]
gusrub has joined #ruby
haylon_ has quit [Ping timeout: 240 seconds]
jphase_ has quit [Remote host closed the connection]
skade_ has quit [Ping timeout: 240 seconds]
haylon has joined #ruby
SeepingN has joined #ruby
northfurr has joined #ruby
<haylon>
I thought I had a grasp on this, but it seems like I don't. I have a ruby script that I made that reads in a few variables and sets them as ENV variables for the duration of the run. Then within this script, I call Packer, but packer doesn't seem to be either understanding my ENV variables, or Ruby just isn't doing it the way I think its handling ENV variables being passed to child processes.
duderonomy has quit [Ping timeout: 260 seconds]
BTRE has joined #ruby
User458764 has joined #ruby
<haylon>
Am I correct in thinking that external programs beign called from Ruby should inherit the ENV variables being set by the script calling it?
<SeepingN>
One would expect that. But in my experience, expect the unexpected
<SeepingN>
ruby and command line stuff can be a lot trickier than it seems
<SeepingN>
I had FileUtils.mkdir_p creating some VERY wacky permissions if I didn't put in :mode => 0664. I checked umask and it was normal at "2" (just 2, no octal value, I foudn that interesting)
jphase has joined #ruby
<SeepingN>
it may start a fresh shell with absolutely nothing loaded. I usually have to source a dotfile if I don't want to futz with things much)
mim1k has joined #ruby
<haylon>
So far, everything I've tested, shell scripts, other ruby scripts, echo, and some other external programs seem to understand the ENV variables being set by my ruby script, just not packer.
<haylon>
So, it might be something with Packer itself.
romank has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<SeepingN>
an setting your own. ok so that's nice, you can set than and "pass them on" (normally, apparently not with this Packer thing)
AndrewIsHere has joined #ruby
mim1k has quit [Ping timeout: 240 seconds]
<SeepingN>
how do you call Packer?
<SeepingN>
I've resorted to using PTY for local calls so I can "stream" it's output while capturing it
tildes has joined #ruby
<haylon>
I was using Open3.popen2e
<haylon>
to do the shell execution so I can print the output,and write it to a file
<SeepingN>
ah nice
<SeepingN>
I tried so hard last year to avoid going into pty and open3 stuff but it seems inevitable if you "want it all"
<haylon>
at first I was using %x[ packer build -machine-readable -debug template.json ]
<haylon>
but that wouldn't output any text until it was over
<baweaver>
Probably because modulo is calling divmod, but they look like aliases
<baweaver>
not sure really
<cek>
next q. How do I optimize %? I'm looking for numbers having 0 mods for a specific number.
northfurr has quit [Quit: northfurr]
<al2o3-cr>
Numeric#% and Numeric#modulo have exactly the same C source
<baweaver>
Looked like it.
skade_ has quit [Ping timeout: 240 seconds]
<baweaver>
though I think it's splitting hairs to try and optimize that
<baweaver>
more than likely the surrounding algorithm is the issue
__Yiota has joined #ruby
roamingdog has joined #ruby
dviola has quit [Quit: WeeChat 1.7.1]
<cek>
>> Benchmark.measure { i=0; max = 10**7; while i<max do i % 128 == 0 ; i+=1; end }
<ruby[bot]>
cek: # => uninitialized constant Benchmark (NameError) ...check link for more (https://eval.in/790059)
<cek>
>> require 'benchmark; print Benchmark.measure { i=0; max = 10**7; while i<max do i % 128 == 0 ; i+=1; end }
<ruby[bot]>
cek: # => /tmp/execpad-1fb91661db18/source-1fb91661db18:2: unterminated string meets end of file ...check link for more (https://eval.in/790061)
<cek>
>> require 'benchmark'; print Benchmark.measure { i=0; max = 10**7; while i<max do i % 128 == 0 ; i+=1; end }
<ruby[bot]>
cek: # => 0.910000 0.000000 0.910000 ( 0.913510) ...check link for more (https://eval.in/790062)
brkkyk has joined #ruby
<cek>
>> require 'benchmark'; print Benchmark.measure { i=0; max = 10**7; while i<max do i.modulo(128) == 0 ; i+=1; end }
<brkkyk>
hey everyone
ishahnaz has joined #ruby
<baweaver>
alo
<baweaver>
also bot is acting up a bit
blackmes1 has joined #ruby
jcao219 has joined #ruby
<SeepingN>
is it?
<baweaver>
well, was earlier.
blackmesa has quit [Ping timeout: 245 seconds]
<brkkyk>
how actioncable act like under pressure?
haylon has joined #ruby
ecdsa521 has left #ruby ["mIRC 1.0 @ XENIX"]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<haylon>
Hello everyone. Why would STDIN.noecho(&gets).chomp throw a file not found error when using Thor for command line processing?
<haylon>
I'm getting: `gets': No such file or directory @ rb_sysopen - login (Errno::ENOENT) when using Thor
jusa has quit [Ping timeout: 272 seconds]
brkkyk has quit [Read error: Connection reset by peer]
jackrandom has quit [Remote host closed the connection]
brkkyk_ has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<morfin>
are you sure it's not &:gets?
<morfin>
STDIN.noecho(&:gets).chomp
jphase has quit [Remote host closed the connection]
fmcgeough has quit [Quit: fmcgeough]
<haylon>
Yeah, that's it, sorry
<haylon>
This was workign until I threw it in a class, and then used Thor to call that class
__Yiota has joined #ruby
northfurr has quit [Quit: northfurr]
ResidentBiscuit has quit [Ping timeout: 264 seconds]
ResidentBiscuit has joined #ruby
ResidentBiscuit has quit [Max SendQ exceeded]
ResidentBiscuit has joined #ruby
ResidentBiscuit has quit [Max SendQ exceeded]
<haylon>
I've read that I'm supposed to use Thor's `ask` function, but then that changes my code base for now
__Yiota has quit [Client Quit]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
ResidentBiscuit has joined #ruby
ResidentBiscuit has quit [Max SendQ exceeded]
<morfin>
crap i hope install does not hang up PC when i build Ruby
mochiyoda_ has quit [Ping timeout: 246 seconds]
ResidentBiscuit has joined #ruby
<haylon>
are you using rbenv,or rvm to install?
jcao219 has quit [Ping timeout: 240 seconds]
lxsameer has quit [Quit: WeeChat 1.7]
bronson has joined #ruby
<morfin>
rbenv
<morfin>
basically proper symlink fixed my issue... i think
<haylon>
When I compile/build Ruby, I notice that it throttles my PC pretty hard until its done
<morfin>
well, my PC died already twice
<morfin>
some hardware issues
<haylon>
because of this?
mnem has quit [Ping timeout: 240 seconds]
<morfin>
basically first time it compiled ruby but for some reason did not move output/finish procedure
hutch34 has quit [Quit: WeeChat 1.5]
mnemon has joined #ruby
<al2o3-cr>
haylon: if you're using >= 2.3 you can use STDIN.getpass :)
mochiyoda_ has joined #ruby
<haylon>
Do I need to require anything, or still 'io/console'?
jcao219 has joined #ruby
<al2o3-cr>
io/console needs requiring
<haylon>
I'll give that a whirl, thank you al2o3-cr, brb
bronson has quit [Ping timeout: 240 seconds]
<morfin>
hmm /home/Alexander/.rbenv/plugins/ruby-build/bin/ruby-build: line 1011: /home/Alexander/.rbenv/versions/2.3.0/bin/ruby: No such file or directory
<SeepingN>
anyone have experience with command line conversion tools like recode and ansi2html? I'm trying to convert ANSI Colorized output with UTF-8 type characters into HTML colors with encoded characters. But feed one of those 2 tools into the other leads to too-many-conversions
ResidentBiscuit has joined #ruby
GodFather has quit [Ping timeout: 260 seconds]
lxsameer has joined #ruby
GodFather has joined #ruby
blackmes1 has joined #ruby
porfa has quit [Quit: porfa]
<morfin>
i guess i just need to install lots of packages
brkkyk_ has quit [Read error: Connection reset by peer]
gaucheph has joined #ruby
brkkyk has joined #ruby
ResidentBiscuit has quit [Ping timeout: 246 seconds]
brent__ has quit [Remote host closed the connection]
blackmes1 has quit [Ping timeout: 272 seconds]
cyphase has quit [Ping timeout: 240 seconds]
lxsameer has quit [Quit: WeeChat 1.7]
fmccann has joined #ruby
d10n-work has quit [Quit: Connection closed for inactivity]
blackmes1 has joined #ruby
Pumukel has joined #ruby
brkkyk has quit [Remote host closed the connection]
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]