apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
<yekta> So I made a gem and released it to my internal gem server using geminabox, however when I install the gem from my gem-server it doesn't seem to install the dependencies, shoudln't the dependencies automatically be installed? (I have them in my gemspec.)
<davidcelis> geminabox
<davidcelis> lawl
<yekta> :)
<davidcelis> won't it look for the dependencies on your internal gem server?
<yekta> Oops, I see I made them development dependencies
<yekta> I guess I gotta switch that to add_runtime_dependency
<davidcelis> ah
<yekta> Do I need separate declarations for development too?
<yekta> or will runtime suffice
hzlocky has joined #ruby
<hzlocky> Guys, I want to mix into true, false, nil method [], is it sounds rational?
<fowl_> no
<fowl_> dont do it just because you can
<hzlocky> but why?
<hzlocky> I am curious why it is bad idea?
BigFatFatty has quit ["Leaving"]
<shadoi> yekta: development dependencies are for things like rdoc and debugging tools
<shadoi> documentation, testing, coverage, debugging, etc.
<shadoi> hzlocky: Monkey patching is generally bad if you modify core language behavior.
wmoxam has joined #ruby
<shadoi> hzlocky: you can't predict how other libraries have used those things and what you'll break by changing it.
andrewhl has joined #ruby
SolarisBoy has joined #ruby
andrewhl has joined #ruby
dfamorato has joined #ruby
nif has joined #ruby
Bartzy has joined #ruby
<rking> An algorithm that checks every element against every other element (like people shaking hands in a meeting) is... O(N*log(N))?
<rking> I'm not so great with this O() biz.
<rking> Not for homework, btw. Only curious. =)
dfamorato_ has joined #ruby
<shadoi> explanation I always use
<rking> Coolness.
<rking> I like things people always use.
<rking> shadoi: Do you have any other explanations of things you always use?
vaxinate has joined #ruby
<rking> OK so it's definitely not log(anything)
<shadoi> BrainException: stack level too deep
<rking> I think it's the O(2^n) case. =(
jwang has joined #ruby
Asebolka has joined #ruby
<rking> Hrm. I found one algorithm that says the total handshakes is n(n-1)/2+n
<rking> Which if I squint is almost n^2/n
<rking> Or maybe not. I suck.
<shadoi> here's one I just found that's got a lot more real-world examples: http://www.cforcoding.com/2009/07/plain-english-explanation-of-big-o.html
<rking> K, yeah, I'm going to have to read these both, carefully.
otters has joined #ruby
<rking> But later. At the moment I'm busy furiously writing the awesome codez into the computir.
<shadoi> The codez are the important part anyway. Worry about optimizing and navel gazing about O notation after everything works nicely. :)
<rking> Right. =)
ZachBeta has joined #ruby
tommyvyo has joined #ruby
wedgex has joined #ruby
macmartine has joined #ruby
otters has joined #ruby
otters has joined #ruby
ryanf has joined #ruby
otters has joined #ruby
MrGando has joined #ruby
Chaazd has joined #ruby
hackingoff has joined #ruby
machine2 has joined #ruby
TomJ has joined #ruby
<Chaazd> Im getting an unexpected ':' expecting keyword_end and unexpected keyword_end expecting ':' on lines 8 and 10 respectively no idea why. http://pastie.org/3771569
<hackingoff> Space out your usage of the ternary operator's ?.
TomJ has joined #ruby
shevy has joined #ruby
* hackingoff doesn't understand why the function is being repeatedly defined inside of the loop.
mfridh has joined #ruby
banisterfiend has joined #ruby
<shadoi> macmartine: if you look at the examples in the docs it includes a time including the GMT offset.
* hackingoff bleaches his eyes.
carlyle has joined #ruby
<shadoi> holy christ crackers that's some hideous code.
<hackingoff> Yeah.
<Chaazd> My first attempt at tinycode
<Chaazd> Prety horrible
<hackingoff> May want to have things spread across multiple lines and ensure they work BEFORE obfuscating it.
<shadoi> why tiny?
<shadoi> ruby's entire purpose for existing is expressive, easy to understand code.
<Chaazd> r/tinycode
dbgster has joined #ruby
<Chaazd> I wanted to try
<shadoi> You do need the spaces for the ternary operator
<hackingoff> It says minimalistic, not obfuscated, right?
<hackingoff> I'm looking at the sidebar, even though I didn't know of that subreddit's existence.
<hackingoff> It's also idiomatic to use {} instead of do-end for one-line blocks, though that's not really the root of any problems.
philcrissman has joined #ruby
<shadoi> it would help shrink and obfuscate it. :)
<hackingoff> E.g.: a.each{|e| stuff}
joaoh82 has joined #ruby
<Chaazd> Revised, but with same problems http://pastie.org/3771596
<hackingoff> I think your def will also need to be def s(x); ... ; end
jitesh_shetty has joined #ruby
emmanuelux has joined #ruby
<shadoi> Chaazd: all the ternary expressions need to be based on a boolean
<banisterfiend> hackingoff: u dont always need the ;
<hackingoff> May as well do while !done while you're at it.
<hackingoff> banisterfiend: TIL
<shadoi> untile done
<banisterfiend> hackingoff: GIL
<shadoi> until done*
CannedCorn has joined #ruby
<CannedCorn> guys what is the best way to remove a prefeix from the front of a line? gsub?
<hackingoff> gsub will be global, throughout the string.
<hackingoff> Do you know the exact length of the prefix?
<hackingoff> If so, you can just do s[offset..-1]
<otters> or sub
<CannedCorn> nah i need sub
<CannedCorn> cause it could be ">"
<CannedCorn> or "> "
<CannedCorn> was thinking: line.sub(/^>\s*/,"").strip
<hackingoff> Is it only those two cases?
<hackingoff> Ah.
<hackingoff> Won't strip kill all the rest of the line's whitespace?
<CannedCorn> yeah but there should be stuff in between
headius has joined #ruby
<CannedCorn> so i want to remove the leading ">" + whitespace, get the meat, and trim whitespace off the back
<shadoi> s.sub(/^>\s/, '')
<hackingoff> The slyest way to get rid of a > and an arbitrary amount of whitespace would be s[1..-1].lstrip, IMO.
<hackingoff> *leading whitespace
<hackingoff> If you're guaranteed to have that stuff in that position, it seems unncessary to incur the cost of a regex,
<shadoi> s.sub(/^>\s+?/, '') if you need to to handle no whitespace also
<hackingoff> s+? = s* ;p
<CannedCorn> thats what i had
<CannedCorn> didn't really understand hackingoff's method
<hackingoff> Which method?
<shadoi> hackingoff: yeah, I always expect * to match more than I wanted though
<Chaazd> The {} actually added a tIdentifier problem. And they are based off of booleans. (I think) http://pastie.org/3771611
<shadoi> Chaazd: you're not ending some of your blocks
<hackingoff> Sometimes ruby complains at me if I don't ()-wrap the boolean expression, so that may eventually be something you run into as well.
<hackingoff> s/ruby/MRI/
<shadoi> Chaazd: and you'd be much better off using a case statement on a
Chryson has joined #ruby
<hackingoff> shadoi: Is "+?" somehow less greedy than "*"?
davidcelis has joined #ruby
* hackingoff has been working with finite automata, so is habituated to thinking of those two expressions as interchangeable.
<shadoi> hackingoff: no I think it's equivalent like you said, just some mental block I have :)
<shadoi> too many shell expansion woes I think
<hackingoff> Chaazd: I think the thing you really want to do is write a version that doesn't attempt to compact everything, and then work on compacting it one step at a time, because there're probably more problems lurking there than you suspect.
<shadoi> Chaazd: the way you have it, all of those ternary expressions are nested.
<Chaazd> I'm actually compacting someone else's code
<shadoi> the colon means "OR"
<shadoi> or more precisely "else"
brngardner has joined #ruby
<Chaazd> And I think you're right, I should probably fix that before making it compact. My intention is an elsif, how may I do that?
<hackingoff> You can nest ternary operators to do that.
<shadoi> Chaazd: use a case.
headius has joined #ruby
<hackingoff> (cond) ? stuff : ((elsifcond) ? elsiftruestuff : elsiffalsestuff)
<hackingoff> Depending on the nature of the condition, you can also take a page from Python idioms and use a dict...
kevinbond has joined #ruby
philips has joined #ruby
dfamorato has joined #ruby
<shadoi> Or just use a case, because it's the clearest. :)
<Chaazd> How compact can I get a case
<hackingoff> Well, he's doing that r/tinycode thing.
<Chaazd> Could you give an example?
<hackingoff> case cond; when 'a' then foo; when 'b' then bar; else; baz ;end
<hackingoff> It's ugly as hell to do it all on one line.
<shadoi> let him make the thing WORK
<shadoi> and then he can obfuscate it a lot easier.
<hackingoff> Yeah, uh... Haha, true.
<Chaazd> Alright
<Chaazd> Making it a case :P
<hackingoff> You can also do assignment via case, IIRC.
<hackingoff> a = case cond ... where a gets assigned the last thing in any when block that triggers.
<hackingoff> Keep in mind that ruby's case/when is not like switch/case in that all whens implicitly end with "break" from C-likes.
<hackingoff> (Read: no fall-through.)
startling has joined #ruby
<macmartine> hackingoff: i tried that too
freeayu has joined #ruby
dhruvasagar has joined #ruby
<Chaazd> It's throwing up errors over the 'then's
<macmartine> hackingoff: https://gist.github.com/2364055
<hackingoff> Your else's block needs to be on a separate line.
<hackingoff> (I have no idea why.)
nerdy_ has joined #ruby
apok has joined #ruby
<macmartine> oh! it's updatedMin in this case. sheesh.
<Chaazd> Now over the 'when's -_-
<macmartine> actually, no, still doesn't work
<macmartine> updatedMin returns 0 result even if I set the year to 1800
<shadoi> Chaazd: what error?
<hackingoff> macmartine: I'm not sure who was initially helping you with that, but I don't think it was me.
<Chaazd> Unexpected, expecting end
<macmartine> hackingoff: oh, sorry
<hackingoff> No problem. :-)
<macmartine> shadoi: adding the offset makes no difference
<shadoi> macmartine: you should construct the URL from what you've put in there and see what it returns.
<shadoi> with just curl
havenn has joined #ruby
blueadept has joined #ruby
Vert has joined #ruby
Husel has joined #ruby
<hackingoff> Neither here nor there, but the current nightmare of web maint is having to consolidate old HTML/CSS into templates and/or extract all the info. I feel the nightmare of "tomorrow" will be trying to track down all of the fucking libraries, frameworks, etc., and maybe some part of that will be having to install all sorts of stuff like npm/lessc to build it all.
<Chaazd> Egh, still no luck. http://pastie.org/3771740, error log: http://pastie.org/3771745
Akuma has joined #ruby
Paradox2000 has joined #ruby
<shadoi> Chaazd: the {} replaces "do end"
senthil has joined #ruby
<hackingoff> You also don't really need to define that s function up there. You're doing a = gets.chomp.split(' ')[0] anyway, right?
<hackingoff> Oh, just saw the call with (1) down below.
<Chaazd> Yea, saves a few characters :P
<hackingoff> Sorry, missed those calls.
<shadoi> Chaazd: you can make it require ARGS to the script and just split those into ip, user, password instead of prompting
<hackingoff> Conversely, you could save more characters by just doing a=gets.chomp.split and then calling a[0] and a[1] instead of a.s(0) and a.s(1).
<shadoi> that will simplify it a ton
robbyoconnor has joined #ruby
<Chaazd> Hm yeah
<shadoi> ip, srv, pass = *ARGV
robdodson has joined #ruby
<hackingoff> If you ever need to put a back together, which you don't, you could just do a.join(' ').
<__null> Are there many alternative Ruby garbage collectors? Or is it not possible to turn off the default gc?
CheeToS has joined #ruby
etank has joined #ruby
td123 has joined #ruby
<chico> __null: why would you turn off the gc?
EzeQL has joined #ruby
headius has joined #ruby
<shadoi> __null: not for YARV/MRI, I believe rubinius played around with different strategies for GC
skipper has joined #ruby
<__null> chico: app performance for many things (including rails) is significantly dominated by the gc
<shadoi> __null: running on JRuby is probably the most sane thing to do for production sites.
<__null> shadoi: thanks. i remember seeing a custom gc in a twitter employee's gh months ago
<shadoi> __null: you might want to check out torquebox
nirjhor has joined #ruby
<shadoi> pretty nice full-stack
<__null> thanks a bunch
nirjhor has quit [#ruby]
andrewhl has joined #ruby
iori has joined #ruby
josefig has joined #ruby
josefig has joined #ruby
steg132 has joined #ruby
frishi has joined #ruby
baroquebobcat has joined #ruby
<Chaazd> Well, it doesn't throw up errors and kind of works, but throws up a weird error: http://pastie.org/3771805 error: http://pastie.org/3771803 Thanks for all your help so far, btw
baroquebobcat has joined #ruby
Cyrus has joined #ruby
<ozzloy> someone say my name please
<hackingoff> ozzloy
havenn has joined #ruby
joaoh82 has joined #ruby
<ozzloy> hackingoff, thanks
<CannedCorn> thaks for the help guys
<CannedCorn> im out
dmn001 has joined #ruby
liluo has joined #ruby
drPoggs has joined #ruby
kpshek has joined #ruby
RORgasm has joined #ruby
malcolmva has joined #ruby
ZachBeta has joined #ruby
Chaazd has quit [#ruby]
lolsuper_ has joined #ruby
richardlxc has joined #ruby
shtirlic has joined #ruby
dbgster has joined #ruby
krusty_ar has joined #ruby
bikcmp has joined #ruby
<bikcmp> where does ruby keep it's gems at?
<bikcmp> i've been 'gem install'ing stuff and it doesn't seem to go into my path
<bikcmp> or something's up
<bikcmp> WARNING: You don't have /home/jason/.gem/ruby/1.8/bin in your PATH, gem executables will not run.
<bikcmp> fair enough
nari has joined #ruby
<bikcmp> nope, still won't work when i gem install something
adamkittelson has joined #ruby
sacarlson has joined #ruby
malcolmva has joined #ruby
d2dchat has joined #ruby
vaxinate has joined #ruby
robdodson has joined #ruby
frogstarr78 has joined #ruby
ZachBeta has joined #ruby
Paradox2000 has joined #ruby
<td123> you need to put that folder into your path
Paradox2000 has joined #ruby
Paradox2000 has joined #ruby
hackingoff has joined #ruby
abra has joined #ruby
micah has quit [#ruby]
apok_ has joined #ruby
prometheus has joined #ruby
RubyRedGirl has quit [#ruby]
kah_ has joined #ruby
<kah_> hey, what's are the most common languages to use with ical
<kah_> xml?
<kah_> javascript?
<any-key> you can use javascript and ical?
<kah_> any-key: are you asking a question or saying, yes you can use javascript and ical
<kah_> ?
<any-key> I don't understand the question
<any-key> what are you trying to do with ical?
<kah_> ideally I would like to take my ical file and import in onto my bar website
<any-key> ah okay that makes a lot more sense
<any-key> the .ics format that ical exports is XML
<any-key> if you wanted to display that on a website I'd use a parser in whatever language you're using on the website to grab all the data and display it
dhruvasagar has joined #ruby
<any-key> or you can use something like google calendar and embed that
<kah_> any-key: so i'm using ruby
<kah_> any-key: that's always an option too, lets say i was to do it with ruby, how would you do that
maletor has joined #ruby
thesirdanny has joined #ruby
thesirdanny has quit [#ruby]
<any-key> I'd use Nokogiri
<kah_> hmm haven't heard of that
<any-key> parse the .ics file, pull out the information you want
<any-key> then just display it however you feel like
<havenn> kah_: Use the gem nokogiri (nokogiri.org) to parse the xml or use RiCal gem or another ical gem.
<kah_> hmm ok, cool guys thanks! I'll look into those
dhruvasagar has joined #ruby
stefanp_ has joined #ruby
jitesh_shetty has joined #ruby
zakwilson has joined #ruby
fukushima has joined #ruby
pjn_oz_ has joined #ruby
williamcotton has joined #ruby
looopy has joined #ruby
beckettsfool_ has joined #ruby
pjn_oz has joined #ruby
pac1 has joined #ruby
Asher has joined #ruby
freeayu_ has joined #ruby
c0rn has joined #ruby
cha1tanya has joined #ruby
mxweas_ has joined #ruby
ctp_ has joined #ruby
jedir0x has joined #ruby
<jedir0x> hi, is ruby 1.9 debuggable in eclipse with DLTK?
ElderFain has joined #ruby
Guest71832 has joined #ruby
ZeBordoada has joined #ruby
mxweas_ has joined #ruby
Hsparks has joined #ruby
headius has joined #ruby
sacarlson has quit [#ruby]
adeponte has joined #ruby
surfprimal has joined #ruby
tommyvyo has joined #ruby
keymone has joined #ruby
zz_skinny_much has joined #ruby
RORgasm has joined #ruby
dfamorato_ has joined #ruby
liluo has joined #ruby
Mohan has joined #ruby
Lyrics has joined #ruby
<Lyrics> Anyone in the room?
Zac_o_O has joined #ruby
delinquentme has joined #ruby
<delinquentme> OOOO OOOO!
<delinquentme> I found a bug in ruby !
<delinquentme> OOOOO!
<shadoi> lol
<shadoi> show and tell time
<delinquentme> or at least .. an inconsistency !
<mrtheshadow> lies
<Lyrics> first time on the webchat client - to join rubyonrails it says i needto be identified with services - anyone know what i can do?
<shadoi> Lyrics: /msg Nickserv help
<Lyrics> ty
<delinquentme> "http://www.intlpress.com/AJM/".split('/') # => ["http:", "", "www.intlpress.com", "AJM"]
<delinquentme> "/http://www.intlpress.com/AJM/".split('/') #=> ["", "http:", "", "www.intlpress.com", "AJM"]
<delinquentme> bug or intentional for some reason?
<shadoi> delinquentme: I don't see an inconsistency there.
<delinquentme> shadoi, so at the beginning of a string
<delinquentme> when you split it you get a ""
<delinquentme> but at the end of the string there is none
<delinquentme> lemme come up with a better example...
yekta has quit [#ruby]
<shadoi> delinquentme: "" =~ /^$/
<delinquentme> "/asdf/".split('/')
kuzushi has joined #ruby
<delinquentme> => ["", "asdf"]
<delinquentme> why not => ["", "asdf", ""] ?
<shadoi> because ^ counts and $ doesn't is sort of the basic explanation.
<delinquentme> shadoi, im just saying if you're telling me this isn't a bug im going to dislike you as a person.
<shadoi> haha
<delinquentme> actually I've only ever seen =~ used in regex comparisons
<shadoi> delinquentme: "/asdf/".split('/',3)
uris has joined #ruby
rohit has joined #ruby
<delinquentme> shadoi, no comprendo?
<shadoi> dunno how I got set to bold there
<shadoi> unless you set a limit, it strips trailing nulls.
<delinquentme> shadoi, TIL you can set a limit for split
<delinquentme> but isnt that non-uniform?
<shadoi> as compared to what?
<delinquentme> why only trailing nils = skipped
<delinquentme> well beginning nils are kept
<shadoi> well
<shadoi> sure, but that's how it works, and it's documented… ;)
ScottNYC has joined #ruby
<delinquentme> haha i was right at that page
<delinquentme> shadoi,
<delinquentme> i dont like you
<shadoi> hahaha
<delinquentme> JKJKJKJ =]
<delinquentme> shadoi, AAAHH HA!
<delinquentme> '/asdf/'.split('/',-1)
<delinquentme> HACKSSSSSSSs
<shadoi> hehe
eam has joined #ruby
jitesh_shetty has joined #ruby
deobald has joined #ruby
chimkan has joined #ruby
Mohan has joined #ruby
Mohan has joined #ruby
rohit has joined #ruby
lkba has joined #ruby
snip_it has joined #ruby
nikhgupta has joined #ruby
groovehunter has joined #ruby
<groovehunter> hi, I use rvm since some time, successfully mostly
<groovehunter> I dont have any repo packages installed on my ubuntu
<groovehunter> now i try a new project, it depends ie on thin
<groovehunter> and other stuff, all listed as packages
<groovehunter> Can I install ruby1.8 parallel to rvm ??
apok has joined #ruby
chopmo has joined #ruby
fearoffish has joined #ruby
<BryanWB> how can I set some common variables for reuse among tests in minitest testcase?
<BryanWB> i try to add vars to @frequently_used_var = "foo" in add_setup_hook but no joy
chimkan___ has joined #ruby
chimkan____ has joined #ruby
chimkan_ has joined #ruby
dfamorato has joined #ruby
chimkan_ has joined #ruby
Morkel has joined #ruby
brianpWins has joined #ruby
greenarrow has joined #ruby
snip_it has joined #ruby
dfamorato_ has joined #ruby
macmartine has joined #ruby
tatsuya_o has joined #ruby
Asher has joined #ruby
replore_ has joined #ruby
yxhuvud has joined #ruby
shadoi has joined #ruby
drKreso has joined #ruby
richardlxc has quit [#ruby]
richardlxc has joined #ruby
tewecske has joined #ruby
MrGando has joined #ruby
KL-7 has joined #ruby
JohnBat26 has joined #ruby
tewecske has joined #ruby
Mohan has joined #ruby
mephux has joined #ruby
tatsuya_o has joined #ruby
gokul has joined #ruby
startling has joined #ruby
jamesbrink has joined #ruby
hukl has joined #ruby
RORgasm has joined #ruby
tatsuya_o has joined #ruby
ed_hz_ has joined #ruby
maveoanir has joined #ruby
mxweas_ has joined #ruby
arturaz has joined #ruby
Gonzih has joined #ruby
djdb has joined #ruby
joener has joined #ruby
<joener> can somebody help me
<davidcelis> nah
<joener> send_file("#{Rails.root}/public/floor-maps/#{@bldg_level.levelMap}", :filename => @bldg_level.levelMap, :type=>@bldg_level.levelMapType, :disposition => "inline")
<arturaz> Jesus can
<joener> doesnt work
<joener> the image is garbage
<joener> can somebody
<joener> help me
<joener> i really appreciated
<joener> @arturaz just shut up if you can help OK!!!!!!
macmartine has joined #ruby
<arturaz> Ok, i'm going to sacrifice a kitty then
daniel_hinojosa has joined #ruby
<joener> funny dude
wefawa has quit [#ruby]
<joener> just shut up dude
cezar-b has joined #ruby
<joener> i know you cant help me
<joener> cause your pretending that you know Ruby
<joener> ok
dhruvasagar has joined #ruby
<davidcelis> And thus spake joener, the man who was no longer able to receive help
pygmael has joined #ruby
ChampS666 has joined #ruby
<joener> ??????
<delinquentme> "
<davidcelis> Please do not query me.
<joener> ok
<davidcelis> delinquentme: Hahha what
<arturaz> Tab instead of space in front?
<davidcelis> that's my guess as well
<delinquentme> phsyics
<joener> i think no one can help me to this room
<delinquentme> damn.
<davidcelis> OH
<davidcelis> typo
<davidcelis> lolol
<davidcelis> Hey cool, joener left
<davidcelis> what a dick
<arturaz> Heh
x0F_ has joined #ruby
dshdsgdfdf has joined #ruby
nu7hatch has joined #ruby
ryanf has joined #ruby
<any-key> wait, was he that same annoying guy that was annoying a few days ago?
iocor has joined #ruby
<delinquentme> whats the most idiomatic ruby way to remove beginning and ending spaces on a string?
startling has quit [#ruby]
sako has joined #ruby
Kireji has joined #ruby
jgrevich has joined #ruby
jgrevich has joined #ruby
workmad3 has joined #ruby
ringotwo has joined #ruby
<davidcelis> .strip
<davidcelis> oh he left
<davidcelis> oh well, he should read the docs anyway. it's not that hard
c0rn has joined #ruby
alem0lars has joined #ruby
GoBin has joined #ruby
ph^ has joined #ruby
maletor has joined #ruby
nfluxx has joined #ruby
ben225 has joined #ruby
KL-7 has joined #ruby
wilmoore has joined #ruby
jamesbrink has quit [#ruby]
IPGlider has joined #ruby
sako has joined #ruby
savage- has joined #ruby
bigkevmcd has joined #ruby
maasha has joined #ruby
Bauer1 has joined #ruby
<maasha> Hello. I want a packed string of a specifed size with zeroed unsigned integers. What is the elegant way?
<maasha> I guess a subquestion is how to create an array of a given size with only 0s?
<maasha> In Perl you can do (0) x size
<maasha> IIRC
io_syl has joined #ruby
CheeToS has joined #ruby
MasterIdler_ has joined #ruby
<maasha> Array.new(size, "\0")
drKreso has quit [#ruby]
<maasha> testing
ElderFain has joined #ruby
<maasha> Array.new(20, 0).pack("I*")
arturaz has joined #ruby
<maasha> thanks :o)
schovi has joined #ruby
ephemerian has joined #ruby
tewecske has joined #ruby
KL-7 has joined #ruby
zakwilson has joined #ruby
Eldariof-ru has joined #ruby
polysics has joined #ruby
trivol has joined #ruby
dfamorato has joined #ruby
mdw has joined #ruby
MrBar has joined #ruby
xnm has joined #ruby
ctp has joined #ruby
robert_ has joined #ruby
dfamorato_ has joined #ruby
dfamorat_ has joined #ruby
banjara has joined #ruby
luckyruby has joined #ruby
<luckyruby> for nokogiri, is it generally better to use xpath or css for searching?
maletor has joined #ruby
<luckyruby> in terms of performance
LMolr has joined #ruby
peterhil` has joined #ruby
blacktulip has joined #ruby
williamcotton has joined #ruby
dfamorato has joined #ruby
ken_barber has joined #ruby
<bounce> now I know nothing about nokogiri, but that question makes no sense whatsoever to me
eka has joined #ruby
tommg has joined #ruby
lillybing has joined #ruby
t0lkman has joined #ruby
eeadc has joined #ruby
apeiros_ has joined #ruby
jenglish has joined #ruby
abra has joined #ruby
RORgasm has joined #ruby
lobolars has joined #ruby
shruggar has joined #ruby
Mon_Ouie has joined #ruby
ben225 has joined #ruby
tyman has joined #ruby
tyman has joined #ruby
jlebrech has joined #ruby
francisfish has joined #ruby
ukwiz has joined #ruby
BiHi has joined #ruby
DuoSRX has joined #ruby
alanp_ has joined #ruby
jeznet has joined #ruby
Mohan has joined #ruby
Mohan has joined #ruby
KL-7 has joined #ruby
roolo has joined #ruby
robotmay has joined #ruby
robert_ has joined #ruby
sspiff has joined #ruby
adac has joined #ruby
bluOxigen has joined #ruby
<tyman> has anyone using the active_directory gem with 1.9?
<tyman> s/using/used/
<maasha> what do we use to output high resolution run time for e.g. number of records processed (every 10000).
<maasha> Perl has TimeHiRes
<maasha> what about Ruby?
d3c has joined #ruby
jmcphers has joined #ruby
<arturaz> miliseconds?
<arturaz> Time.now.to_f
<arturaz> Lower than that? JRuby has Java::java.lang.System.nano_time
<Mon_Ouie> Time.now.usec
<maasha> excellent
<maasha> usec it is
<Mon_Ouie> Actually you can even go as far as Time#nsec
<maasha> enuf :o)
waxjar has joined #ruby
<lillybing> Mon_Ouie: have oyu just been away on holiday?
<Mon_Ouie> Nope, Internet connection stopped to work here for a couple of days
pietr0 has joined #ruby
<lillybing> Mon_Ouie: ouch, what did u do instead?
<lillybing> Mon_Ouie: or did u just spent the entire time refreshing the google home page and staring blankly at the screen
lobolars has joined #ruby
kmurph79 has joined #ruby
tatsuya_o has joined #ruby
__main__ has joined #ruby
berkes has joined #ruby
RubyPanther has joined #ruby
sohocoke has joined #ruby
trivol has joined #ruby
workmad3 has joined #ruby
Mchl has joined #ruby
dhruvasagar has joined #ruby
ickmund has joined #ruby
Advocation has joined #ruby
dzhulk has joined #ruby
<shevy> he did what every french without internet does
<shevy> he danced on the streets!!!
fivetwentysix has joined #ruby
<fivetwentysix> whats the correct way to test that a class includes a module
sohocoke has joined #ruby
<apeiros_> fivetwentysix: SomeClass < SomeModule
<fivetwentysix> apeiros_: example with assertion/shoulda?
williamcotton has joined #ruby
<apeiros_> nocando
mengu_ has joined #ruby
bier has joined #ruby
<workmad3> fivetwentysix: do you really need to test that?
<fivetwentysix> workmad3: not really, it's covered by my integration tests, but i want a unit test for all production code lol
<workmad3> fivetwentysix: ... you want to create useless tests that add no value?
<workmad3> fivetwentysix: nice to see you have money to burn ;)
<fivetwentysix> workmad3: nice insult
<workmad3> :)
<workmad3> fivetwentysix: seriously though... think about how long it will take to write that test (obviously that's already reaching 15 mins) compared to how much utility it actually gives you
<workmad3> fivetwentysix: and add to that the fact that if this changes in the future, you will then need to change both your integration tests and your unit tests
<workmad3> (and if it isn't going to change and already works... why add extra tests to it? :) )
<fivetwentysix> workmad3: good point
<fivetwentysix> workmad3: its just weird looking at a spec
<fivetwentysix> and it not completely covering the file it's testing
Mohan has joined #ruby
Mohan has joined #ruby
<Advocation> hey guys, I have a weird issue with Git after installing rbenv.
<Advocation> if I type 'git' into terminal, it comes up with -bash: git: command not found
<Advocation> it was working before installing rbenv, but I'm just wondering what I've messed up!
<Advocation> fairly new to this stuff..
<Advocation> anyone got any ideas?
twinturbo has joined #ruby
SPYGAME has joined #ruby
berserkr has joined #ruby
banisterfiend has joined #ruby
dfamorato_ has joined #ruby
jesly has joined #ruby
<jesly> any good gem via which i can manage external processes??
iocor has joined #ruby
jenglish has joined #ruby
jenglish has joined #ruby
pygmael has joined #ruby
flou has joined #ruby
tk__ has joined #ruby
Squarepy has joined #ruby
FACEFOX has joined #ruby
dfamorato has joined #ruby
batmanian has joined #ruby
FACEFOX has joined #ruby
tvw has joined #ruby
dfamorat_ has joined #ruby
FACEFOX has joined #ruby
FACEFOX has joined #ruby
Axsuul has joined #ruby
radoen has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
<radoen> hi mate
<radoen> i've trouble with singleton someone can take a look at http://pastebin.com/5P8TTiPY
BrianE has joined #ruby
luckyruby has joined #ruby
iocor has joined #ruby
richardlxc has joined #ruby
replore_ has joined #ruby
RORgasm has joined #ruby
richardl1c has joined #ruby
S1kx has joined #ruby
fortysixandtwo has joined #ruby
LMolr has joined #ruby
jds has joined #ruby
hukl has joined #ruby
<shevy> that code is a mess
<shevy> even @@class variables, and it is complicated anc convoluted
<shevy> when you have a problem, it is best to bring it down to the most simplest form
ken_barber has joined #ruby
<shevy> like a few lines where you can reproduce the problem, and also say what you expected or want to have instead
bluenemo has joined #ruby
arturaz has joined #ruby
<Mon_Ouie> shevy: Check #ruby-lang
<Mon_Ouie> radoen: do not cross post like that
fr0gprince_mac has joined #ruby
Mohan has joined #ruby
Mohan has joined #ruby
richardlxc has joined #ruby
<shevy> ah I see
nari has joined #ruby
arnihermann has quit [#ruby]
t0lkman has quit [#ruby]
williamcotton has joined #ruby
pibako has joined #ruby
falena has joined #ruby
pibako has joined #ruby
ukd1 has joined #ruby
clockwize has joined #ruby
<TTilus> fivetwentysix: you need to think what you are up to with testing
<TTilus> fivetwentysix: is it complete line coverage, branch coverage, path coverage or just plain you being sure that what you do works?
pibako has joined #ruby
freenetw has joined #ruby
pibako has joined #ruby
Squarepy has joined #ruby
akemrir has joined #ruby
dbgster has joined #ruby
LMolr has joined #ruby
banjara has joined #ruby
LMolr has joined #ruby
freenetw has quit ["Bye"]
pibako has joined #ruby
davidpk has joined #ruby
pibako has joined #ruby
bluelf has joined #ruby
pibako has joined #ruby
emmanuelux has joined #ruby
dhruvasagar has joined #ruby
sheldonh has joined #ruby
sheldonh has quit [#ruby]
davidcelis has joined #ruby
frishi has joined #ruby
ph^_ has joined #ruby
williamcotton_ has joined #ruby
iamjarvo has joined #ruby
krusty_ar has joined #ruby
eam has joined #ruby
Kireji has joined #ruby
nu7hatch has joined #ruby
radic has joined #ruby
_AlbireoX has joined #ruby
nanderoo has joined #ruby
iocor has joined #ruby
Ammar01 has joined #ruby
mcwise has joined #ruby
cha1tanya has joined #ruby
davidpk has joined #ruby
fayimora has joined #ruby
ph^ has joined #ruby
xcvd has joined #ruby
JCBK has joined #ruby
<JCBK> is there some way to get wildcards to work with dir.foreach?
JohnBat26 has joined #ruby
kmurph79 has joined #ruby
mdw has joined #ruby
riginding has joined #ruby
wvdschel has joined #ruby
RORgasm has joined #ruby
sectionme has joined #ruby
fermion has joined #ruby
ph^ has joined #ruby
`brendan has joined #ruby
dshdsgdfdf has joined #ruby
<Mon_Ouie> Use Dir.glob instead?
tijmencc has joined #ruby
mcwise has joined #ruby
BiHi has joined #ruby
<JCBK> Mon_Ouie yeah did that now, works well. but then I want to write the whole bunch to a single string, how do I do that?
<Mon_Ouie> I don't know what you mean by that. #join?
<JCBK> well the whole process I'm trying to accomplish is this
apok has joined #ruby
<JCBK> scan a directory for html files, omit the directory and the extension (so /foo.html and /foo/bar.html become foo and /foo/bar) and then write it all to all json file
ken_barber1 has joined #ruby
jbw has joined #ruby
lorandi has joined #ruby
ken_barber1 has joined #ruby
n1x has joined #ruby
<canton7> JCBK something like Dir.glob('**/*.html').map{ |f| f.chomp('.html') } (there might be a neater way to get the extension off)
n1x has quit [#ruby]
<apeiros_> canton7: I doubt it. it's a very nice way IMO.
<canton7> sweet!
<JCBK> cheers
jenglish has joined #ruby
<canton7> I always feel like I should be using strip/lstrip/rstrip to get arbitrary characters off the ends of a string, and chomp to get whitespace off the end
<JCBK> I've got this right now: Dir.glob('../_site/**/*.html') {|x| puts "#{x}, "}
<JCBK> how would I implement chomp into that?
fbernier has joined #ruby
rking has joined #ruby
Kireji has joined #ruby
Advocation has joined #ruby
<JCBK> because I need to omit both "../_site" and ".html"
fr0gprince_ has joined #ruby
<apeiros_> to omit the "../_site", use Dir.chdir
<apeiros_> Dir.chdir("../_site") { …glob stuff… }
eam has joined #ruby
<canton7> pastie.org/3773895 for one way of doing it
iocor has joined #ruby
* apeiros_ prefers {} for return-value (and do/end for side-effect)
chico has joined #ruby
<JCBK> brilliant, thanks so much!
fmcgeough has joined #ruby
<JCBK> managed to write the it all to json as well, perfect
vrinek1 has joined #ruby
tommyvyo has joined #ruby
mattyoho has joined #ruby
philcrissman has joined #ruby
mattyoho has joined #ruby
glosoli has joined #ruby
dql has joined #ruby
dshdsgdfdf has joined #ruby
Sailias has joined #ruby
hirotoshi has joined #ruby
pu22l3r has joined #ruby
pu22l3r has joined #ruby
jesly has joined #ruby
<revon> any one familiar with ffi??
jrist has joined #ruby
delinquentme has joined #ruby
<delinquentme> hey all I'm wondering whats the best way to run a cron job and if it gets any errors ... id like it to email me
iamjarvo has joined #ruby
<workmad3> delinquentme: err... that sounds like a normal cronjob
<delinquentme> oh?
<workmad3> delinquentme: you just need to set up your crontab appropriately
<delinquentme> i've never run one
<delinquentme> but after some googling .. rake tasks are better?
<workmad3> rake tasks don't have the scheduling built in... but a popular thing to do is to write a rake task to do what you want and then schedule it with cron
<delinquentme> yeahhh
<delinquentme> thats what they're suggesting
<workmad3> and make sure your task writes to stdout and stderr appropriately
cjs226 has joined #ruby
<workmad3> a crontab with an email set up will email the output :)
pangur has joined #ruby
<delinquentme> does capistrano run rake tasks?
<workmad3> no
<workmad3> you can get capistrano to run a rake task, but cap tasks aren't rake tasks
<delinquentme> can a crontab be run from a ruby script?
<delinquentme> erm.
<delinquentme> cancel that
_ack_ has joined #ruby
<pangur> undefined method `surname' for nil:NilClass in line: 38 of http://pastie.org/3774046. I have a nil data item in my first and various other rows. How do I cope with that?
Radium_ has joined #ruby
<pangur> line 38 should be line 21 (only showing an excerpt).
mcwise has joined #ruby
<pangur> I guess that would be obvious to anyone able to help though :)
<shevy> pangur you should not have nil objects
<delinquentme> ok so the heroku application runs on debian ... so the cron code should be exactly the same right?
<shevy> also why do you use .strip.to_s()
<shevy> I mean, if you'd be consistent, you'd at least use .strip().to_s()
<pangur> the to_s() I need because otherwise I get a bytesize error :(
Synthead has joined #ruby
<shevy> do you have the example "finreg.csv"
<shevy> even if only a small part of it where the error is established
<pangur> just a mo
dhruvasagar has joined #ruby
<shevy> moooooooooooh
<shevy> like a cooooooooooooow
<pangur> MacLeod,John,4,X, triggers the error, I believe, because of the lack of a fifth data item
td123 has joined #ruby
<pangur> What I imagine happens is that an object is not generated because there is a data item missing?
d3vic3 has joined #ruby
<pangur> Or else the data item being supplied is a nil
<shevy> ok so you require 5 entries but you have a line with only four
<pangur> That's it
<shevy> now you must decide what to do in this case
polysics_ has joined #ruby
<shevy> your five entries are:
<pangur> surname, forename, age, pup, sci
<shevy> surname, forename, age, pup, sci
<shevy> yeah
kvirani has joined #ruby
<shevy> the first thing is - do you allow nil entries, yes or no.
<shevy> if not, you should specify default values in case a nil occurs
<shevy> OR
<pangur> yes
<pangur> ah
<shevy> "finreg.csv" needs to have the correct input
<shevy> I dont know how many more entries can be faulty or not, but if it is always the last entry, then you could do a simple check
<shevy> p.sci = fields[4].tr_s('"','').strip.to_s()
<shevy> if p.sci.nil?
<pangur> so I should have pup="blank", sci="blank" because these are the ones likely to return a nil.
<shevy> p.sci = 'MISSING ENTRY!'
<shevy> end
<shevy> yeah, you can safeguard after that
<shevy> and check whether they are nil or not
ecolitan has joined #ruby
<pangur> Thanks shevy :)
<shevy> yeah
v0n has joined #ruby
<shevy> I think I myself would prefer the assumption that the input data is always correct :)
<shevy> I always try to assume that thinks early in the chain should not fail... and only then in the event that they really fail, do I want to write code that handles that failure
<shevy> *things early in the chain
<shevy> sadly reallife often is messy and faulty and crappy
<shevy> so my code tends to (must) handle all those things that fail anyway
<shevy> I want to live in a perfect world instead :(
<relix> hey guys
<pangur> If the form of the original data is such that the fifth item is a nil, how would I change the original csv file to make that nil into something acceptable?
<relix> unfortunately the guys in #ror arent' responding, so maybe you know a good answer for this
<apeiros_> shevy: tr(…, '') --> delete(…)
fbernier has joined #ruby
<shevy> apeiros_ eh I dont touch other people's code ;P
<relix> I have a ruby application and a ruby on rails application, I'd like the ruby app to consume the REST API of the ruby on rails app (they're both mine)
<relix> what's the best way/library to use for this?
<relix> thanks davidcelis to point me in this direction by the way
<shevy> pangur I am not sure, just add an entry there?
<pangur> like the word "nil"?
<shevy> "nil" would be a string
<pangur> or "blank" or something?
<shevy> but, you already have a nil there, dont you? :P
<shevy> fields[4]
<shevy> if it does not exist it is nil
<pangur> fields[4]=nil but I want that to be an acceptable value.
<shevy> what value should it be when it would be assigned nil?
<pangur> Basically, it is a list of who is registering for a kids event: puppets or science :)
mstratman has joined #ruby
<shevy> you have [0] [1] [2] [3] [4], 5 entries if you count that
<pangur> correct
<shevy> "MacLeod,John,4,X, "
<shevy> perhaps the CSV parser in ruby assumes that after the , comes something
<shevy> just check if fields[4] is nil, then assign to some other value instead.
<pangur> ah, ok, thanks.
A124 has joined #ruby
<shevy> btw
<shevy> you could write a second small class
A124 has quit [#ruby]
<shevy> class AllMyPeople
<shevy> hehehe
<ezkl> shevy: Is pangur using CSV from stdlib or just the File/IO handler?
<shevy> oh, vice versa... extending class People would be easier
wallerdev has joined #ruby
cha1tanya has joined #ruby
<pangur> I have require 'csv'
<shevy> p = Person.new
<shevy> p.assign_data line
<shevy> and the rest of it could be moved into this method, including sanity checking on your entries
<shevy> oops
<shevy> should be:
<pangur> ezkl, standard library, I believe.
<shevy> p.assign_data fields
* pangur feels that AllMyPeople has an imperious sound to it :)
geekbri has joined #ruby
mrwalker has joined #ruby
vrinek1 has quit [#ruby]
<ezkl> pangur: Once shevy is done showing you the proper way to approach the problem, make sure you check out http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html :)
<pangur> Thanks, ezkl :)
linoj has joined #ruby
<pangur> Thanks, shevy :)
glosoli has joined #ruby
* pangur is going to try and apply these pieces of advice and code to his little script.
ceej has joined #ruby
nilan has joined #ruby
philcrissman has joined #ruby
polysics has joined #ruby
LBRapid has joined #ruby
bbttxu_ has joined #ruby
polysics_ has joined #ruby
nacengineer has joined #ruby
randym_ has joined #ruby
glosoli has joined #ruby
iamjarvo1 has joined #ruby
strife25 has joined #ruby
iamjarvo has joined #ruby
dv310p3r has joined #ruby
tobago has joined #ruby
phantasm66 has joined #ruby
wataken44 has joined #ruby
crankycoder has joined #ruby
trivol_ has joined #ruby
theRoUS has joined #ruby
RORgasm has joined #ruby
uris has joined #ruby
rodd has joined #ruby
d2dchat has joined #ruby
steg132 has joined #ruby
sectionme has joined #ruby
IPGlider has joined #ruby
headius has joined #ruby
theRoUS has joined #ruby
EvanR has joined #ruby
EvanR has joined #ruby
kpshek has joined #ruby
CaoBranco has joined #ruby
CaoBranco has quit ["
RubyRedGirl has joined #ruby
Lyrics has quit [#ruby]
brngardner has joined #ruby
sohocoke has joined #ruby
RORgasm has joined #ruby
<delinquentme> grrr could you guys do me a favor https://raw.github.com/andreashappe/smtp_add_tls_support/master/lib/smtp_add_tls_support.rb << I just used this code in a connection to my gmail account to send an email without checking it =/
chson has joined #ruby
<delinquentme> im waaaaay tired and basically " Did I send my password to anyone with that code ? "
[-mX-] has joined #ruby
abra has joined #ruby
Sailias has joined #ruby
thone_ has joined #ruby
io_syl has joined #ruby
abstrusenick has joined #ruby
yekta has joined #ruby
jrist has joined #ruby
wallerdev has joined #ruby
mikepack has joined #ruby
bbttxu_ has joined #ruby
<Boohbah> delinquentme: hwæt
<delinquentme> ??
carlyle has joined #ruby
jenglish has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
snip_it has joined #ruby
zonetti has joined #ruby
Ammar01 has joined #ruby
manohara has joined #ruby
danielpunt has joined #ruby
Kireji has joined #ruby
josefig has joined #ruby
jaywastaken has joined #ruby
Radium has joined #ruby
eam has joined #ruby
nlc has joined #ruby
bbttxu_ has joined #ruby
wallerdev has joined #ruby
kevinbond has joined #ruby
albemuth has joined #ruby
ceej_ has joined #ruby
ysiad has joined #ruby
<td123> delinquentme: check your logs
<chico> any tips for generating an TAGS file for ruby?
bean has joined #ruby
vaxinate has joined #ruby
ghanima has joined #ruby
__main__ has joined #ruby
netzapper has joined #ruby
vectorshelve has joined #ruby
joaoh82 has joined #ruby
<netzapper> how can I compose one regex into another one? Is it just /outer_regex_stuff#{inner_regex}more_outer_stuff/?
ukd1 has joined #ruby
<Mon_Ouie> Yep
sleetdrop has joined #ruby
<netzapper> Mon_Ouie: was that to me?
<Mon_Ouie> Even works if your inner_regex has different options than the outer one
<netzapper> woah! for serious? Neat!
<Mon_Ouie> (e.g. case insensitive)
__main__ has joined #ruby
<apeiros_> netzapper: irb ftw :-p
<apeiros_> it's great for "can I do X?" type questions
16SAA0QJD has joined #ruby
<netzapper> what about capture groups? If my LABEL_RE has a capture group, and I want to do "INDIRECT_LABEL = /\[(#{LABEL_RE})\]/", which capture group gets used?
<netzapper> apeiros_: it is good, except that the input pre-processing is kind of a bitch and makes it hard for me to just play with it in irb.
<apeiros_> input preprocessing?
<vectorshelve> which method do you think is better ? -> http://pastie.org/3774592
<netzapper> apeiros_: yeah, the data I'm using goes through a normalization pass... although, I suppose a test case would be easy enough to make
<Mon_Ouie> vectorshelve: second one could possibly silence a bug
<apeiros_> um, no, there's no input-preprocessing in irb, netzapper.
<apeiros_> all it does is accumulate until you have a complete statement
rye_ has joined #ruby
<netzapper> apeiros_: no, no. I just mean that the data I'm regex'ing requires preprocessing. But, test case, I know...
<vectorshelve> Mon_Ouie: yeah thanks but do you think it could be slower the first ?
CheeToS has joined #ruby
<apeiros_> netzapper: um, yeah… :)
<Mon_Ouie> netzapper: You could use any data you want to test if you can nest two regexps using the syntax you mentionned
<netzapper> I know, I'm working on that.
PragCypher has joined #ruby
<shevy> what do you guys use when you want fancy colours in your project? (commandline based, linux primarily)
<canton7> vectorshelve, the speed difference is going to be minimal. focus on what's more readable and better behaved
<vectorshelve> canton7: ok thanks mate
mikepack has joined #ruby
<canton7> vectorshelve, I might be tempted to do this: http://pastie.org/3774640 . It makes the assumption that @current_user will always be nil if session[:user_id] is nil, which might or might not be right
<vectorshelve> canton7: right mate thanks
<Mon_Ouie> shevy: I usually use the term-ansicolor gem
<vectorshelve> canton7: makes sense.. with concise code :) looks beautiful as ruby
<vectorshelve> canton7: ruby <3
EzeQL has joined #ruby
ckrailo has joined #ruby
<canton7> vectorshelve, hehe, yup :D You start to wonder how other languages manage to be so verbose :P
<vectorshelve> canton7: but I think it's pretty much wrong to begin with, if the user in the session is nil or doesn't exist in the database, you are not logged in, please go see the login screen right ?
rippa has joined #ruby
IrishGringo has joined #ruby
<canton7> vectorshelve, hrm? I don't know how your site works. If this is only going to be used on pages you have to be logged in to see, then it's pretty safe to assume that the session[:user_id] must be set by the time that current_user is called
<vectorshelve> canton7: thanks mate :(
francisfish has joined #ruby
<vectorshelve> canton7: :)
paxcoder has joined #ruby
<canton7> vectorshelve, on the other hand, if this function might be used on a page where the user could or could not be logged in, it's worth making it behave nicely if session[:user_id] doesn't exist
<paxcoder> i need to match $var, is the correct regex $var or \$var?
<vectorshelve> canton7: right
iocor has joined #ruby
<canton7> paxcoder, the latter
<paxcoder> thx
<canton7> paxcoder, rubular.com is pretty good btw
<vectorshelve> It's getting too too hot in India now :(
slonimsky has joined #ruby
lkba has joined #ruby
flagg0204 has joined #ruby
<canton7> it keeps hailing in england... opposite problem
Vert has joined #ruby
hydrozen has joined #ruby
<paxcoder> canton7: thanks
JCBK has quit [#ruby]
artm has joined #ruby
krusty_ar_ has joined #ruby
* artm is implementing custom YAMLisation for an object (implementing 'encode_with(codec)'). Is it possible to force inline format for lists for this class?
bglusman has joined #ruby
dql has joined #ruby
davidpk has joined #ruby
workmad3 has joined #ruby
InBar has joined #ruby
jeebster has joined #ruby
sterNiX has joined #ruby
kenperkins has joined #ruby
jeebster has quit [#ruby]
jeebster has joined #ruby
cbuxton has joined #ruby
qos has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
davidcelis has joined #ruby
<paxcoder> this line returns a Matchdata object, why: "anna".match(/a/) {|a| puts a}
dfamorato has joined #ruby
<paxcoder> (nothing is printed)
<any-key> try changing puts to p
<paxcoder> no effect
<paxcoder> guess it doesn't call the block
<paxcoder> no matches? how?
<any-key> "anna".match(/a/)[0] # => "a"
andrewhl has joined #ruby
arkiver has joined #ruby
<paxcoder> any-key: i remember trying .each, failing, then reading that match takes a block... *shrug*
<any-key> paxcoder: "anna".match(/a/) { |a| puts a } # => a
<any-key> paxcoder: what version of ruby?
<paxcoder> any-key: old one? :-)
<arkiver> Hi, I'm trying to create a database in rails and I need to use enums. How to do this in rails ?
<any-key> paxcoder: yeah I'm not sure how match behaves pre-1.9
baroquebobcat has joined #ruby
<shevy> arkiver the rails people fled to #rubyonrails
<shevy> we here know only general ruby things
<any-key> we chased them out with torches and pitchforks
<shevy> yeah
<shevy> I also told them to press the any-key
<arkiver> shevy: Thanks.
<shevy> these turned mad
<any-key> arkiver: ruby doesn't have enums, symbols are the closest thing
<shevy> he probably meant symbols
<shevy> wonder where he got the word enum ...
JohnBat26 has joined #ruby
<any-key> every other programming language?
<canton7> databases often support enums
<davidcelis> no, he means enum
<any-key> it really depends on the DB he's using
<shevy> !!!
<davidcelis> it's a database string-like field that only allows a specific set of values
<paxcoder> any-key: alright, using 1.9.2 now. i get a single "a". shouldn't it match globally?
<shevy> a database that has enums???
<canton7> mysql, for starters
<shevy> whoa
<any-key> paxcoder: nope, match just finds the first occurrence iirc
bluOxigen has joined #ruby
<davidcelis> shevy: it's a database string-like field that only allows a specific set of values
<shevy> like a programming language!
<shevy> inbuilt if conditionals!
<canton7> paxcoder, maybe you're after #scan ?
Poapfel has joined #ruby
<any-key> paxcoder: scan is what you want
<paxcoder> canton7: thanks
<any-key> damn he beat me to it
Poapfel has joined #ruby
<canton7> heh, speedy typing
<canton7> you provided the docs link though, so we balance out :P
<shevy> hmm canton7 is a nice man
<davidcelis> i decree any-key the victor, actually
<any-key> yay!
<any-key> awesome
<shevy> he just does not rub it into your face that were you slow as old man
* canton7 gracefully concedes arbitrary defeat
arturaz has joined #ruby
<paxcoder> davidcelis: impostor! only *I* have that right. *sits his royal butt back in the chair*
adamkittelson has joined #ruby
daniel_hinojosa has joined #ruby
<shevy> hmm what is better... a royal chair... or a royal butt ...
ziggles has joined #ruby
<paxcoder> :-D
h4mz1d has joined #ruby
Abner_ has joined #ruby
<shevy> I think a royal butt
<paxcoder> hey, unrelated note: why does ruby have "elsif", instead of, say, "elif"?
<shevy> because a chair could get lost, or you have to carry it with you all the time
<shevy> dunno, I think matz preferred the "s"
<shevy> or perhaps there was another reason
<shevy> why does python have "elif"?
n1x has joined #ruby
<paxcoder> bash has elif
<paxcoder> it's shorter
<canton7> it's the same length as "else", and looks nice :P
<rippa> why not ef?
<rippa> it's shorter
<paxcoder> rippa: -_- <-- look at my face!
<rippa> and same length as if
<rippa> and el instade of else
<rippa> and de instead of def
<paxcoder> you didn't look at my face, rippa
niku4i has joined #ruby
n1x has quit [#ruby]
<canton7> I might get along with 'el'. Would make your "if" and "else if" statements line up nicely
<canton7> s/el/es/
<paxcoder> canton7: now you look at my face
<rippa> cl St; de fo; :ba; en; en
<rippa> ShortRuby
<paxcoder> rippa: your logic, the other way: why not "elseif"? why not "else if that's not the case then"
gaugauuu has joined #ruby
<paxcoder> the only reason that comes to my mind is that maybe elsif *sounds* like else if
blueadept has joined #ruby
blueadept has joined #ruby
SphericalCow has joined #ruby
CannedCorn has joined #ruby
IPGlider has joined #ruby
xorrbit has joined #ruby
jgrevich has joined #ruby
nilan has joined #ruby
mdw has joined #ruby
<davidcelis> unlesif
shruggar has joined #ruby
apeiros_ has joined #ruby
<paxcoder> davidcelis: ouch
<davidcelis> :)
<canton7> elseunless
<davidcelis> elsunless*
Indian has joined #ruby
<apeiros_> o0
hasrb has joined #ruby
brngardner has joined #ruby
PhilK has joined #ruby
mrtheshadow has joined #ruby
DrShoggoth has joined #ruby
<xorrbit> how would I turn a binary string ("01100001") to it's ascii representation in a string ("a") ?
<apeiros_> to_i(2).chr
* paxcoder stops trying to check if that's a
<apeiros_> it is
<paxcoder> heh
<apeiros_> you can't read binary? :)
ph^ has joined #ruby
<xorrbit> what about a longer string
<xorrbit> "0110000101100010" to "ab"
<apeiros_> xorrbit: take a look at unpack
macmartine has joined #ruby
joaoh82 has joined #ruby
SegFaultAX|work has joined #ruby
<apeiros_> actually, pack
<xorrbit> hmm
dzhulk has joined #ruby
Advocation has joined #ruby
<xorrbit> "0110000101100010".unpack("B") looks like it should do what I want but it returns ["0"]
rodd has joined #ruby
<apeiros_> yeah, it's the other way round, also you need B*:
<apeiros_> ["0110000101100010"].pack("B*") # => "ab"
<xorrbit> ah
<xorrbit> nice, thanks
<apeiros_> that's why I rectified my statement, from unpack to pack :)
maletor has joined #ruby
pygmael has joined #ruby
luckyruby has joined #ruby
<rodd> Hi, I'm new to ruby and would like some help. Been trying to setup rvm + passenger + apache2, followed a few tutorials including this one http://beginrescueend.com/integration/passenger/ The setup went fine, apparently. However when running the app i get the following msg: "Could not find rake-0.9.2 in any of the sources (Bundler::GemNotFound)" Any idea on how I could get that sorted out? thanks in advance
<apeiros_> rodd: run `gem install rake`
<rodd> I have rake installed
cwang has joined #ruby
<canton7> rodd, is your Gemfile right? Does it have the correct source at the top?
<rodd> here's a copy of it: http://pastie.org/3775004
gaugauuu has quit [#ruby]
jcromartie has joined #ruby
<canton7> have you bundle install'd?
<rodd> yes
<rodd> there were a few dep, managed them and re ran it
<workmad3> rodd: how did you do your bundle install? for a deployment, it's normally safest to do 'bundle install --deployment'
Cyrus has joined #ruby
<rodd> workmad3, I just entered 'bundle install'
<rodd> can I reset a bundle install?
<workmad3> rodd: just run the command I just gave again, it'll change the bundle config and reinstall ;)
<rodd> sweet let me tr
<rodd> y
<workmad3> and it will do a full reinstall with that one... it'll install all your gems into vendor/bundle
mxweas_ has joined #ruby
PragCypher has joined #ruby
adamkittelson has joined #ruby
<rodd> bundle complete
jhunter has joined #ruby
<rodd> awesome, it worked!
hadees has joined #ruby
<rodd> thanks a lot, I've been hitting my head on this one for hours
sako has joined #ruby
kenperkins has joined #ruby
<workmad3> rodd: the issue was probably then that your passenger wrapper wasn't seeing the same gemset as you'd installed into... but that's why the --deployment flag is good :)
<rodd> great, thanks workmad3 !
radic has joined #ruby
_adeponte has joined #ruby
<paxcoder> "two".scan(/(one)|(two)/) returns [[nil, "two"]], i want *either* group to be matched. in other words, how do i get it to return ["two"]?
brianpWins has joined #ruby
<paxcoder> oh, and note that i need those groups.
<apeiros_> (one|two)
<paxcoder> apeiros_: the above.
<apeiros_> that makes no sense
<apeiros_> you either have two groups or one group
<paxcoder> apeiros_: ok, how do i flatten each array in an array (to remove nil)?
<apeiros_> maybe you're explaining your problem badly, and you're looking for non-capturing groups…
<apeiros_> yeah, now it sounds like that…
<paxcoder> apeiros_: i can give you the real regex
<apeiros_> (?:one)|(?:two)
yxhuvud has joined #ruby
<paxcoder> apeiros_: you mean ((?:one)|(?:two)) ?
savage- has joined #ruby
<apeiros_> no outer parens required, no
<apeiros_> just /(?:one)|(?:two)/
<apeiros_> unless your explanation is still laking…
<apeiros_> *lacking
<paxcoder> actually, that's not it. you're going to need the full regex
<paxcoder> apeiros_: line.scan(/('[^\$][^']+')|'(\$[^']+)'/)
<apeiros_> you don't need grouping for that at all
<apeiros_> got an example line?
<paxcoder> apeiros_: for string "'$one' 'two' 'three' '$four'", it should return ["$one", "'two'", "'three'", "$four"] #notice the quotes around two and three
shtirlic has joined #ruby
hrs has joined #ruby
schovi has joined #ruby
pluerna has joined #ruby
<pluerna> hi guys
<apeiros_> paxcoder: yeah, then as said, you don't need no grouping. just drop the parens.
eywu has joined #ruby
<paxcoder> apeiros_: i'm actually making a script to turn bad SQL-injection prone statements into nice, prepared ones.
<apeiros_> paxcoder: wrong solution.
<apeiros_> paxcoder: trying to sanitize sql is doomed to fail. use bind variables.
<pluerna> what is the reverse of the next methods (string) ?
<paxcoder> apeiros_: i'm not sanitizing it manually
<canton7> pluerna, it's not really possible
<paxcoder> apeiros_: anyway, the key there is not to have quotes around $vars
ed_hz_ has joined #ruby
shtirlic_ has joined #ruby
<apeiros_> paxcoder: it doesn't matter whether you do it manually or automatically. trying to sanitize sql is the wrong approach.
<pluerna> canton7: why ?
<apeiros_> paxcoder: seriously, read up on bind variables.
<paxcoder> apeiros_: if i leave the groups out, i'm going to have them, or otherwise match a variable that's not quoted
<paxcoder> apeiros_: you don't understand, i'm separating strings ad variables into an array, and then I have those "?"'s in their place in the SQL string.
<canton7> pluerna, hrm I'm having trouble finding the post I read that in. http://snippets.dzone.com/posts/show/2474 looks interesting anyway
<paxcoder> apeiros_: eg. for $query="SELECT * from $table"; $db->query($query) i'm going to get $query="SELECT * from ?"; $db->query($query, array($table))
Sailias has joined #ruby
Araxia_ has joined #ruby
<arturaz> i thought this is #ruby, not #php :)
<apeiros_> paxcoder: you mean your db is crappy and doesn't know keyword bind-variables, so you do that manually?
<paxcoder> apeiros_: no, it can keyword-bind. it's just easier to do this, and the end result is pretty much the same
<apeiros_> …
* apeiros_ is stunned
maskact has joined #ruby
* paxcoder rolls eyes
Mohan has joined #ruby
<apeiros_> well, I told you how to do the scan
<paxcoder> apeiros_: your way would match quotes. i don't want quotes.
<paxcoder> or rather, i do, but not around php variable identifiers
<apeiros_> then do a 2nd step and strip them
bluenemo has joined #ruby
bluenemo has joined #ruby
<paxcoder> sigh
<apeiros_> or use look-arounds
<paxcoder> how?
<apeiros_> you either get a nested array or you get the quotes. that's how scan works.
<apeiros_> scan will either contain the complete match or all capturing groups
<apeiros_> (?<=') and (?=')
vaxinate has joined #ruby
<paxcoder> apeiros_: i know! :-)
* apeiros_ holds hands…
<apeiros_> ruby-1.9.2:025:0>> "'$one' 'two' 'three' '$four'".scan(/(?<=')[^\$][^']+(?=')|'\$[^']+'/) # => ["'$one'", "two", "three", "'$four'"]
tewecske has joined #ruby
<apeiros_> oh, wrong side…
<paxcoder> apeiros_: i'll drop the groups where they are now, and make two that are ignored for quotes - one for each one
<apeiros_> "'$one' 'two' 'three' '$four'".scan(/'[^\$][^']+'|(?<=')\$[^']+(?=')/) # => ["$one", "'two'", "'three'", "$four"]
maahes has joined #ruby
<paxcoder> apeiros_: see? it can be done :-P
apok has joined #ruby
* apeiros_ sobds
<apeiros_> *sobs
<apeiros_> so I show you how it can be done and you tell me that it can be done… amazing.
<canton7> there's got to be a nicer way of doing that with less regex and more functions :P
<apeiros_> anyway, I still think the whole endeavor reeks.
sectionme has joined #ruby
kidoz has joined #ruby
pu22l3r_ has joined #ruby
hadees_ has joined #ruby
phantomfakeBNC has joined #ruby
ryanf has joined #ruby
tewecske has joined #ruby
<paxcoder> apeiros_: you never explained why, so i'm not really concerned.
brianstorti has joined #ruby
<paxcoder> apeiros_: you first said it cannot be done. i was thinking of (?:') but those don't help of course.
jrist has joined #ruby
<pluerna> Why I can't do that with ERB : http://codepad.org/56apf5Fz ?
ank has joined #ruby
cbuxton has joined #ruby
etehtsea has joined #ruby
<apeiros_> paxcoder: I said how it can be done, I also said what the limits of scan are. Don't claim I said things which I didn't.
SphericalCow has joined #ruby
<paxcoder> <apeiros_> you either get a nested array or you get the quotes. that's how scan works.
<paxcoder> in your final result, there are no nested arrays, and there are no quotes around $vars. who's crazy here?
<apeiros_> paxcoder: 18:54 apeiros_: or use look-arounds
<apeiros_> I said that before that statement. you know, context matters.
<paxcoder> apeiros_: which makes it even stranger
<paxcoder> anyway
<apeiros_> only because you don't understand how it works…
<canton7> pluerna, single quotes = no interpolation
<apeiros_> a look-around doesn't consume
<paxcoder> apeiros_: can you explain what exactly do <= and = do?
brianstorti has joined #ruby
<apeiros_> paxcoder: google for look-around
d3vic3 has joined #ruby
phantomfakeBNC has joined #ruby
<paxcoder> apeiros_: please tell me, i did that once already. obviously it was of no use
<canton7> pluerna, so your html string looks like 'ya <%= blabla(col) %>', and col is undefined when the ebr parser comes around
<canton7> pluerna, you might want soemthing like "yo <%= blabla('#{col}') %>", which will interpolate to e.g. "yo <%= blaabla('A') %>"
guyface has joined #ruby
<apeiros_> canton7: ", not '
<apeiros_> (or any of the other dquote literals)
<apeiros_> canton7: oooh
<apeiros_> sorry, I think I misread - he wants the erb template to be interpolated, i.e before being passed to erb?
<apeiros_> yeah, seems like (read the paste), nvm then.
flak has joined #ruby
phantomfakeBNC has joined #ruby
tewecske has joined #ruby
MrGando has joined #ruby
maskact has joined #ruby
atmosx has joined #ruby
Notimik has joined #ruby
MrGando has joined #ruby
oooPaul has joined #ruby
mengu_ has joined #ruby
savage- has joined #ruby
nfluxx has joined #ruby
fbernier has joined #ruby
brianstorti has quit [#ruby]
brianstorti has joined #ruby
twinturbo has joined #ruby
pu22l3r has joined #ruby
ringotwo has joined #ruby
mxweas_ has joined #ruby
carlyle has joined #ruby
ringotwo has joined #ruby
c0rn has joined #ruby
mk03 has joined #ruby
kenichi has joined #ruby
<canton7> apeiros_, yeah that's how I read it
moshee has joined #ruby
moshee has joined #ruby
krz has joined #ruby
mrtheshadow has joined #ruby
brngardner has joined #ruby
ringotwo has joined #ruby
ringotwo has joined #ruby
GoogleGuy_ has joined #ruby
l3ck has joined #ruby
<Synthead> When using ternary operations like this: "var = x + y + z ? x + y + z : nil", can I assign var to x + y + z without stating it twice?
netrealm has joined #ruby
<apeiros_> Synthead: no
hasrb has joined #ruby
GoogleGuy_ has joined #ruby
<apeiros_> you could use || for that, even though I see little point in what you do. var = x + y + z || nil
<apeiros_> all that `|| nil` (or your ternary) could possibly do is change a false to nil
banjara has joined #ruby
<Synthead> hmmm
<Synthead> ooh, you just make me think of a better flow for this
ringotwo has joined #ruby
<Synthead> is there a method for testing if a number is positive?
PragCypher has joined #ruby
<Mon_Ouie> a >= 0
<oooPaul> 0.<(x)
<oooPaul> is_positive = 0.method(:<)
<oooPaul> is_positive.call(1) => true
greenarrow has joined #ruby
Russell^^ has joined #ruby
jankly has joined #ruby
emmanuelux has joined #ruby
Eldariof-ru has joined #ruby
crankycoder has joined #ruby
tayy has joined #ruby
Advocation has joined #ruby
twinturbo has joined #ruby
trivol has joined #ruby
<davidcelis> 0 isn't positive
<davidcelis> so a >= 0 is not a good test
kenperkins has joined #ruby
<oooPaul> 0.<(x). :)
rippa has joined #ruby
<davidcelis> i was talking to Mon_Ouie
<oooPaul> I knows it. :)
* oooPaul is jacked up on coffee and Coke Zero.
hadees_ has joined #ruby
billy_ran_away has joined #ruby
n1x has joined #ruby
<billy_ran_away> Is there a find_all collect equilvent? I want to collect the results of a block unless it's false run on every element of an array…
deobald has joined #ruby
<geekbri> Is it allowed to have the elements of an array seperate by a newline after their comma?
<rippa> yes
krusty_ar has joined #ruby
emmanuelux has joined #ruby
tewecske has joined #ruby
thecreators has joined #ruby
tewecske has joined #ruby
mrtheshadow has joined #ruby
brianstorti has quit [#ruby]
<Kovensky> http://i.imgur.com/P5yEr.png <-- wat
ryanf has joined #ruby
<Synthead> can I store a function's name as a string, then execute it from the string?
<td123> Kovensky: ruby 1.9.3 p125 is alright
<td123> not sure what 1.8.7 is doing :P
<Kovensky> me neither
<Kovensky> my guess would be that (1 < 0) returns nil instead of false
<Mon_Ouie> puts ((1 < 0) == (0 < 1)) ? "WTF" : "all is right" works just fine here
<apeiros_> Kovensky: can't reproduce
<apeiros_> even with 1.8.7
<Synthead> eval! eval(string)
<Kovensky> hmm
<sam113101> Synthead: method('string').call(args)
<Mon_Ouie> Synthead: No, you most likely want to use Object#send
<apeiros_> Synthead: given that ruby has no functions, no. but you can store the name of a method as a string.
<Kovensky> I don't have a ruby on this computer so I couldn't verify myself
<apeiros_> Synthead: and then send, as Mon_Ouie already said. damn. too fast he is! :(
ctp has joined #ruby
<apeiros_> also you can store a Method instance and call it later (unlike just having the method name, a Method instance also encompasses the receiver)
<Kovensky> also, that screenshot has a p. high linecount on irb
<Kovensky> nothing prevents the guy from having monkeypatched ==
cha1tanya has joined #ruby
<apeiros_> Kovensky: so that's not your irb session?
<Kovensky> nah, someone linked that on another channel
<apeiros_> even low line count means nothing. can use irb -r to load stuff.
<Kovensky> probably got linked from somewhere else too
<Kovensky> heh
TheIronWolf has joined #ruby
<sam113101> how do I use the send method
<td123> Kovensky: somebody's probably just screwing around :P
<Mon_Ouie> object.send(method_name, *arguments)
<Kovensky> <<instance>>.send(symbol, *args) => does the same as <<instance>>.symbol(*args)
two- has joined #ruby
<sam113101> is it better send or method(method_name).call(*args)
mdhopkins has joined #ruby
kenichi has joined #ruby
<Kovensky> method(method_name) will return method_name on *your* object, not on the object you want to call
<Kovensky> just use send; method().call() ends up just being boilerplate
<Kovensky> (in that case)
Vert has joined #ruby
<hashpuppy> in irb, i'll get stuck where my evaluations don't get processed. is there a way i can break out of this w/o quitting
<hashpuppy> for example, when i forget a }
<apeiros_> ctrl-c
strife25 has joined #ruby
<hashpuppy> for some reason, that doesn't seem to work sometimes
<hashpuppy> maybe i'm imagining things
jacktrick has joined #ruby
Ontolog has joined #ruby
voodoofish430 has joined #ruby
fr0gprince_ has joined #ruby
tatsuya_o has joined #ruby
mcwise has joined #ruby
tatsuya_o has joined #ruby
stephenjudkins has joined #ruby
mxweas_ has joined #ruby
musl has joined #ruby
shadoi has joined #ruby
kmurph79 has joined #ruby
looopy has joined #ruby
nikhgupta has joined #ruby
senthil has joined #ruby
f0ster has quit [#ruby]
johnn has joined #ruby
Advocation has joined #ruby
crankyco_ has joined #ruby
srnty has joined #ruby
d34th4ck3r has joined #ruby
vaxinate has joined #ruby
strife25 has joined #ruby
mrtheshadow has joined #ruby
workmad3 has joined #ruby
crankycoder has joined #ruby
nightlycoder has joined #ruby
PragCypher has joined #ruby
thecreators has joined #ruby
srnty has joined #ruby
PaciFisT has joined #ruby
kirun has joined #ruby
krzkrzkrz has joined #ruby
Araxia_ has joined #ruby
brngardner has joined #ruby
snearch has joined #ruby
imsplitbit has joined #ruby
mikeycgto has joined #ruby
mikeycgto has joined #ruby
maskact has joined #ruby
axl___ has joined #ruby
macroevolve has joined #ruby
<macroevolve> join #rails
adac has joined #ruby
n3m has joined #ruby
francisfish has joined #ruby
<apeiros_> macroevolve: you're aware that #rails is a dead thing, the channel you want is #rubyonrails (#ror forwards to it)
KL-7 has joined #ruby
linoj_ has joined #ruby
d3c has joined #ruby
benoit___ has joined #ruby
workmad3 has joined #ruby
startling has joined #ruby
williamcotton has joined #ruby
ceej_ has joined #ruby
nobitanobi has joined #ruby
savage- has joined #ruby
<nobitanobi> I have a question... Given that I don't know if a variable is declared or not, how do I assign the variable value to another variable if it exists, and assign nil, if it doesn't? So something like: my_new_var = my_old_var
<nobitanobi> but if my_old_var doesn't exist, assign nil to my_new_var
shruggar has joined #ruby
<apeiros_> nobitanobi: if you do not know whether a local variable has been defined at a given point, then you've done something very very wrong
<apeiros_> local scopes should be quite short (<50 lines, preferably in the 5-15 lines range)
_numbers has joined #ruby
<nobitanobi> actually, I can defined to nil and then it can be overwritten
<_numbers> in a Capfile with capistrano 2.x you can provide command-line configuration variable overrides using the -s var=new_value argument
<Mon_Ouie> nobitanobi: I think you're confusing "references nil" and "doesn't exist"
ed_hz_ has joined #ruby
<_numbers> but how do you reference it from within the capfile?
<nobitanobi> Mon_Ouie: no. I know the difference. But I am just wondering what's the correct way of doing this in Ruby.
<nobitanobi> It comes from here my doubt: raw_date = auth.fetch('extra', {}).fetch('raw_info', {})['birthday'] if auth.fetch('extra', {}).fetch('raw_info', {})['birthday']
<nobitanobi> I would like raw_date to be nil, if the conditional is false.
<Mon_Ouie> That's already the case as it is
berkes has joined #ruby
<Mon_Ouie> if's and loops don't create a new local variable scope
<nobitanobi> oh, ok..
<Mon_Ouie> Also, I wouldn't repeat the auth.fetch('extra', {}).fetch('raw_info', {})['birthday'] twice
<Mon_Ouie> Plus if that expression can't evaluate to nil, all you have to do is drop the condition
<canton7> in fact, if the if statement is checking to see whether ...['birthday'] is nil (not false) you can skip the if cnodition altogether
<Mon_Ouie> I meant to false*
<_numbers> whats the shortest way i could search ARGV for a value "-s" and then delete it and the next array index after it?
tommyvyo has joined #ruby
<canton7> or, if auth...['birthday'] *can* be false, you could do raw_date = auth...['birthday'] || nil
<nobitanobi> Mon_Ouie: you wouldn-t repeat that? Then how yould you know if is fetchable?
<canton7> nobitanobi, you're fetching it and seeing if it exists, then fetching it *again* if it does
Araxia_ has joined #ruby
<hashpuppy> I'm working on an old rails 2 app and the only way I can get it running is if I add "require 'thread'" above require boot in my Rakefile, environment file, and script/server file. what's the impact of this if I deploy to production running nginx like this?
<hashpuppy> wrong channel... meant #rails
ctp has joined #ruby
<nobitanobi> canton7: I thought by doing the condition I was ensuring to try to fetch it, to avoid getting undefined index.
ceej has joined #ruby
<canton7> nobitanobi, to simplify your statement, you're doing raw_data = a['key'] if a['key']
<nobitanobi> canton7: what worries me is the index 'birthday' if is not there, and I don't do the conditional, I will get an undefined index.
<canton7> I mean, if you were doing raw_data = a['key'] if a.include?(:key) I would understand where you were coming from
<canton7> anyway, accessing an undefined hash index in ruby results in nil, not an error
<nobitanobi> ok.
<nobitanobi> thanks canton7
<canton7> _numbers, something like parts = ARVG.slice!(ARGV.index('-s'), 2) if ARGV.include?('-s') ?
<canton7> _numbers, use something like OptionParser or trollop, anyway
<nobitanobi> canton7: the problem is when doing chaining in access a has. If the first index doesn't exist, you will try to access a key within a nil object.
<nobitanobi> right?
<canton7> nobitanobi, sure. You weren't checking that, though
<nobitanobi> *in access a hash.
<nobitanobi> canton7: so what's the correct way of checking that, in a one liner version? Checking let's say a three dimension hash.
<nobitanobi> so I am expecting my_hash['extra']['raw_info']['birthday']
<canton7> nobitanobi, I haven't come across a neat way to do that... I'd do var = ... if my_hash['extra'] && my_hash['exta']['raw_info#
<canton7> * ['raw_info'] && my_hash['extra']['raw_input']['birthday']
<canton7> but maybe someone on here has a nicer way
<canton7> hashpuppy, I tihnk #rubyonrails is more activ
krzkrzkrz has joined #ruby
<hashpuppy> thanks
Akuma has joined #ruby
<nobitanobi> canton7: ok...
<nobitanobi> thanks
<any-key> wow that's a lot of hashes
<any-key> "yo dawg, I heard you like hashes..."
<canton7> I've seen stuff that size crop up when parsing config files and the like
<canton7> where the user might or might not have deleted a particular key...
lkb has joined #ruby
<canton7> though I guess you *could* monkey-patch NilClass to respond to [], and return nil
<canton7> actually that works quite well. It's probably got some hidden dangers and potential pitfalls though
<any-key> I dunno if this helps, but you can initialize a hash's default value with a proc
stkowski has joined #ruby
<canton7> heh, I guess you could set the default value to an empty hash. Not as easy to test for, though, and someway disposed towards creating confusion in the future
<any-key> changing default hash values is kind of frowned upon :\
<any-key> but if it makes life much easier I say go for it
<canton7> easier for whom? You or the guy maintaining your code? :P
<nobitanobi> any-key: that has comes from Facebook API
<nobitanobi> so FB loves hashes >_>
<any-key> "has comes from" broke my English parser
hydrozen has joined #ruby
whitey`` has joined #ruby
<nobitanobi> any-key: that HASH comes from
<nobitanobi> sorry
<nobitanobi> hehe
tommyvyo has joined #ruby
andantino has joined #ruby
blischalk has joined #ruby
bwlang has joined #ruby
RubyPanther has joined #ruby
otters has joined #ruby
blischalk has joined #ruby
* shevy clicks the any-key
<shevy> are you fixed now any-key ??
_numbers has quit [#ruby]
<matti> shevy: So much anger!
<matti> shevy: What would Yoda say?!
<matti> ;/
<shevy> I will knock that yoda bitch out
bwlang_ has joined #ruby
<matti> Hehe
brngardner has joined #ruby
whitey`` has quit [#ruby]
josefig has joined #ruby
strife25 has joined #ruby
tvw has joined #ruby
Tomasso has joined #ruby
CharlieSu has joined #ruby
<CharlieSu> I'd love if anyone can help me figure out why I can't install Gems now that I upgraded ruby.. https://gist.github.com/af52351ffb2097a5b932
polysics has joined #ruby
__class__ has joined #ruby
bwlang_ has joined #ruby
atmosx has joined #ruby
mbreedlove has joined #ruby
tommyvyo has joined #ruby
__class__ has joined #ruby
strife25 has joined #ruby
axl_ has joined #ruby
kmurph79 has joined #ruby
Ontolog has joined #ruby
rramsden has joined #ruby
mdhopkins has joined #ruby
nlc has joined #ruby
atmosx has joined #ruby
_class_ has joined #ruby
ctp has joined #ruby
jfelchner has joined #ruby
scwh has joined #ruby
Axsuul has joined #ruby
<Tasser> CharlieSu, 1.9.3 is somewhat of up-to-date
robbyoconnor has joined #ruby
stephenjudkins has joined #ruby
<shevy> CharlieSu your ruby is very old
dv310p3r has joined #ruby
startling has joined #ruby
<andantino> what is a good book for beginning programmers to learn ruby
kalv has quit [#ruby]
<shevy> andantino chris pine learn to program
<shevy> http://pine.fm/LearnToProgram/?Chapter=01 work through it as quickly as possible
<andantino> im going through that now actually
<andantino> i am kind of looking for something to keep me busier a bit longer
td123 has joined #ruby
brngardner has joined #ruby
<shevy> well
<shevy> I dunno really
<shevy> the pickaxe is ok
<shevy> but to be honest
<shevy> I think for 95% of the problems where it gets much more complicated than in the chris pine tutorial... something is wrong
<shevy> best thing is to start a project, with several .rb files and classes and modules on your own
_class_ has joined #ruby
<shevy> that'll teach you how to install things, how to require things properly, how to all turn it into a gem
<shevy> ideally host the project at github
Guest5330 has joined #ruby
davorb has joined #ruby
<shevy> ah yes, and slowly let your project grow
Guest5330 has quit [#ruby]
<andantino> what if it wilts?
<shevy> simply add things slowly
h4mz1d has joined #ruby
<shevy> eventually you'll come at a point where you will rewrite parts of it anyway
<shevy> ideally you'll do that in a way as to keep the project still working at any given time
<shevy> and you can use tests to ensure that, too
<atmosx> andantino: I'm very satisfied by… "Beginning Ruby: From Novice to Professional" by Peter Cooper
<atmosx> andantino: Chris Pine's book is kinda limited .. it's like for kids
<andantino> yeah i was looking at that one
<andantino> or learning ruby
<oooPaul> Isn't Chris Pine the guy who's playing the new Kirk?
<andantino> like i have done some programming....ive basically done language hopping for about a year
<atmosx> While this one is at least as comprehensive and has a huge variety of topics on it… I mean I stopped at the 6th chapter, because I was able (with some help from the ml and here) to crate my own projects easily.
<atmosx> at least the ones I wanted to mess with so far.
<andantino> im almost done a perl in 24hours book here but the grass looks greener on the ruby side
<atmosx> andantino: the one I mention is really good. You can start with no knowledge of programming and (if you read the entire thing) end with a good grasp of ruby. You can do practically everything. You don't become an *expert* with one book though and… above all imho the best thing is to write programs as much as possible.. it's the only way of learning fast.
vaxinate has joined #ruby
<atmosx> perl? omg
senthil has joined #ruby
<atmosx> that's a cryptic language lost in time
<atmosx> do people still do that? I mean, for things other than regexp?
<andantino> perl is kinda fun
<atmosx> for is like Chinese
<senthil> do you guys remember that one rubyist personal website which has a cmd line interface?
<atmosx> for *me*
<atmosx> senthil: I know that are you talking about but I don't remember the URL
<atmosx> s/that/what … shit it's late, I have to go to bed (apparently)
<senthil> atmosx: was it peter cooper?
EvanR has joined #ruby
<atmosx> senthil: hmm might be, yes
<atmosx> or the other guy, that I follow on twitter maybe
<atmosx> it was a geek of that statue though
<andantino> well i might go with beginning ruby then...
bwlang_ has joined #ruby
<atmosx> andantino: good luck and have fun!
<atmosx> I'm gonna continue reading cryptonomicon! yay!
<andantino> ive dabbled in a bunch of languages without going really far
ephemerian has joined #ruby
EvanR has joined #ruby
<atmosx> later all
<andantino> see ya atmos
<oooPaul> As a complete aside, my whole role as a ruby/rails engineer here is to port a legacy Perl app. :)
netogallo has joined #ruby
<andantino> thanks for your suggestions
<andantino> you too shevy
<atmosx> andantino: see?
<atmosx> hehe
<atmosx> gniteee
dkissell has joined #ruby
surfprimal has joined #ruby
dkissell has joined #ruby
netogallo has joined #ruby
man has joined #ruby
inemion has joined #ruby
<man> some girl to talk about sex?´
CoderCR|work has joined #ruby
strife25 has joined #ruby
man has quit [#ruby]
Witold has joined #ruby
shtirlic has joined #ruby
snearch has joined #ruby
<Witold> Join
voodoofish4301 has joined #ruby
mikepack_ has joined #ruby
<Witold> Hi
ixx has joined #ruby
kevinbond has joined #ruby
EddieS_ has joined #ruby
s1n4 has joined #ruby
polysics_ has joined #ruby
tatsuya_o has joined #ruby
bwlang_ has joined #ruby
rushed has joined #ruby
thecreators has joined #ruby
jlebrech has joined #ruby
VegetableSpoon has joined #ruby
<jlebrech> is there a gem that can list the classes, class variables and methods in classes of ruby files from the command line?
mborromeo has joined #ruby
__class__ has joined #ruby
<apeiros_> jlebrech: ri (comes with ruby), yri (comes with yard)
tewecske has joined #ruby
<apeiros_> I don't think anything lists class variables, though. makes no sense anyway.
kjellski has joined #ruby
<jlebrech> apeiros_ so as to use ed to edit files. list a method. oh line 3 has a bug. replace x for y..
<apeiros_> ?
<jlebrech> bam you don't even need a text editor
<Mon_Ouie> I think YARD does make class variables appear in the documentation when they are set within the class body
<apeiros_> it should also output a warning… "beware, this library uses class variables"
<apeiros_> alternatively, "run forrest, run!"
<jlebrech> woops I use class variables, for singleton behavior
strife25 has joined #ruby
<Mon_Ouie> What do you expect if you create a subclass of the class that has this class variable?
<apeiros_> muaha, "Alan Moore - Writer, Wizzard, Mall Santa, Rasputin Impersonator" - tv caption :D
dv310p3r has joined #ruby
<jlebrech> Mon_Ouie that's not a problem in my instance
s0ber_ has joined #ruby
y3llow_ has joined #ruby
ghanima has joined #ruby
<shevy> "Rasputin impersonator"
<shevy> man
<shevy> I wanna be a Rasputing impersonator
<shevy> but I can never get such a great beard :(
pangur has joined #ruby
krusty_ar has joined #ruby
y3llow has joined #ruby
<senthil> we can't have growl notifications sent from a browser right?
sebastorama has joined #ruby
<apeiros_> partially wrong
<apeiros_> you can have the browser send a request to a server running on your computer and have that server translate it to a growl message
ezkl has joined #ruby
ezkl has joined #ruby
<senthil> apeiros_: seems complex for something so simple
<apeiros_> you have an odd idea about simple…
xcvd has joined #ruby
ezkl has joined #ruby
y3llow has joined #ruby
<pangur> http://pastie.org/3776686 gives me the error on line 20. Otherwise it tells me that surname is not the attribute of a nil class. Are my data not getting to my instance attributes? What do I need to do to fix my error, please?
ezkl has joined #ruby
ezkl has joined #ruby
<apeiros_> pangur: yay, you're creating a new class on every request there!
<apeiros_> don't put class definitions inside blocks/methods
ezkl has joined #ruby
<apeiros_> pangur: paste the error you get
<pangur> Is my class definition not within my struct, apeiros_? All I am doing in 10..14 is mapping my data to the attributes? No?
<pangur> ok
<apeiros_> pangur: you define your class within the `get '/fun' do` block
<apeiros_> don't
<apeiros_> put it above it
<pangur> ah
<apeiros_> also, use [] instead of Array.new
<apeiros_> ah, I didn't spot the problem because you indent badly
<pangur> sorry
<apeiros_> .each { … } introduces a new scope for local variables. p is not defined outside of it. do `p = nil` before the each.
<shadoi> pangur: a good general rule is use { .. } when it's a one-liner and do … end when it's multi-line
<apeiros_> shadoi: I disagree :-p
<shadoi> apeiros_: but you're wrong! :)
<apeiros_> a good general rule is use { … } if you care about the return value, use do … end when you care about the side-effect
<apeiros_> single- vs. multiline is easy to see without using {} vs do/end
mengu_ has joined #ruby
mengu_ has joined #ruby
<apeiros_> using do/end for side-effect works nicely with DSLs too, where you usually don't want to use parens.
<shadoi> apeiros_: I guess I almost always only do multi-line blocks for things that I care about the side-effect for.
waxjar has joined #ruby
<apeiros_> and using {} for return values works well because do/end looks stupid when you chain
<shadoi> yup
VegetableSpoon has quit ["Leaving"]
<shadoi> same result, different rule I guess
<apeiros_> not for me. I've a couple of multi-line {}'s
<apeiros_> I rarely ever have single line do/end's, though.
limed has joined #ruby
Guedes has joined #ruby
Guedes has joined #ruby
__class__ has joined #ruby
tijmencc has joined #ruby
chico` has joined #ruby
mdw has joined #ruby
strife25 has joined #ruby
trivol has joined #ruby
two- has joined #ruby
strife25 has joined #ruby
michaeldeol has joined #ruby
mborromeo has joined #ruby
senthil has joined #ruby
strife25 has joined #ruby
__class__ has joined #ruby
<Tasser> apeiros_, good idea
williamcotton_ has joined #ruby
heftig has joined #ruby
Witold has joined #ruby
Witold has joined #ruby
Sailias has joined #ruby
<d34th4ck3r> !next
workmad3_ has joined #ruby
_class_ has joined #ruby
iamjarvo has joined #ruby
pangur has joined #ruby
<pangur> Why can I only get one surname? http://pastie.org/3776844. I was expecting 76 surnames.
Guedes has joined #ruby
__class__ has joined #ruby
cHarNe2 has joined #ruby
<pangur> Should people.each do |p| return p.surname not give me every surname in the array?
looopy has joined #ruby
<d34th4ck3r> pangur: no.
<oooPaul> Return jumps the code block.
<apeiros_> pangur: people.map { |p| p.surname }
<oooPaul> Yes -- try that.
<oooPaul> (beat me to it)
<pangur> thanks apeiros_
<pangur> and oooPaul :)
<pangur> and d34th4ck3r :)
hcumberdale has joined #ruby
cHarNe2 has quit [#ruby]
mxweas_ has joined #ruby
looopy has joined #ruby
<d34th4ck3r> pangur: you can return a value just one time. you can't return something from within loop. you can return something from function. the funtion terminates after return and the lines in the funtion below are not executed.
_class_ has joined #ruby
<pangur> Thanks d34th4ck3r. Where do I put my return for the people.map { |p| p.surname }
dwon has joined #ruby
<pangur> I have tried it after that line and I have tried it within the {} but only one surname each time.
<inemion> Any good resources out there for doing a rails at that would be real time monitoring system? Not sure where to start on this one
<d34th4ck3r> pangur: no where. I'd suggest pack the values into an array and then return the array.
<pangur> Is that not what people.map does?
<pangur> I have the values in people.
jacob1 has joined #ruby
Squarepy has joined #ruby
tommyvyo has joined #ruby
<pangur> When I do return people.to_s - there is only one surname
<d34th4ck3r> pangur: u can user people[index][surname]
emmanuelux has joined #ruby
<d34th4ck3r> *u can use people[index][surname]
<d34th4ck3r> to get the value of specific person's sername.
Squarepy has joined #ruby
<d34th4ck3r> like people[1][surname]
<d34th4ck3r> or people[0][surname]
<d34th4ck3r> basically people is a 2D array from what I could get.
<pangur> It is an array of rows - each row being a person's data.
<pangur> I want each row in the array returned
<pangur> Is that a nested array?
<d34th4ck3r> pangur: yea.
<pangur> So, what I want is for each row to be returned.
<d34th4ck3r> pangur: you can get each row from people using people[index]
<d34th4ck3r> example: people[0] will return first row.
keymone_ has joined #ruby
ken_barber has joined #ruby
<pangur> OK, I can get each person like but I want it to run off the entire contents of the array without my input, as it were.
williamcotton_ has joined #ruby
<pangur> OK, I can get each person like return people[12] but I want it to run off the entire contents of the array without my input, as it were.
_class_ has joined #ruby
looopy has joined #ruby
<pangur> Like a kind of while array loop?
<Squarepy> pangur use an iterator
* pangur looks hopefully at Squarepy :)
* pangur needs a bit more clues
mxweas_ has joined #ruby
* pangur looks clueless
<pangur> The conundrum is how to return all the values in an array but using return after which nothing else will execute.
<Squarepy> a.each{|element| puts element}, or am I being silly
<d34th4ck3r> pangur: create a callback, in which you pass the value and it would return people[value_passed] , not in the main body create a loop calling callback. :P
wbc3 has joined #ruby
<pangur> puts will output to the console but only return will output to the screen.
<d34th4ck3r> pangur: I can return only one value , so, to overcome this problem we use arrays.
<d34th4ck3r> in arrays we pack the value to be returned, and then we access these value using array_name[index_of_value_needed]
<pangur> So, I need to fetch the names from my people array and then join them into a single string and then return them?
<pangur> return the one string
kpshek has joined #ruby
<Squarepy> return an array if you want
<Spaceghostc2c> I'd prefer it if you'd return with a sandwich for me.
<pangur> people.each { |p| return p.surname } only gives me one surname
<apeiros_> pangur: I already told you to use map
<Spaceghostc2c> ^
<d34th4ck3r> pangur: yea, that would just give u first surname
<pangur> people.map { |p| return p.surname } only gives me one surname
<apeiros_> people.map { |person| person.surname } # <-- this will return an array of all surnames
<apeiros_> pangur: no, NOT return
<pangur> It does not matter whether I use map or each - the result is the same
<apeiros_> this isn't java/javascript/php
<apeiros_> pangur: yes, because you put a return in there. don't.
<apeiros_> just as I wrote it.
<pangur> Yeehah :)
<d34th4ck3r> pangur: map is completely different thing from looping, dont get confused there. (If thats what confuses you)
<apeiros_> pangur: http://pastie.org/3776973 - this is what your return does
<Spaceghostc2c> With ruby, the last thing evaluated is the last thing that gets returned, no explicit returns.
<pangur> Thanks apeiros_ - I had not realised that it was returning as it did not use the word :/
<apeiros_> whoopsie, reload http://pastie.org/3776973 - forgot a # sign
<pangur> It is working for me now :) Thanks again, apeiros_ :)
<pangur> d34th4ck3r, the fact that there was not an explicit mention of return made me think that I had to add a return.
ceej_ has joined #ruby
<pangur> I think that I have gotten the hang of it now :)
* pangur realises that he is kidding himself
* pangur goes away feeling pleased that he has learned a few new things - especially about map.
looopy has joined #ruby
d34th4ck3r has joined #ruby
nightlycoder has quit ["Ухожу я от вас (xchat 2.4.5 или старше)"]
Jortuny has joined #ruby
<Jortuny> howdy - how is the seed for Array.sample decided on? (aka, how can I see sample...?)
ZachBeta has joined #ruby
Chryson has joined #ruby
mikepack has joined #ruby
mxweas_ has joined #ruby
<d34th4ck3r> Jortuny: seed ?? random variable's seed?
<Jortuny> d34th4ck3r: the rng's seed
<Jortuny> the docs say sample should take a Random argument, but maybe my ruby isn't new enough :'(
elalande has joined #ruby
gregorg has joined #ruby
gregorg has joined #ruby
startling has quit [#ruby]
<Squarepy> it probably takes the current time, like rand
asobrasil has quit [#ruby]
ben225 has joined #ruby
dshdsgdfdf has joined #ruby
seraph787 has joined #ruby
cinnamon has joined #ruby
guns has joined #ruby
Guedes has joined #ruby
nari has joined #ruby
My_Hearing has joined #ruby
ben_alman has joined #ruby
fbernier has joined #ruby
tewecske has joined #ruby
joaoh82 has joined #ruby
dfamorato has joined #ruby
Asebolka has joined #ruby
dfamorato_ has joined #ruby
iamjarvo has joined #ruby
jcrossley3 has joined #ruby
_null has joined #ruby
bwlang has joined #ruby
pu22l3r_ has joined #ruby
jcrossley3 has quit ["ERC Version 5.3 (IRC client for Emacs)"]
KL-7 has joined #ruby
fayimora has joined #ruby
sspiff has joined #ruby
chico has joined #ruby
sspiff has joined #ruby
inemion has joined #ruby
slonimsky has joined #ruby
<Shamgar> Question for you guys. I'm working on a client that speaks a protocol that requires sending messages that are the length of the message + msg
<Shamgar> i.e. msg = "cmd blah blah"
<Shamgar> length = [msg.length].pack(n)
<Shamgar> newmsg = length << msg
<Shamgar> I then need to send that to the remote tcp socket
<shadoi> hmm, I think you want to pack after combining.
<Shamgar> Some of these can be quite long, and I need to do them by increments
<Shamgar> only the length should be packed
<shadoi> … odd
<Shamgar> it reads those bytes, then reads <x> bytes based on unpacking that
<Shamgar> on the remote end
<Shamgar> So, I have a socket open
<Shamgar> and I'm trying to send the message
<Shamgar> I created a socket with Net::InternetMessageIO.new(s)
<Shamgar> where s is the result of a Socket.connect call
<Shamgar> but when I call @socket.send(msg, 0) I get an exception
<Shamgar> It complains about the 'NUL' in the message (because some of the packed data comes out as \0)
<Shamgar> and claims there's "no such method"
<Shamgar> I thought "send" was the right method to use, so I would get back the length of bytes written and I could loop until all of the message was sent
<Shamgar> the others all seem to be line oriented, which isn't what i want.
<shadoi> you have the stack trace?
beilabs has joined #ruby
<Shamgar> that's an excerpt
<Shamgar> hang on
michaeldeol has quit [#ruby]
<Shamgar> added as a comment on that gist
<Shamgar> it's not very long
icy` has joined #ruby
icy` has joined #ruby