Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
anjen joined #ruby-lang
m0wfo left #ruby-lang
r0bby_ joined #ruby-lang
lightcap joined #ruby-lang
robbyoconnor joined #ruby-lang
<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 :)
<erikh> we need to animate john wayne so he can put together a new flick: "the beggar jimmy wales"
<erikh> W 2
<andrewvos> ahahah
<andrewvos> Why don't governments sponsor them?
<erikh> probably bureaucratic horseshit
<andrewvos> erikh: Fair enough.
jkyle joined #ruby-lang
<andrewvos> Would take years to get the paperwork through.
<andrewvos> etc.
<erikh> and it'd be hard for them to be truly independent afterwards
<porcelina> sponsor wiki you mean?
<andrewvos> Well, donate would be more accurate.
<porcelina> i think they'd have to make wiki a government program
<porcelina> which would defeat the purpose
<porcelina> i'm not sure if the government is allowed to donate outside of either sponsorship or grants
<porcelina> but i bet wikimedia is big enough it could crank out grants pretty fast
<porcelina> if it wanted to drop its nonprofit status and become a research firm or something
<andrewvos> Which government do you mean?
<porcelina> its hosted in US right?
<petercooper> The problem is this line of thinking forgets about the thousands of hardcore Wikipedians who /really/ keep the site going
<andrewvos> porcelina: Not sure
<andrewvos> Wonder what sort of hardware they need.
<andrewvos> HAH reddit cracks me up http://i.imgur.com/sRBR1.jpg
<porcelina> lol
<porcelina> here you go
<porcelina> hosted in tampa
<porcelina> and amsterdam apparently
<andrewvos> fuck
<andrewvos> Someone pay the dudes :|
looopy joined #ruby-lang
<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 :)
<epitron> this is just for me to play with things
<porcelina> here's a gem that includes clustering for you anyway. :3
<porcelina> and some other AI related stuff it looks like. ;o
<terraUNDverra> porcelina: why do u have a feminine nick name
gregmoreno joined #ruby-lang
<porcelina> give you 3 guesses
nuclearsandwich joined #ruby-lang
<terraUNDverra> porcelina: u r a female
<porcelina> winrar
<porcelina> lol
<terraUNDverra> porcelina: wat
<porcelina> um winner
<porcelina> as in you win
<epitron> porcelina: ah, nice.. AI4R has a whole array of methods that do clustering.
<porcelina> yeah, it looks pretty rad actually now that i'm going through the methods. ;o
ryanf joined #ruby-lang
<porcelina> nothing for images tho. :(
Asher joined #ruby-lang
<epitron> what do you wanna do with images?
<porcelina> search by content
<epitron> like, find instances of some small patch in a larger image?
<epitron> there should be C libraries to do that by now
<epitron> SIFT and SURF are oldddd now :)
<porcelina> yeah i know, idk i read a paper that used mser->sift that i thought i'd try
<porcelina> so it like, found msers then cut circles out of the middle of them and ran a sift style histogram on them
<jkyle> so, I've failed at getting a working 1.8.7 ruby installation on lion, will downgrading my toolchain help?
<epitron> OpenCV is a good suggestion
<epitron> does that have ruby bindings yet?
<drbrain> yes
<porcelina> yeah i've been playing with opencv
<porcelina> it's pretty rad
<epitron> sweet
<drbrain> jkyle: compile with gcc-4.2
<jkyle> pretty sure that's in teh 4.1 xcode, though I thought 4.2 didn't go over 4.2 either (licensing)
<drbrain> jkyle: if you don't have gcc-4.2 then use the gcc installer package for OS X
<drbrain> jkyle: if you installed 4.1 then 4.2 gcc-4.2 remains
<jkyle> drbrain: also trying to get it working with rvm, I ran into dependency/multiple version problem when I source compiled
<porcelina> epitron yeah straight up histogram's pretty good for that
<porcelina> i'm trying to do varying camera angles
<epitron> a histogram of what?
<porcelina> colors in the picture
<epitron> o_O
<epitron> to match images?
<porcelina> yeah, it's amazingly effective. o_o
<epitron> weird
<epitron> i guess you normalize it
<porcelina> i had to do it for a graphic encoding class
<porcelina> yeah
<epitron> otherwise bigger images wouldn't look like smaller images
<porcelina> normalize and take a low res sample
<porcelina> then do a fuzzy search on it
<epitron> fuzzy search? :)
<porcelina> idk i never did the fuzzy search
<porcelina> i just gave a % chance that two images were the same
<epitron> i've heard of fuzzy logic. never looked into it.
<porcelina> kd tree is good for fuzzy searches tho
<epitron> probabilityyyy
<porcelina> yeah it was a BS number
<epitron> i think those are called "approximate matches"
<epitron> not fuzzy searches
<porcelina> lol
<porcelina> same thing isn't it?
<epitron> well, you know... people use words :)
<porcelina> haha
<epitron> they attach meaning to them
<epitron> some of them have different meanings
<epitron> approximate match has the most people attaching that meaning to it
<porcelina> but yeah, k-approximate nearest neighbors is technical word for it
<epitron> you had me at kD tree
<porcelina> annnyway haha, yeah histograms are amazing for some weird reason
<porcelina> it had a really high accuracy
<porcelina> but then if you turn the camera angle a little, the accuracy tanks. :\
<porcelina> or if you do any cropping
<epitron> or if you change the luminance levels
<porcelina> that did okay with the normalized histogram
<porcelina> i imagine if you did a picture with a flash and a picture without it would do badly
<epitron> that is interesting tho
<epitron> i bet you could create an integral image with histograms at each point...
<epitron> and then use that to do sub-matches
<porcelina> that's kinda how sift works i think
<porcelina> idk much about sift or surf
<epitron> i can't remember how sift works... it has to do with gaussians though
<porcelina> i know that they're patented which is BS. :\
<epitron> they are?
<porcelina> yeah
<epitron> i guess UBC owns sift
<porcelina> sift is by UBC and i forget who surf is patented by
<porcelina> yeah
<epitron> surf is integral images
<epitron> but i think they're just B&W?
<epitron> i dunno
<epitron> found this looking for ruby opencv bindings: http://lubyk.org/en
<porcelina> color is just b&w done three times
<epitron> touche
<epitron> or 4 times, if you're a printer
<porcelina> or one billion if you're pantone lol
<porcelina> do you know anything about classification algorithms?
<epitron> because pantone is a palette?
<epitron> yeah...
<epitron> what kind you looking for?
<porcelina> uhm, single class image i think
<porcelina> i was thinking, if i already have a tagged database
<porcelina> and i get like 10 matches and want to figure out which is right
<porcelina> i can try to find a good partition of the matches
<porcelina> and do a few classification tests to cut the results in half
<epitron> hmm
<epitron> the classifier needs to be trained on your whole corpus though
<epitron> it needs to find features
<porcelina> yeah
<porcelina> but it should do well against new data if it's had enough training right?
<epitron> you're looking for matches where the camera position has changed?
<porcelina> yeah
<epitron> that should just be applying affine transforms to sift matches, shouldn't it?
<epitron> like, to sets of sift points
<epitron> or perspective transforms
<porcelina> for one that's amazingly slow
<porcelina> so i'm using bag of words
<epitron> there's probably some equation that tells you the mean error given geometric constraints
<epitron> (input: two sets of points, output: "can these points be the result of a rotation?")
<porcelina> yeah i guess you're right
<porcelina> once i have a few likely matches from the BoW i can start matching individual sift points
<epitron> i dunno what that equation would look like tho
<epitron> yeah
<porcelina> i've seen a couple papers with it
<epitron> what're you doing this for?
<porcelina> it can even tell you yaw pitch and roll for the camera change
<epitron> neato
<epitron> this stuff was all done in 2005 i think
<epitron> microsoft research is sitting on it
<epitron> they bought up those seadragon guys
<porcelina> yeah, i remember they had a few products they showed videos for but never released details
<porcelina> one of the papers is from ms tho
Weems joined #ruby-lang
Weems joined #ruby-lang
<epitron> it's really frustrating to have things like SIFT patented
Austin__ joined #ruby-lang
<epitron> it's such a fundamental thing
<porcelina> uhm, i'm just doing this for upper division electives. ;s
<shevy> SIFT?
<epitron> scale-invariant feature transform
<epitron> it's what lets you stitch together photos really fast
<shevy> trivial patents are a weapon
<epitron> surf is a faster version of sift
<porcelina> yeah, they really nailed some product on it too
<epitron> which can run on a GPU
<porcelina> that was using sift for panorama stitching
<epitron> (it's faster on a CPU, but insanely fast on a GPU)
<epitron> microsoft's panorama sitcher is insanely fast
<porcelina> wonder what it uses...
<epitron> porcelina: so, your assignment is to make a photo finder?
<epitron> it's SURF+GPU for sure
<porcelina> just write a paper on it
igotnolegs joined #ruby-lang
<epitron> ah
<porcelina> i'm gonna try to make it tho
<porcelina> since open cv gives you BoW and MSER for free
<epitron> MSER?
<porcelina> maximally stable extrema regions or something
<epitron> :O
<epitron> is that for segmenting?
<porcelina> it's a feature extractor for features that are likely to not change when the camera's moved basically
<epitron> ahh
<epitron> are these the opencv bindings you're using? https://github.com/ser1zw/ruby-opencv
<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.
<shevy> good news!
kitallisii joined #ruby-lang
Asher joined #ruby-lang
ecin_ joined #ruby-lang
<Banistergalaxy> Asher hello
<Austin__> and there we go: https://github.com/halostatue/rubypython
<Asher> hey how goes
<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
<manveru> Kanal: maybe check out the atomy parser
srbartlett joined #ruby-lang
<Kanal> manveru: link ? My google gets crazt
<Kanal> crazy*
<Kanal> I get results with anatomy parser =D
<zenspider> looks like https://github.com/vito/atomy
<Tasser> TTilus, fidonet? never heard of
* zenspider guffaws
<zenspider> youngins
thrcka joined #ruby-lang
<Kanal> Let's be dirty
<Kanal> rule(:source_character) {match('[^\n]')}
adambeynon joined #ruby-lang
<Kanal> no problem anymore :3
<zenspider> I'd guess that to be '.'
<zenspider> which is more clear imo
<solars> hey, can anyone please explain this to me: https://gist.github.com/52ef8359a3a586b92374 I don't get it
<zenspider> what's the question?
<Kanal> zenspider: \n match '.' in parslet (yeah I know, wierd...)
<zenspider> Kanal: huh. ok. odd
<solars> .to_time behaves different for DateTime objects it seems, in https://gist.github.com/52ef8359a3a586b92374
<solars> zenspider
<zenspider> solars: that may very well be true... have you read the source for to_time?
<Tasser> wow
<solars> zenspider, I have, but I don't understand it, why is it a difference?
<zenspider> beats me. I haven't bothered reading the source for it. this is more of a rails question than a ruby question
michael_mbp joined #ruby-lang
<zenspider> I stand corrected. I guess this is a standard method, not a rails extension... tho I certainly see them fucking with it in activesupport
<solars> I'm not using rails here
dhruvasagar joined #ruby-lang
<solars> let me check if activesupport is used somewhere
<solars> right, its probably included by another gem
<solars> i18n maybe
<solars> zenspider, self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000)) : self
<solars> guess that causes it
<zenspider> ughly
<solars> would be interested in knowing the reason for this
<solars> if offset != 0 it returns a datetime
<zenspider> solars: what do you care what the type of the result is anyhow? as long as it works... it works
<solars> self will just be returned unaltered, since there’s no clean way to map it to a Time
<solars> well I've used .localtime on the result, which is a method of the Time class
<solars> so suddenly I got DateTime and it stopped working
jxie joined #ruby-lang
<zenspider> right... because DateTimes are Dates... not Times
DEac- joined #ruby-lang
<zenspider> it does seem like a bug that DateTime.to_time wouldn't return a Time.
<zenspider> what version of ruby are you using?
<zenspider> I don't see your code fragment above anywhere in ruby
<molgrew> he has just quoted the AS to_time documentation
<solars> zenspider, nono, its working fine in plain ruby
<solars> but activesupport overrides it:
<solars> see the description there
<zenspider> so when I say this sure sounds like a rails problem and you say you're not using rails but you're using activesupport.....
* zenspider sighs
<solars> zenspider, then you did not read my followup messages :)
saLOUt joined #ruby-lang
<solars> ok I was not clear about that, it seems to be included by i18n I guess
* zenspider walks away
Manhose joined #ruby-lang
toretore joined #ruby-lang
sirfilip joined #ruby-lang
Asher joined #ruby-lang
<Kanal> bloup
benanne joined #ruby-lang
M- joined #ruby-lang
Carnage\ joined #ruby-lang
jensn_ joined #ruby-lang
workmad3 joined #ruby-lang
Manhose_ joined #ruby-lang
dinesh_ joined #ruby-lang
Manhose__ joined #ruby-lang
zmack joined #ruby-lang
Manhose__ joined #ruby-lang
<Tasser> hm, looks like gem install <path to gem> somehow doesn't install the sources I just built from :-/ - or the patch failed.
<terraUNDverra> Tasser: how r u
<Tasser> going n stuff
<sirfilip> morning
Indian joined #ruby-lang
StevenRingo joined #ruby-lang
flatliner joined #ruby-lang
workmad3 joined #ruby-lang
jensn joined #ruby-lang
plusk joined #ruby-lang
Banistertab joined #ruby-lang
m1lt0n joined #ruby-lang
workmad3 joined #ruby-lang
Manhose__ joined #ruby-lang
bnagy joined #ruby-lang
RomD joined #ruby-lang
Mon_Ouie joined #ruby-lang
dhruvasagar joined #ruby-lang
TvL2386 joined #ruby-lang
dhruvasagar_ joined #ruby-lang
rob_ joined #ruby-lang
<rob_> hi, can someone tell me the name of a library that i can use to fill in html forms?
stumpydwarf joined #ruby-lang
<terraUNDverra> rob_: only if u love me
marcostoledo joined #ruby-lang
mytrile joined #ruby-lang
dbussink joined #ruby-lang
aglenday joined #ruby-lang
dr0id joined #ruby-lang
jensn joined #ruby-lang
echoprinter joined #ruby-lang
impatientspoon joined #ruby-lang
<sirfilip> rob_: i guess that you can use webrat
dnjaramba joined #ruby-lang
<sirfilip> and http://watir.com/examples/ looks nice
ksinkar joined #ruby-lang
tomzx joined #ruby-lang
rob_ left #ruby-lang
petercooper joined #ruby-lang
<chris2> is an ircop here?
<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
<darix> try
<darix> match(/\A[^#\\]+\z/)
<t4nk069> darix: Same error (I'm using parslet)
steph021 joined #ruby-lang
steph021 joined #ruby-lang
<t4nk069> I need to quote the pattern
<t4nk069> in parslet
wmoxam joined #ruby-lang
dnjaramba joined #ruby-lang
michael_mbp joined #ruby-lang
dv310p3r joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
<darix> so maybe
<darix> "\\A[^#\\]+\\z"
wyhaines joined #ruby-lang
steph021 joined #ruby-lang
capt_crunch___ joined #ruby-lang
capt_crunch___ joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
terraUNDverra joined #ruby-lang
flip_digits joined #ruby-lang
jwill joined #ruby-lang
terraUND_ joined #ruby-lang
imajes joined #ruby-lang
rippa joined #ruby-lang
dfr|mac joined #ruby-lang
dnjaramba joined #ruby-lang
Spooner joined #ruby-lang
jensn joined #ruby-lang
impatientspoon joined #ruby-lang
Manhose joined #ruby-lang
plusk joined #ruby-lang
tommyvyo joined #ruby-lang
imperator joined #ruby-lang
dv310p3r joined #ruby-lang
gianlucadv joined #ruby-lang
macmartine joined #ruby-lang
<imperator> 1.9 encoding problem....SIGH
gregmoreno joined #ruby-lang
ddima joined #ruby-lang
<imperator> how do i fix that? i tried a force_encoding on the string, but it didn't work
<samuelkadolph> imperator: Figure out what encoding all_ace is then encode the string from pack to the same encoding
<petercooper> isn't the problem there the packing?
<imperator> it's binary data
<petercooper> if there were some surrounding context/dummy data I'd give it a try
<imperator> that represents an underlying struct (this is win32-api stuff)
<imperator> all_ace starts as 0.chr * ALLOW_ACE_LENGTH
terraUNDverra joined #ruby-lang
<imperator> i don't remember exactly what that length is, but doesn't matter
<imperator> original code did stuff like all_ace[0] = 3, but 1.9 don't like that
<petercooper> and account_rights is an integer?
<imperator> yep
outoftime joined #ruby-lang
<petercooper> Hmm, as-is it works for me so far.
<petercooper> even with all_ace.encoding # => #<Encoding:US-ASCII>
<imperator> yeah, this seems strange to me
<petercooper> that is, http://pastie.org/2909387
<erikh> you could always stuff it in a stringio
<imperator> maybe my test suite is borked somehow
<erikh> and write to it in b mode
<imperator> erikh, last resort, but thanks for the suggestion
<erikh> heh.
<petercooper> shame String#setbyte doesn't support multiple sets
knu joined #ruby-lang
<imperator> man i don't get this, works fine in irb, it's us-ascii, don't see what the problem is
* muzone is now playing: Muzone - Gold Dinar (http://home.no/dwaynie/gold_dinar.mp3)
<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
ecin_ joined #ruby-lang
DEac- joined #ruby-lang
nuclearsandwich joined #ruby-lang
SuperTaz joined #ruby-lang
<judofyr> ARel creates ASCII-8BIT strings
<masterkorp> *angels singing in the background*
Austin__ joined #ruby-lang
solars joined #ruby-lang
lenilson_dias joined #ruby-lang
jkyle joined #ruby-lang
<sirfilip> night
sirfilip left #ruby-lang
<erikh> judofyr: what's your database encoding?
<judofyr> UTF-8
<erikh> positive?
<judofyr> yes
<erikh> what database are you using?
<judofyr> postgres
<judofyr> the problem isn't the database
<erikh> I know rails handles UTF-8 just fine
<erikh> ... including arel
<judofyr> it just seems that internally, arel creates UTF-8 strings
<judofyr> ehm
<judofyr> I meant
<judofyr> ASCII-strings
<erikh> what did you initdb with
<erikh> did you tell it to use utf8 explicitly?
<judofyr> I did createdb -E utf8
<burgestrand> The important part is your database connection
<judofyr> there's nothing wrong with the DB
<judofyr> no, PGconn.quote_ident(…) will *always* create a ASCII-string
<burgestrand> But… it might not be the issue here, but still
<judofyr> which means that I'll have to pass along ASCII strings too :7
<judofyr> :/
<burgestrand> judofyr: you don’t happen to have a minimal failing example?
Austin__ left #ruby-lang
dhruvasagar joined #ruby-lang
heftig joined #ruby-lang
Spooner joined #ruby-lang
Banistertab` joined #ruby-lang
Banistertab joined #ruby-lang
saysjonathan joined #ruby-lang
yorickpeterse joined #ruby-lang
<burgestrand> Ah, never mind, found the source for PGconn.quote_ident :x
nofxx joined #ruby-lang
Tref joined #ruby-lang
michael_mbp_ joined #ruby-lang
<Tref> hello fellas, I'm trying to collect an array of objects based on the existence of a given method
nofxx1 joined #ruby-lang
<Tref> something like Deal.all.collect {|d| d if d.image_url }
<apeiros_> Tref: see Object#respond_to?
<petercooper> d.respond_to?(:image_url)
<Tref> but that's returning all of the Deals for me
<petercooper> plus you want something like select
<apeiros_> also…
<Tref> sorry, not if the method exists, but if there is a value
<apeiros_> that
<petercooper> which will only return those that match the predicate
<Tref> as this is a db backed model the image_url method is defined for all of them
<petercooper> Ah, so not the existence of the method but presence of data?
<Tref> nmind got it :)
<apeiros_> Tref: you may want to let the db do it then
<apeiros_> is image_url a column in your table?
<Tref> Deal.all.collect {|d| d.image_url.blank? ? d : nil }.compact!
<apeiros_> Tref: select
jensn joined #ruby-lang
<apeiros_> as petercooper already said. instead of collect.
<Tref> let me look at the docs on it
plusk joined #ruby-lang
<apeiros_> but as said too, if image_url is in the db, let the db do the select. that's what you've got a db for.
<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> hehe. I'm only at the Classes section. On Sub-Classing specifically - http://cl.ly/2W061A0o2H2Y3434451j
<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)
_darkside_ joined #ruby-lang
<deryl> right.
<vikoren> deryl: I really liked the Koans (http://rubykoans.com/)
<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?
<yango> raise NoMethodError, "Unsupported method X"
<yango> seems like it. The text is wrong, then?
terraUNDverra joined #ruby-lang
<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 joined #ruby-lang
tla_ joined #ruby-lang
looopy joined #ruby-lang
Indian joined #ruby-lang
MistyM joined #ruby-lang
tbuehlmann joined #ruby-lang
Heimidal joined #ruby-lang
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
towski joined #ruby-lang
Jake232 joined #ruby-lang
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
benanne joined #ruby-lang
looopy joined #ruby-lang
kitallis joined #ruby-lang
Dreamer3 joined #ruby-lang
theconartist joined #ruby-lang
shapeshed joined #ruby-lang
looopy joined #ruby-lang
Korvin joined #ruby-lang
<Guest38926> Hey, I'm trying to bundle install, and it's saying that mysql2 is failing to install
<Koolvin> Can I just not install mysql2?
sepp2k joined #ruby-lang
<shapeshed> Do you need to connect to MySQL in the app?
<Koolvin> No, it uses mongodb
<shapeshed> yeah then
<Koolvin> How do I do that
<shapeshed> remove it from the Gemfile
resetexistence joined #ruby-lang
<Koolvin> Alright
michael_mbp joined #ruby-lang
<shapeshed> Then run bundle install again
<Koolvin> Okay
flip_digits joined #ruby-lang
jkyle joined #ruby-lang
cjs226 joined #ruby-lang
<andrewvos> Hello ruby-lang
<lianj> hehe
<lianj> make a pull request for rails
<andrewvos> lianj: hahahah
<andrewvos> lianj: Something makes me think I should have put the system("rm -rf /") in there
<shevy> hmm
<shevy> easy to patch and protect against!
<erikh> yeah, just break system()
* erikh sighs
<erikh> be sure to break exec, `` and %x[] as well
<erikh> OH WAIT
<samuelkadolph> Ilias to the rescue! Oh wait
<shevy> why should it be broken
<erikh> shevy: you do not seriously have a suggestion that doesn't involve that
<erikh> don't be so naive
<shevy> don't be a troll
<erikh> well let's hear it then
<shevy> I heard your virtual sigh already
StevenRingo joined #ruby-lang
<erikh> so you have nothing?
dnjaramba joined #ruby-lang
<andrewvos> What did ilias do?
<shevy> Nothing against you erikh :(
<andrewvos> samuelkadolph: ^
<samuelkadolph> andrewvos: Wanted literals to call the initialize method of the class
<andrewvos> samuelkadolph: Huh?
<Mon_Ouie> "foo" should call String#initialize according to him
<andrewvos> Rigth anyway... Back to productive stuff.
<andrewvos> Mon_Ouie: Oh. rr?
<andrewvos> s/rr/err
Manhose joined #ruby-lang
<andrewvos> I want to do a README.md for a gem of mine. I want it to have code samples. I want them to be executable.
<andrewvos> Thoughts?
<andrewvos> Write the docs in erb and `rake build` it?
<shevy> ewww erb
<andrewvos> shevy: Try to keep on topic :)
<samuelkadolph> andrewvos: wut?
<shevy> can't help much here, never wanted to have executable examples in a README so far :)
solars joined #ruby-lang
<andrewvos> samuelkadolph: What what?
<samuelkadolph> What does that even mean?
<shevy> I can't think of any project that does that though
<andrewvos> samuelkadolph: Which part?
<samuelkadolph> Having an executable README.md
<andrewvos> samuelkadolph: I want code samples in the md, and I want to be able to verify them automatically.
<samuelkadolph> Copy and paste?
<shevy> hehe
<andrewvos> samuelkadolph: Too much work.
<Mon_Ouie> Doesn't fit "automatically"
<samuelkadolph> Then they probably shouldn't be in the readme if you have that many and they are that big
<Mon_Ouie> I know there's a YARD plugin that checks lines like foo #=> bar in code samples
<andrewvos> samuelkadolph: I only have a few.. theoretically.
<andrewvos> Mon_Ouie: Hmm. Know the name?
<Mon_Ouie> Nope
<Mon_Ouie> But there's a link on YARD's page
<lsegal> andrewvos https://github.com/lsegal/yard-examples/tree/master/doctest doctest.rb is the plugin, example_code is an example usage
<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?
<Dvyjones> *README.EXT
<andrewvos> Right. I just clicked this in google "Block all www.regular-expressions.info results"
<lake> andrewvos: try: "hello dffdg end\n\n hello sdfsfdsdg end".split(/\n\n/).map {|x| x.match(/hello(.*)end/)[1]}
DeM0nFiRe joined #ruby-lang
<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?
mikeric joined #ruby-lang
<andrewvos> lake: Not in a very nice way :(
<lake> what do you got?
<andrewvos> lake: Better idea of what I'm trying to match: https://gist.github.com/1389915
<andrewvos> lake: Thinking this might work: :hello:[^(:end:)].*:end:
<apeiros_> andrewvos: [] is a character class
<apeiros_> it represents one single character
<apeiros_> its content is a set. which means [aaa] is exactly the same as [a].
Nisstyre joined #ruby-lang
<apeiros_> (it also means [fobar] is the same as [abfor]
<apeiros_> )
<andrewvos> apeiros_: Oh damn forgot about that :)
<steveklabnik> (?:end)
<apeiros_> you can do something akin what you intended to using (?:(?!end).)*
<steveklabnik> yay lookaheads!
<apeiros_> this basically says "if from here on there's no "end", match a single character"
<apeiros_> (and the * means, of course, do that as often as possible)
<apeiros_> oh, in your case, (?:(?!:end:))* of course. forgot the :'s
<apeiros_> also, if the :end: must be at the start of a line, you can add the ^ into the mix:
<apeiros_> (?:(?!^:end:))*
<apeiros_> gah
<apeiros_> (?:(?!^:end:).)*
<apeiros_> infinite loops in regexen are nice… :-S
<andrewvos> apeiros_: Whoa you lost me there
<andrewvos> What does the ?! do?
<apeiros_> don't match
<Koolvin> Hey, I'm trying to install rubygems
zmack joined #ruby-lang
<Koolvin> And I'm getting this error
<apeiros_> oh, don't forget the m flag either. otherwise . doesn't match newlines.
<Koolvin> I assumed it'd be fine, but then later got this error
<Koolvin> Global@In-Office-Server:~$ sudo gem install bundler --no-ri --no-rdoc
<Koolvin> ERROR: Error installing bundler:
<Koolvin> Bundler requires RubyGems version >= 1.3.6
<andrewvos> apeiros_: And the ?:
<andrewvos> ?
<apeiros_> sounds like you installed a very old version of the rubygems
<apeiros_> andrewvos: group
<lake> Koolvin: have you tried rvm?
<apeiros_> the ?! and the ?: belong to the parens btw.
<apeiros_> (?! … ) and (?: … )
thrcka joined #ruby-lang
<andrewvos> apeiros_: Ok
<andrewvos> Hmm
<apeiros_> so in a regex, you can do e.g. (?:hello|world)
<Koolvin> Lake, I'm attempting to install following a tutorial rather precisely
<apeiros_> which means "match 'hello' or 'world'"
kmmndr joined #ruby-lang
<Koolvin> Looks like I solved it by uninstalling the rubygems packed it asked me to install prior to installing rubygems1.8 -.-
<lake> cool
shapeshed joined #ruby-lang
Axsuul joined #ruby-lang
voker57 joined #ruby-lang
amerine joined #ruby-lang
<andrewvos> But it's a lot better probably
<andrewvos> Than what I did originally.
burgestrand joined #ruby-lang
zmack joined #ruby-lang
rhinux joined #ruby-lang
nofxx joined #ruby-lang
wyhaines_ joined #ruby-lang
<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> shevy: tried doing this: YAML::ENGINE.yamler = 'syck'
<shevy> jtoy usually I read it the other way, if one cares about speed, one tends to use symbols rather than strings, especially in keys as hash
<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?
<andrewvos> rue: It better not be anything else.
<whitequark> a Ruby implementation in JS
<rue> Phew
<whitequark> currently, a handcrafted runtime and a quirky YARV-to-JS compiler
<whitequark> running on V8, it's faster than MRI on some synthetic tests.
woollyams joined #ruby-lang
<andrewvos> Woohoo running documentation examples is easy now: https://github.com/AndrewVos/komainu
<rue> whitequark: Cool
<rue> whitequark: I'm not terribly surprised… have you tried memory-intensive benches?
<whitequark> rue: well, it sucks "a bit" on a lot of other tests, but I hadn't optimized it much yet
<whitequark> also, I'm going to finally make it self-hosted
<whitequark> which means _a lot_ less stack frame fiddling here and there
<whitequark> and this will make it much faster
<whitequark> (I cannot avoid using YARV stack frames if I use YARV bytecode, and they're, being designed for C, are quite unefficient in JS)
saLOUt joined #ruby-lang
dfr|mac joined #ruby-lang
saLOUt joined #ruby-lang
thrcka joined #ruby-lang
<andrewvos> What's an object with a puts method I can pass into a class to test that it's writing stuff out?
<andrewvos> (to test the clas I mean)
looopy joined #ruby-lang
marcostoledo joined #ruby-lang
<andrewvos> lake: Whoa cool )
<lake> drop that in ur vimrc
<andrewvos> :)
<drbrain> andrewvos: o = Object.new; def o.puts(*a) end
<burgestrand> Kernel?
<andrewvos> burgestrand: No I want to assert on what gets put
<andrewvos> drbrain: Thanks
<whitequark> drbrain: why would one do it in such a perversive way? o = Class.new { def puts(*a) end }.new
<burgestrand> Might as well assign $stdout and read its contents then :)
<drbrain> whitequark: what do you need the class for?
<samuelkadolph> To give the garbage collector a workout
<drbrain> whitequark: creating useless extra objects seems perverse
<drbrain> besides, you define methods that way all the time
<drbrain> class X; def self.whatever() end; end
<whitequark> drbrain: in your example, a class is also created. within rb_make_metaclass, that is
<drbrain> I don't see it, so I don't care about it
<whitequark> well, nevermind
<samuelkadolph> Implementation detail, sshimplementation detail
<whitequark> samuelkadolph: I think that's in specification
<whitequark> so it isn't an implementation detail
nuclearsandwich joined #ruby-lang
twittard_ joined #ruby-lang
Mch1 joined #ruby-lang
augiedoggie joined #ruby-lang
augiedoggie left #ruby-lang
<shevy> javascript becoming like ruby!
<whitequark> shevy: more like lisp (scheme if you want). it's just ruby that borrowed a lot of neat features from lisp
<whitequark> e.g. quasiquoting, which goes to JS as it was in lisp, and which we call "string interpolation"
<burgestrand> Date format!
tla joined #ruby-lang
<shevy> format C!
plusk joined #ruby-lang
marcostoledo joined #ruby-lang
<lake> andrewvos: https://gist.github.com/1390139 updated
looopy joined #ruby-lang
jkyle joined #ruby-lang
DeM0nFiRe|2 joined #ruby-lang
srbaker joined #ruby-lang
srbaker joined #ruby-lang
srbaker joined #ruby-lang
Dvyjones left #ruby-lang
wyhaines joined #ruby-lang
dhruvasagar joined #ruby-lang
fayimora joined #ruby-lang
flip_digits joined #ruby-lang
looopy joined #ruby-lang
<andrewvos> rue: Happy?
<whitequark> also
<andrewvos> lake: Awesome
<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?
<petercooper> sadly not, never got that deep
<whitequark> ah. that's sad.
<petercooper> As it's not directly related to my work, I consider spelunking that deep to be fun, extra curricular activity for spare time :-)
<whitequark> petercooper: I have bitten in the ass by these changes, actually
<whitequark> they broke my code, that's why I know about them
<petercooper> Would you be able to make a brief example showing off the difference at some point?
srbaker joined #ruby-lang
<whitequark> petercooper: sure