<AdmiraI>
Anyone knowledgable about spawning new processes in ruby?
<volty>
g0th: i tell you another good point: i do not use 'i' because I use it when doing each_with_index where 'i' stays for index, i use el. or obj, or o
<pontiki>
AdmiraI: somewhat?
<volty>
... for the elements, depending on context
<g0th>
ok
<pontiki>
i haven't written a lot of concurrent stuff in ruby
<g0th>
I just started using ruby this week
<g0th>
so I am always happy for feedback
<pontiki>
and nothing complicated
<AdmiraI>
pontiki: This isn't quite concurrent.
<pontiki>
g0th: i am impressed that you're using inject already!
<bnagy>
AdmiraI: you really need to google around
brupeb has quit [Remote host closed the connection]
<volty>
go with this density of ruby, logic be with you !
<bnagy>
there are a LOT of ways to do it and they're all subtly different
<AdmiraI>
bnagy: That's what this whole day has been.
<pontiki>
AdmiraI: what is the actual question
<bnagy>
sadly :/
<g0th>
I had trouble understanding the &obj thingy
<AdmiraI>
I've got a long-running external command that sometimes hangs the system.
<g0th>
but
<AdmiraI>
To prevent that, I want to launch it in ruby and kill it after some period of time.
<g0th>
it's ok now, I don't use it anyway
<bnagy>
g0th: so basically you're brute forcing to find out the odds of 3d4 + 4 < 9 or whatever?
<AdmiraI>
I also want to collect the stdout and stderr of the external command.
<pontiki>
so what's the problem with implementing that, AdmiraI ?
<bnagy>
AdmiraI: sounds like Open3
<AdmiraI>
Well, after spawning the process, and killing it when it hangs, it never transfers control back to the parent.
<pontiki>
^bnagy
<g0th>
bnagy: yes
<bnagy>
popen3 for example gives you the pipes and also the thread obj
<g0th>
bnagy: but in an intelligent way
<g0th>
bnagy: only brute force where necessary
<pontiki>
AdmiraI: look at Open3#popen3
<g0th>
bnagy: e.g. the line above would not be done with brute force
benzocoumaran35 has quit [Ping timeout: 240 seconds]
mercwithamouth has joined #ruby
<volty>
AdmiraI: which control? what do you mean by 'control'?
bobinator60_ has quit [Quit: bobinator60_]
ewnd9 has joined #ruby
<AdmiraI>
volty: As in, I kill the process after the timeout occurs, but then the rest of the script doesn't execute.
quoin has joined #ruby
tvw has quit []
<volty>
of course, you are (probably) killing the same process
<volty>
you have to spawn another process for that to work
b00stfr3ak has quit [Ping timeout: 240 seconds]
<bnagy>
g0th: cool. There's a product method somewhere
<volty>
and would be nicer if you kill the child process from inside your parent processs
<AdmiraI>
volty: Are you saying I'm killing the parent process?
<bnagy>
anyway, just saying, cartesian product + #count is pretty elegant
brum has quit [Remote host closed the connection]
<bnagy>
if memory intensive :P
<g0th>
bnagy: yes
<g0th>
but I have weighted probabilities
<g0th>
for the thing you mentioned I have a much faster algorithm anyway
<bnagy>
oh no doubt
<g0th>
only in rare circumstances I have to use brute force
<bnagy>
this is slow as balls, it's just super easy to code
<g0th>
maybe it is possible to do it faster
<g0th>
but that's something
Nogbit has joined #ruby
<g0th>
you could probably publish papers for such results
<g0th>
if you get a precise formula
tgraham|away is now known as tgraham
<g0th>
e.g. toss a d20, if 20 comes, don't count it but toss two d20, keep going with that
justsee has quit [Ping timeout: 245 seconds]
einarj has joined #ruby
<volty>
AdmiraI: you have to tell us what is happening
cj3kim_ has quit [Remote host closed the connection]
sectionme has quit [Ping timeout: 246 seconds]
<g0th>
at the end drop the 10 smallest rolls
<g0th>
and sum it
<bnagy>
g0th: yeah I did some of that crap in excel, was a pain
<g0th>
what's the probability to get a 87?
<AdmiraI>
volty: With regards to my gist?
<volty>
btw check if the process got effectively killed
<bnagy>
really need a DSL at that point
zastern has quit [Remote host closed the connection]
osvico has quit [Ping timeout: 246 seconds]
<bnagy>
if you don't _really_ care about exact precision you could just model your rules and do monte-carlo
<volty>
and you have also to check if Process.wait works this way (not really returning )
ssvo has quit [Ping timeout: 248 seconds]
<bnagy>
also very easy to code, but also crazy slow
<AdmiraI>
volty: So far the processes haven't actually been killed.
jrobeson has quit [Ping timeout: 256 seconds]
<AdmiraI>
Because the kill command under OS X is stupid.
<volty>
you've checked outside, from the command line?
<AdmiraI>
They aren't zombies, but they're thrown into a "Trying to exit" state.
<AdmiraI>
volty: yes.
<bnagy>
basically you make a statemachine and walk it stochastically n times, recording the results
tabolario has joined #ruby
<g0th>
bnagy: ok I solved it
dodosan has joined #ruby
hadees has joined #ruby
<g0th>
bnagy: it was just a wrong choice of shift/drop/sort order
<volty>
try another one, 'TERM'
Nogbit has quit [Client Quit]
<bnagy>
also, give jruby a shot
heidi has joined #ruby
<AdmiraI>
volty: Same behavior.
<bnagy>
some of my unreated Set based stuff is MANY times faster on jruby than mri
czhang_______ has quit [Quit: Leaving.]
<bnagy>
*unrelated
lukec_ has joined #ruby
<volty>
or whatever else, try to kill it with a utility, you have to find why the OS cannot kill it
bobinator60_ has joined #ruby
<AdmiraI>
According to the man page for ps, that process is in a "Trying to exit" state. Looking around online, it seems the only way to get rid of these processes is a reboot.
lukec has quit [Ping timeout: 268 seconds]
lukec_ is now known as lukec
|jemc| has joined #ruby
einarj has quit [Ping timeout: 248 seconds]
julian-delphiki has joined #ruby
<volty>
what command you are running ?
<AdmiraI>
It's a buggy CLI application at work.
roflmaus has quit [Read error: Connection reset by peer]
<volty>
AdmiraI: make sure to set 'past year' when searching with google
<volty>
because the os's got 'stronger' meanwhile
lolmaus has joined #ruby
quoin has quit [Ping timeout: 252 seconds]
jb41 has quit [Ping timeout: 260 seconds]
<AdmiraI>
volty: Yes, many old results around for process management in Ruby.
bean has quit [Ping timeout: 248 seconds]
Nogbit has joined #ruby
<volty>
i'm talking about bash, ps, kill, signal etc
<g0th>
everything is working now. :) Thanks for the help
felipec has quit [Quit: Leaving]
<volty>
try SIGKILL (-9)
staafl has quit [Ping timeout: 248 seconds]
jaimef has quit [Excess Flood]
<AdmiraI>
volty: Even -9 doesn't work.
dodosan has quit [Remote host closed the connection]
<volty>
ah, you are on saint's os
<AdmiraI>
kill -9 is different between linux and OS X.
<volty>
sudo kill (and try various) - the last resort
dankest has quit [Quit: dankest]
senayar has joined #ruby
<AdmiraI>
Like they said in that serverfault link, the only way is to reboot.
<volty>
(because the os could have took the ownership of the execution out of you - for some reason)
<volty>
sorry for you, then :(
<AdmiraI>
volty: I'll give sudo a shot, but I doubt it will work.
<AdmiraI>
Eh, it's okay.
<AdmiraI>
I just wish this application wasn't so damn buggy.
<MrZYX>
is it even still consuming cycles?
bobinator60_ has quit [Quit: bobinator60_]
<MrZYX>
if not, who cares about another entry in the table...
<AdmiraI>
MrZYX: I'm not exactly sure if it is or not.
<volty>
AdmiraI: try to see the ownership ...
<AdmiraI>
It's owned by me.
bean has joined #ruby
lukec has quit [Ping timeout: 248 seconds]
xk_id has quit [Quit:
Lewix has quit [Remote host closed the connection]
<volty>
MrZYX: not that easy, the app could have locked some resources -- you never know with that buggy old stuff, you cannot be sure that a new instance could run cleanly if there's another one, 'hanging around'
lukec has joined #ruby
<AdmiraI>
And no, in this case it's not a big deal to leave a few entries in the table, but I'll eventually be running this app over 500 times.
<volty>
AdmiraI: i mean the process, not the executable
r0bglees0n has quit [Ping timeout: 245 seconds]
<AdmiraI>
Yes, the process is owned by me.
<AdmiraI>
It wasn't handed off to the OS.
<volty>
but the os isn't owned by you :)
SkuliOskarsson has quit [Quit: Leaving.]
estebanrules has joined #ruby
visof has quit [Remote host closed the connection]
RichardBaker has quit [Quit: RichardBaker]
devoldmx has joined #ruby
tgraham is now known as tgraham|away
MrZYX is now known as MrZYX|off
BillCriswell has joined #ruby
julian-delphiki has quit [Ping timeout: 260 seconds]
senayar has quit [Ping timeout: 245 seconds]
jaimef has joined #ruby
<pontiki>
hum
<volty>
and from the os x menu? (the famous eaten apple)
GeissT has joined #ruby
tgraham|away is now known as tgraham
<pontiki>
AdmiraI: you're gist does seem to work, more-or-less.
<AdmiraI>
pontiki: What command did you run it with?
devoldmx3 has quit [Ping timeout: 251 seconds]
<AdmiraI>
This problem may be a result of the application I'm executing.
<volty>
pontiki: he has an old buggy application to run, and his os is buggy, cannot kill that process
pleal has quit [Remote host closed the connection]
<AdmiraI>
OS isn't buggy, that's how they documented it.
<pontiki>
hum
<AdmiraI>
But it sucks that kill -9 doesn't kill like it should.
<AdmiraI>
More and more I'm thinking it's this application.
<AdmiraI>
I tried using the native timeout feature of the open4 gem, and the application did *not* like that at all.
<volty>
no no, you can google, an os is buggy when it cannot kill a process
dmerrick has quit [Remote host closed the connection]
<pontiki>
well, the *right* thing to do is fix the long-running app that hangs the system, really, innit?
<pontiki>
what OS?
<AdmiraI>
pontiki: Yes, of course, but I'm writing a test system for said app so that we can make it better :P
<AdmiraI>
pontiki: OS X.
<pontiki>
OS/X can certainly be buggy about things like that; eating up all the VRAM is kind of interesting to do
<volty>
AdmiraI: you can spawn your buggy app separately, redirecting its output in a file, and reading that file from ruby -- if you think it is ruby that makes problems
<pontiki>
as is opening and closing lots and lots of files
zeade has quit [Quit: Leaving.]
<pontiki>
and filling the disk the swap is on :)
<AdmiraI>
pontiki: I have a feeling that's what i just did (the VRAM, that is).
kayloos has quit [Remote host closed the connection]
<pontiki>
i've broken my OS lots of times :>
<bnagy>
process monitoring is nontrivial, which is why there are so many frameworks for it
lfox has quit [Quit: ZZZzzz…]
<AdmiraI>
pontiki: Ahh, I do not miss days like that.
havenwood has quit [Remote host closed the connection]
<pontiki>
it can be dangerous
nari has joined #ruby
DanKnox is now known as DanKnox_away
<AdmiraI>
Well, open4 seemed to work.
angoragoats has joined #ruby
havenwood has joined #ruby
<pontiki>
sorta like my ex-f-i-l said "sinking your boat can ruin your whole day" - blowing apart your OS can too
<AdmiraI>
Minus making my display kind of wonky
<AdmiraI>
(this buggy application does some interested things with the graphics subsystem)
bklane_ has joined #ruby
bklane has quit [Read error: Connection reset by peer]
<pontiki>
is this some inhouse proprietary thing?
brupeb has joined #ruby
<AdmiraI>
pontiki: Yep.
seanmccann has quit [Quit: Computer has gone to sleep.]
brum has joined #ruby
mansi has quit [Ping timeout: 240 seconds]
hogeo has joined #ruby
<pontiki>
is anyone there who initially wrote it?
narcan has joined #ruby
<AdmiraI>
My company doesn't own the code, it was developed by another company.
<pontiki>
ah ha
<AdmiraI>
And another guy on my team said we can basically forget about getting any updates to it.
Atrumx has joined #ruby
<pontiki>
not supported any more?
<pontiki>
about the same thing, really
<pontiki>
do you have the source?
<volty>
AdmiraI: could that app wait for input ?
<AdmiraI>
pontiki: Nope, just a binary.
<pontiki>
crushing
<AdmiraI>
volty: What do you mean?
<AdmiraI>
As in, does it take input? No, it's all passed via flags.
<volty>
i see in your code that you are just accumulating output that comes from that app
axl_ has joined #ruby
<volty>
i'm asking if that app could, at some time, ask for some input
<pontiki>
which would make it hang
<AdmiraI>
volty: I'm not sure if that's the right way to accumulate input.
<AdmiraI>
No, the app doesn't ask for input.
<pontiki>
hum
havenwood has quit [Ping timeout: 240 seconds]
<pontiki>
up for a tiny experiment?
<AdmiraI>
I was wanting to get input as it was generated, because this app can fail for a variety of reasons. Any output would be helpful.
<AdmiraI>
pontiki: sure.
osvico has joined #ruby
<pontiki>
redirect /dev/null to input for that app when you run it
Lewix has joined #ruby
<volty>
if that app doesn't send newline you'll never get a string
i_s has quit [Remote host closed the connection]
<banisterfiend>
pontiki what is "ex-f-i-l " ?
devoldmx has quit [Ping timeout: 264 seconds]
<pontiki>
since you're working on a complete black box here, AdmiraI, could be something strange like that going on, too
<pontiki>
banisterfiend: ex Father-in-Law
jonathanwallace has joined #ruby
<banisterfiend>
ah:) thx
brum has quit [Ping timeout: 264 seconds]
<AdmiraI>
pontiki: I'll give it a shot after this initial test with open4.
<AdmiraI>
In my small test script open4 killed it successfully.
i_s has joined #ruby
<pontiki>
also, volty is right in that using gets means it needs to get a newline
<pontiki>
you might just do reads
<pontiki>
binreads, maybe?
c0rn has quit [Quit: Computer has gone to sleep.]
<volty>
much better with binreads, or even getting single data as soon as ready
<pontiki>
nod
<AdmiraI>
I was thinking of using pty as well.
<AdmiraI>
To get output as soon as it's generated.
<volty>
but above all, if i were him I would make a log of commands so that when it hangs the next time he can run it from bash and redirect output to a file, and see how it behaves
snovak has joined #ruby
<pontiki>
yeah
sniffingcats has joined #ruby
devoldmx has joined #ruby
<AdmiraI>
volty: I've done so. It simply hangs the entire system.
<volty>
with bash?
<AdmiraI>
Or rather, it hangs the main UI because (I think) the graphics system resources have been used up completely.
<AdmiraI>
volty: yep.
<volty>
no popen can help you then
<AdmiraI>
I was afraid of that :(
<pontiki>
if you really cannot kill this thing, nothing is
<AdmiraI>
I have to run this application around 540 times (all different input).
iliketurtles has quit [Quit: zzzzz…..]
<pontiki>
what??
<pontiki>
i thought it was long-running
<AdmiraI>
Relatively long-running compared to most other commands.
<AdmiraI>
A few minutes I'd say.
<AdmiraI>
It depends on the input.
<pontiki>
holy cow
<pontiki>
that is NOT long running
<AdmiraI>
long-running was perhaps a poor choice.
<volty>
could you give us an example of the parameters?
* bnagy
waits patiently for the halting problem jokes
<pontiki>
httpd is a long-running process
<volty>
the input is by parameters or by file / script ?
<pontiki>
a few minutes is "it just takes a little longer"
<pontiki>
hehehe
<AdmiraI>
volty: file.
<pontiki>
however, the system hang and non-killable is the main problem
<pontiki>
what in the world does this thing *do* ?
<AdmiraI>
Video decoding.
<pontiki>
oh fun!!
<pontiki>
yes that is definitely a way to crash your system ;)
<AdmiraI>
I don't actually know much about what it does, but I was told to run it with several inputs.
<AdmiraI>
Hence the fun graphical bugs.
<volty>
i would be nice to have a VM running that app, but the saint's os doesn't allow for a VM
<bnagy>
AdmiraI: get hold of radamsa
iliketurtles has joined #ruby
snovak has quit [Ping timeout: 264 seconds]
bricker`LA has joined #ruby
<pontiki>
especially if you are using a mac with a bad graphics controller! or a bad SMC!
<bnagy>
volty: you can virtualise OSX
<volty>
bnagy: from when ?
<pontiki>
virtualbox can
estebanrules has quit [Quit: Leaving]
<bnagy>
ages
<volty>
i checked a few months ago
<bnagy>
just only legally on mac hardware
<onewheelskyward>
So can parallels.
<bnagy>
it also works on kvm (intel only) but requires pretty nasty hackery
<pontiki>
if you want to do it on non-mac hardware, you need some kernel mods
benzocoumaran35 has quit [Ping timeout: 264 seconds]
<volty>
i have installed virtualbox and running windows and linux on a mac but couldn't find a way to run os x
<bnagy>
anyway all the major products support it, just only on mac
<bnagy>
pontiki: no you don't
<sniffingcats>
anything for geoip in ruby? I want to look for countries using IPs
<volty>
mah! i'll check again
<bnagy>
you need a patched bios and a patched qemu, but you can run unmodified kernel
<onewheelskyward>
I've never used it but google had tons of results
<volty>
nothing tricky
<AdmiraI>
With what I'm eventually going to do though, virtualization doesn't work.
<sniffingcats>
onewheelskyward: It takes domain, not IP…
<pontiki>
anyway, interesting diversion
<onewheelskyward>
"GeoIP searches a GeoIP database for a given host or IP address, and returns information about the country where the IP address is allocated, and the city, ISP and other information, if you have that database version."
chxane has quit [Quit: Leaving]
brianpWins has quit [Quit: brianpWins]
<AdmiraI>
So it seems that my script just keeps waiting on the process to end.
<AdmiraI>
But this application doesn't want to give up control.
<pontiki>
AdmiraI: did you look at the gist i posted? you have your Process.wait in the wrong place
<g0th>
attr_accessor :foo, :bar
<g0th>
if I add this to a class
blischalk has joined #ruby
benzocoumaran35 has joined #ruby
<AdmiraI>
pontiki: I've switched to using open4.spawn
amsi has quit [Quit: Leaving]
<g0th>
then I should be able to do z.foo for instances of that class, no?
<g0th>
somehow I get an error
<AdmiraI>
But looking at the backtrace after I killed my script, it's stopping in a Thread.wait
lfox has joined #ruby
<bnagy>
g0th: yes
d2dchat has quit [Remote host closed the connection]
sarlalian has quit [Ping timeout: 256 seconds]
<g0th>
but it doesn't work :(
<pontiki>
please show error?
nhhagen has quit [Read error: Connection reset by peer]
<pontiki>
or are you asking for help?
<bnagy>
>> class Foo; attr_accessor :thing; end; f=Foo.new; f.thing=4; f.thing
tabolario has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
okinomo has joined #ruby
sayan has quit [Ping timeout: 246 seconds]
b00stfr3ak has joined #ruby
narcan has quit [Quit: -[AppDelegate installMalware]: unrecognized selector sent to instance 0x156109c0]
brum has joined #ruby
k610 has quit [Ping timeout: 260 seconds]
dzhulk has joined #ruby
dhruvasagar has joined #ruby
schaerli has quit [Remote host closed the connection]
iliketurtles has joined #ruby
petey has quit [Remote host closed the connection]
brum has quit [Ping timeout: 260 seconds]
girija has joined #ruby
girija has left #ruby [#ruby]
zerun0 has quit [Ping timeout: 240 seconds]
Jdubs has joined #ruby
zerun0 has joined #ruby
i_s has quit [Remote host closed the connection]
T_T has joined #ruby
narcan has joined #ruby
Bosox20051 has quit [Quit: Leaving]
IcyDragon has quit [Quit: Space~~~]
BizarreCake has joined #ruby
saarinen has quit [Quit: saarinen]
aryaching has quit [Ping timeout: 264 seconds]
aagdbl has joined #ruby
larissa has quit [Quit: Leaving]
_maes_ has joined #ruby
T_T has quit [Remote host closed the connection]
ananthakumaran has joined #ruby
aagdbl has quit [Quit: Leaving.]
aagdbl has joined #ruby
tsykoduk is now known as zz_tsykoduk
michael_mbp is now known as zz_michael_mbp
vim_shim has quit [Ping timeout: 248 seconds]
schaerli has joined #ruby
DanKnox_away is now known as DanKnox
adeponte has joined #ruby
Lewix has quit [Remote host closed the connection]
quoin has joined #ruby
JohnBat26 has joined #ruby
aagdbl1 has joined #ruby
adeponte has quit [Ping timeout: 240 seconds]
mercwithamouth has quit [Ping timeout: 245 seconds]
jefflyne1 has joined #ruby
OdNairy has joined #ruby
mercwithamouth has joined #ruby
sectionme has joined #ruby
brum has joined #ruby
relix has joined #ruby
aagdbl has quit [Ping timeout: 256 seconds]
T_T has joined #ruby
Monie has joined #ruby
tagrudev has joined #ruby
|jemc| has quit [Ping timeout: 264 seconds]
aagdbl1 is now known as aagdbl
sectionme has quit [Ping timeout: 240 seconds]
codecop has joined #ruby
brum has quit [Ping timeout: 260 seconds]
cads has quit [Ping timeout: 252 seconds]
schaerli has quit [Remote host closed the connection]
pontiki has quit [Quit: "Poets have been mysteriously silent on the subject of cheese." -- G.K.Chesterson]
quoin has quit [Ping timeout: 240 seconds]
sayan has joined #ruby
amacgregor has joined #ruby
dzhulk has quit [Quit: Leaving.]
Monie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
i_s has joined #ruby
mac___ has quit [Remote host closed the connection]
DanKnox is now known as DanKnox_away
T_T has quit [Remote host closed the connection]
jefflyne1 has quit [Ping timeout: 248 seconds]
chairabanta has joined #ruby
snovak has joined #ruby
i_s has quit [Ping timeout: 248 seconds]
kizzx2 has joined #ruby
cads has joined #ruby
apeiros has joined #ruby
vborja has joined #ruby
browndawg has quit [Ping timeout: 240 seconds]
Domon has joined #ruby
snovak has quit [Ping timeout: 264 seconds]
mrsolo has quit [Quit: This computer has gone to sleep]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
lurch_ has joined #ruby
zoee has joined #ruby
jaimef has quit [Excess Flood]
nextdropping has quit [Ping timeout: 246 seconds]
mac_ has joined #ruby
zz_michael_mbp is now known as michael_mbp
toah has joined #ruby
jaimef has joined #ruby
chairabanta has quit [Quit: Leaving...]
nextdropping has joined #ruby
relix has joined #ruby
brum has joined #ruby
kil0byte has joined #ruby
pwh has quit [Quit: pwh]
Kricir has quit [Remote host closed the connection]
ehaliewicz has quit [Ping timeout: 264 seconds]
i_s has joined #ruby
mercwithamouth has quit [Ping timeout: 240 seconds]
Schuy13r has quit [Ping timeout: 245 seconds]
Schuy13r has joined #ruby
brum has quit [Ping timeout: 240 seconds]
maveonair has joined #ruby
browndawg has joined #ruby
mac_ has quit [Remote host closed the connection]
digifiv5e has joined #ruby
Tarential has quit [Excess Flood]
Tarential has joined #ruby
maveonair has quit [Read error: Connection reset by peer]
svector has joined #ruby
Elhu has joined #ruby
ry4nn_ has quit [Remote host closed the connection]
raar has quit [Ping timeout: 245 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hanoi has quit [Quit: bye]
cj3kim_ has joined #ruby
deavidsedice has joined #ruby
DrCode has quit [Ping timeout: 240 seconds]
ged_ has joined #ruby
Kabaka has quit [Ping timeout: 240 seconds]
raar has joined #ruby
deavid has quit [Read error: Connection reset by peer]
gener1c has quit [Ping timeout: 264 seconds]
filipe__ has quit [Ping timeout: 264 seconds]
ujjain has quit [Ping timeout: 264 seconds]
ged has quit [Ping timeout: 264 seconds]
ujjain has joined #ruby
gener1c has joined #ruby
raar is now known as Guest33827
dzhulk has joined #ruby
mercwithamouth has joined #ruby
OdNairy has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
aboudreault has quit [Ping timeout: 264 seconds]
filipe__ has joined #ruby
DrCode has joined #ruby
osvico has quit [Ping timeout: 240 seconds]
relix has joined #ruby
browndawg has quit [Ping timeout: 246 seconds]
coderhs has joined #ruby
bricker`LA has quit [Ping timeout: 260 seconds]
tatsuya_o has joined #ruby
aboudreault has joined #ruby
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
kil0byte has quit [Remote host closed the connection]
bricker`LA has joined #ruby
tatsuya_o has quit [Remote host closed the connection]
diegoviola has quit [Quit: WeeChat 0.4.1]
nextdropping has quit [Ping timeout: 240 seconds]
osvico has joined #ruby
bubbajones has quit [Ping timeout: 245 seconds]
i_s has quit [Remote host closed the connection]
r0bglees0n has joined #ruby
bubbajones has joined #ruby
svector has quit [Read error: Connection timed out]
amacgregor_ has joined #ruby
nisstyre has quit [Quit: Leaving]
prophile has quit [Ping timeout: 264 seconds]
Jetchisel has joined #ruby
dash_ has joined #ruby
zz_tsykoduk is now known as tsykoduk
amacgregor has quit [Ping timeout: 248 seconds]
brum has joined #ruby
Kricir has joined #ruby
aganov has joined #ruby
quoin has joined #ruby
svector has joined #ruby
narcan has quit [Quit: -[AppDelegate installMalware]: unrecognized selector sent to instance 0x156109c0]
brum has quit [Ping timeout: 260 seconds]
noop has joined #ruby
lfox has quit [Quit: ZZZzzz…]
Takehiro has joined #ruby
Kricir has quit [Ping timeout: 245 seconds]
michael_mbp is now known as zz_michael_mbp
tsykoduk is now known as zz_tsykoduk
atno|AFK is now known as atno
wyclif has quit [Ping timeout: 248 seconds]
himsin has joined #ruby
wyclif has joined #ruby
quoin has quit [Ping timeout: 248 seconds]
OdNairy has joined #ruby
funburn has quit [Quit: funburn]
thinkclay has joined #ruby
persand has joined #ruby
<thinkclay>
does rails follow a cascading pattern for the asset pipeline?
SHyx0rmZ has quit [Quit: ネウロイを負かさなきゃならないね]
<popl>
I don't know, thinkclay, but there is a #rubyonrails channel specifically for rails
<popl>
they might know
sectionme has joined #ruby
<thinkclay>
okay, thanks!
* sevenseacat
doesnt know
snovak has joined #ruby
evelyette_ has quit [Read error: Connection reset by peer]
evelyette_ has joined #ruby
freezey has quit [Remote host closed the connection]
Elhu has quit [Quit: Computer has gone to sleep.]
swordsmanz has quit [Read error: Connection reset by peer]
swordsmanz has joined #ruby
sr78ger has joined #ruby
tommyvyo has quit [Ping timeout: 246 seconds]
snovak has quit [Read error: Operation timed out]
denysonique has quit [Ping timeout: 260 seconds]
Zai00 has joined #ruby
iliketurtles has quit [Quit: zzzzz…..]
nextdropping has joined #ruby
Es0teric has joined #ruby
narcan has joined #ruby
OdNairy has quit [Ping timeout: 260 seconds]
osvico has quit [Ping timeout: 252 seconds]
Es0teric has quit [Max SendQ exceeded]
brum has joined #ruby
narcan has quit [Client Quit]
narcan has joined #ruby
kazuuu has quit [Remote host closed the connection]
Tearan has quit [Quit: Sleepy Badger....]
rezzack has quit [Ping timeout: 245 seconds]
Deele has quit [Ping timeout: 260 seconds]
bartocc has joined #ruby
brum has quit [Ping timeout: 240 seconds]
svector has quit [Read error: Connection timed out]
svector has joined #ruby
mengu has joined #ruby
h_kon has joined #ruby
siwica has joined #ruby
end_guy has quit [Remote host closed the connection]
Targen has quit [Ping timeout: 245 seconds]
scottstamp is now known as zz_scottstamp
araujo has quit [Ping timeout: 264 seconds]
aryaching has joined #ruby
jprovazn has joined #ruby
kaspergrubbe has joined #ruby
epta has quit [Ping timeout: 264 seconds]
epta has joined #ruby
trq has joined #ruby
okinomo has quit [Ping timeout: 264 seconds]
<trq>
I just have a very quick question. Can someone please just point me to some docs or tell me the name of these things so that I can look them up myself.
<trq>
I see a lot of function arguments defined as (:foo, :bar)
<trq>
What are these things?
<trq>
Kinda like constants
Hanmac has joined #ruby
<trq>
?
razi has joined #ruby
JPascal has quit [Ping timeout: 246 seconds]
adeponte has joined #ruby
razi has quit [Remote host closed the connection]
<jrobeson>
trq, they are symbols
timonv has joined #ruby
<trq>
3Thanks man.. thats enough for me to start a search
timonv has quit [Remote host closed the connection]
nextdropping has quit [Ping timeout: 245 seconds]
timonv has joined #ruby
alup has joined #ruby
timonv has quit [Read error: Operation timed out]
boxmein has joined #ruby
* boxmein
becomes idler
epta has quit [Ping timeout: 256 seconds]
De`off has joined #ruby
Macaveli has joined #ruby
vishal has joined #ruby
iliketurtles has joined #ruby
Advocation has joined #ruby
Deele has quit [Ping timeout: 260 seconds]
boxmein has quit [Quit: [02:26.00] <Ristovski> mozzarella filofax fadget]
mrsolo has joined #ruby
atno has quit [Read error: No route to host]
atno has joined #ruby
atno has quit [Remote host closed the connection]
vishal has quit [Read error: Connection reset by peer]
atno has joined #ruby
vishal has joined #ruby
i_s has joined #ruby
De`off has quit [Ping timeout: 260 seconds]
epta has joined #ruby
dangerousdave has joined #ruby
evelyette_ has quit [Remote host closed the connection]
Takehiro_ has joined #ruby
evelyette_ has joined #ruby
marius has quit [Quit: x]
brum has joined #ruby
allsystemsarego has joined #ruby
i_s has quit [Ping timeout: 246 seconds]
Kricir has joined #ruby
Takehiro has quit [Ping timeout: 248 seconds]
ahawkins has joined #ruby
Deele has joined #ruby
tonni has joined #ruby
persand has quit [Ping timeout: 245 seconds]
emergion has joined #ruby
brum has quit [Ping timeout: 264 seconds]
wallerdev has quit [Quit: wallerdev]
siwica has quit [Read error: Connection reset by peer]
Kricir has quit [Ping timeout: 246 seconds]
Bosox20051 has joined #ruby
io_syl has quit []
Kar- has joined #ruby
svector has quit [Read error: Connection timed out]
ewnd9 has joined #ruby
svector has joined #ruby
Takehiro_ has quit [Remote host closed the connection]
araujo has joined #ruby
wallerdev has joined #ruby
siwica has joined #ruby
atno has quit [Remote host closed the connection]
benzocoumaran35 has quit [Ping timeout: 248 seconds]
atno has joined #ruby
quoin has joined #ruby
Deele has quit [Ping timeout: 260 seconds]
rahulkmr has joined #ruby
emergion has quit [Read error: Connection reset by peer]
Elhu has joined #ruby
b00stfr3ak has quit [Ping timeout: 256 seconds]
jefflyne1 has joined #ruby
avril14th has joined #ruby
benzocoumaran35 has joined #ruby
_maes_ has quit [Read error: Connection timed out]
jibi has joined #ruby
Advocation has quit [Quit: Advocation]
araujo has quit [Max SendQ exceeded]
araujo has joined #ruby
adeponte has quit [Remote host closed the connection]
tonni has quit [Read error: Connection reset by peer]
quoin has quit [Ping timeout: 256 seconds]
funburn has joined #ruby
brandon has quit [Ping timeout: 240 seconds]
greengriminal has joined #ruby
relix has joined #ruby
snovak has joined #ruby
shaunbaker has joined #ruby
Deele has joined #ruby
shaunbak_ has joined #ruby
xk_id has joined #ruby
timonv has joined #ruby
tesuji has joined #ruby
ayaz has joined #ruby
gr33n7007h has quit [Ping timeout: 248 seconds]
gcds has joined #ruby
araujo has quit [Ping timeout: 252 seconds]
pranny has joined #ruby
shaunbaker has quit [Ping timeout: 259 seconds]
snovak has quit [Ping timeout: 264 seconds]
adambeynon has joined #ruby
jonahR has quit [Quit: jonahR]
Deele has quit [Ping timeout: 260 seconds]
obs has joined #ruby
marcgg_ has joined #ruby
tonni has joined #ruby
iliketurtles has quit [Quit: zzzzz…..]
jbpros has joined #ruby
rahulkmr has quit [Read error: Connection reset by peer]
rahulkmr has joined #ruby
araujo has joined #ruby
rahulkmr has quit [Read error: Connection reset by peer]
sectionme has quit [Ping timeout: 240 seconds]
rahulkmr has joined #ruby
hoelzro has joined #ruby
mengu has quit [Remote host closed the connection]
rahulkmr has quit [Read error: Connection reset by peer]
rahulkmr has joined #ruby
marcgg has quit [Ping timeout: 240 seconds]
sectionme has joined #ruby
tonni has quit [Read error: Connection reset by peer]
brum has joined #ruby
petey has joined #ruby
popl has quit [Quit: We must make an idol of our fear, and call it God.]
araujo has quit [Ping timeout: 246 seconds]
shaunbak_ has quit [Remote host closed the connection]
petey has quit [Remote host closed the connection]
Advocation has joined #ruby
Macaveli has quit [Read error: Connection reset by peer]
Macaveli has joined #ruby
araujo has joined #ruby
rahulkmr1 has joined #ruby
senayar has joined #ruby
rahulkmr has quit [Ping timeout: 245 seconds]
brum has quit [Ping timeout: 260 seconds]
elaptics`away is now known as elaptics
araujo has quit [Max SendQ exceeded]
nikeita has joined #ruby
araujo has joined #ruby
araujo has quit [Changing host]
araujo has joined #ruby
Olipro has quit [Ping timeout: 260 seconds]
einarj has joined #ruby
gr33n7007h has joined #ruby
_maes_ has joined #ruby
SkuliOskarsson has joined #ruby
svector has quit [Read error: Connection timed out]
SkuliOskarsson has quit [Read error: Connection reset by peer]
wallerdev has quit [Quit: wallerdev]
svector has joined #ruby
SkuliOskarsson has joined #ruby
tonni has joined #ruby
maoko has joined #ruby
cj3kim_ has quit [Ping timeout: 256 seconds]
tacos1de has quit [Ping timeout: 240 seconds]
AndChat| has joined #ruby
BraddBitt has quit [Ping timeout: 245 seconds]
araujo has quit [Ping timeout: 246 seconds]
gr33n7007h has quit [Ping timeout: 248 seconds]
SkuliOskarsson has quit [Client Quit]
AndChat- has joined #ruby
OdNairy has joined #ruby
lkba has quit [Ping timeout: 245 seconds]
AndChat| has quit [Read error: Connection reset by peer]
araujo has joined #ruby
Deele has joined #ruby
<lessless>
folks, somtimes number is 12.2343243 4 and I want to round up it to the second number after the point - .round(2), but sometimes number is 123 and I want it to have a zero after the rounding, i.e. 123.0. How to put this logic in single expression?
<lessless>
sevenseacat, there is two different cases: if there is valuable numbers after the point they must stay, but if there is not, like number.round(2) => 123.00001, I want to display integer, not a float
Deele has quit [Ping timeout: 260 seconds]
<sevenseacat>
0 is a valuable number
mengu has joined #ruby
zz_scottstamp is now known as scottstamp
<Hanmac>
lessless: round(2) can not return what what you shows to us .. (as far as i know)
<Hanmac>
>> i = 123.001; (n = i.round(2)) == i.to_i ? i.to_i : n
svector has quit [Read error: Connection timed out]
himsin has joined #ruby
DonRichie has joined #ruby
svector has joined #ruby
Deele has quit [Ping timeout: 260 seconds]
brum has joined #ruby
Kricir has joined #ruby
timonv has quit [Remote host closed the connection]
senayar has quit [Remote host closed the connection]
xk_id has quit [Quit:
varfoo has joined #ruby
workmad3 has joined #ruby
tonni has quit [Read error: Connection reset by peer]
ry4nn_ has joined #ruby
brum has quit [Ping timeout: 248 seconds]
Kricir has quit [Ping timeout: 240 seconds]
quoin has joined #ruby
ry4nn has quit [Ping timeout: 268 seconds]
OdNairy has quit [Ping timeout: 248 seconds]
Deele has joined #ruby
pranny has quit [Quit: Leaving.]
atno has quit [Remote host closed the connection]
aspiers has quit [Ping timeout: 260 seconds]
aspiers has joined #ruby
<jlebrech>
i think foreman needs a menu, or either zsh should have a plugin to select Procfile lines
prophile has joined #ruby
dawkirst has quit [Ping timeout: 246 seconds]
predator217 has joined #ruby
tonni has joined #ruby
predator117 has quit [Ping timeout: 240 seconds]
nomenkun has joined #ruby
tonni has quit [Remote host closed the connection]
senayar has joined #ruby
cads has joined #ruby
<jlebrech>
can you do a coalesce with blank strings? ie. nil_object || blank_string || "nothing to see here"
__userna1 has quit [Ping timeout: 240 seconds]
atno has joined #ruby
<jlebrech>
obviously not with ||, i wouldn't be asking here otherwise :P
noname001 has joined #ruby
<tobiasvl>
irb
tommyvyo has joined #ruby
jefflyne1 has quit [Ping timeout: 264 seconds]
<jlebrech>
is there a way to convert "" to nil?
<tobiasvl>
you mean false, don't you
<tobiasvl>
or "falsey"
<Hanmac>
jlebrech: check with !str.empty?
<jlebrech>
ok, will have a look
denysonique has joined #ruby
<Hanmac>
tobiasvl: i think the currect pronouncing is "fals-ey" ;P
Sammael has quit [Ping timeout: 246 seconds]
snovak has joined #ruby
tatsuya_o has joined #ruby
<jlebrech>
hanmac: oh, || checks falseyness not nillyness :P
<jlebrech>
i'd need a method which returns false or value
<tobiasvl>
jlebrech: yes, hence my question ;) nil is falsey, "" is not
emergion has joined #ruby
Xeago has joined #ruby
snovak has quit [Ping timeout: 245 seconds]
adeponte has joined #ruby
<Hanmac>
ruby is way more consequent in checking "falsey" than php … in ruby everything is true, except for false and nil (but for more fun you can manipulate the "not" operator ;P )
<jlebrech>
i know :) but i wanna to wrap my variables in a method that returns the value if it's not empty but false if it is
<jlebrech>
mhh
Darshan has joined #ruby
mercwithamouth has quit [Ping timeout: 256 seconds]
<jlebrech>
how come empty? return true or false when the original value would be truthy if not false
svector has quit [Read error: Connection timed out]
timonv has joined #ruby
svector has joined #ruby
narcan has quit [Quit: -[AppDelegate installMalware]: unrecognized selector sent to instance 0x156109c0]
<tobiasvl>
jlebrech: what do you mean?
<jlebrech>
found a better way: .select{|i| !i.empty? && !i.nil? }
_maes_ has joined #ruby
chinkung has joined #ruby
<Hanmac>
i think you should switch it … check for nil first
adeponte has quit [Ping timeout: 240 seconds]
funburn has quit [Quit: funburn]
xk_id has joined #ruby
mikecmpbll has joined #ruby
mercwithamouth has joined #ruby
kofno has quit [Ping timeout: 240 seconds]
brum has joined #ruby
kung has quit [Ping timeout: 252 seconds]
lkba has joined #ruby
kofno has joined #ruby
<canton7>
is this for checking for an empty/nil string? you can be a bit dirty and to string.to_s.empty? as well :P
gr33n7007h has joined #ruby
kreantos has joined #ruby
_maes_ has quit [Ping timeout: 252 seconds]
tonni has joined #ruby
tobago has joined #ruby
dawkirst has joined #ruby
brum has quit [Ping timeout: 260 seconds]
aryaching_ has joined #ruby
nbrosnahan has joined #ruby
sevenseacat has quit [Quit: Leaving.]
<Hanmac>
or use [nil,"","a","bc"].grep /./ #=> ["a", "bc"]
<kreantos>
hi having a activemodel class XY: "XY.new nil" what is the nil parameter for
aryaching has quit [Ping timeout: 248 seconds]
<tobiasvl>
argument for the constructor
<tobiasvl>
XY.new(nil)
<tobiasvl>
is the same
<Hanmac>
kreantos look at #rubyonrails … the amount of help you get, that is nil
skaflem has joined #ruby
gilesw_ has quit [Ping timeout: 245 seconds]
nbrosnahan has quit [Read error: Connection reset by peer]
<kreantos>
yes, i have an app where the specs are ok under 1.9.2 but failing on 1.9.3
dawkirst has quit [Ping timeout: 240 seconds]
nbrosnahan has joined #ruby
priyam_ has quit [Ping timeout: 264 seconds]
kizzx2 has quit [Ping timeout: 252 seconds]
kizzx2 has joined #ruby
aryaching_ has quit [Ping timeout: 264 seconds]
senayar has quit [Remote host closed the connection]
brunto_ has joined #ruby
<brunto_>
Hi
senayar has joined #ruby
<Hanmac>
kreantos: you need to make a gist of the code … otherwise only psychics lvl 5+ can help you … and my crystalball tells me that you used "super" in your code?
<brunto_>
I'd like to know if there is a short way to do this : string.scan(/(?<=\{\{)[^\{\{\}\}]+(?=\}\})/)
<tobiasvl>
brunto_: lol. what is "this"? what does that regex actually do?
<tobiasvl>
or do you expect us to parse that :P
siwica has quit [Quit: siwica]
SkuliOskarsson has quit [Quit: Leaving.]
<workmad3>
brunto_: finding stuff that's between {{ and }} ?
<brunto_>
tobiasvl: sorry I want to parse a string like "Something {{replace me}} and {{replace that}}"
SkuliOskarsson has joined #ruby
<brunto_>
.scan() give me an array and then I want to replace {{something}} with .sub()
<brunto_>
Do you want a gist to see my code ?
binw_ has joined #ruby
filipe__ has quit [Read error: Operation timed out]
Ripp__ has quit []
<Hanmac>
brunto_: why not use gsub directly?
nomenkun has quit [Remote host closed the connection]
SkuliOskarsson has quit [Client Quit]
nomenkun has joined #ruby
<brunto_>
hanmac: because I'd like to do different things if it's "replace me" or "replace that"
camilasa_ has quit [Remote host closed the connection]
ravster has joined #ruby
seanmccann has quit [Ping timeout: 248 seconds]
bwwrd has joined #ruby
Elhu has joined #ruby
allanm has quit [Read error: Connection reset by peer]
mercwithamouth has quit [Ping timeout: 240 seconds]
<Hanmac>
"Triple DES requires a 24-byte key, with Ruby this means a string with 24 characters."
vim_shim has quit [Ping timeout: 240 seconds]
geggam has quit [Quit: Leaving]
<dukz>
hanmac: The given key is 16 characters, and i'm trying to figure out what that C# code is doing that makes it work. :(
<crunch-choco>
it's a bit out of topic but can rails 4 be installed in any kind of server?
amacgregor has joined #ruby
<Hanmac>
crunch-choco: #rubyonrails
<crunch-choco>
yes :p
WoodsDog has quit []
mlpinit has joined #ruby
<wuest>
dukz: check out the API they're using. It might be null-padding, or it might repeat the key, then only use the first 24 bytes. I've seen both of those strategies.
angusiguess has joined #ruby
duggiefresh has joined #ruby
user258467 has quit [Remote host closed the connection]
<dukz>
wuest: They are using PKCS7 padding, i've read on it earlier, and am now trying to figure out how to put it into code in ruby.
<dukz>
Thanks.
<wuest>
Good luck! :)
Guest52560 has quit [Ping timeout: 246 seconds]
<Advocation>
this is probably a really stupid issue, but I can't install any gems without using sudo.. Any ideas what I'm doing wrong?
jonathanwallace has quit [Ping timeout: 246 seconds]
<Hanmac>
Advocation: it depends who your ruby is installed … if your ruby is installed into your system, you can only install gems into your system
jpun has quit [Ping timeout: 246 seconds]
Amnesia has joined #ruby
<Advocation>
hanmac: I'm using rbenv to manage it
Amnesia is now known as Guest72338
jpun has joined #ruby
kaspergrubbe has quit [Read error: Connection reset by peer]
<Hanmac>
then maybe "gem" points to the wrong file
<Advocation>
workmad3: ah shoot, I didn't install that
<Advocation>
that explains a lot
dangerousdave has joined #ruby
joofsh has quit [Remote host closed the connection]
allanm has joined #ruby
<workmad3>
Advocation: yeah, heroku stopped distributing updates to the toolbelt as gems, they have their own installer now
<Advocation>
perfect, I installed the toolbelt and it's all working fine now :)
<Advocation>
thanks you guys!
<Hanmac>
its own installer, with own NSA backdoor? ;P
amacgregor has quit [Ping timeout: 240 seconds]
obs has quit [Quit: Konversation terminated!]
burlyscudd has quit [Quit: Leaving.]
Phobos has joined #ruby
<Phobos>
Hello guys
dkamioka has joined #ruby
drizz has quit [Read error: Connection reset by peer]
ananthakumaran1 has quit [Quit: Leaving.]
obs has joined #ruby
himsin has quit [Quit: himsin]
<ravster>
hello
petey has joined #ruby
jefflyne1 has joined #ruby
wallerdev has joined #ruby
<Phobos>
I am really struggling in achieving something basic in ruby.. All I wanted to do is this simple inheritance use case.. I have a class vehicle with name attribute, and a child class that inherite the name parent attribute so sometimes it override it sometimes it doesn't
<Phobos>
My problem is that I can't do something like : car = Car.new
<hoelzro>
Phobos: would you mind pasting some code on a pastebin and sending us a link?
<aganov>
Hi all, I have implemented multithreaded TcpSever (with short-living connections) but my main process memory is very hight, 200 MB, I've also noticed that there are many TIME_WAIT connections?
noop has quit [Ping timeout: 264 seconds]
<aganov>
Is there any way i can reduce memory usage/ TIME_WAIT connections?
cads has joined #ruby
ccooke is now known as ccooke_
dash_ has quit [Quit: dash_]
jbpros has quit [Quit: jbpros]
<bean__>
aganov: so, TIME_WAIT is actually OS specific. Once you close the TCP connection the OS leaves the socket connection open for a certain amount of time.
ahawkins has quit [Quit: leaving]
<bean__>
This is apparently done to prevent packet colission
<Phobos>
bean__, I have a last question sorry.. I heard that in ruby there is something called class instance variables which is the best solution for our current use case.. Is that true ? and how to implement that in object context rather than class context ?
burlyscudd has joined #ruby
<bean__>
Phobos: everything (well, nearly everything) in ruby is an object
<Phobos>
And what's about module mixing ? Can I use that instead of inheritance ?
<bean__>
I can't say i've used modules much
<bean__>
short of my cute little colors.rb module
<bean__>
to add colored output to all of the things.
ccooke_ is now known as ccooke
<Phobos>
bean__, OK ! but here to access for exemple class instance variable.. we call the Class directly for example : Car.name instead of Car.new etc...
Catie has quit [Ping timeout: 248 seconds]
<bean__>
mind explaining why you want to do that?
<Phobos>
bean__, OK because I've found those information in Eloquent ruby book
<Phobos>
I think it's a famous one
* bean__
hasn't read any ruby books.
<bean__>
not a big fan of reading books to learn programming
rhys has joined #ruby
Catie has joined #ruby
<Phobos>
bean__, To acheive the same thing as we said but in "RUBY WAY"
obs has quit [Quit: Konversation terminated!]
balboah has joined #ruby
<aganov>
bean__, ok about TIME_WAIT, any idea why ruby process is allocating that much memory
<bean__>
Phobos: I'd say what I showed you is a completely valid "ruby way"
balboah has left #ruby [#ruby]
<bean__>
aganov: not without seeing code :)
<Phobos>
bean__, OK friend :)
<Phobos>
bean__, thank you so much
obs has joined #ruby
<bean__>
Phobos: I'd only ever use a class variable is for things that you'd want to be constant for every class, and never change. I rarely use them though.
xk_id has quit [Quit:
mlpinit_ has joined #ruby
mlpinit has quit [Read error: Connection reset by peer]
<Phobos>
bean__, because here in the examples that I have found in that book is a very similar use case to the one we discussed earlier.. And the author used class instance variables to solve that
dhruvasagar has joined #ruby
jefflyne1 has quit [Ping timeout: 252 seconds]
snyp has joined #ruby
lfox has joined #ruby
ananthakumaran has joined #ruby
ananthakumaran has quit [Max SendQ exceeded]
evenix has joined #ruby
ananthakumaran has joined #ruby
coderhs has joined #ruby
ananthakumaran has quit [Max SendQ exceeded]
vim_shim has joined #ruby
mary5030 has joined #ruby
dawkirst has quit [Ping timeout: 246 seconds]
<Phobos>
bean__, OK I will adapt authors ideas for the same use case... And we will share and discuss that together...
ananthakumaran has joined #ruby
ananthakumaran has quit [Max SendQ exceeded]
burlyscudd has quit [Ping timeout: 245 seconds]
ananthakumaran has joined #ruby
<bean__>
sure, i'll look at it if i get time
xjiujiu has quit [Read error: Connection reset by peer]
petey_ has joined #ruby
<bean__>
aganov: odd. I'm going to try and reproduce it locally here.
tagrudev has quit [Quit: Me = Awesome]
<Phobos>
bean__, Of course friend take your time.. All I need is your precious advices :)
petey has quit [Read error: Connection reset by peer]
tacos1de has quit [Remote host closed the connection]
quoin has joined #ruby
saarinen has joined #ruby
<deception>
I have a client who will be sending purchase orders via CSV and our order entry software only accepts XML. Would using an Object Relational Mapper be the best way to accomplish the conversion?
testtst has joined #ruby
tacos1de has joined #ruby
Nogbit has quit [Quit: Leaving.]
adeponte has joined #ruby
Nogbit has joined #ruby
mlpinit has joined #ruby
lukec has quit [Quit: lukec]
camilasan has quit [Remote host closed the connection]
testtst is now known as testtst2
<duke_nukem>
ORMs don't have much to do with data conversion. You probably want to add a step in somewhere that converts the CSV to XML
pwh has joined #ruby
swordsmanz has quit [Quit: swordsmanz]
cody-- has joined #ruby
kevinykc_ has quit [Quit: Computer has gone to sleep.]
dhruvasagar has quit [Ping timeout: 245 seconds]
dhruvasagar has joined #ruby
<deception>
duke_nukem, What is the best tool or library to do the conversion or would I just parse the CSV and write the output logic myself?
kirun has joined #ruby
<canton7>
yeah, there are some nice libraries for writing xml
shaunbaker has joined #ruby
<duke_nukem>
deception: well parsing the CSV would be pretty easy since there's a native gem for that, I haven't done any XML stuff in ruby yet so someone else could surely direct you there
testtst2 has quit [Ping timeout: 240 seconds]
<duke_nukem>
shouldn't be very hard at all really
Nogbit has quit [Quit: Leaving.]
Nogbit has joined #ruby
quoin has quit [Ping timeout: 256 seconds]
<canton7>
nokogiri has a nice xml writer imo
enriclluelles has joined #ruby
dodosan has joined #ruby
<deception>
I already have the rows parsed and imported into an array. I'll take a look at nokogiri and see if I can build the XML file the way I need it to be. Thanks!
Falcore has joined #ruby
<duke_nukem>
nokogiri is pretty sweet
<Hanmac>
shevy !! the found something like "Photonic molecules" … do you know that what means? ;D
kaldrenon has quit [Remote host closed the connection]
alex__c2022 has joined #ruby
MrThePlague has quit [Remote host closed the connection]
raphaelivan has joined #ruby
kaspergrubbe has joined #ruby
kaldrenon has joined #ruby
Monie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
c0rn has joined #ruby
Guest55008 is now known as riku
riku is now known as Guest22892
apeiros has joined #ruby
Nogbit has quit [Client Quit]
larissa has quit [Quit: Leaving]
Nogbit has joined #ruby
burlyscudd has joined #ruby
octoberry has joined #ruby
nomenkun has quit [Remote host closed the connection]
Blue_Ice_ is now known as Blue_Ice
kaldrenon has quit [Ping timeout: 260 seconds]
c0rn has quit [Ping timeout: 248 seconds]
rupee has joined #ruby
i_s has joined #ruby
whunt has joined #ruby
burlyscudd has quit [Ping timeout: 264 seconds]
kaldrenon has joined #ruby
smigg has joined #ruby
__username__ has quit [Ping timeout: 245 seconds]
Nogbit has quit [Quit: Leaving.]
c0rn has joined #ruby
Nogbit has joined #ruby
toastynerd has quit [Remote host closed the connection]
Nenor has joined #ruby
lfox has quit [Quit: ZZZzzz…]
bean__ has quit [Read error: Connection reset by peer]
io_syl has joined #ruby
thinkclay has joined #ruby
rahulkmr1 has joined #ruby
sailias has quit [Ping timeout: 260 seconds]
Nogbit has quit [Client Quit]
Nogbit has joined #ruby
interactionjaxsn has quit [Remote host closed the connection]
rahulkmr has quit [Ping timeout: 240 seconds]
interactionjaxsn has joined #ruby
evelyette_ has quit [Remote host closed the connection]
<Morrolan>
CTCP is a protocol which IRC clients use to request information from each other.
<havenwood>
but clojure lib looks more complete
<canton7>
be nice to have argument checking on that too, maybe? dunno, it starts to get more complicated
awkisopen has joined #ruby
klrr_ has left #ruby [#ruby]
quoin has quit [Ping timeout: 240 seconds]
OdNairy has joined #ruby
GoldenGiant has quit [Ping timeout: 264 seconds]
<apeiros>
class ImplementationMismatchError < ArgumentError; end; def implement!(module, message=nil); raise ImplementationMismatchError, (message || "#{inspect} was expected to implement #{module} but does not"); end
<apeiros>
I wrote something like that ~7y ago. never used it because I'm too much of a performance fetishist.
d45h has joined #ruby
dodosan has quit [Remote host closed the connection]
dodosan has joined #ruby
carraroj has joined #ruby
interactionjaxsn has joined #ruby
<apeiros>
btw. Morrolan - your website works! :)
browndawg has left #ruby [#ruby]
Ripp__ has quit []
mityaz has joined #ruby
Desert_eagle has quit [Quit: Leaving]
dodosan has quit [Read error: Connection reset by peer]
Monie has joined #ruby
OdNairy has quit [Ping timeout: 264 seconds]
octoberry has quit [Ping timeout: 264 seconds]
alex__c2022 has joined #ruby
ghost2060 has joined #ruby
dodosan has joined #ruby
shaunbaker has quit [Remote host closed the connection]
mrsolo has quit [Quit: This computer has gone to sleep]
GoldenGiant has joined #ruby
rupee has joined #ruby
yacks has joined #ruby
tvw has quit [Read error: Connection reset by peer]
saysjonathan has quit [Quit: leaving]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
allaire has joined #ruby
Fire-Dragon-DoL has joined #ruby
Fire-Dragon-DoL has quit [Client Quit]
pwh has quit [Quit: pwh]
burlyscudd has joined #ruby
saysjonathan has joined #ruby
julweber has quit [Remote host closed the connection]
mrsolo has joined #ruby
twoism has joined #ruby
Falcore has quit [Quit: Falcore]
Elhu has quit [Quit: Computer has gone to sleep.]
saysjonathan has quit [Client Quit]
ColKurtz has joined #ruby
shadoi has joined #ruby
cj3kim_ has joined #ruby
Kruppe has quit [Ping timeout: 240 seconds]
saysjonathan has joined #ruby
snyp has joined #ruby
Xeago has quit [Ping timeout: 240 seconds]
Kruppe has joined #ruby
<Morrolan>
apeiros: Hah. :)
snyp has left #ruby [#ruby]
pwh has joined #ruby
Ripp__ has joined #ruby
gwb3 has quit [Remote host closed the connection]
gwb3 has joined #ruby
asobrasil has quit [Quit: Leaving.]
chickenf_ has quit [Quit: Computer has gone to sleep.]
gwb3 has quit [Remote host closed the connection]
tacos1de has quit [Ping timeout: 240 seconds]
<Uranio>
there is any camping (a ruby web framework) user here?
petey has quit [Remote host closed the connection]
Xeago has joined #ruby
Elhu has joined #ruby
Bry8Star{T2 has quit [Ping timeout: 240 seconds]
skaflem has quit [Quit: Leaving]
kaspergrubbe has joined #ruby
mklappst_ has joined #ruby
dangerousdave has joined #ruby
iravan has quit [Ping timeout: 260 seconds]
Tearan has joined #ruby
netQT_ has joined #ruby
_adeponte has quit [Remote host closed the connection]
AdmiraI has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Guest41596 has quit [Ping timeout: 264 seconds]
relix has joined #ruby
digifiv5e has joined #ruby
mklappstuhl has quit [Ping timeout: 240 seconds]
digifiv5e is now known as Guest64730
jerrad has joined #ruby
rezzack has joined #ruby
Guest64730 has quit [Changing host]
Guest64730 has joined #ruby
Guest64730 is now known as guyz
Michael has joined #ruby
Elhu has quit [Quit: Computer has gone to sleep.]
netQT_ has quit [Remote host closed the connection]
Michael is now known as Guest29237
Fernandos has joined #ruby
<Fernandos>
hi
DrCode has quit [Ping timeout: 240 seconds]
crunch-choco has left #ruby [#ruby]
<Fernandos>
I haven't used the irb for years.. but need to create a test account and running this command fails: AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up
<Fernandos>
I'm getting: NameError: undefined local variable or method `direction' for main:Object
joesavage has joined #ruby
<Fernandos>
NameError: uninitialized constant AdminUser (without if direction)
zacts has quit [Quit: leaving]
tgraham is now known as tgraham|away
petey has joined #ruby
<canton7>
Fernandos, have you require'd the files which define those classes and variables?
Xeago_ has joined #ruby
joofsh has quit [Read error: No route to host]
joofsh has joined #ruby
DrCode has joined #ruby
<Fernandos>
hmm no.. do I need to do that, which files should I require?
Bry8Star{T2 has joined #ruby
tatsuya_o has joined #ruby
<Fernandos>
would irb -I repo/ work?
Guest72338 is now known as Amnesia
Amnesia has quit [Changing host]
Amnesia has joined #ruby
zeade has quit [Quit: Leaving.]
burlyscudd has quit [Ping timeout: 246 seconds]
<canton7>
you'd still need to require the files you need. irb doesn't magically include all files in a particular dir
ebobby has joined #ruby
zeade has joined #ruby
jlast_ has joined #ruby
BizarreCake has quit [Quit: Leaving]
allaire has quit []
<sweeper>
Fernandos: if this is a rails app, go into the repo and type rails c
<Fernandos>
ok
<sweeper>
that WILL magically include everything :)
m8 has joined #ruby
RichardBaker has quit [Quit: RichardBaker]
ehaliewicz has joined #ruby
kil0byte has quit [Remote host closed the connection]
<Fernandos>
nice, will try that
jlast has quit [Ping timeout: 264 seconds]
kil0byte has joined #ruby
RichardBaker has joined #ruby
<joesavage>
I'm trying to accomplish some really basic async functionality out of some synchronous methods I've written using SSLSocket.syswrite -- people seem to be recommending stuff like EventMachine, but it seems really overkill and complicated for this situation. Any suggestions?
kil0byte has quit [Remote host closed the connection]
popl has quit [Quit: We must make an idol of our fear, and call it God.]
ebobby has left #ruby [#ruby]
i_s has quit [Remote host closed the connection]
burlyscudd has joined #ruby
chairabanta has quit [Quit: Leaving...]
SkuliOskarsson has quit [Quit: Leaving.]
ij has joined #ruby
quoin has joined #ruby
Kricir has quit [Remote host closed the connection]
johnnyfuchs has joined #ruby
petey has quit [Remote host closed the connection]
anonymus_ has quit [Remote host closed the connection]
anonymuse has joined #ruby
quoin has quit [Ping timeout: 264 seconds]
<Fernandos>
sweeper: thank you it almost worked. I could successfully add: AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')
Bry8Star{T2 has quit [Remote host closed the connection]
Falcore has joined #ruby
<Fernandos>
sweeper: but I cannot login with that user and password.. any ideas? It keeps telling me that the password/username is wrong
tgraham|away is now known as tgraham
sailias has quit [Ping timeout: 248 seconds]
zets has quit [Ping timeout: 240 seconds]
mlpinit has quit [Ping timeout: 248 seconds]
spyderma_ has quit [Remote host closed the connection]
jprovazn has quit [Quit: Odcházím]
rudisimo has joined #ruby
dash_ has quit [Ping timeout: 245 seconds]
amacgregor has joined #ruby
RichardBaker has quit [Quit: RichardBaker]
RichardBaker has joined #ruby
johnnyfuchs has quit [Remote host closed the connection]
keee has quit [Ping timeout: 245 seconds]
johnnyfuchs has joined #ruby
martxel has quit [Ping timeout: 245 seconds]
pwh has quit [Quit: pwh]
ehaliewicz has quit [Read error: Connection reset by peer]
benlieb has quit [Ping timeout: 260 seconds]
zarubin has quit [Ping timeout: 260 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ehaliewicz has joined #ruby
SkuliOskarsson has joined #ruby
i_s has joined #ruby
keee has joined #ruby
gcds has joined #ruby
petey has joined #ruby
<sweeper>
Fernandos: that's going to depend on your application, and how it saves passwords, wtc
<sweeper>
*etc
mdst_ has joined #ruby
k610 has joined #ruby
alvaro_o_ has joined #ruby
sailias has joined #ruby
mist has quit [Remote host closed the connection]
Guest29237 has quit [Remote host closed the connection]
araujo has quit [Ping timeout: 248 seconds]
dangerousdave has quit [Read error: Connection reset by peer]
schaerli has quit [Remote host closed the connection]
KobraKao has quit [Ping timeout: 246 seconds]
Sander^work has quit [Ping timeout: 251 seconds]
mrmist has joined #ruby
decoponyo has quit [Quit: Leaving...]
cpruitt has quit [Ping timeout: 268 seconds]
julweber has joined #ruby
<snyp>
Classes in ruby can be called 'object makers' (bear with me) and these object-makers have the class type 'Class'. The objects made with these classes (object makers) have their .class = objectmakername. right?
<Hanmac>
snyp Classes in ruby are also objects made by the class "Class" ;P
quoin has quit [Ping timeout: 246 seconds]
<sweeper>
did you run the migrations?
martxel has joined #ruby
martxel has quit [Changing host]
martxel has joined #ruby
Targen has joined #ruby
<snyp>
i see.. this is really confusing..
<snyp>
though it's easy to visualise
Emmanuel_Chanel has quit [Ping timeout: 256 seconds]
petey has quit [Remote host closed the connection]
harmaz has joined #ruby
petey has joined #ruby
MrPoT4tO has joined #ruby
<banisterfiend>
hanmac have you seen love games?
<banisterfiend>
hanmac (the new A.T episode)
<snyp>
These 'class'es in ruby are sort of loosely implemented using Module's functionalities
julweber has quit [Ping timeout: 264 seconds]
Kricir has joined #ruby
SkuliOskarsson has quit [Quit: Leaving.]
araujo has joined #ruby
araujo has joined #ruby
k610 has quit [Ping timeout: 240 seconds]
<Hanmac>
snyp: classes are objects of Class, modules are object of Module, Class inherit from Module … but Module itself is also a class so its Module.class #=> Class
mlpinit has joined #ruby
chairabanta has joined #ruby
chairabanta has quit [Client Quit]
ghost2060 has quit [Ping timeout: 245 seconds]
<harmaz>
what do people use for checking ruby 1.9+ for memory leaks?
chairabanta has joined #ruby
Kricir has quit [Remote host closed the connection]
chairabanta has quit [Client Quit]
<apeiros>
snyp: the speciality of the class Class is Class#allocate (the "object maker" facility)
ghost2060 has joined #ruby
Kricir has joined #ruby
<snyp>
i see
<banisterfiend>
hanmac answer bb
<apeiros>
snyp: and don't mind too much that rubys root level is somewhat circular (Class subclassing Module while Module is a Class, Object being a Class while Class is an Object etc.)
<apeiros>
they cheat, to achieve that :)
cody-- has quit [Quit: derp]
<Hanmac>
harmaz: i use "divining rods" for this ;P
<fryguy>
snyp: i'd highly recommend the metaprogramming ruby book
jmccune has quit [Ping timeout: 252 seconds]
* Hanmac
waves the hand: "everything you can see, is an object in ruby" ;P
pel_daniel has joined #ruby
adeponte has joined #ruby
<snyp>
subclassing is just copy-pasting the methods of a class into another class, right?
fmcgeough has quit [Quit: fmcgeough]
<apeiros>
wrong
<snyp>
hmm
<apeiros>
subclassing means that method lookup is chained
robustus has joined #ruby
rahulkmr1 has quit [Ping timeout: 248 seconds]
<apeiros>
obj.foo --> look up in obj.singleton_class, then obj.class, then obj.class.ancestors
<apeiros>
when that's through, go through it again, looking for :method_missing instead of :foo
<Fernandos>
sweeper: yes I ran the migrations, that's why I'm confused, I created another test user, but I cannot login with that user also.
<apeiros>
and after all of that - raise a NoMethodError
jmccune has joined #ruby
<snyp>
apeiros: i see...
sambao21 has quit [Quit: Computer has gone to sleep.]
<snyp>
fryguy: thanks for recommending
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<fryguy>
apeiros: actually you missed Kernel, which is where method_missing is defined to actually raise that error
<apeiros>
fryguy: I did not
<apeiros>
you missed the point about .ancestors
SloggerKhan has joined #ruby
<apeiros>
but: are you sure it's Kernel?
<fryguy>
apeiros: you represented it like NoMethodError was some core ruby behavior, which it's not
gwb3 has joined #ruby
RichardBaker has quit [Quit: RichardBaker]
Michael has joined #ruby
cody-- has joined #ruby
<apeiros>
fryguy: anything to back that up?
Michael is now known as Guest72063
<Fernandos>
sweeper: that was exactly the file I had my eyes on and it's pretty easy to understand, but it's weird that admin@exampl.com and password doesn't allow me to login
pwh has joined #ruby
<snyp>
What's the difference between a class and a module?
Speed has quit [Ping timeout: 260 seconds]
<apeiros>
snyp: a module can't allocate
<snyp>
you cannot instantiate moduele?
<apeiros>
snyp: and a class can't be used with Module#include or Object#extend
<snyp>
ah
<apeiros>
not directly, no
<snyp>
so modules are like code copy-pasting purposes?
<apeiros>
code-sharing
<apeiros>
they also provide namespaces
<apeiros>
module X; class String; end; X::String != ::String
<apeiros>
+end 0:-)
<snyp>
hmm hmm
petey has quit [Remote host closed the connection]
gwb3 has quit [Ping timeout: 245 seconds]
claymore has quit [Quit: Leaving]
starship has quit [Ping timeout: 264 seconds]
<SloggerKhan>
Anybody use OmniAuth with rails? Is it a good choice?
<apeiros>
fryguy: I seriously doubt your claim that NoMethodError stems from Kernel. E.g. BasicObject doesn't include Kernel. I also doubt it's even implemented in terms of plain ruby.
<Fernandos>
SloggerKhan: I used it 1-2y ago, wasn't mature at that time, but maybe it's now :) sorry, that I can't help more. It was quite easy to setup though.
<snyp>
ok thanks a lot for helping, apeiros. i will carry on learning ruby.
digifiv5e has joined #ruby
snyp has quit [Quit: "bbl"]
digifiv5e is now known as Guest26180
starship has joined #ruby
mikeg has joined #ruby
jibi has quit [Read error: Connection reset by peer]
jibi has joined #ruby
starship is now known as Guest76549
<SloggerKhan>
Fernandos: Thanks!
<ylluminate>
i have a huge number of product descriptions from some vendors that i need to list, but i have to uniquify them so that google doesn't discount them since they'd match a lot of other vendors who use these same product descriptions. i've got a few hundred thousand items to do this for, so i really need to automate this.
Emmanuel_Chanel has joined #ruby
<ylluminate>
i was thinking about using https://github.com/ged/ruby-wordnet, but i wanted to see if anyone else might have some suggestions on working with synonym replacement for words and phrases in ruby
pwh has quit [Quit: pwh]
<shevy>
hanmac what are "photonic molecules"?
havenwood has quit [Remote host closed the connection]
maniacal_ has joined #ruby
tyfighter has joined #ruby
adeponte has quit [Remote host closed the connection]
havenwood has joined #ruby
OdNairy has joined #ruby
jlast_ has quit [Remote host closed the connection]
Hanmac has quit [Read error: Connection reset by peer]
Hanmac has joined #ruby
carraroj has quit [Quit: Konversation terminated!]
joofsh_ has joined #ruby
Dreamer3 has quit [Quit: Computer has gone to sleep.]
joofsh has quit [Ping timeout: 248 seconds]
quoin has joined #ruby
raphaelivan has quit [Quit: Leaving.]
pel_daniel1 has joined #ruby
mayorga has joined #ruby
adambeynon has joined #ruby
Dreamer3 has joined #ruby
pel_daniel has quit [Ping timeout: 260 seconds]
postmodern has joined #ruby
nhmood_ has joined #ruby
robbyoconnor has joined #ruby
funburn has joined #ruby
freezey has quit [Remote host closed the connection]
geekbri has quit [Remote host closed the connection]
quoin has quit [Ping timeout: 252 seconds]
Guest95708 has quit [Quit: Leaving...]
mlpinit has quit [Ping timeout: 246 seconds]
jibi has quit [Quit: .]
Guest72063 has quit [Remote host closed the connection]
Fernandos has left #ruby ["PART #rails :PONG :ZNC"]
xk_id has joined #ruby
<nhmood_>
Is there a way to use a method from a different class (in the same module) without explicitly scoping it with the Module::Class.method? (http://paste.kde.org/pd4abaa30/)
jibi has joined #ruby
atno has quit [Quit: Leaving]
kleinerdrache has quit [Quit: Ex-Chat]
heidi has quit [Quit: Leaving.]
Michael has joined #ruby
kaspergrubbe has quit [Remote host closed the connection]
jbpros has quit [Quit: jbpros]
Michael is now known as Guest61315
<Eiam>
whats wrong with specifying the scope?
visof has joined #ruby
visof has quit [Changing host]
visof has joined #ruby
AdmiraI has joined #ruby
<Eiam>
you could try include Priner
<Eiam>
include Printer
Kricir has quit [Remote host closed the connection]
<fryguy>
apeiros: yah i guess i was wrong, been looking through the ruby source. must have misread something a while ago
<nhmood_>
I plan on using the debug_print call semi-often and that is a lot of extra code to write :-/
<Eiam>
nhmood_: make it a method in the module?
cj3kim_ has joined #ruby
AdmiraI has quit [Client Quit]
<Eiam>
Project.dp = project.debug print =p
crus` has joined #ruby
crus has quit [Ping timeout: 260 seconds]
<nhmood_>
Eiam, do you mean use module_method?
freezey has joined #ruby
<nhmood_>
Also, what is the .dp method you were referring to?
<nhmood_>
I tried doing the include method but I get the following error: 'uninitialized constant Project::Help::Printer (NameError) '
<Eiam>
nhmood_: define the method name as "dp" so its shorter to type!
mlpinit has joined #ruby
mlpinit has quit [Remote host closed the connection]
mlpinit has joined #ruby
<nhmood_>
Eiam: Ohh I see haha, that is valid but it breaks the rule of having descriptive method/var names!
dzhulk has quit [Quit: Leaving.]
yfeldblum has quit [Ping timeout: 248 seconds]
<Eiam>
its for debugging =)
<nhmood_>
Good point :P
ciziar has joined #ruby
gcds has quit [Quit: gcds]
<nhmood_>
However, for future reference, should the include way work?
rupee has quit [Quit: Leaving]
<nhmood_>
Or do I need to inherit the other class into the current class in order to use the same namespace/scope
<AntelopeSalad>
is there a non-messy way to convert 0 to nil?
crus` has quit [Ping timeout: 264 seconds]
crus has joined #ruby
<workmad3>
AntelopeSalad: what do you class as 'messy'?
sailias has quit [Quit: Leaving.]
<AntelopeSalad>
workmad3: checking the variable if it's 0, then setting a new variable to nil, then working with the new variable
<sweeper>
foo == 0 ? nil : foo
Dreamer3 has quit [Quit: Computer has gone to sleep.]
<workmad3>
AntelopeSalad: 'foo = nil if foo.zero?'
gcds has joined #ruby
<AntelopeSalad>
do you know offhand if rail's params are mutable?
<workmad3>
AntelopeSalad: that said, I would tend to prefer to leave such a variable as 0
<sweeper>
workmad3: bar = foo.zero? ? nil : foo
<AntelopeSalad>
workmad3: i noticed an inconsistency in how rails treats an empty select box
<AntelopeSalad>
sometimes it reports back 0 and other times it reports nil
<AntelopeSalad>
and i'm adding the result as a FK to a db, so i'd rather they all be the same (nil)
gcds has quit [Client Quit]
<sweeper>
err to wrong person
<workmad3>
AntelopeSalad: 'select box'? I take it you mean a check box?
<sweeper>
AntelopeSalad: try to_b
<AntelopeSalad>
no, a select drop down box
<sweeper>
oh that
VTLob has quit [Quit: VTLob]
<sweeper>
that is freaking bizzare
nhmood_ has quit [Quit: Page closed]
<AntelopeSalad>
if i make a new resource or edit a resource an empty drop down box value is nil
S0da has quit [Read error: Connection reset by peer]
nhmood has joined #ruby
<sweeper>
sure you're not setting 0 as the empty value?
AdmiraI has joined #ruby
<AntelopeSalad>
if i do a bulk update with update_all then it sets it as 0
<AntelopeSalad>
100% sure
<sweeper>
no default?
bean__ has quit [Quit: Computer has gone to sleep.]
aryaching_ has quit [Ping timeout: 264 seconds]
<AntelopeSalad>
i didn't set a default
<AntelopeSalad>
what's interesting though is a FK is an integer but the value is nil when i create a new resource with no FK
<AntelopeSalad>
i'm not a db wizard though so i'm not sure if that is standard, it might be
nomenkun has joined #ruby
smigg has quit [Remote host closed the connection]
Hanmac has quit [Quit: Leaving.]
<workmad3>
AntelopeSalad: if it's plain activerecord, they're just integer fields without constraints anyway (unless you added a non-null constraint to them, which it sounds like you wouldn't want anyway)
Soda has joined #ruby
<AntelopeSalad>
workmad3: yep, correct on both accounts
SkuliOskarsson has joined #ruby
<AntelopeSalad>
i want to allow a nil FK in this case, i just found it odd that update_all will zero out empty values rather than just use nil
mlpinit_ has joined #ruby
cj3kim_ has quit [Remote host closed the connection]
bean__ has joined #ruby
bean__ has quit [Client Quit]
funburn has quit [Quit: funburn]
interactionjaxsn has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: odd... sounds like something else is going on there
<AntelopeSalad>
workmad3: do you think that's something i should open a bug for? it seems like unexpected behavior to me
<AntelopeSalad>
*bug ticket
coderhs has quit [Ping timeout: 256 seconds]
<workmad3>
AntelopeSalad: would need to see the code first
interactionjaxsn has joined #ruby
iamjarvo_ has joined #ruby
iamjarvo_ has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: most likely, something else is affecting it and causing that behaviour
BillCriswell has quit [Remote host closed the connection]
<AntelopeSalad>
that is with the new fixed implementation although i didn't test it yet
<AntelopeSalad>
i actually see a bug but ignore it :D
<workmad3>
AntelopeSalad: would want to see the original, along with the model code and schema.rb
robbyoconnor has quit [Excess Flood]
<AntelopeSalad>
ok give me a sec, let me make sure the fixed ver works
robbyoconnor has joined #ruby
<AntelopeSalad>
and i'll gist everything that's relevant
mlpinit_ has quit [Ping timeout: 245 seconds]
swistak36 is now known as swistak35
brennanMKE has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: if you can also gist the log output of the SQL that's executed with the bug in place, that would be great :)
iamjarvo has quit [Ping timeout: 245 seconds]
<AntelopeSalad>
hmm i'm actually getting an undefined method zero?
gcds has joined #ruby
<sweeper>
are you getting "0" or 0 ?
<AntelopeSalad>
0
<AntelopeSalad>
and the value is coming from params[:category][:id]
<workmad3>
AntelopeSalad: sounds like you're really getting "0"
joesavage has quit [Quit: joesavage]
<AntelopeSalad>
workmad3: yeah i think you're right, since it's coming from an http request it has to be a string?
<AntelopeSalad>
it just happens to store 0
Kricir has joined #ruby
angusiguess has quit [Ping timeout: 245 seconds]
interactionjaxsn has quit [Ping timeout: 268 seconds]
boxmein has quit [Quit: [02:26.00] <Ristovski> mozzarella filofax fadget]
awarner has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: right, the rails code knows to map the string params onto integers
|jemc|_ has joined #ruby
dkamioka has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: when appropriate (such as assigning them to an integer field)
platzhirsch1 has joined #ruby
breakingthings has quit []
<platzhirsch1>
Darn, how do you think should I split words in a sentence? With /\w+/ alphanumeric characters or /\s+/ whitespace?
<AntelopeSalad>
i'm getting hung up on all sorts of method not founds atm or i would have gisted it sooner
i_s has quit [Remote host closed the connection]
<AntelopeSalad>
even .defined? isn't there
<platzhirsch1>
Because "8.3".split /\w+/ gives me [8.3]
lsoa has quit [Ping timeout: 245 seconds]
petey has joined #ruby
<AntelopeSalad>
nm i got it working now, i just had to check if it's == to nil -- incoming gist in ~2min
iamjarvo_ has quit [Read error: Connection reset by peer]
zarubin has joined #ruby
it_tard has joined #ruby
iamjarvo has joined #ruby
JohnBat26 has quit [Ping timeout: 240 seconds]
|jemc|_ is now known as |jemc|
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<AntelopeSalad>
workmad3: what aspect of the model do you need to see? it's very uncomplicated right now
<AntelopeSalad>
it's just a couple of scopes/validations and one instance method
colonolGron has joined #ruby
kirun has quit [Quit: Client exiting]
<sn0wb1rd>
How do I mock a class method in rspec?
bluenemo has quit [Ping timeout: 248 seconds]
<sn0wb1rd>
This is what I want to mock:
<sn0wb1rd>
class Chef
<sn0wb1rd>
class Log
<sn0wb1rd>
def self.warn(str); end
<sn0wb1rd>
end
<workmad3>
AntelopeSalad: just gist the entire thing, the log output from hitting it, the controller code, the schema.rb and maybe the view that's generating the select box
OdNairy has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Ox6abe has joined #ruby
<sn0wb1rd>
workmad3: sure
<AntelopeSalad>
workmad3: ok, this is also my first real project with ruby/rails so feel free to rip into the code and call me a retard, i'd love constructive critism
ldnunes has quit [Quit: Leaving]
relix has joined #ruby
Nenor has quit [Remote host closed the connection]
araujo has quit [Read error: Connection reset by peer]
<workmad3>
AntelopeSalad: that's pretty well known... update_all is closer to 'raw' sql
Liothen has joined #ruby
jonathanwallace has quit [Ping timeout: 245 seconds]
<AntelopeSalad>
ok, so it's unexpected behavior until you read the docs? heh
bluenemo has joined #ruby
phantasm66 has quit [Quit: *sleeeep….]
cj3kim_ has quit [Remote host closed the connection]
<AntelopeSalad>
update_all didn't run any validations too, so it being closer to raw sql does make sense
<workmad3>
AntelopeSalad: I doubt this specific behaviour is documented ;) but yeah, I wouldn't exactly expect update_all to do quite the right thing when I pass it '' for an integer valued field
<workmad3>
the most I'd expect is for .to_i to be called on it (and ''.to_i == 0)
<BraddPitt>
well i realized that will only call the method at the time of creation of the hash
<AntelopeSalad>
workmad3: are you a rails committer?
Kricir has joined #ruby
<BraddPitt>
so i still have the same problem, but im reading up on Symbols now, but i still don't quite get it
<workmad3>
AntelopeSalad: nope... just a long-time user
scottstamp has joined #ruby
<workmad3>
AntelopeSalad: well... I do have 4 commits into the rails codebase... from back in the 3.0 beta days, a minor fix to the new command migrator
<AntelopeSalad>
ah, thanks for confirming it tho
<apeiros>
BraddPitt: unrelated to your problem but: Test.stuff uses puts, and you do puts Test.stuff. that makes little sense. let the method just return the string.
<apeiros>
BraddPitt: you could do either of these:
ghost2060 has quit [Quit: leaving]
<apeiros>
a) hashy = {:a => proc { Test.stuff("just a test") } }; puts hash[:a].call
<AntelopeSalad>
workmad3: i guess i won't open a ticket if it's semi-expected behavior by someone who is used to rails
<apeiros>
b) hashy = {:a => Test.method(:stuff)}; puts hash[:a].call("just a test")
<AntelopeSalad>
i've read a couple of dhh's posts though and the work around for it seems like it would be something that would make him flip out tho
<BraddPitt>
but won't that call Test.method when the hash is create/initialized?
<apeiros>
c) hashy = {:a => :stuff}; puts Test.send(hashy[:a], "just a test")
<apeiros>
BraddPitt: yes. and Test.method returns a Method instance.
<BraddPitt>
;/
osvico has joined #ruby
<apeiros>
which you can later call. Method knows two things: the receiver and the name of the method to call. it does not have/know arguments.
<workmad3>
AntelopeSalad: I wouldn't base too many decisions on whether they'd make DHH flip out or not :P
<BraddPitt>
The problem is that I need to create this hash of callable methods WITHOUT having them called when I create the hash
<AntelopeSalad>
is my "fix" as clean as it could be?
<BraddPitt>
is such a thing possibel?
<BraddPitt>
possible*
<apeiros>
BraddPitt: it does NOT call the method "stuff"
<apeiros>
BraddPitt: also, take another look at example a)
Stalkr^ has quit [Changing host]
Stalkr^ has joined #ruby
Naoe-Kanno has quit [Quit: ネウロイを負かさなきゃならないね]
quoin has joined #ruby
<apeiros>
Foo.method(:bar) # <-- this does NOT call :bar on Foo
SHyx0rmZ has joined #ruby
<apeiros>
Foo.method(:bar).call # <-- this does. the `.call` part.
<BraddPitt>
ah ok
<shevy>
BraddPitt .method() gives you the associated method
<apeiros>
:bar # this does NOT call :bar on anything
<apeiros>
Foo.send(:bar) # this does. the `.send` part.
<apeiros>
proc { Foo.bar } # <-- this does NOT call .bar on Foo
<apeiros>
proc { Foo.bar }.call # <-- this does. the `.call` part
dhruvasagar has quit [Ping timeout: 240 seconds]
<apeiros>
hth
<workmad3>
AntelopeSalad: checking the params, does the id ever actually come in as 0? or does it only come in as '', which ends up as 0 in the db due to some SQL mischief?
<workmad3>
AntelopeSalad: because if it's the latter, you can just do 'category_id = params[:category][:id].presence'
<BraddPitt>
thank you apeiros, I appreciate it
<AntelopeSalad>
it could in theory come in as 0 if someone edited the select drop down box in chrome before submitting
<AntelopeSalad>
and ideally i would want that blocked
<workmad3>
AntelopeSalad: right, but you could also in-theory have an ID of 0 for a category
quoin has quit [Ping timeout: 245 seconds]
<workmad3>
AntelopeSalad: that one would be solved by your code to just check if the category exists
<AntelopeSalad>
i thought mysql/postgres start with 1?
k610 has joined #ruby
RichardBaker has quit [Quit: RichardBaker]
Monie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<AntelopeSalad>
wait you're getting me worked up for no reason now i think haha
<AntelopeSalad>
Category.exists?(category_id) is doing that check
<workmad3>
AntelopeSalad: right
<AntelopeSalad>
that is what i added in to make sure no one did any funny business with the form before submitting
kaldrenon has quit [Remote host closed the connection]
jibi has joined #ruby
SkuliOskarsson has joined #ruby
<workmad3>
AntelopeSalad: so yeah, I'd probably do 'category_id = params[:category][:id].presence; if category_id.nil? || Category.exists(category_id)'
kaldrenon has joined #ruby
Speed has joined #ruby
<AntelopeSalad>
so that will allow 0 if it exists but my version does not?
<workmad3>
AntelopeSalad: pretty much
<workmad3>
AntelopeSalad: it'll also not bother checking if a category exists with a null id ;)
soheil has quit [Read error: Connection timed out]
dodosan has quit [Remote host closed the connection]
brennanMKE has joined #ruby
<AntelopeSalad>
workmad3: you're right, i just dropped in a 0
<workmad3>
AntelopeSalad: and a .presence call looks a lot nicer in your controller than a ternary :)
<AntelopeSalad>
and it passed right through
bluenemo has quit [Quit: Verlassend]
soheil has joined #ruby
<AntelopeSalad>
a category can't exist with a null id but it's good to know that
<AntelopeSalad>
your implementation is so much nicer
<workmad3>
AntelopeSalad: yeah, I know that too :) which is why it doesn't make sense to hit the database for the .exists? check before checking if category_id is nil ;)
<AntelopeSalad>
it reads 100x better and is less complicated
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<AntelopeSalad>
and is not buggy haha
duggiefresh has joined #ruby
<BraddPitt>
ah works perfectly apeiros, thank you again!
<BraddPitt>
I see the beauty of procs now ;)
<AntelopeSalad>
workmad3: wait tho, it actually failed
<workmad3>
AntelopeSalad: don't exagerate... it's not that much cleaner, it's just a small bit of re-ordering
<workmad3>
AntelopeSalad: what failed?
<shevy>
it is the cleanest code that was ever written
<AntelopeSalad>
nm, i copied it as is
<AntelopeSalad>
you forgot the ? after exists
<shevy>
AntelopeSalad just discovered that
<workmad3>
AntelopeSalad: hehe :)
<shevy>
damn, workmad3 you noob!!!
amsi has joined #ruby
brennanMKE has quit [Remote host closed the connection]
<workmad3>
AntelopeSalad: I like to leave typos in as exercises to the copy-paster :P
kaldrenon has quit [Ping timeout: 245 seconds]
<shevy>
you forced AntelopeSalad to think ...
brennanMKE has joined #ruby
<workmad3>
(also, I'm typing code directly into IRC at almost 11pm... but lets go with the first explanation)
<shevy>
luckily for him he succeeded
<shevy>
else he might have to go and use php now
kpshek has quit []
<AntelopeSalad>
yeah, shame on you for making me use my brain
ryandeussing has quit [Read error: Connection reset by peer]
ryandeussing has joined #ruby
<workmad3>
shevy: ssh, don't mention PHP... this wouldn't be a problem there! because "0" == false
<shevy>
haha
Jetchisel has joined #ruby
<AntelopeSalad>
btw i'm fairly new to tdd/testing too, is it reasonable to have tests setup to check empty/0/valid categories?
<AntelopeSalad>
it's really annoying to manually do it every time i change the code
<workmad3>
AntelopeSalad: if it's annoying you doing it manually, automate it
<workmad3>
AntelopeSalad: that's really the golden rule of almost anything to do with development :)
kaspergrubbe has joined #ruby
v0n has quit [Ping timeout: 252 seconds]
mityaz has quit [Quit: See ya!]
<AntelopeSalad>
i just did the empty/0/valid test manually and your version passed (it blocked 0)
failshell has quit [Ping timeout: 245 seconds]
<shevy>
I need chinese hackers to code for me
<AntelopeSalad>
i figured i would do this project, and then write all the tests later
<AntelopeSalad>
seemed like too much to take in ruby/rails/tdd at once
RichardBaker has joined #ruby
<workmad3>
AntelopeSalad: I'd probably have started with ruby + tdd
<workmad3>
AntelopeSalad: test-last too quickly becomes test-never
<colonolGron>
i know this is a dumb question. i am doing some googling already, but want to ask here still: should i learn rails or sinatra?
<workmad3>
AntelopeSalad: especially if you're not used to the style of testable code... my past experience of pre-tdd code was that I'd end up writing stuff that I now see would be almost impossible to write automatic tests :)
<AntelopeSalad>
workmad3: this project i'm working on is mainly for myself, i went down the path of winging it already for a long time in other languages
theRoUS has quit [Ping timeout: 260 seconds]
<AntelopeSalad>
with no deadlines i think i can control myself to stop adding features and just start writing tests, because it's something i want to do
it_tard has quit [Quit: yawn]
kpshek has joined #ruby
<AntelopeSalad>
but as for testing philosophies, i've always been in the camp that you should only test things that are meaningful to your app, it's a waste to go crazy and start testing framework code (imo)
peregrine81 has quit []
<workmad3>
AntelopeSalad: sure :) but that doesn't prevent you from ending up with untestable code
joofsh_ has quit [Remote host closed the connection]
petey has quit [Remote host closed the connection]
<AntelopeSalad>
workmad3: i think this controller method might be untestable
<AntelopeSalad>
unless i did full integration test i guess?
<AntelopeSalad>
*a
<AntelopeSalad>
since it depends on params[] that automatically makes it annoying to test
justsee has joined #ruby
it_tard has joined #ruby
it_tard has quit [Changing host]
it_tard has joined #ruby
snovak has quit [Remote host closed the connection]
Bira has quit [Remote host closed the connection]
alex__c2022 has quit [Quit: alex__c2022]
jerius has quit [Ping timeout: 240 seconds]
snovak has joined #ruby
snovak has quit [Remote host closed the connection]
petey has joined #ruby
nisstyre has joined #ruby
<scottstamp>
I've been curious, I notice a lot of projects "require" all their gems and dependencies from one file and all the files that file refers to automagically have those dependencies loaded. How is that done? My attempts to do it have been futile at best.
mklappst_ has quit [Remote host closed the connection]
iamjarvo has quit [Remote host closed the connection]
havenwood has quit [Ping timeout: 256 seconds]
kaspergrubbe has quit [Remote host closed the connection]
baordog_ has quit [Remote host closed the connection]
iamjarvo has joined #ruby
evenix has joined #ruby
jerrad has joined #ruby
elux has quit [Quit: Bye!]
Nenor has quit [Quit: Nenor]
dsferreira has quit [Quit: This computer has gone to sleep]
buibex has joined #ruby
Falcore has joined #ruby
<scottstamp>
atmosx, not quite, I know how to use a Gemfile to include my dependencies, I mean how do I go about not having to require whatever lib / gem my class file depends on in each class file.
<zeade>
scottstamp: (obviously) the required gems need to be installed, if you're using bundler then you may need to also run your app with bundle exec (for example if you have any git-based gems), if you're requiring files (not gems) via their path they should be discoverable at runtime. these are just guesses, tho
<zeade>
even if you create a "master manifest" file, that has to be required somewhere
freezey has joined #ruby
<scottstamp>
I think a Master Manifest file I what I'm looking for. Do you know any tutorials?
<scottstamp>
I'm kind of new to Ruby.
<zeade>
e.g. require 'lib/all_the_things'
cj3kim_ has joined #ruby
vim_shim has quit [Ping timeout: 245 seconds]
iamjarvo has quit [Ping timeout: 248 seconds]
cj3kim_ has quit [Remote host closed the connection]
<bnagy>
that sounds like it would make things pretty annoying to test
<scottstamp>
will lib/* classes automatically have access to dependencies outlined in their caller? (The file containing require 'lib/all_the_things')
evenix has quit [Ping timeout: 252 seconds]
<bnagy>
yes
<scottstamp>
okay, cool. That's what I was looking for.
<bnagy>
but then those individual lib files are broken, as individuals
colonolGron has quit [Quit: Lost terminal]
rhys has quit [Quit: Leaving]
<bnagy>
which sounds dumb
sniffingcats has joined #ruby
xk_id has joined #ruby
<bnagy>
I'm all in favour of a require 'easyprojectname' style loader file that loads up assorted of your own libfiles
<bnagy>
but dubious about loading all dependencies in that file
<scottstamp>
I'm only really loading a few dependencies, it's just a caching library.
<banisterfiend>
bnagy sup nagg-dogg
adkron has quit [Ping timeout: 252 seconds]
<bnagy>
nm, went out for drinks last night, and to watch the sumo at the bar
apeiros has joined #ruby
<bnagy>
oh, my last day of official employment today, that's pretty frickin sweeeet
bobinator60_ has quit [Quit: bobinator60_]
<scottstamp>
I hear that. I ragequit my job not too long ago after my boss kept fucking me over.
simoz has quit [Ping timeout: 256 seconds]
zz_taion809 is now known as taion809
mrsolo has joined #ruby
endash has joined #ruby
Ox6abe has quit [Remote host closed the connection]
xk_id has quit [Quit:
wallerdev has quit [Quit: wallerdev]
KobraKao has joined #ruby
ldnunes has joined #ruby
Mon_Ouie has quit [Ping timeout: 240 seconds]
leonidlm has quit [Ping timeout: 248 seconds]
blischalk has quit [Ping timeout: 248 seconds]
emergion has joined #ruby
Nogbit has quit [Ping timeout: 260 seconds]
weems has joined #ruby
harmaz has quit [Quit: Page closed]
mansi has quit [Remote host closed the connection]
kvirani has quit [Remote host closed the connection]
mansi has joined #ruby
anonymus_ has joined #ruby
kvirani has joined #ruby
mansi has quit [Read error: Connection reset by peer]
sniffingcats has quit [Quit: Til rivido Idisti!]
mansi has joined #ruby
fuhgeddaboudit has joined #ruby
Guest61315 has quit [Remote host closed the connection]
anonymu__ has joined #ruby
AdmiraI has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
axl_ has quit [Quit: axl_]
anonymuse has quit [Ping timeout: 268 seconds]
petey has quit [Remote host closed the connection]
snovak has joined #ruby
jlast has quit [Remote host closed the connection]
visof has quit [Quit: Leaving]
kvirani has quit [Ping timeout: 248 seconds]
it_tard has quit [Quit: yawn]
brennanMKE has quit [Remote host closed the connection]
johnnyfuchs has quit [Remote host closed the connection]
staafl has quit [Ping timeout: 260 seconds]
anonymus_ has quit [Ping timeout: 245 seconds]
|jemc| has quit [Ping timeout: 240 seconds]
ericmathison has joined #ruby
mansi has quit [Remote host closed the connection]
Stalkr^ has quit [Quit: Leaving...]
sloucher has joined #ruby
anonymu__ has quit [Read error: Operation timed out]
mansi has joined #ruby
heidi has quit [Quit: Leaving.]
tgraham is now known as tgraham|away
Ripp__ has quit []
Ripp__ has joined #ruby
nari has joined #ruby
quoin has joined #ruby
Mon_Ouie has joined #ruby
buibex has quit [Remote host closed the connection]
dzhulk has quit [Quit: Leaving.]
rupee has joined #ruby
snovak has quit [Ping timeout: 245 seconds]
tgraham|away is now known as tgraham
platzhirsch1 has left #ruby [#ruby]
lolmaus has quit [Read error: Connection reset by peer]
mansi has quit [Ping timeout: 245 seconds]
mxweas has joined #ruby
AdmiraI has joined #ruby
AdmiraI has quit [Client Quit]
quoin has quit [Ping timeout: 246 seconds]
havenwood has joined #ruby
lolmaus has joined #ruby
justsee has quit [Ping timeout: 252 seconds]
Nogbit has joined #ruby
ColKurtz has joined #ruby
<Eiam>
nhmood: I don't know, try it out? I don't use include/extend much/ever
lolmaus has quit [Read error: Connection reset by peer]
heidi has joined #ruby
proxie is now known as virtualentity
Kricir has quit [Remote host closed the connection]
GoldenGiant has quit [Quit: Computer has gone to sleep.]
lukec has quit [Ping timeout: 248 seconds]
ScaredWeems has joined #ruby
lolmaus has joined #ruby
Nogbit has quit [Client Quit]
iamjarvo has joined #ruby
lukec has joined #ruby
rupee has quit [Quit: Leaving]
fuhgeddaboudit has quit [Ping timeout: 245 seconds]
cj3kim_ has joined #ruby
weems has quit [Ping timeout: 248 seconds]
platzhirsch1 has joined #ruby
ciziar has quit [Quit: Computer has gone to sleep.]
platzhirsch1 has left #ruby [#ruby]
boboc has joined #ruby
KobraKao has quit [Ping timeout: 256 seconds]
<boboc>
hello
<bnagy>
GREETINGS HUMAN
raphaelivan has joined #ruby
<boboc>
guys i would like to learn the Ruby language, can you recommend a good book?
sloucher has quit [Quit: sloucher]
m8 has quit [Quit: Sto andando via]
<bnagy>
people seem to speak highly of Programming Ruby
<bnagy>
I don't read programming books.
<Eiam>
I used "The Ruby Programming Language"
<Eiam>
and this channel =)
<Eiam>
(this channel is better)
<havenwood>
boboc: Coming from other languages or new to programming?
<boboc>
i'm not new to programming, i have 3+ years experience with ios
Kricir has joined #ruby
<havenwood>
boboc: The Ruby Programming Language is a great book.
<boboc>
havenwood: yes, objective c
v0n has quit [Ping timeout: 240 seconds]
RORgasm_ has quit [Remote host closed the connection]
<havenwood>
boboc: If you didn't already know Obj-C I'd have said Learn to Program by Chris Pine.
Popple has joined #ruby
staafl has joined #ruby
<havenwood>
boboc: The former starts off a bit quicker but is a fantastic book and will take you a long ways.
sepp2k1 has joined #ruby
<gcds>
how to call JSON.generate inside module? I getting uninitialized constant Beefeater::Worker::JSON
<boboc>
havenwood: are there any major syntax changes between ruby 1.9 and 2.0?
<boboc>
almost all books i've seen are for 1.9
Zai00 has quit [Quit: Zai00]
Michael has joined #ruby
<atmosx>
gcds: require 'json'?
<havenwood>
boboc: 1.9 is fine, small differences that are easy to catch up on
Michael is now known as Guest23568
<havenwood>
boboc: 2.0 is largely compatible with 1.9
sepp2k has quit [Ping timeout: 240 seconds]
<atmosx>
gcds: actually gist your code and the output you want to get
<havenwood>
boboc: and 2.1 around the corner
RDash[AW] has quit [Quit: Poweroff]
<Eiam>
boboc: 2.0 has named parameters
<Eiam>
fairly minor
<havenwood>
Eiam: i like the option for mandatory named params in 2.1
<Eiam>
did 2.0 have the new hash format or was that 1.9?
tgraham is now known as tgraham|away
<havenwood>
Eiam: 1.9
<boboc>
the hash still has the key=>value syntax?
<havenwood>
boboc: yes
<Eiam>
boboc: you can do { key: value} too
<havenwood>
boboc: indeed
cody-- has joined #ruby
<boboc>
Eiam: great
<atmosx>
I like key: 'value'
<havenwood>
boboc: the latter only for keys that are symbols
<havenwood>
boboc: the former for anything else as a key
<Eiam>
havenwood: I'm a fan of named parameters mostly from obj-c days, I like when things are a bit more explicit in what they expect
Nogbit has joined #ruby
<boboc>
a symbol is an immutable string in ruby?
<havenwood>
boboc: an interned string
<atmosx>
string.to_sym
<havenwood>
boboc: actually an immutable string syntax is a new feature of 2.1: "i'm an immutable string"f
KobraKao has joined #ruby
<atmosx>
good night
<havenwood>
or the alias of string.to_sym: string.intern
Guest23568 has quit [Remote host closed the connection]
benzocoumaran35 has quit [Ping timeout: 248 seconds]
<Eiam>
havenwood: I'm not sure i see the different
awarner has quit [Remote host closed the connection]
Speed has quit [Quit: When two people dream the same dream, it ceases to be an illusion.]
gadgetoid has joined #ruby
ryandeussing has quit [Remote host closed the connection]
c0rn has joined #ruby
boboc has quit [Remote host closed the connection]
cody-- has quit [Quit: derp]
justsee has joined #ruby
boboc has joined #ruby
boboc has quit [Remote host closed the connection]
boboc has joined #ruby
simoz has joined #ruby
kay__ has joined #ruby
cj3kim_ has quit [Remote host closed the connection]
boboc has quit [Remote host closed the connection]
boboc has joined #ruby
<g0th>
hi
mklappstuhl has joined #ruby
kitak has joined #ruby
gcds has quit [Quit: gcds]
<g0th>
in a class initialize() I do stuff, at the end I would like to multiply "myself" by a number
<g0th>
how do I do that?
blarghmatey has joined #ruby
<g0th>
I can calculate the result
heidi has joined #ruby
<g0th>
but somehow I can't do self=result
<havenwood>
g0th: You want??: YourClass.new(5) #=> 25
<g0th>
what?
<havenwood>
g0th: i can't tell what you want
<g0th>
class A
<g0th>
def initialize()
<havenwood>
g0th: can you give an example of calling the method and what'd be returned?
<g0th>
it's the initialize method
mansi has joined #ruby
<g0th>
I want to setup the class
jerrad has quit [Quit: Leaving...]
Davey has quit [Quit: Computer has gone to sleep.]
<g0th>
the *() operator is a binary operator
dallasm has joined #ruby
<g0th>
hmm
<g0th>
oh
<havenwood>
g0th: So presume your class is already setup. You want to do something. What would that look like in terms of what you'd type and what the result would be.
<g0th>
how do I set myclass to itself times 10?
iamjarvo has quit [Remote host closed the connection]
zarubin has quit [Ping timeout: 252 seconds]
Stalkr^ has joined #ruby
<g0th>
(my_class*10)
mklappstuhl has quit [Ping timeout: 248 seconds]
<g0th>
([my_class]*10).inject(:+) to be precise
iamjarvo has joined #ruby
<g0th>
do I have to introduce an extra class for that?
nomenkun has joined #ruby
<g0th>
class A and class ATimes10 ?
huoxito has quit [Ping timeout: 248 seconds]
<havenwood>
g0th: What you're doing presumable has a way to be called. How?? Do you want, for example: 10.your_method(2) #=> 20
joshwines has joined #ruby
<g0th>
called?
<havenwood>
g0th: I don't get what you want. But how you want it to look in its final form might be quite informative.
<g0th>
yes, the class is used/instanciated
<boboc>
g0th: what is that parameter? (:+) ?
<g0th>
havenwood: in general I want to build a certain class
<g0th>
in initialize I have to setup values
kaspergrubbe has joined #ruby
freerobby has quit [Quit: Leaving.]
Stalkr^ has quit [Ping timeout: 245 seconds]
<havenwood>
g0th: sure, you call #new on that class and pass it args
iamjarvo has quit [Ping timeout: 240 seconds]
freerobby has joined #ruby
<g0th>
the values should be as if I did: z=[SomeBaseClass.new()]*10.inject(:+);
siwica1 has joined #ruby
nomenkun has quit [Ping timeout: 264 seconds]
<g0th>
so like copying all properties of the right hand side to self
<bnagy>
ok, so all subclasses of Density have a d method which returns a hash of rationals?
<bnagy>
if so, just build that in your subclass
<havenwood>
g0th: on the first one, ln2 put a space between `is_a?` and `Density`; ln 3 drop the `return` for an idiomatic implicit return; ln 5 drop #to_a as it is already an enumerable
tgraham is now known as tgraham|away
gazarsgo has quit [Quit: gazarsgo]
brennanMKE has joined #ruby
freezey has quit [Remote host closed the connection]
jonr22 has joined #ruby
freezey has joined #ruby
snovak has joined #ruby
<havenwood>
g0th: oh, sry the #to_a should just be an #each or #to_enum not dropped
<havenwood>
g0th: you're starting with a range not an enum, my bad
<g0th>
if I drop the return
<g0th>
will it return?
<havenwood>
yup
adeponte has quit [Remote host closed the connection]
<havenwood>
implicitly the last line of the method will be the return value
<havenwood>
always drop return unless returning early in flow control
<g0th>
it is not the last line
cody-- has joined #ruby
<g0th>
it is the first one
failshell has joined #ruby
<g0th>
so I put a return
<g0th>
to return early
<havenwood>
oops! again... i'm on a negative roll
<g0th>
sigh
<havenwood>
but line 30
quoin has joined #ruby
<g0th>
one after another
<havenwood>
is the thing i was initially looking at
<havenwood>
so still relevant
<g0th>
to.a gives an array
<g0th>
I want an array
Kricir has quit [Read error: Connection reset by peer]
<g0th>
not a hash
<g0th>
if I drop .to_a I get a hash
<bnagy>
also you either don't want Forwardable, or you don't want attr_accessor on :d
adeponte has joined #ruby
<g0th>
I dont want an accessor
<g0th>
but at some point I needed it
adeponte has quit [Remote host closed the connection]
c0rn has quit [Quit: Computer has gone to sleep.]
<g0th>
delete_if
mary5030 has joined #ruby
<bnagy>
imho, though, just have attr_reader on your @d hash, Forwardable is lame
<g0th>
that doesn't work
brennanMKE has quit [Ping timeout: 260 seconds]
<g0th>
I thought about that
<g0th>
anyway
<g0th>
that was not my question
<g0th>
but thanks
<bnagy>
it gives the impression that you're creating a restricted API, which you just can't do with ruby tbh
sepp2k1 has quit [Read error: Connection reset by peer]
mrsolo has quit [Quit: This computer has gone to sleep]
benzocoumaran35 has quit [Ping timeout: 246 seconds]
<g0th>
can I do self*=?
<havenwood>
no
<bnagy>
you can't assign to self
snovak has quit [Ping timeout: 256 seconds]
<g0th>
so how do I do what I want?
<g0th>
I want to initialize something
<bnagy>
it sounds like you just want to set up your @d thing
<g0th>
yes
<bnagy>
so do that
<g0th>
how?
<bnagy>
@d = something
<havenwood>
it is an instance variable
<havenwood>
set it
<g0th>
then I have to essentially copy all methods of Density
<g0th>
in particular the *() method
<havenwood>
no empty parens
petey has joined #ruby
<g0th>
here it is emphasise
quoin has quit [Ping timeout: 246 seconds]
<g0th>
I want to put something in ()
<g0th>
but saying *(v) method looks stupid
<g0th>
because that is not a method that is the returned value
emergion has quit [Quit: Computer has gone to sleep.]
<g0th>
ok I should say :* method
<g0th>
anyway
<g0th>
so I just can't do it?
<havenwood>
g0th: yeah, that totally makes sense - because its an instance method the norm is #*
Vivekananda has quit [Remote host closed the connection]
ehc has quit [Quit: ehc]
<havenwood>
:* makes sense**
failshell has quit [Remote host closed the connection]
benzocoumaran35 has joined #ruby
c0rn has joined #ruby
<bnagy>
you can't assign to self
pwh has joined #ruby
aryaching has joined #ruby
<ccooke>
g0th: the key thing here is that, in ruby, there's no value for self. Everything is a method call, everywhere.
<havenwood>
g0th: you can set the #inspect
<g0th>
hey ccooke
freerobby has quit [Ping timeout: 248 seconds]
<ccooke>
g0th: what you want to do is make sure that the method calls you use will function *as if* you multiplied the putative value by X
benzocoumaran35 has quit [Client Quit]
<g0th>
I would have liked to have a density subclass that returns a certain density
<ccooke>
g0th: assigning a value to an object instance is, I think, a holdover from languages with incomplete object models - in essence, the class is a framework around a "real" value. Ruby isn't like that.
<g0th>
one which is constructed using *
AdmiraI has joined #ruby
seejohnrun has joined #ruby
<ccooke>
g0th: so the question you need to answer is, how would it return a certain density?
<g0th>
I could just copy the whole Density *() body
Michael has joined #ruby
<g0th>
that might work
<ccooke>
g0th: what would you do to get the density?
<g0th>
density=SubDensity.new()
Michael is now known as Guest10465
<havenwood>
g0th: yeah, you can set the #inspect that may return when viewing the object - but if you want a return value set an instance variable and a corresponding method to be called
<ccooke>
because objects simply don't have any implicit value.
<ccooke>
g0th: when you print an object, what actually happens is that the object's to_s method is called and that value is used.
Spami has joined #ruby
<g0th>
I don't care about printing
<g0th>
havenwood: brought this up
<g0th>
-:
<g0th>
anyway
<g0th>
I want a method that gives me a certain density
<ccooke>
g0th: no, you care about the math. What you need to do is make sure that the mathematical operators work in the way you want
<g0th>
I thought about making a class for that
<havenwood>
g0th: can only access values from within the object by creating a method to expose it, create that method
<g0th>
but it seems I can't
<havenwood>
g0th: expose the ivar with the method, done
<g0th>
I'm just trying to find a solution
tvw has joined #ruby
<g0th>
so the solution is to make the class a constructor class?
<ccooke>
g0th: you seem to have a misconception about how things work
<g0th>
i.e. keep it basic but add some method that constructs what I want?
<ccooke>
no, every class should implement the functionality it requires.
unlikable43 has joined #ruby
<g0th>
so I initialize it with super(0)
<g0th>
then I do several modifications to the values
<g0th>
and then I would like to modify the values as if I applied the *(10).inject(:+) operator
<g0th>
I "could" theoretically write down exactly what I want
<g0th>
without ever using "self"
<g0th>
but that would in essence just copy a whole chunk from Density
<g0th>
my question is: what is the correct/elegant way to approach this?
Stalkr^ has joined #ruby
<bnagy>
if you had an array of 10 Density objects and did inject(:+) what would that return?
<pontiki>
write it in C
<bnagy>
a Density?
<g0th>
a Density object
<bnagy>
ok, and is the "guts" of a Density that @d thing?
<g0th>
yes
<g0th>
well
<g0th>
the methods
<bnagy>
ok so @d = [blah].inject(:+).d
<g0th>
nope
<g0th>
that doesn't work
<g0th>
oh
<bnagy>
elaborate
felixjet_ has quit [Quit: felixjet_]
<g0th>
maybe it does
<g0th>
*g*
endash has joined #ruby
felixjet has joined #ruby
* g0th
hides in a corner
<g0th>
that works
visof has joined #ruby
gwb3 has joined #ruby
<g0th>
I overlooked the .d
<g0th>
sigh, all solved
<bnagy>
it's ok, you're just thinking in another language, I think, so rubyish stuff is going to clash
Vivekananda has joined #ruby
SkuliOskarsson has quit [Quit: Leaving.]
<g0th>
well I knew it didn't make sense
<g0th>
(what I wrote)
<g0th>
that's why I came to the channel to ask for a solution
tvw has quit [Ping timeout: 264 seconds]
<g0th>
anyway, thanks a lot
<bnagy>
np
byprdct has joined #ruby
byprdct has quit [Max SendQ exceeded]
tatsuya_o has quit [Remote host closed the connection]
Stalkr^ has quit [Ping timeout: 256 seconds]
cody-- has quit [Quit: derp]
T_T has quit [Ping timeout: 252 seconds]
jibi has quit [Quit: .]
raphaelivan has quit [Ping timeout: 268 seconds]
i_s has joined #ruby
hogeo has quit [Remote host closed the connection]