<drbrain>
RickHull: rdoc isn't smart enough to figure out externs across C files ☹
<RickHull>
now that i've got the latest pg gem installed (presumably), I need to tell rubygems to use it and not the old system one, right?
<drbrain>
RickHull: what does `gem list pg` say?
<RickHull>
shows both :)
<drbrain>
if it lists your new version, you need not do anything
<RickHull>
it went better than I expected
<RickHull>
hmm...
<RickHull>
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- pg (LoadError)
<drbrain>
it should show both, RubyGems will automatically pick the highest version unless a dependency forces it lower
jmontross has quit [#ruby-lang]
<drbrain>
that is interesting!
<drbrain>
you did `gem install --user-install pg`?
<drbrain>
… yes
<drbrain>
I have found the problem
<RickHull>
the last two args reversed, y
<drbrain>
`gem` is for ruby 1.8
<RickHull>
ah
<drbrain>
`ruby` is ruby 1.9
<RickHull>
i use ruby19 for 1.9
<RickHull>
ruby goes to 1.8
<drbrain>
"You don't have /users/home/RickHull/.gem/ruby/1.8/bin"
<drbrain>
so, you probably need to gem19 install pg --user-install
<RickHull>
indeed :)
<RickHull>
so, that warning
<RickHull>
about gem executables
<RickHull>
do i care?
<RickHull>
also, no warnings on ri and rdoc
<drbrain>
if you did `gem19 install rake --user-install`, you would
dr0id has joined #ruby-lang
<drbrain>
RickHull: ah, then you must have been using super old rdoc 1.0.1
<drbrain>
which is the default that ships with ruby 1.8
<RickHull>
i'd just as soon have as much up to date as is feasible
<RickHull>
so i would want the rake gem
<drbrain>
you just have to add it to your $PATH
<RickHull>
to replace the system rake?
<drbrain>
it was just an example, for when a new rake comes out, or other gem that has executables
<RickHull>
oh, duh, i get it
<RickHull>
so, what do you think of: alias gem='gem19 --user-install' ?
<drbrain>
I have a better idea
igotnolegs has joined #ruby-lang
<drbrain>
add "gem: --user-install" to ~/.gemrc
ramonmaruko has joined #ruby-lang
<RickHull>
it works! i still may alias gem and ruby
<RickHull>
i have to use zile instead of emacs :/
RORgasm has joined #ruby-lang
JohnBat26 has joined #ruby-lang
Karmaon has joined #ruby-lang
Sailias has joined #ruby-lang
<RickHull>
thanks drbrain!
<RickHull>
ged: around? I'm curious about the prepared statements
<RickHull>
is it necessary to name them via string in the first parameter? why not assign the statment to variable and pass that to exec?
<RickHull>
or call exec on it or w/e
Karmaon has joined #ruby-lang
<RickHull>
maybe i'm reading it incorrectly, but it sounds like you create the prepared statement and name it with a string. that string is like the name of a pseudovariable behind the scenes
<RickHull>
and then you reference that name with exec_prepared ?
<RickHull>
why not just make it a ruby variable?
mikeric has joined #ruby-lang
* RickHull
whips up a paste
<RickHull>
ok, i see
<RickHull>
it's in the PGResult
<RickHull>
still strikes me as funky but maybe i just need to get comfortable
<zenspider>
ZOMG BRILLIANT IDEAS ARE COMING OUT OF SEATTLE.RB NERD PARTY!!!
<erikh>
I'm still not convinced someone hasn't done something to your file descriptor
<erikh>
anyhow, work time, later.
<zenspider>
Doobie: what are you trying to do?
<Doobie>
zenspider: end child processes if the parent dies. eg: kill -9
<zenspider>
Doobie: why?
<Doobie>
zenspider: so that there are no zombie processes?
<zenspider>
what's your current process architecture? what are they doing? why?
<Doobie>
zenspider: spawning worker processes that are used via DRB
<Doobie>
they use other cores
<zenspider>
and a heartbeat is out of the question?
<Doobie>
it is not ideal. but it doesnt seem like there is any other option
<Doobie>
i was almost sure stdin would work
sora_h has joined #ruby-lang
<zenspider>
why isn't it ideal?
workmad3 has joined #ruby-lang
<Doobie>
well, not all child processes use DRB
<zenspider>
aaaaaand the teeth pulling begins
<Doobie>
it seems unnecessary to implement DRB for a job that std streams should technically be able to do
<Doobie>
but it looks like i have no choice
<Doobie>
std steams are useless
<Doobie>
i just wish i understood why this does not work
francisfish has joined #ruby-lang
<shevy>
today I shall code something cool
rolfb has joined #ruby-lang
futurechimp has joined #ruby-lang
<injekt>
shevy: lies
<shevy>
hehe
<Defusal>
Doobie: i am using a text file to store child pids so that they can be killed on next start, i have tested countless methods of doing this in the past and was not able to get any solution using pipes to work :(
<Doobie>
Defusal: yes, this is one of the only things ive ever noticed that ruby is missing
apeiros_ has joined #ruby-lang
ruskie has joined #ruby-lang
heftig has joined #ruby-lang
fayimora has joined #ruby-lang
tekin has joined #ruby-lang
necromancer has joined #ruby-lang
ioga_wrk has joined #ruby-lang
havenn has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
<andrewvos>
Defusal: Just kill them at_exit
<Defusal>
andrewvos, there is no at_exit if you kill -9 a process
<Defusal>
it just dies immediately
<shevy>
cool
<andrewvos>
CSB
<injekt>
andrewvos: grats on mobile launch :)
<erikh>
oh you're at the BBC?
<andrewvos>
injekt: Thanks :)
<andrewvos>
erikh: Yeah
<erikh>
neato
<erikh>
you work on the perl team?
<erikh>
I know they had a lot of perl hackers there at one point
<andrewvos>
erikh: Nope.
<injekt>
I doubt that
<injekt>
:D
<andrewvos>
erikh: although I think I can see the perl team from here. Just a guess though
<andrewvos>
(they have beards)
<erikh>
lord.
<injekt>
that's them
<andrewvos>
hah
<injekt>
although I never had a beard when I wrote perl
<injekt>
then again I was 14
<andrewvos>
hehe
<injekt>
I still <3 perl
<erikh>
hah
<injekt>
except I wont touch perl 6 :/
<shevy>
hahaha
<injekt>
erikh: when you find a minute, any chance you could visit the launched startup and pick the shit out of it from a UI/UX standpoint? I'd appreciate your feedback
<erikh>
UI?
<erikh>
man
<erikh>
I made twitter bootstrap look bad
<erikh>
I am the last person you want to ask
<injekt>
you still have an opinion :D
<andrewvos>
hahaha
<injekt>
more UX, most people seem pleased with the UI
<erikh>
yeah but it's all like "I DID THIS ON GEOCITIES YEARS AGO AND IT WORKS FOR ME"
<apeiros_>
again, Kernel#chomp is *not meant to be called with a receiver*, it makes no sense to use it with a receiver
bryanl has joined #ruby-lang
<apeiros_>
essentially, it is: module Kernel; def chomp; $_.chomp; end; end
* andrewvos
looks up Kernel#chomp
<apeiros_>
it doesn't make any use of self -> pseudo-function, not a method.
<apeiros_>
all Kernel methods are that way
<andrewvos>
What is it mean to do?
<andrewvos>
Kernel#chomp
<apeiros_>
as said, return a chomped $_
gianlucadv has joined #ruby-lang
<tobiasvl>
and in case you don't know what $_ is, andrewvos
<tobiasvl>
# The last line read by <tt>Kernel.gets</tt> or
<tobiasvl>
# <tt>Kernel.readline</tt>. Many string-related functions in the
<tobiasvl>
# +Kernel+ module operate on <tt>$_</tt> by default. The variable is
<tobiasvl>
# local to the current scope. Thread local.
<tobiasvl>
alias $LAST_READ_LINE $_
<tobiasvl>
oops, sorry, a bit too many lines there
<tobiasvl>
but anyway
<andrewvos>
tobiasvl: I was just trying to find out more on $_ :)
<apeiros_>
you don't want to use any Kernel instance methods in general (except for puts/printf maybe - but not even gets, as it operates on ARGF, not on $stdin as many think…)
<tobiasvl>
as it operates on the last read line, it doesn't make sense to call it with a receiver
<apeiros_>
oh, and require/load of course.
<apeiros_>
almost all other methods are mostly for short scripts, like ruby -pe '…some script…'
<andrewvos>
Ahhh ok interesting
<apeiros_>
iow, Array#chomp does not exist. period.
<apeiros_>
and bottom line is that ruby tells you that you try to call chomp on an array (directly or indirectly). if @response.body is not an array, then probably you (again, directly or indirectly) don't call chomp on that.
<apeiros_>
but hey, you've got the backtrace. it's *easy* to figure out.
Radium has joined #ruby-lang
<andrewvos>
apeiros_: Apparently it's the diff tool in rspec-expectations that is crashing :(
<dominikh>
apeiros_: I try to avoid business terms ;)
<apeiros_>
if it costs too much to maintain and gives not enough benefit in return - drop it. it's sometimes hard to estimate the cost and/or the benefit.
<apeiros_>
that's not just business. it costs you time and happiness to maintain stuff
<apeiros_>
(happiness mostly if the stuff you maintain is considered to be broken)
<dominikh>
I know, but when you refer to costs, many will not make that apparent connection to time/happiness.
<dominikh>
but of course you're right
<apeiros_>
back to the topic, now that this is established…
<judofyr>
BREAK ALL THE APIs!
<apeiros_>
given that this is free software, the only benefit that matters is *your* benefit. if your users are unhappy with it - they can fork the old code.
<dominikh>
oy, don't make me write the "forking is bad" article I had planned for some time :)
<apeiros_>
iow, if *you* don't have a direct benefit of maintaining the old API, kill it. with fire.
<apeiros_>
forking for personal use is great
<apeiros_>
forking for public use has issues… (mainly fragmentation)
<apeiros_>
also forking and pull-requesting is great
<judofyr>
forking + public use isn't that common though
<judofyr>
even in the GitHub-world we live in
<apeiros_>
it's very common for unmaintained software
<dominikh>
forking and pull-requesting isn't really what the definition of forking means
<dominikh>
that's just github's weird nomen clature..
<apeiros_>
dominikh: I'm more referring to the workflow, not githubs specific implementation. dvcs's enabled that kind of contribution. and IMO it made contribution easier, better, more widespread
<dominikh>
apeiros_: it's still not forking. that's called submitting patches :)
<dominikh>
forking with the intention of getting everything back upstream isn't forking, it's plain contributing
<dominikh>
if your changes get rejected and you continue to maintain them, then you've got yourself a fork.
<apeiros_>
dominikh: it's still a fork, even if temporarily. but anyway, since you just said "forking" and didn't specify it, is why we got here…
<dominikh>
it's not a fork
<apeiros_>
I think we both agree, that this kind of forking is not what you consider as bad forking (since you don't consider it to be forking)
<dominikh>
right
Radium has joined #ruby-lang
<apeiros_>
leaves the former two
<judofyr>
forking privately doesn't harm anything, it just means that little gets back to the community (e.g. GitHub's fork of Rails)
kvirani has joined #ruby-lang
Natch| has joined #ruby-lang
tekin has joined #ruby-lang
mark_locklear has joined #ruby-lang
dr0id has joined #ruby-lang
lele|w has joined #ruby-lang
Sulfur has joined #ruby-lang
rohit_ has joined #ruby-lang
rohit has joined #ruby-lang
Radium has joined #ruby-lang
slyphon has joined #ruby-lang
looopy has joined #ruby-lang
chimkan has joined #ruby-lang
vereteran has joined #ruby-lang
mytrile has joined #ruby-lang
tommyvyo has joined #ruby-lang
jmeeuwen_ has joined #ruby-lang
codewrangler has joined #ruby-lang
KillerFox has joined #ruby-lang
cyril_ has joined #ruby-lang
enebo has joined #ruby-lang
fayimora has joined #ruby-lang
cyri_ has joined #ruby-lang
dv310p3r has joined #ruby-lang
divoxx has joined #ruby-lang
dous has joined #ruby-lang
RORgasm has joined #ruby-lang
fayimora_ has joined #ruby-lang
tekin has joined #ruby-lang
mikeric has joined #ruby-lang
Radium has joined #ruby-lang
jxie has joined #ruby-lang
dv310p3r has joined #ruby-lang
dfr|mac has joined #ruby-lang
udzinari has joined #ruby-lang
JEG2 has joined #ruby-lang
jkprg has joined #ruby-lang
chimkan_ has joined #ruby-lang
Sailias has joined #ruby-lang
Radium has joined #ruby-lang
casaram has joined #ruby-lang
<Defusal>
hmm
outoftime has joined #ruby-lang
uberjar has joined #ruby-lang
<Defusal>
can be tricky balancing reading large amounts of data from a processes stdout without locking up all IO of the app
<Defusal>
and without slowing it down too much
<judofyr>
Defusal: read it in chunks
<uberjar>
hi. if I have a method inside a timer like so: Timeout::timeout(31337) { some_method() } <--- will the timer become skewed if I catch an exception and use retry inside some_method ?
crudson has joined #ruby-lang
<Defusal>
judofyr, i just started doing so, but its still tricky to find the right balance
dhruvasagar has joined #ruby-lang
divoxx has joined #ruby-lang
<Defusal>
does anyone know what the minimum amount of time sleep() works for?
<judofyr>
uberjar: it shouldn't
<uberjar>
judofyr: it seems to in jruby land at least
<uberjar>
judofyr: but thanks for letting me know it shouldn't I'll make a writeup that demonstrates it if I can.. maybe it's a jruby only problem or maybe I'm just doing something wrong
mssola has joined #ruby-lang
mistym has joined #ruby-lang
<Defusal>
ok well reading 250 lines every 0.025 seconds seems ok
<headius>
uberjar: should have no impact in jruby...if it does that's some kind of bug
<Defusal>
will have to make sure that isnt too much IO load later
<Defusal>
but so far so good
<judofyr>
Defusal: what? why are you sleeping? just use blocking I/O?
<uberjar>
ok I'll make a proof of concept code that tries to prove it's a bug then go from there. thanks
<headius>
in JRuby timeout spins up a separate thread that just waits for the time out to expire before raising in the main thread
<Defusal>
judofyr, the point is to give other threads time to IO
<headius>
regardless of what the main thread does, timeout length should be unaffected
<uberjar>
good to know
<judofyr>
Defusal: blocking I/O on one thread doesn't block I/O on other threads
<Defusal>
judofyr, if this thread uses read_lines, it goes quickly but other threads, including my EventMachine reactor locks up
<Defusal>
readlines*
<Defusal>
judofyr, it is a huge amount of data
<Defusal>
it took me a while to figure out this what was what causing the lockups
<Defusal>
but sleeping 0.025 every 250 lines seems fine now
<judofyr>
ah
<Defusal>
i could probably up it more
<Defusal>
but im not even sure how to monitor the apps IO
<Defusal>
or how to tell what the limit is
<Defusal>
actually, 500 lines every 0.025 seconds is fine :)
<Defusal>
and a lot quicker
<Defusal>
takes 5 - 6 seconds to read 2289649 bytes
<Defusal>
but since the output is from filesystem operations, it takes a few seconds anyway
kvirani has joined #ruby-lang
<Defusal>
it copies 5GB in those 6 seconds, so thats not bad
wmoxam has joined #ruby-lang
wyhaines has joined #ruby-lang
chimkan has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
Sailias_ has joined #ruby-lang
imajes has joined #ruby-lang
dv310p3r has joined #ruby-lang
bglusman has joined #ruby-lang
bglusman has joined #ruby-lang
morozovm has quit [#ruby-lang]
morozovm has joined #ruby-lang
sodani has joined #ruby-lang
rippa has joined #ruby-lang
<sodani>
i'm getting the message /usr/bin/env: ruby: No such file or directory in my cron log. my cronjob looks like cd ~/rails_app && /path/to/rake rake_task. can someone tell me what's causing the error?
havenn has joined #ruby-lang
<rue>
Assuming that /usr/bin/env ruby works otherwise, bad shebang line?
<sodani>
rue: actually I have ruby in ~/.rvm
<sodani>
so I guess it's looking for ruby in the wrong place, but I'm not sure how to fix the cronjob
gsav has joined #ruby-lang
<rue>
You could try adding it to the path
<sodani>
oh that makes sense
<sodani>
thanks
<rue>
Cron jobs don't share your env, so you may need to add various things
joast has joined #ruby-lang
chimkan has joined #ruby-lang
casaram has joined #ruby-lang
<sodani>
rue: I see. I wish they shared my env
chimkan has joined #ruby-lang
chimkan_ has joined #ruby-lang
<rue>
Does Whenever (and similar) offer anything to help with basically keeping the env intact?
tekin has joined #ruby-lang
moogs has joined #ruby-lang
dejongge has joined #ruby-lang
RORgasm has joined #ruby-lang
<sodani>
not sure what 'Whenever' is. but I tried adding the rvm ruby bin to the path at the beginning of my cron file, so hopefully that'll work.
robotmay has joined #ruby-lang
Kichael has joined #ruby-lang
francisfish has joined #ruby-lang
jkyle has joined #ruby-lang
brianpWins has joined #ruby-lang
Indian has joined #ruby-lang
<sodani>
oh Whenever is cron for ruby. will check it out
<any-key>
apeiros_: were you the guy who was doing mechanize?
io_syl has joined #ruby-lang
<Mon_Ouie>
It's drbrain
<any-key>
ohyeah!
deception_ has joined #ruby-lang
<deception_>
Anyone here have experience with web scraping via Mechanize or something similar?
<apeiros_>
any-key: I'm sorry, I only do girls, errr, women…
<any-key>
deception_: drbrain is the guy you want to talk to
<deception_>
I have used Mechanize but now the site has JS and Mechanize can't handle it properly.
<deception_>
Ty
olesu has joined #ruby-lang
chimkan has joined #ruby-lang
<rue>
Isn't there that headless full browser thingy?
<any-key>
Watir/Selenium
<any-key>
that's overkill
<any-key>
well, yes and no
<any-key>
if it's a single site he's scraping he can reverse engineer the JS to grab the URL it's using to fetch JSON or whatever
<deception_>
drbrain: When you have a free second to offer advice and are willing: What could one use to scrape a website that uses JS to open a UPS address validation form.
<any-key>
if it's a general scrap then he may want to use Watir, although that'll slow things down considerably
<deception_>
It's a single site
yango has joined #ruby-lang
<deception_>
Speed isn't much of an issue
fayimora has joined #ruby-lang
<any-key>
deception_: pop open the JS, see where it's pulling the data from
<uniqanomaly_>
phantomjs.org
<deception_>
k
<deception_>
Ty
<any-key>
you should be able to use that URL...which in theory could make scraping somewhat unneccessary
<any-key>
seeing as you could get the raw data
havenn has joined #ruby-lang
tekin has joined #ruby-lang
<deception_>
Well the site polls UPS for address validation
<deception_>
I'm using a script to submit orders instead of typing them in by hand.
<deception_>
So all I really need to do is hit the submit button on the form but Mechanize doesn't see that form in the html
<any-key>
do they use a JS event handler to submit the form after validation?
<any-key>
you don't even need to "click" the button, unless there's session information
<any-key>
just do a POST with your data to whatever address it submits to
<deception_>
That makes sense
<any-key>
I'm assuming this doesn't require being logged in?
<deception_>
Correct
<any-key>
awesome, you're set then
<deception_>
It's a small site if you want to see the source. I don't know too much JS
<any-key>
what browser do you use?
<deception_>
But ty for the pointers
<any-key>
you don't even need JS
<deception_>
Chrome or firefox
<any-key>
fire up chrome, then pull up the web inspector and click the "Network" tab
<deception_>
Ahh so that's where that info is!
<any-key>
then enter the data on the web page and click the submit button, take a look at the POST request it sends
<deception_>
KK hold on
<any-key>
now you can use net/http or any other thingamajig to POST that data yourself
<any-key>
and tada, your life is much simpler, no need to use external libraries
darkf has joined #ruby-lang
<deception_>
any-key: Thanks. I'm at work now and don't have time to deal with it but you sound right. I'll give it a shot tonight Thanks!
<any-key>
No problem, hope it works
<deception_>
Me too lol
<any-key>
I kind of miss doing gratuitous amounts of scraping...my first internship had me violating the TOS for all the major newspapers in the US :)
<deception_>
Ahaha got to love when jobs make you do shady stuff
<deception_>
Just reversed our accounting software to increase the allowed amount of active users ;P
chimkan has joined #ruby-lang
<shevy>
:P
casaram has joined #ruby-lang
<hagabaka>
wouldn't it be trouble for your company if it was found out?
<any-key>
damn, doing print "hello"; sleep 1; printf "\033[K" doesn't seem to clear the line
<freedrull>
wtf my sinatra app is like 20 processes
<deception_>
The software is EOL and they don't provide support or means to increase users
<deception_>
Sooo not much else to do. They dont car.
<deception_>
care*
Stalkr_ has joined #ruby-lang
gregmoreno has joined #ruby-lang
<shevy>
car car car
sepp2k has joined #ruby-lang
gregmoreno has joined #ruby-lang
bglusman has joined #ruby-lang
Swimming_Bird has joined #ruby-lang
robgleeson|mba has joined #ruby-lang
<robgleeson|mba>
injekt: ping
mrsolo has joined #ruby-lang
yango has joined #ruby-lang
achiu has joined #ruby-lang
retro|cz has joined #ruby-lang
jkyle has joined #ruby-lang
dominikh has joined #ruby-lang
RORgasm has joined #ruby-lang
casaram has joined #ruby-lang
ascarter has joined #ruby-lang
gianlucadv has joined #ruby-lang
gregmore_ has joined #ruby-lang
deception_ has quit [#ruby-lang]
malev has joined #ruby-lang
RickHull has joined #ruby-lang
rushed has joined #ruby-lang
arkonova has joined #ruby-lang
ThatDudeGuy_ has joined #ruby-lang
havenn has joined #ruby-lang
arkonova has joined #ruby-lang
kitallis has joined #ruby-lang
Radium has joined #ruby-lang
bish0p has joined #ruby-lang
<bish0p>
not a real problem, but wondering if anybody can explain why the extra 000004 shows up here: 27766.73 + 10481.46 + 11024.40 => 49272.590000000004
<bish0p>
using: ruby-1.9.2-p290
chimkan has joined #ruby-lang
Cherrum has joined #ruby-lang
<rking>
bish0p: I'm not (yet) an expert, but that looks like classic floating point error.
workmad3 has joined #ruby-lang
retro|cz has joined #ruby-lang
<rking>
bish0p: The basic idea is that computers get loosey-goosey with the decimal places for floating-point numbers in the interests of speed, so stuff like that happens. What I'd try is multiplying it by 100 then using it as an int.
<apeiros_>
rking: the basic idea is that not all numbers can be represented precisely. you can't represent 1/3 in decimal either e.g.
francisfish has joined #ruby-lang
<rking>
apeiros_: Ahh, good, yep. So the FP error stuff is not about speed, only the rational representation?
<apeiros_>
given that floats are in base 2, even numbers that are real and finite in base 10 can't be represented by floats
<bish0p>
ok, i'm parsing how that could happen now
yxhuvud has joined #ruby-lang
casaram has joined #ruby-lang
<rking>
apeiros_: I wouldn't say they "can't" be -- a 32-bit word could have 16 bits for the numerator and 16 for the denominator, and it would work though its range would be more limited.
<apeiros_>
rking: you get it wrong
<apeiros_>
you could represent 1/3 in a finite number in base 3
<apeiros_>
you can't in base 10
<rking>
apeiros_: That's assuming you don't have a numerator and a denominator.
<mikkelb>
Stuff like BETWEEN ? AND , IS NOT NULL as well as stuff like def completed?; !! completed_at; end, def payment_required?; total.to_f > 0.0; end etc.?
RORgasm has joined #ruby-lang
Boohbah has joined #ruby-lang
<yxhuvud>
mikkelb: seems mostly fine. all code bases that size have issues that should be improved.
<yxhuvud>
The biggest problem is that the model is waaaaay too fat
Torrieri has joined #ruby-lang
<mikkelb>
yxhuvud: cool
Asher has joined #ruby-lang
sandbags has joined #ruby-lang
tekin has joined #ruby-lang
jbwiv has joined #ruby-lang
kvirani has joined #ruby-lang
olesu has joined #ruby-lang
phaedrix has joined #ruby-lang
justinmcp has joined #ruby-lang
virunga has joined #ruby-lang
m3nd3s has joined #ruby-lang
publicvoid has joined #ruby-lang
havenn_ has joined #ruby-lang
postmodern has joined #ruby-lang
dcorbin has joined #ruby-lang
<RickHull>
i've got a table of the form (pid, id, name) where pid is parent_id, and parent_id == NULL indicates root node
<RickHull>
this describes a tree, if you will. with NULL as the root
<RickHull>
to be consistent, i should say that parent_id == NULL indicates the initial trunks
<RickHull>
i am trying to generate a "temporary" table of the form (tid, id, name) where tid is the trunk_id
<RickHull>
basically collapsing all leaves and interim branches to the trunk
<RickHull>
that is, for every (id,name) i simply want to have a temp table noting its trunk id
<RickHull>
this is so I don't have to walk the tree, given an id, to find its trunk id
<RickHull>
as it happens, the initial table is in a database, and my temp lookup table will be in a database as well
<RickHull>
my goal in creating the temporary table is to incur the tree-walking cost once, though perhaps this is premature
<RickHull>
it seems to me that to determine the trunk_id for a given id using only the first table would require several queries. unless there is a tricky way to do it with joins or something
<RickHull>
my tree depth may go as high as 20
<RickHull>
and there are on the order of a million ids
<RickHull>
so you can see why my temp table may be helpful
<RickHull>
my initial approach is to grab the trunk ids, then for each of those, find their children and insert them into the temp table. so and and so forth for the children
<neilc>
zenspider: around?
<yxhuvud>
RickHull: seems like you might want a better data structure than a single pointer to the parent
sdeobald has joined #ruby-lang
<RickHull>
yxhuvud: i don't disagree. i am given the intitial table though
<RickHull>
i can't change what I am given. i can create something new from it
<RickHull>
part of my pain is that i'm doing this sort of mechanistically, layer by layer, with no real stopping condition
<RickHull>
i know there is a way to express this as a loop, stopping when I hit a leaf node (no children)
<RickHull>
and it's a real pain coding around the db interface
<RickHull>
nested queries and whatnot
<yxhuvud>
what db?
<RickHull>
postgres
<RickHull>
using pg gem and small wrapper i made
<RickHull>
another approach i was imagining is to just slurp out all the tuples from the initial table and try to figure out the tree strictly from that, and somehow bulk insert into the temp table
<yxhuvud>
Hmm. Then you should be able to write recursive queries in sql.
<RickHull>
i don't doubt it. this would be a totally new area for me
<jkyle>
where can I find documentation on a built in ruby debugger? I'm searching ruby-doc.org
<optikalmouse>
how do I check the syntax of my ruby files?
<drbrain>
ruby -c
<optikalmouse>
I dont even understand wtf happened but I keep getting a syntaxerror
<drbrain>
or just run them
<optikalmouse>
run what
<optikalmouse>
the file? to check the syntax?
<optikalmouse>
-_-'
<drbrain>
the ruby file
<optikalmouse>
yeah no, it's part of a rails project.
<drbrain>
ruby -c path/to/the/file.rb is the fast way
ascarter has joined #ruby-lang
<drbrain>
… if you have lots of other files to load before getting to the syntax error
<lianj>
cool. never knew :)
<Asher>
what is a good control structure for this pattern: match path parts (/some/path/parts), 1 part to 1 object that determines match (ie some compared to 'some'), except that one type of match test requires testing the next part
Lee_A has joined #ruby-lang
<Asher>
ie part 1 matches only if part 2 matches
<Asher>
so individual part matchers are objects, and they are collected together, but i want the match comparison to remain in the object context (so different types can be determined)
lordzero has joined #ruby-lang
chimkan has joined #ruby-lang
chimkan has joined #ruby-lang
<lordzero>
stupid question probably, but what is the best way to loops something like TweetStream::Client.new.track(queryFormat(tResults)) do |status| so I can change the results value?
<lordzero>
so the tResults changes occassionaly, i need to modifying what I'm searching for
<drbrain>
lordzero: that's a pretty crazy amount of stuff to have on one line
<lordzero>
it is?
<drbrain>
client = TweetStream::Client.new; query = queryFormat tResults; client.track query do |status| … end
<lordzero>
its actually @client.new etc
<lordzero>
i mean @client.track
<lordzero>
i just combinded it for the channel
<lordzero>
but yes, you are right
<drbrain>
ok
<lordzero>
cant wrap my head around how to loop this
<lordzero>
so i pickup or remove new valies
<lordzero>
values
<drbrain>
so your user says "I want to track dogs on twitter" then "I want to track cats on twitter"?
<lordzero>
pretty much
<lordzero>
or they want to track dogs and cats
<lordzero>
novel idea right
<drbrain>
loop do query = queryFormat tResults; client.track query do |status| next unless current_query == query; … end
<drbrain>
oops, I missed an end
francisfish has joined #ruby-lang
<drbrain>
I assume that client.track never returns?
<lordzero>
nope
<drbrain>
actually, the next should be braek
<drbrain>
in that case, take out the next expression and you should be fine
RORgasm has joined #ruby-lang
<lordzero>
you mind reposting that, apparently my xterm bugged out and i cant scroll up
<lordzero>
running it in unity mode in vmware
optikalmouse has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<drbrain>
loop do query = queryFormat tResults; client.track query do |status| … end end
<drbrain>
I took out the `next unless`
<lordzero>
thank you
<lordzero>
:)
<Boohbah>
unless4lyfe!
RickHull has joined #ruby-lang
Nss has joined #ruby-lang
<slyphon>
i will *always* somewhat resent matz for making me spell 'initialize' accurately
<slyphon>
that has got to be the most annoying self-inflicted wound
<slyphon>
it's like the paper cut of ruby programming
<RickHull>
you'd think his nick would be mats
<slyphon>
nah
<slyphon>
matz is way cooler
<RickHull>
hence, initialize
<lordzero>
hah
<drbrain>
slyphon: in the very beginning you needed to resque exceptions
<slyphon>
drbrain: are you kidding?
<slyphon>
it's not the spelling
<drbrain>
slyphon: no, it was a typo
<slyphon>
it's initialize comes out iniitalize or such every once in a while
<slyphon>
hahahahahhaha
<drbrain>
I think only in ruby 1.0
<slyphon>
that's too funny
<slyphon>
i still think it's awesome they have a module 'rinda'
<slyphon>
*that* shows a good sense of humor
<drbrain>
yes
casaram has joined #ruby-lang
Lee_A has joined #ruby-lang
kitallis has joined #ruby-lang
<Boohbah>
at least he didn't choose the English spelling 'initialise' :)
* slyphon
tries to figure out the behavior of Object#==
<slyphon>
well, guess, really
<RickHull>
Boohbah: that's what i thought slyphon's complaint was
<drbrain>
slyphon: this should be enough: ruby -e 'o = Object.new; p o == o, o == o.dup'
<slyphon>
RickHull: oh no, i'm a 'murican
<RickHull>
hence, initialize is spelt correctly ;)
<slyphon>
drbrain: does it compare instance variables of two objects of the same class?
<slyphon>
i'm just trying to figure out if i need to override it here
<drbrain>
slyphon: nope
<slyphon>
balls!
<slyphon>
ok
<slyphon>
thanks
<drbrain>
Object#== is Object#eql? is Object#equal?
<slyphon>
!
<slyphon>
that's not confusing
<drbrain>
it only checks if they're the same object, nothing else
* slyphon
nods
nguerin has joined #ruby-lang
<slyphon>
drbrain: oh, so that's a quick short circuit
<slyphon>
before comparing ivars
* slyphon
hadn't thought of that
<drbrain>
there is no comparing of ivars
<slyphon>
no no
<slyphon>
i'm gonna write taht
<slyphon>
well, using attr_reader, y'know, i'm not a heathen
<drbrain>
oh, yeah, you can super
<slyphon>
i can super like you can't believe
<Boohbah>
RickHull: spelt is not a word in American :)
<drbrain>
but I generally write def == other; self.class === other and @foo == other.foo and … end
<rue>
Boohbah: It is, actually
<Boohbah>
RickHull: well it is, but it's a type of grain
<rue>
It's a grain
<slyphon>
past tense of spell
<Boohbah>
rue: yes
<slyphon>
?
<slyphon>
spelled?
<RickHull>
Boohbah: yeah, that was part of my joke
<Boohbah>
RickHull: i like that :)
<drbrain>
it might be a tad faster to super or (my stuff)
<RickHull>
don't encourage me
<drbrain>
depending on how ofter you compared identical items
<Boohbah>
rubbish!
<drbrain>
objects
<slyphon>
duck typing is bollocks
<slyphon>
there
<slyphon>
i said it
<slyphon>
:w
<slyphon>
laksjdfljak
havenn has joined #ruby-lang
<whitequark>
hm
<drbrain>
your admission seems to have caused a muscle spasm
<slyphon>
drbrain: it's the first step in the healing process
<whitequark>
do you possibly know a way (including insane ones) to hook into rubygems from an external gem?
<slyphon>
i know what all those words mean, individually
<drbrain>
whitequark: "hook into rubygems" to do what?
<whitequark>
drbrain: I'm sick of writing "bundle exec shit" each time
<RickHull>
there was a reddit post today about that
<whitequark>
hivemind
<kenips>
hello, is there a method that picks out all the substrings in a string that matches a regex pattern? sort of like the inverse of .split(pattern)?
<rue>
kenips: There is indeed, did you check the String doc?
<whitequark>
drbrain: you are awesome
<rue>
Two, actually
<drbrain>
kenips: scan
<slyphon>
bah
<kenips>
rue: okay... let me look then again :)
<slyphon>
alias be='bundle exec'
<slyphon>
there, fixed that for you
<kenips>
drbrain: thanks!
<drbrain>
if you can't solve it with split, scan is your friend
<slyphon>
alias bers='bundle exec rspec spec'
<rue>
kenips: Your penance is to read the docs anyway :)
<slyphon>
even awesomer!
<RickHull>
can we make it beers somehow?
<slyphon>
RickHull: chars are free
<slyphon>
8 bits each, actually
<RickHull>
not semantically
<slyphon>
but they're so cheap these days
looopy has joined #ruby-lang
<slyphon>
then again, if a shave and a haircut is two bits, that's like US$17 these days
<RickHull>
six bits, i thought
<slyphon>
only on IBM System/370
<RickHull>
heh
<slyphon>
:)
<kenips>
rue: I agree... did a quick scan, but I guess too quick :)
<RickHull>
you gotta String#scan the String doc
<RickHull>
it's a bit of a catch 22
* slyphon
throw(22)
<slyphon>
nope, that's a TypeError
<slyphon>
damn you ruby!!!
* slyphon
shakes fist
prsimp has joined #ruby-lang
<drbrain>
slyphon: ?? works fine for me
<slyphon>
oh hah
<slyphon>
i actually didn't check
<slyphon>
i thought throw only took a symbol
<drbrain>
(actually, it fails on ruby 1.8, but not 1.9+
<slyphon>
ahhh
<slyphon>
ok, that's what i was remembering
<drbrain>
I just wanted to be a smartass
<RickHull>
dumb question (pure semantic OCD): would you call the item(s) with parent_id = NULL a trunk or a root node? in my particular case, i have several
<slyphon>
drbrain: hah! nah, that's good to know
<drbrain>
RickHull: roots
<RickHull>
roots, sounds reasonable. it will make for some ugly table names and variables i think
<drbrain>
I think symbols and integers were interchangeable once upon a time
<RickHull>
i was imagining id=NULL = THE ROOT, so they could be "trunks"
<drbrain>
which is probably why 1.8 complains
<RickHull>
though I guess i could just consider N distinct trees
tjadc has joined #ruby-lang
<RickHull>
trunk isn't really a CS tree term, I don't think :(
casaram has joined #ruby-lang
dejongge has joined #ruby-lang
shyouhei_ has joined #ruby-lang
<slyphon>
so
<slyphon>
in the past with #<Foo:29039840>
<slyphon>
the integer was not the object_id
prsimp has joined #ruby-lang
<slyphon>
what the heck is it?
<RickHull>
the # for tech support
* slyphon
lulz
<slyphon>
woah, wtf
<slyphon>
overriding #to_s changes #inspect ?
WillMarshall has joined #ruby-lang
* slyphon
is confusored
* slyphon
smells activesupport
<RickHull>
i wouldn't think so, unless #inspect calls it
<RickHull>
which seems reasonably plausible for some cases
<rue>
Default
<rue>
Dunno if it'd make more sense for the default #to_s to be #inspect, but it's the other way
<slyphon>
really?!
<slyphon>
how have i never run into this before..
<slyphon>
.
countskm has joined #ruby-lang
<drbrain>
slyphon: I think the behavior changed in 1.9
<slyphon>
ahh
<slyphon>
man
<RickHull>
i still can't use 1.9 at work, but i just started this side/home project so I'm finally diving in
<slyphon>
i'm still in this middle ground, all our software is 1.9, but chef is running under 1.8
<slyphon>
so i'm always just being conservative
<RickHull>
is manipulating $RUBYLIB still a good way to have clean requires? i.e. instead of require './foo.rb'
* slyphon
skeeves
<slyphon>
well, i modify $LOAD_PATH
<slyphon>
so i shouldn't be one to talk
<drbrain>
I use ruby -I
<RickHull>
don't let me imply it was ever a good way
<slyphon>
RickHull: i think the official answer is ^^
<drbrain>
ruby -I.
<RickHull>
it has worked fine for me, but i don't really distribute
<drbrain>
I think RUBYLIB is ok
<drbrain>
so long as you keep it on your system and your code can work without it when packaged and released
<RickHull>
i've never packaged or released ;)
<RickHull>
it's something i'd like to do, but there's no need/budget for it at work
jayne has joined #ruby-lang
<RickHull>
and my side stuff has been withering
<RickHull>
but not for long!
tenderlove has joined #ruby-lang
kenips has joined #ruby-lang
<denysonique>
Can you make Ruby << operator accept blocks?
<drbrain>
denysonique: if you call it like obj.<<, yes
<RickHull>
that takes the fun away
<drbrain>
obj << x do end is a syntax error
<denysonique>
hmm
<denysonique>
this is a bug then
<denysonique>
it restricts me from defining cool syntax
<denysonique>
this is against the spirit of Ruby
<drbrain>
it's not a bug
<RickHull>
pitchforks!
<drbrain>
it is not against the spirit of ruby
<denysonique>
ok, so tell me Distributed Ruby Brain, why Ruby doesn't allow for this?
<denysonique>
(;
<denysonique>
or actually
<denysonique>
Distributed Ruby Rain
<denysonique>
;>
<drbrain>
denysonique: none of the operator syntax allows blocks because it is hard to read and understand
<drbrain>
would it be `obj << (x do … end)` or `obj.<<(x) do end`
<drbrain>
denysonique: what about menu << quit do $app.quit end
<Boohbah>
drbrain: where do you get that ellipsis … character from?
<slyphon>
soooo
<Boohbah>
i mean, is it easy for you to type?
<slyphon>
Boohbah: his client probalby does that by default
<drbrain>
Boohbah: I have an OS X text replacement that changes three periods to the elipsis
<slyphon>
Adium does that, annoyingly
<denysonique>
drbrain: 'quit' is a varius string
<denysonique>
various*
<denysonique>
a GUI menu item
<Boohbah>
drbrain: ahh, interesting
<drbrain>
slyphon: right-click the text input bar, Substitutions, uncheck Text Replacements
<slyphon>
drbrain: way ahead of ya
<drbrain>
denysonique: what if I don't want to use a string?
<slyphon>
drbrain: do you know, offhand, with Hash, if you want to prevent a key from being set more than once, is there *one* method you can override to do that?
<denysonique>
and the block defines what happens when the user cicks the menu item
<drbrain>
slyphon: in MRI, no
<slyphon>
balls
<denysonique>
drbrain: hmm, then this method should be only implemented for string scenarios (;
nguerin has joined #ruby-lang
<denysonique>
the << 'string' &blk method
<drbrain>
ruby calls rb_hash_aset(), but it should be possible for rubinius
<slyphon>
that's annoying
<drbrain>
denysonique: then the same syntax has different effects, not a good design choice
<slyphon>
oh well, it doesn't have to be perfect...
<denysonique>
ok
<denysonique>
but why does it work with the . then
<denysonique>
.<<
<slyphon>
drbrain: oh, so it's just Hash#[]= and Hash#store
<slyphon>
...it looks like
<denysonique>
drbrain: in the API I am creating strings would be used %99 of the time
<denysonique>
for nonstrings there will be an alternative method
<drbrain>
denysonique: it's using regular method call syntax there, which allows a block to follow
<drbrain>
denysonique: but that's just you
<drbrain>
everybody will be able to use this syntax, and won't immediately know the difference
<denysonique>
ok
<denysonique>
thanks for the time and explaining
<denysonique>
I will still think about it (;
<drbrain>
denysonique: I think menu.item 'Quit' do $app.quit end is just as good
<denysonique>
drbrain: yep, thats exactly what I am considering as an alternative, you read my mind
* slyphon
creates ParanoidHash
<slyphon>
best thing with SociopathicEggs
havenn has joined #ruby-lang
<RickHull>
I tried to make a hash-like wrapper for redis
<RickHull>
i guess i succeeded. i use it
<RickHull>
but one thing i recall, i needed more than just the methods i wanted to respond to
<RickHull>
almost as if the private designation had some use
<RickHull>
and i needed to have the private methods implemented
looopy has joined #ruby-lang
<RickHull>
i probably tried to inherit from Hash, not sure. i should check. this is likely apocrypha v0v
Skif has joined #ruby-lang
<rue>
slyphon: That was a little runny :) You need to hang out here more, tighten up your game
<slyphon>
hahah
<slyphon>
PsychoticCoffee?
<RickHull>
I started walking down the path and I couldn't turn around :/