<andrewvos>
Man. Code up a gem. Write a billion tests. Release. See extremely obvious bug. Every. Time.
<jammi>
patch the bug, release patched version. no problem.
mksm joined #ruby-lang
<zenspider>
andrewvos: hah... I feel your pain
<zenspider>
I added a rule a while back: no releases after midnight
<zenspider>
helped
<erikh>
I had a co-worker who actually added a unit test for that
<andrewvos>
zenspider: Hmmm. I released at exactly 00:00 and I have a bug. Not a show-stopper, but just irritating enough to make me not want to sleep :)
<erikh>
after 9pm or so
<erikh>
it's abort
<erikh>
and say something like "GO HOME"
<andrewvos>
erikh: What, like in "rake release"?
<erikh>
no it was a unit test
<erikh>
so rake test would fail
<andrewvos>
erikh: Oh ok just to fail when it's too late :)
<porcelina>
awww, doesn't look like they host their bookkeeping on metawiki anymore
<porcelina>
it stops at 2007
EvilJStoker joined #ruby-lang
looopy joined #ruby-lang
WillMarshall joined #ruby-lang
StevenRingo joined #ruby-lang
srbaker joined #ruby-lang
<jkyle>
something is wrong with this: /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake --version => rake, version 0.9.2.2
GutenLinux joined #ruby-lang
<jkyle>
I'm trying to get rake 0.8.7 installed....gem isntall rake --version=0.8.7 is, apparently, installing 0.9.2.2
<drbrain>
jkyle: rake _0.8.7_ blah
looopy joined #ruby-lang
amerine joined #ruby-lang
srbaker joined #ruby-lang
<jkyle>
thanks!
<jkyle>
so rake is like a wrapper script?
<zenspider>
exactly
mksm joined #ruby-lang
<jkyle>
I gave rvm a shot for a bit, but all the utilities started segfaulting when I installed the second ruby version :P this rails dep list is pretty large, been resisting bundler I guess I'll give it a go now
<shevy>
cool jkyle
<shevy>
we gotta shape it and break it
Spooner joined #ruby-lang
terraUNDverra joined #ruby-lang
scottschecter joined #ruby-lang
wmoxam joined #ruby-lang
Manhose_ joined #ruby-lang
mnaim left #ruby-lang
wmoxam joined #ruby-lang
spuk joined #ruby-lang
Indian joined #ruby-lang
<Indian>
some one here posted Indian bollywood movies
<terraUNDverra>
Indian: which is your favorite curry
slyphon joined #ruby-lang
<Indian>
Home made mango and potato
<terraUNDverra>
Indian: which is your fave meat curry
<Indian>
depends most resturants suck
<Indian>
but I like chicken madras
<Indian>
or vindaloo
<terraUNDverra>
Indian: vindaloo is too hot
yfeldblum joined #ruby-lang
<Indian>
watch this
perryh joined #ruby-lang
perryh joined #ruby-lang
<Indian>
terraUNDverra: chicken madras is not bad
rhinux joined #ruby-lang
reh0009 joined #ruby-lang
srbaker joined #ruby-lang
JaphMalik joined #ruby-lang
krz joined #ruby-lang
EvilJStoker joined #ruby-lang
neoesque joined #ruby-lang
pabloh joined #ruby-lang
<epitron>
hmmm... i'm trying to figure out a good set of tools for making it easy to cluster things
<epitron>
it's a problem i seem to run into a lot
<epitron>
does ruby's stdlib have some methods that can be used in clever ways to do that? :)
<epitron>
i noticed some weird things like repeated_permutation
<terraUNDverra>
epitron: what do u mean cluster things epy
<epitron>
well, the simple problem i'm trying to solve right now is clustering log lines records by closeness in time
<epitron>
-records
<jkyle>
I'm poking around for older versions of ruby (1.8.7), where can I find the source?
<epitron>
eg: group together things that happened together
<epitron>
within some threshhold
<jkyle>
I'm on the downloads page
<terraUNDverra>
epitron: you know about group_by right?
<epitron>
it's easy with each_cons, but i'm interested in a more general approach
<epitron>
how would you do that with group_by?
StevenRingo joined #ruby-lang
<epitron>
like, i want to group things together that happened within a minute of each other
<terraUNDverra>
im not sure, just wondering if you knew about it ;)
wmoxam joined #ruby-lang
<epitron>
that's a very easy example
<epitron>
a general purpose clustering thing would have to do repeated passes until there's no change (eg: the clusters stabilize)
<epitron>
and they use a distance metric
<terraUNDverra>
epitron: ping cirwin on #pry i'd say he does this stuff all the time
<epitron>
i was thinking of something like: array.cluster_by { |a,b| distance(a,b) }
<porcelina>
epitron you mean k-means clustering?
<porcelina>
that's some pretty heavy algorithms
<epitron>
not k-means...
<epitron>
i'm thinking agglomerative
<epitron>
where you just stick things together until nothing is close enough to stick together anymore
<porcelina>
probably... it's in some statistics gem somewhere
<epitron>
orly
<porcelina>
it's pretty common in statistics
<porcelina>
to group statistically similar items in a collection
<porcelina>
but yeah, don't exepct the algorithms to be anywhere near fast on large data sets. according to wiki most clustering algorithms are O(n^3)
<epitron>
true, true
<epitron>
i'm not dealing with giant databases tho :)
<porcelina>
it's basically a faster version of the watershed algorithm but i haven't looked into how it actually works yet
<porcelina>
i'm actually just writing it in c. ;s
<epitron>
ahh :)
<mksm>
a cool feature that cameras have is WYSIWYG :D
<epitron>
i enjoy seeing what i get
<porcelina>
i wish that you actually got what you saw, i would take pictures of everything. ;o
<porcelina>
be like "nope i saw it, it's mine" when the cops come
<mksm>
:D
<epitron>
it's like patents!
<epitron>
and colonialism!
<epitron>
"britain took over the world by clever use of flags"
<mksm>
searching for the ultimate tea
elephants joined #ruby-lang
<epitron>
whee, building ruby-opencv \o/
<porcelina>
:D
StevenRingo joined #ruby-lang
<porcelina>
lemme know if it's easy to work with. ;o i might wanna switch to ruby bindings
<jkyle>
woot! worked. what a pain though
flip_digits joined #ruby-lang
Manhose__ joined #ruby-lang
dr0id joined #ruby-lang
<zenspider>
epitron: haha. I need to watch that again
lsegal joined #ruby-lang
EvilJStoker joined #ruby-lang
looopy joined #ruby-lang
tomzx joined #ruby-lang
havenn joined #ruby-lang
cjs226 joined #ruby-lang
cjs226 joined #ruby-lang
Swimming_Bird joined #ruby-lang
livinded joined #ruby-lang
whitequark left #ruby-lang
<porcelina>
shit, what is the name of that thing that gives multi-line editing to irb
<zenspider>
huh. not in my quickref
<terraUNDverra>
porcelina: multi-line editing? in what sense?
<petercooper>
not thinking of Pry?
<zenspider>
picaxe doesn't refer to it either... so yeah. prolly pry
twittard joined #ruby-lang
<zenspider>
pickaxe... damn fingers
<petercooper>
unless it's one of those 'integrate irb with vim' type things
<zenspider>
vim?!? editorist
<petercooper>
in Pry, though, if you run 'edit' it'll bring up the current input buffer in your editor, so maybe that.
<petercooper>
Ah, I'm only speaking in English too, I've gotten comfortable with being selective ;-)
<porcelina>
idk, probably pry
<porcelina>
i saw it at work as i was leaving a couple days then forgot about it
<porcelina>
couple days ago*
nofxx joined #ruby-lang
<Austin__>
sigh.
<terraUNDverra>
Austin__: why are you sad
<shevy>
he is always sad
x0F_ joined #ruby-lang
<Austin__>
No, I'm not always sad, and I'm not really sad now (aside from the joblessness thing at the moment)
QaDeS joined #ruby-lang
<Austin__>
I'm…there's something I need to refactor and what I don't like about it is that it's going to cause a fairly large cascade of changes.
lightcap joined #ruby-lang
<shevy>
ah
* zenspider
blinks
<shevy>
that would make me sad
<zenspider>
zomg Austin__
brushbox1 joined #ruby-lang
<Austin__>
Hi, zenspider
<Austin__>
The cascade can't really be avoided; I'm changing how a library is loaded with FFI so that I can prevent multiple conflicting versions of the library from being loaded simultaneous (crash city) or the reload of the library.
<Austin__>
Also crash city.
josh9 joined #ruby-lang
ben____ joined #ruby-lang
the_great_cornho joined #ruby-lang
ivorybishop joined #ruby-lang
<krz>
whats the equivalent of doing this js code: Date.UTC(1970, 10, 10) in ruby ?
wyhaines joined #ruby-lang
ksinkar joined #ruby-lang
<shevy>
krz you asked that in #ruby and you got your answer
voker57_ joined #ruby-lang
<krz>
heap i noticed. thanks shevy
kitallis joined #ruby-lang
Tref joined #ruby-lang
SuperTaz joined #ruby-lang
dfr|mac joined #ruby-lang
dnjaramba joined #ruby-lang
Banistergalaxy joined #ruby-lang
frangiz joined #ruby-lang
towski joined #ruby-lang
plusk joined #ruby-lang
brianpWins joined #ruby-lang
wmoxam joined #ruby-lang
dc5ala joined #ruby-lang
ABK joined #ruby-lang
gnufied joined #ruby-lang
diegoviola joined #ruby-lang
mksm joined #ruby-lang
amerine joined #ruby-lang
bnagy joined #ruby-lang
macmartine joined #ruby-lang
steph021 joined #ruby-lang
GutenLinux joined #ruby-lang
GutenLinux joined #ruby-lang
yxhuvud joined #ruby-lang
ecin joined #ruby-lang
<Austin__>
ah. the cascade appears to be less problematic than I feared.
<Austin__>
not quite ready for a release…needs to have some banging against it because I think that the new load mechanism might be a bit dangerous.
<Austin__>
every 20th spec run seems to report some sort of crash.
looopy joined #ruby-lang
<kitallisii>
I need to call a method from inside a method that has FSSM block's update/delete/create block - https://github.com/ttilley/fssm
<kitallisii>
but I cannot do that as, self context is lost, cleanest way?
EvilJStoker joined #ruby-lang
hahuang65 joined #ruby-lang
savage- joined #ruby-lang
Banistergalaxy joined #ruby-lang
amerine joined #ruby-lang
tallship joined #ruby-lang
ryanf joined #ruby-lang
solars joined #ruby-lang
nuclearsandwich joined #ruby-lang
WillMarshall joined #ruby-lang
EvilJStoker joined #ruby-lang
dhruvasagar joined #ruby-lang
robotmay joined #ruby-lang
hebz0rl joined #ruby-lang
JohnBat26 joined #ruby-lang
looopy joined #ruby-lang
heftig joined #ruby-lang
WillMarshall joined #ruby-lang
daglees joined #ruby-lang
daglees joined #ruby-lang
dhruvasagar joined #ruby-lang
workmad3 joined #ruby-lang
cyri_ joined #ruby-lang
twittard_ joined #ruby-lang
yorickpeterse joined #ruby-lang
Tanal joined #ruby-lang
molgrew joined #ruby-lang
woollyams joined #ruby-lang
<Tanal>
Good morning everyone. I'm trying to use Parslet but I get stuck on very simple example : http://pastie.org/2907607
<Tanal>
Could someone take a look @ it please ?
WillMarshall joined #ruby-lang
<Tanal>
By the way the error is line 2, not 3 (wrong output)
terraUNDverra joined #ruby-lang
srbartlett joined #ruby-lang
apeiros_ joined #ruby-lang
woollyams joined #ruby-lang
robbyoconnor joined #ruby-lang
robotmay joined #ruby-lang
nuclearsandwich joined #ruby-lang
<zenspider>
Tanal: is any eating the line terminator?
<Tasser>
TTilus, you're probably too slow >:)
<kalleth>
i dunno, are line terminators tasty?
<Tanal>
zenspider: That's what I thought, but how can I avoid that :/ Because source_character can be \n according to the ruby specs...
<zenspider>
you're not actually trying to use parslet to write a ruby parser, are you?
<Tanal>
zenspider: I just want to parse comments ;)
Mchl joined #ruby-lang
saLOUt joined #ruby-lang
<Tanal>
zenspider: because if I say "yes i'm", i'll get kicked for being dumb =D
<zenspider>
Tanal: you have to parse a lot of ruby just to parse comments
<zenspider>
example = <<-EOF
<zenspider>
# looks like a comment but is a string
<zenspider>
EOF
<Tanal>
zenspider: yes I'm just focusins on general comments, so # comment
<Tanal>
or
<Tanal>
=begin
<Tanal>
something
<Tanal>
=end
<TTilus>
Tasser: ?
<TTilus>
Tasser: ...and false positives arent a problem?
<TTilus>
damn tab completion
<TTilus>
Tasser: the latter was ment for Tanal
<terraUNDverra>
Tasser, TTilus, Tanal: one of u change your nickname im too drunk to tell u apart
StevenRingo joined #ruby-lang
<Kanal>
terraUNDverra: ;oP
* TTilus
has been TTilus since fidonet =D
<terraUNDverra>
Kanal: thanks pig
<TTilus>
Kanal: so, ...and false positives arent a problem?
<Kanal>
TTilus: Currently not
<TTilus>
Kanal: but they will? ;)
<Kanal>
But i'm not parsing from nothing, I use the Ruby specs draft
<Kanal>
I just translate it into parslet
<zenspider>
Tanal: well... I've never used parslet so I can't help much... but http://kschiess.github.com/parslet/get-started.html seems to be a good start. I would start by working through that tutorial and then adapt it towards your goal one small rule change at a time
<Kanal>
zenspider: I read that website about 1 million times ^^. I even asked Kaspar Schiess himself about that problem, he might do a tutorial about that
<zenspider>
is there a reason you want to do this?
<zenspider>
or is it just a learning exercise?
<Kanal>
learning
<zenspider>
kk... because there are tools that already do this
<petercooper>
they're too busy pepper spraying lurkers in #occupy
judofyr joined #ruby-lang
vmil86 joined #ruby-lang
aglenday joined #ruby-lang
sepp2k joined #ruby-lang
malev joined #ruby-lang
aglenday joined #ruby-lang
terraUNDverra joined #ruby-lang
Banistertab joined #ruby-lang
<andrewvos>
webrat???
<andrewvos>
capybara!!
t4nk069 joined #ruby-lang
<t4nk069>
Hi guys. I'm having some fun with regexp, though i'm getting stuck. How can I say "everything but # or \" ?
dnjaramba joined #ruby-lang
<sirfilip>
[^#\/]+
<sirfilip>
that is escaped / not V
<t4nk069>
and + means at least one, am I right ?
<petercooper>
1 or more but as many times as possible, ideally
<t4nk069>
ok :o)
<t4nk069>
thanks
<apeiros_>
+ means {1,}
* apeiros_
grins
<sirfilip>
not 100% sure try it out
<petercooper>
one thing I learned recently is you make quantities non greedy as well
<petercooper>
you /can/, even :)
tommyvyo joined #ruby-lang
shevy joined #ruby-lang
<sirfilip>
yup this is the one /^[^#\/]+$/
<sirfilip>
i forgot the anchors
<sirfilip>
sorry about that t4nk069
dnjaramba joined #ruby-lang
<apeiros_>
sirfilip: wrong anchors
<apeiros_>
you want \A and \z
<sirfilip>
nope
<apeiros_>
^ and $ is relative to line
<apeiros_>
\A and \z is relative to whole string
<sirfilip>
right
<sirfilip>
what was the flag to use multiple lines ?
<apeiros_>
unrelated to that
<apeiros_>
m
<apeiros_>
but multiline flag is only related to what . matches
mark_locklear joined #ruby-lang
<sirfilip>
didnt know that apeiros_
<apeiros_>
so again: wrong anchors.
wmoxam joined #ruby-lang
<apeiros_>
note that other regex engines can/will work differently
<sirfilip>
/\A[^#\/]+\Z/ well this is the right one i guess
<petercooper>
\z btw
<sirfilip>
/\A[^#\/]+\z/ :D
M- joined #ruby-lang
<petercooper>
I do tend to see ^ and $ used more in the wild, for better or worse.
Banistertab joined #ruby-lang
<apeiros_>
petercooper: sadly usually worse.
terraUNDverra joined #ruby-lang
<sirfilip>
i have use them everywhere
<petercooper>
I was going to say "only you know your data" but in a way, no-one does ;-)
<sirfilip>
didnt know about this limitation
<apeiros_>
I think it's same to assume that more than half of all validations using anchors in ruby are broken
<apeiros_>
s/same/safe/
<sirfilip>
yup this wont work "this is a test\na/" =~ /^[^#\/]+$/
<sirfilip>
while this one does "this is a test\na/" =~ /\A[^#\/]+\z/
<sirfilip>
tnx guys i think i have learned a valuable lesson
dnjaramba joined #ruby-lang
<FiXato>
note that \z matches the whole string including trailing newlines, while \Z matches right before the trailing newline of a string.
cjs226 joined #ruby-lang
lenilson_dias joined #ruby-lang
saLOUt joined #ruby-lang
hundfred left #ruby-lang
yfeldblum joined #ruby-lang
echoprinter left #ruby-lang
plusk joined #ruby-lang
lenilson_dias joined #ruby-lang
dr0id joined #ruby-lang
plusk joined #ruby-lang
Pip joined #ruby-lang
terraUNDverra joined #ruby-lang
terraUNDverra joined #ruby-lang
mksm joined #ruby-lang
Banistertab joined #ruby-lang
DEac- joined #ruby-lang
dnjaramba joined #ruby-lang
jsaak joined #ruby-lang
nofxx joined #ruby-lang
alex_mekhovov1 joined #ruby-lang
<t4nk069>
sirfilip: Sry I just came back. I tried that : /^[^#\/]+$/, but shouldn't it be something like /^[^#\\]+$/ (since I want to say "everything but # or \". I know the regexp I just posted doesn't work, but I think the regex you gave me allows \ character
<sirfilip>
yup but you should use anchors like this /\A[^#\/]+\z/
<sirfilip>
well it does allow \ it does not allow /
<sirfilip>
maybe i got it wrong
<sirfilip>
then you should do this /\A[^#\\]+\z/
<sirfilip>
sorry t4nk069
<t4nk069>
Thanks :o)
<sirfilip>
np mate
dnjaramba joined #ruby-lang
<t4nk069>
I got that : premature end of regular expression: /A[^#\]+z/
<t4nk069>
Here's my 'code' : match("\A[^#\\]+\z")
<darix>
t4nk069: those \ are mostlikely used for the "" already
<imperator>
forcing it 8bit at a later point works
<imperator>
pssh, whatever
steph021 joined #ruby-lang
steph021 joined #ruby-lang
knu joined #ruby-lang
ksinkar joined #ruby-lang
plusk joined #ruby-lang
bnagy joined #ruby-lang
looopy joined #ruby-lang
srbaker joined #ruby-lang
burgestrand joined #ruby-lang
terraUNDverra joined #ruby-lang
RomD joined #ruby-lang
DRCALKIN joined #ruby-lang
plusk joined #ruby-lang
apeiros_ joined #ruby-lang
mhink joined #ruby-lang
lenilson_dias joined #ruby-lang
jpeasy joined #ruby-lang
looopy joined #ruby-lang
Banistertab joined #ruby-lang
darkf joined #ruby-lang
<judofyr>
I some help with encoding
<yfeldblum>
sup
<judofyr>
I'm generating SQL-statements
<judofyr>
that's getting passed to ActiveRecord
<judofyr>
but I end up with the crappy: incompatible character encodings: UTF-8 and ASCII-8BIT
lenilson_dias joined #ruby-lang
<judofyr>
because PGconn.quote_ident(…) always returns an ASCII-8BIT-string
<judofyr>
so I'm wondering: what's the best way to deal with encodings here?
<judofyr>
should everything be bytes or should everything be UTF-8?
<yfeldblum>
what version of ruby, what version of rails?
<judofyr>
1.9.2
<judofyr>
rails 3
<judofyr>
(or, it''s outside of Rails)
<judofyr>
but it's activerecord (3.1.3)
<yfeldblum>
and pg, is that latest?
<judofyr>
yeah
<judofyr>
0.11.0
<yfeldblum>
what does the activerecord postgresql driver do?
<judofyr>
I thought that Rails used UTF-8 internally
<judofyr>
but quote_column_name (which is implemented by Rails) creates ASCII-8BIT strings :/
<yfeldblum>
right, so, my best suggestion at the moment is to trace ActiveRecord's code path for constructing queries, paying attention to what it does when it has to interpolate a quoted column name
<burgestrand>
you sure you have your files declared as UTF-8 before you pass the string away?
<judofyr>
burgestrand: yes, the string I pass to quote_column_name is UTF-8
<petercooper>
which is pretty awesome reading at any time, TBH
<petercooper>
for some reason I always get reminded of a method I'd forgotten about
solars joined #ruby-lang
<Tref>
so Deal.all.select {|d| d.image_url.blank? }
<Tref>
that works
<Tref>
I knew there had to be a method for that :)
<apeiros_>
Tref: Deal.where("image_url IS NOT NULL").all
<petercooper>
apeiros_' method is more efficient, though you'll need to be running a tight ship data wise
<apeiros_>
it's always advisable to run a tight ship
<apeiros_>
less bugs
<Tref>
what's the .all doing in there?
<Tref>
my data on that is good
<Tref>
it seems like it returns the same without the .all
<petercooper>
Since .blank? will treat even " " as blank.. whereas that wouldn't be NULL in SQL terms.
<petercooper>
If you try and enumerate it, yeah, it will.
<apeiros_>
Tref: no, it doesn't. the result of .where will not have yet executed the query
savage- joined #ruby-lang
<apeiros_>
.all will
<apeiros_>
if you look at an inspect, the query will be executed too
<Tref>
right on
<Tref>
apeiros_: so can i combine that with other where statements?
<apeiros_>
yes
<apeiros_>
they'll be AND'ed
<Tref>
like
<Tref>
where("image IS NOT NULL and featured = ? and start < ? and finish > ?", true, Time.now, Time.now)
<Tref>
sorry
<Tref>
where("image IS NOT NULL and featured = ? and start < ? and finish > ?", true, Time.now, Time.now).all
<apeiros_>
yes. preferably you execute Time.now only once.
looopy joined #ruby-lang
ecin_ joined #ruby-lang
<apeiros_>
where("image IS NOT NULL and featured = :featured and start < :now and finish > :now", :featured => true, :now => Time.now) # e.g.
<Tref>
I'm on 1.8.7
<Tref>
that looks like 1.9 syntax
<apeiros_>
doesn't matter. that's an AR thing.
<petercooper>
1.9 syntax would be featured: true, now: Time.now
<apeiros_>
also, for something like that you can use a BETWEEN statement:
<apeiros_>
where("image IS NOT NULL AND featured = :featured AND :now BETWEEN start AND finish", :featured => true, :now => Time.now) # e.g.
DEac- joined #ruby-lang
<savage->
petercooper: do you like that syntax? I'm not sure I like it since it ultimately allows two different ways to represent a symbol.
<petercooper>
I like it but am on the fence about using it in anything that's not solely for my eyes only.
<apeiros_>
savage-: there's like ~5 ways to represent a string…
<Tref>
apeiros_: doesn't seem to like that for some reason
<apeiros_>
Tref: "for some reason" is pretty vague in programming…
<Tref>
apeiros_: wait that's my bad
<apeiros_>
works for your girlfriends' taste…
<savage->
apeiros_: I just can't come to grips with this: h = { x: :y, b: :foo }
<apeiros_>
savage-: heh
<savage->
::::::
<apeiros_>
yes, doesn't look nice
<petercooper>
Maybe it's just me but I don't often see symbols used as values in that way
<apeiros_>
but I don't think it's the "more than 1 way to represent X"
<Tref>
apeiros_: Deal.where("image IS NOT NULL AND start < ? and finish > ?", Time.now, Time.now).all
<Tref>
thats looking good :)
nuclearsandwich joined #ruby-lang
Phrogz joined #ruby-lang
<Phrogz>
[OT] Can anyone suggest what the equation in blue might be, if the equation in red is an ellipse? http://i.stack.imgur.com/4iqZn.png
dhruvasagar joined #ruby-lang
towski joined #ruby-lang
twittard joined #ruby-lang
gianlucadv joined #ruby-lang
scampbell joined #ruby-lang
<deryl>
ok, I'm more than fairly confused here. https://gist.github.com/1389382 I created class Cow < Animal and added def color to Cow which should override Animal's yet its not.
<deryl>
can anyone explaint o me why?
<deryl>
err explain to
<apeiros_>
deryl: your create_with_attributes returns an Animal, not a caw
<apeiros_>
*cow
<apeiros_>
line 22: animal = Animal.new(noise)
<petercooper>
yeah, ditch the "Animal."
<apeiros_>
change that to: animal = new(noise)
<apeiros_>
deryl: also if you're at that state of ruby comprehension - do NOT use @@vars, srsly
<petercooper>
We've been quite the tag team this afternoon, apeiros_.
<apeiros_>
they almost certainly do not work the way you probably think they would.
<apeiros_>
petercooper: o/
<deryl>
apeiros_: no no, the @@vars were part of a tutorial
<deryl>
my bad, should have removed then
<apeiros_>
deryl: y…uck
<deryl>
err them
<deryl>
apeiros_: they were explaining what class vars *were*. I just forgot to remove the code
<apeiros_>
a tutorial teaching class vars… :-S I'd be so god damn very surprised if it teaches their actual functionality…
<apeiros_>
got a link to that tuto?
<deryl>
what part of 'they were teaching what class vars WERE' are you missing?
<deryl>
they gave demonstration code of how they worked
<deryl>
its Lynda.Com
<apeiros_>
deryl: the part that they most likely explain it wrong.
<deryl>
and you gleaned that remarkable insight from that TINY bit of code... how?
<apeiros_>
deryl: I gleaned that from knowing that ~90% of ruby coders get it wrong.
<apeiros_>
7 years of helping people in irc, baby…
<deryl>
they even tell you in the tutorial that this is not how you would normally use them. this was to show how they work
lightcap joined #ruby-lang
<petercooper>
Must admit I've been guilty of the old "you wouldn't really do this but check this out" approach before.
<petercooper>
And I hate myself for it.
<deryl>
they go through showing each of the different types of variables. from block, to local, to instance, to class, to global
<apeiros_>
ok, I'll give them the benefit of the doubt
<deryl>
and whether we should be using them or not, class vars ARE part of the language. so any reasonably complete tutorial SHOULD cover them
<apeiros_>
that part, I agree.
<deryl>
as to my original question, all I can say is "ahhh. I totally missed that. stemming from the create_with_attributes() in Animal"
<vikoren>
<3 @@
<deryl>
now how would I change that? is there a way to say something like (self.class).create_with_attributes?
<apeiros_>
class vars are probably the hardest thing about ruby as a language
<deryl>
so you wouldn't have to rewrite the method?
<apeiros_>
19:06 apeiros_: change that to: animal = new(noise)
solars joined #ruby-lang
<deryl>
apeiros_: yeah I am using them incorrectly in one of my apps as well. I have to fix that
<deryl>
oh hehe missed that line :) thanks apeiros_
<apeiros_>
`new` without a receiver will call it on self. self will be whatever class you called the method on.
<deryl>
THAT is amistake in the tutorial because he never changes that
<apeiros_>
send him/her a mail then…
<deryl>
definitely
<deryl>
I learn better from video tutorials (guess its vision, sound, and my typing that gets things through the short term memory problems and into the long term. so I use them a lot)
lightcap joined #ruby-lang
<apeiros_>
I'll refrain from other refactoring comments then.
<deryl>
tired of constantly googling and trying to fill in my knowledge as i go. So, figured I'd do a courseware to solidify what i already know, and learn whatever I missed self-teaching myself
<apeiros_>
line 32: puts "A new Animal has been instantiated."
<apeiros_>
should probably be: puts "A new #{self.class} has been instantiated."
<apeiros_>
or alternatively lowercased. but Animal capitalized seems to indicate the class.
<deryl>
yeah that was what was meant (the class)
<deryl>
think I goofed that part. (i think)
<apeiros_>
(you need the `self.` there because `class` alone is a keyword)
<deryl>
vikoren: those are next on my list because they also teach testing as part of the approach AS part and parcel.
amerine joined #ruby-lang
udzinari joined #ruby-lang
<deryl>
i know enough to be dangerous i think, so I'm trying to follow a structured course. Friend gave me the videos when he heard i was trying to get better. so, working through them all.
<deryl>
and, i've nothing but time so why not :)
<deryl>
thanks for the help guys.
dhruvasagar joined #ruby-lang
yango joined #ruby-lang
<yango>
Hi, I've been reading about extending a class by using method_missing. The text says that now such a class is going to be harder to debug because the users won't be able to tell when a method is missing. But I'm wondering if there's no way to call the regular functionality of method_missing after I've plugged in the new methods I want there?
<yango>
in fact, I could just raise if the name of the method isn't one I'm expecting, couldn't I?
<vikoren>
yango: it's just that the burden of recognizing a non conforming method falls to you
<apeiros_>
yango: just call super
<apeiros_>
return super unless i_can_handle_this_missing_method
<apeiros_>
super might eventually be a NoMethodError
<yango>
okay, I'll submit a bug :)
hahuang65 joined #ruby-lang
terraUNDverra joined #ruby-lang
<Mon_Ouie>
Though sometimes all methods are handled, meaning you will never get an error message
jensn joined #ruby-lang
Jake232 joined #ruby-lang
lenilson_dias joined #ruby-lang
sonney2k joined #ruby-lang
<sonney2k>
Hi, I have a C program extending ruby that needs to access a global const. In ruby 1.8.x I could use rb_const_get(ruby_class, rb_intern("NArray")); but in ruby 1.9.x ruby_class is no longer defined in libruby*.so
<sonney2k>
Any ideas what I should do to get the global class?
<deryl>
apeiros_: *I* goofed. Somewhere between the previous video and this one, he changed Animal.new to self.new in the create_with_attributes method on Animal class.
Indian joined #ruby-lang
<deryl>
I went back over the previous video and it was still Animal.new not self.new. So he goofed by not mentioning the change, and I goofed by not catching it
looopy joined #ruby-lang
robotmay joined #ruby-lang
babinho joined #ruby-lang
<Tasser>
better way than @fields += Array(field)
artOfWar_ joined #ruby-lang
<deryl>
if @fields is already an array, @fields << field ?
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
<deryl>
if if you want field to be an array and @fields is alrady an array - @fields << Array(field) (making an array of arrays of fields)
<Tasser>
deryl, I want it to do exactly the same as above ^^
<deryl>
yeah you have a @fields variable that is already an array correct? because you can't add an array to a string. (unless you call .to_s) like @fields = "Bye" ; field = "Hello" ; @fields += Array(field) will error with TypeError: can't convert Array into String. But you can get the string representation by doing @fields += Array(field).to_s
<deryl>
so it depends on what Type the @fields var is
<lsegal>
andrewvos you could potentially adjust to work in a readme
<andrewvos>
lsegal: Hmmm... So it just looks for code blocks and executes them?
<lsegal>
andrewvos basically, you could probably do the same without yard if you just follow a consistent syntax
<andrewvos>
lsegal: Yeah that's what I'm thinking.
<andrewvos>
lsegal: Thanks you've given me some great ideas
<lsegal>
np
* andrewvos
starts thinking regular expressions
* Koolvin
Regular Expression #1: Smile
<rue>
Reminds me, does anyone have an idea as to what a “functional regexp” would be like? As in, different from regular regexps
<Koolvin>
Rue, the distinction is a regular expression selects while a funtion regular expression parses
<Koolvin>
Such as with PHP preg_match vs preg_replace
<shevy>
eeks
<shevy>
Koolvin tries to bring in ugly PHP here
<andrewvos>
Does ruby support named regex match groups?
<Koolvin>
Idonno ruby =[
<apeiros_>
andrewvos: in 1.9, yes
<Koolvin>
I find named groups to be ugly and useless
<shevy>
useless?
<shevy>
I find regexes ugly but rarely useless
<Koolvin>
Not regex
<Koolvin>
Named groups
<rue>
Koolvin: That doesn't make any sense
<Koolvin>
What rue?
<samuelkadolph>
Named groups are like the polish on the turd that is regex
<Koolvin>
They are completely redundant
<Koolvin>
And make bloated arrays/objects of matches
<andrewvos>
I suppose
<apeiros_>
so what's the redundant part?
<samuelkadolph>
I think you need look up the meaning of that word
<rue>
"foobar" =~ /foo/ # How do you make that “functional”?
<Koolvin>
Depends on the language maybe
<rue>
Or how is it not functional
<Koolvin>
Rue, in ruby I have no idea
<Koolvin>
However when regex is parsing text with replacement or something of the like, it's functional
<shevy>
Koolvin and in PHP?
<apeiros_>
redundant means there's plenty of other things that can take over the given functionality
<apeiros_>
so I wonder, what can take over the functionality of named groups?
<samuelkadolph>
PHP!
<Koolvin>
The redundancy comes in the output
<shevy>
:(
<Koolvin>
It returns each matched value twice
<Koolvin>
Once with the numbered key, and another with the name.
<apeiros_>
uuuh
<apeiros_>
not really…
<Koolvin>
It probably depends on the language.
<apeiros_>
a = b = "hello" is not having 2 strings
<apeiros_>
it's having one string referenced from two places
<samuelkadolph>
I still don't see how you can make a distinction between the type of regexp you pass to preg_match and preg_replace
<Koolvin>
Right, but [4=>'hello','group'=>'hello'] is having two strings
<apeiros_>
oh, you're talking about *php*
<samuelkadolph>
But that 4 can also be a 3 or a 2 or a 5
<Koolvin>
Right
babinho joined #ruby-lang
<samuelkadolph>
But it will always be ground
<apeiros_>
well, php is a turd and manages to turn most things into turns alike.
<samuelkadolph>
group*
<Koolvin>
I gues that's true
<Koolvin>
Guess*
<samuelkadolph>
apeiros_: He mentioned preg_match and preg_replace as a distinction between regex and "functional" regex.
<apeiros_>
samuelkadolph: see, it even turns thoughts into turds!
<shevy>
that's the true power of PHP
<shevy>
and didn't you all start with PHP once
<apeiros_>
poo hyper powered!
towski joined #ruby-lang
<apeiros_>
shevy: no
<shevy>
didn't you have that 60k lines of code PHP app!
<samuelkadolph>
Thankfully no, I avoided that career blackhole.
babinho joined #ruby-lang
<shevy>
or was that manveru ...
<apeiros_>
shevy: I did do php, but it wasn't where I started
<shevy>
hehe
<apeiros_>
coming from perl to php, I knew php was a turd back then already.
<Koolvin>
Lol.
<Koolvin>
I try to stay away from perl
<Koolvin>
Makes me drool too much
<lake>
Is there some convention in ruby that if your "project" has a lib/project.rb file, that file is automatically required when you `gem "project"` from a Gemfile?
<shevy>
I drool every time I must do ; in perl
<Koolvin>
I always try to for (1..10) and then cry.
<apeiros_>
lake: no
<apeiros_>
lake: gem does *never* require anything
<samuelkadolph>
lake: That's a convention in rails
<apeiros_>
gem 'foo' only sets up the load path
<apeiros_>
and technically you *never* need `gem 'foo'`, only `gem 'foo', some_specific_version`
<lake>
ah, okay.
<apeiros_>
in a bundler gemfile, you can afaik specify that it should already load stuff via the :require option
<apeiros_>
also, sorry, but "and technically you *never* need `gem 'foo'`, only `gem 'foo', some_specific_version`" does not apply to gemfiles
<samuelkadolph>
You can tell it what to require when you call Bundler.setup
<apeiros_>
that's for ruby source
<samuelkadolph>
Bundler.require now I suppose and not setup
thone_ joined #ruby-lang
felipegb joined #ruby-lang
<lake>
apeiros_: nice. the require worked from bundler. much thanks for the info samuelkadolph and apeiros_
nofxx joined #ruby-lang
saysjonathan joined #ruby-lang
<andrewvos>
If I have "hello dffdg end\n\n hello sdfsfdsdg end" how would I find all matches between hello and end?
<andrewvos>
.* seems to be matching from the first hello to the last end. I'm using multiline
Dvyjones joined #ruby-lang
<Dvyjones>
Are there man pages for the Ruby C extension library? Or any documentation except for README.ext?
<andrewvos>
lake: Sorry should have mentioned that it's more like this "hello\nTEXTHERE\nend\n\nhello\nTEXTHERE\nend
<andrewvos>
"
<lake>
you should be able to modify it easily to meet that requirement
looopy joined #ruby-lang
woollyams joined #ruby-lang
<lake>
could anyone recommend a way to mock a dns server in ruby/cucumber?
<andrewvos>
lake: Why do you need to do that?
<lake>
i am validating that a custom domain is pointing to a correct subdomain. I want my code to respond one way if it does and another way if it does not point to a correct subdomian.
<lake>
cname record
<lake>
i'm using net/dns to check the record.
havenn joined #ruby-lang
udzinari` joined #ruby-lang
StevenRingo joined #ruby-lang
<andrewvos>
lake: Not sure how
bnagy joined #ruby-lang
<lake>
andrewvos: did you figure out your problem?
<rue>
andrewvos: I'd probably go with N passed, M failed, with return != 0 if M != 0
<rue>
And loosen the extraction just a bit
<rue>
Maybe tally up any examples that don't have an expected value
<rue>
To avoid the required :end:, could just assume it's until the end of the comment block, or if you wanted to be elaborate, implement an RDoc/YARD parser to extract it
<andrewvos>
rue: Until the #=> you mean?
<rue>
Yes
<andrewvos>
Hmmm. maybe at a later date.
singpoly1a joined #ruby-lang
<andrewvos>
rue: Don't want to do too much work on it now.
<andrewvos>
Maybe I'll make a gem or something at some point.
Jake232 joined #ruby-lang
<rue>
Well, wrap it up as a rake plugin, put it on Github and wait for magic to happen
<andrewvos>
Magic :)
<jtoy>
what tools do you guys recommend for finding memory leaks on ruby 1.9.x ?
<andrewvos>
Yeah I will. It does seem like something that would get some use.
<jtoy>
i see a bunch of toosl for the 1.8 series, but all my code wont run on older versions
<rue>
jtoy: Do you suspect a memory leak?
srbartlett joined #ruby-lang
<jtoy>
rue there is certainly some baddly written code, cood be mine or a lib, but i dont really know how to find these issues
<freedrull>
okay well, i should have realized syck isn't 1.9 compatible right?
gix joined #ruby-lang
<shevy>
freedrull I think you can use syck too
<shevy>
but it's not the default
<jtoy>
are there any guides on best practices for dealing with memory in ruby, the only link i found was saying dont use too many symbols
<wmoxam>
jtoy: don't use too many symbols? Where did you read that?
<freedrull>
but i get inexplicable 'invalid byte sequence in UTF-8' errors
<shevy>
freedrull awww :(
<shevy>
the invalid byte shit is taking the fun away from ruby
<rue>
Too many symbols isn't really a memory leak in the conventional sense of the word
<wmoxam>
jtoy: that's more about abusing symbols :p
<rue>
In fact, pretty much none of the “memory leaks” discussed in Ruby land are
<shevy>
always those railsers ...
<shevy>
but you know
<shevy>
every newcomer to ruby faces that question
<shevy>
"shall I use symbols or shall I use strings"
<rue>
jtoy: You could use .count_objects to get a rough gauge, if you have a situation where you can expect a certain type of object creation (= memory usage) pattern
<jtoy>
great, im not using rails, im using ruby, do you guys know of good tutorials/info I should use to understand where my problem is
<rue>
I dunno if memprof works with 1.9?
<rue>
There's always valgrind
<jtoy>
rue, memprof says 1.9 support soon about a year ago :(
<rue>
With rbx, you could do memory dumps, which might also help
<rue>
Theoretically speaking any improvements you find there would translate to MRI
M- joined #ruby-lang
emboss joined #ruby-lang
<shevy>
ok so
<shevy>
should I use symbols or not
ivanoats joined #ruby-lang
ivanoats joined #ruby-lang
<porcelina>
only use ints
<porcelina>
and just keep a table of them next to your computer
<porcelina>
^_^
<shevy>
rails kinda annoys me
<andrewvos>
Does inspect call to_s?
<lake>
yes
<andrewvos>
lake: Thanks
<rue>
It's the other way around, isn't it? Object#to_s == Object#inspect
postmodern joined #ruby-lang
<andrewvos>
Damn this example executor is fucking aweeesome!
resetexistence joined #ruby-lang
<andrewvos>
Anyone else wish they had a .vimlocal file in the root of eery project that would automatically execute?
<lake>
andrewvos: man, seems like you could implement that somehow.
<andrewvos>
lake: Yeah pretty simple
<rue>
andrewvos: Here's a pull request: if example =~ /#\s*=>\s*(.+)/; expected = $1
<andrewvos>
lake: Just scared that I end up with .vimlocal files everywhere
whitequark joined #ruby-lang
<andrewvos>
rue: Pull request accepted.
<lake>
why not just add them where you want them, add a funtion to vimrc that sources it if it exists on startup
<andrewvos>
rue: Actually could you email me that in a word document?
<whitequark>
yay! looks like I will work on ColdRuby for my employer!
<lake>
lol
<andrewvos>
lake: Yeah
<rue>
Is WordPerfect OK?
<rue>
whitequark: That's not ColdFusion-related, is it?
<whitequark>
cref alteration rules have changed in 1.9.3 compared to 1.9.2 in regard to Class.new and class_exec
<whitequark>
does anyone have a clue of how exactly they did?
<whitequark>
I _think_ that earlier class_exec has pushed the ddef of class_exec statement environment itself to the current cref at evaluation, and it appears that in 1.0.3 it does not
<whitequark>
but I'm not sure
<whitequark>
or that may be not ddef, but self.
petercooper joined #ruby-lang
<shevy>
never heard of class_exec before
<shevy>
all those meta things seem to be too complicated anyway
<whitequark>
shevy: the *_exec functions are just same as *_eval, but work only with blocks
<shevy>
hehe
<whitequark>
there are some runtimes (e.g. my coldruby) which cannot eval, but that does not prevent them from exec'ing
<whitequark>
I consider this to be a very neat and well-planned feature
<petercooper>
<3 _execs
ngw joined #ruby-lang
<whitequark>
petercooper: got any clue about cref changes in 1.9.3?