<banistergalaxy> can someone give me a regex that matches all strings except ones that begin with ‘-’ ? <kp666> @banistergalaxy /A[^-]/ <methoddk> regex makes my head hurt <banistergalaxy> kp666: thanks, but it has to be a string of alphabet characters, i dont want it to match numbers too lke “0″ it should not match <banistergalaxy> sorr i didnt make that clear <methoddk> http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ <sjang> Try this: /(^[^-].*$|^$)/ <sjang> Well… never mind. <kp666> @banistergalaxy u mean something like this /^[a-zA-Z_]*$/ ?? <kp666> @banistergalaxy try this : /^[^-][^0-9][a-z]*$/ <kp666> or ^[^-][^0-9][a-zA-Z]*$ <banistergalaxy> kp666: thanks <GSpotAssassin> newbold_cloud: OS X has cron, but Apple came up with its own init.d type process that also assumes all cron responsibilities <GSpotAssassin> newbold_cloud: But the cron daemon is still there <banistergalaxy> kp666: why does this return nil? /^[^-][^0-9][a-z]/ =~ “a” <GSpotAssassin> banistergalaxy: you’re not making those first characters optional <GSpotAssassin> [stuff][stuff] means “match something” <GSpotAssassin> like [^-] means “match a character that is not a hyphen” and then you don’t specify a count of +, * or {i,j} after it so it assumes you are looking for exactly 1 character that is not a hyphen <banistergalaxy> GSpotAssassin: I want to be able to match only words that dont start with ‘-’ (i dont awnt to match numbers either, so -4 or 4 is a no match, but “hello” is a match and “-h” is a no match” <banistergalaxy> ) <jsonperl> can anyone shed any light on this: <jsonperl> [BUG] Stack consistency error (sp: 52, bp: 53) <jsonperl> what does [BUG] indicate… like a known bug in ruby or something? <banistergalaxy> jsonperl: segfault <banistergalaxy> jsonperl: usually <banistergalaxy> jsonperl: or just a core error in Ruby itself, it’s either a bug in ruby core, or a bug in a C extension that is doing crzy shit <jsonperl> well <jsonperl> … <GSpotAssassin> banistergalaxy: so just do /^[^-].*$/, the only catch being that it will only match strings of at least 1 character <jsonperl> it’s my c extension <jsonperl> that is doing crazy shit <GSpotAssassin> banistergalaxy: I didn’t include numbers there hold on <jsonperl> it’s really crap debug info though… any thoughts on how to go about debugging? <banistergalaxy> jsonperl: use gdb <GSpotAssassin> banistergalaxy: /^[^-][^0-9]*$/ I think <banistergalaxy> GSpotAssassin: that sitll matches “0″ <banistergalaxy>
<jsonperl> any idea what sp and bp represent? <jsonperl> sp: 52, bp: 53 <banistergalaxy> jsonperl: stack pointer, base pointer <GSpotAssassin> banistergalaxy: /^[^-0][^0-9]*$/ I think <GSpotAssassin> lol <GSpotAssassin> oh you may have to escape the hyphen, not sure <banistergalaxy> GSpotAssassin: hehe, but i dont want it to match ANY nubers
<GSpotAssassin> banistergalaxy: /^[^-0][^0-9]*$/ I think <GSpotAssassin> banistergalaxy: /^[^-0-9][^0-9]*$/ I think <banistergalaxy> GSpotAssassin: but that still matches “2″ right <methoddk> i don’t understand how it means NOT a hyphen <GSpotAssassin> how about that <banistergalaxy> GSpotAssassin: haha finally, i think that works!
thanks <GSpotAssassin> methoddk: [^ starts a "not in this set" matcher <GSpotAssassin> banistergalaxy: it's still not perfect... but what in programming is. it should get you there tho. YW <methoddk> so basically not a - not a number, anything else <GSpotAssassin> [^-0-9] means match any single character that is not a hyphen and not a digit <GSpotAssassin> you can specify a range of characters so 0-9 is the set of digits <methoddk> whats the /^ <GSpotAssassin> there is no /^ <methoddk> in the beginning <GSpotAssassin> there is only a [^ in the beginning. there's a backslash which escapes the hyphen so the regex parser won't try to interpret it as some kind of set of characters, it treats it like a "real" hyphen. It m <GSpotAssassin> along the same lines, since a period in regex means "match any character", if you want to *actually* match a period you need to escape it with . <GSpotAssassin> escaping with backslash in almost all programming languages means "treat the character following the backslash as a literal thing" <GSpotAssassin> like, don't try to parse it <GSpotAssassin> i gotta go to bed, have fun with regex... try this http://rubular.com/ Session Close: Tue Feb 07 00:52:03 2012 * Disconnected * Attempting to rejoin channel #ruby * Rejoined channel #ruby * Topic is 'Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/' * Set by apeiros_!~apei...@80-218-50-128.dclient.hispeed.ch on Thu Aug 26 17:55:05 -barjavel.freenode.net:#ruby- [freenode-info] if you’re at a conference and other people are having trouble connecting, please mention it to staff: http://freenode.net/faq.shtml#gettinghelp <nobitanobi> oooPaul: sorry I was away <nobitanobi> that nil? is working fine <nobitanobi> if it exists it goes in <oooPaul> Ah, cool. <nobitanobi> the thing is <nobitanobi> I want to select <nobitanobi> some value depending on that in one lin <oooPaul> Select in what context? <nobitanobi> 1 if @client.state <nobitanobi> in a html selector <oooPaul> Ah. <nobitanobi> it’s cool, I just need to know the syntax <nobitanobi> 1 if @client.state 0 otherwise <nobitanobi> can’t that be done in one line in ruby? <oooPaul> @client.state.nil? : 0 : 1 <oooPaul> Er, sorry <oooPaul> @client.state.nil? ? 0 : 1 <nobitanobi> not nil <nobitanobi> actually I have to check <nobitanobi> if it’s true or false <nobitanobi> but yes, I got it <oooPaul> Oh, hmm. <nobitanobi> @consumer.state? <nobitanobi> should do the trick <oooPaul> I think I’m still missing the point of what you’re doing, sorry.
<nobitanobi> hehe <nobitanobi> let me clarify <nobitanobi> I have two states <nobitanobi> 1 and 0 <nobitanobi> I also have a selector <nobitanobi> active = 1 <nobitanobi> inactive = 0 <nobitanobi> when I get the result back from the databse, I want to select from an HTML selector <oooPaul> I think the question is — are you treating “nil” and “false” as the same thing. <nobitanobi> not anymore <nobitanobi> I was <nobitanobi> now everything is wroking as expected <nobitanobi> so thank you <oooPaul> Or are you just differentiating between “nil” and “true/false”. <nobitanobi>
<oooPaul> AH, cool. <oooPaul> Glad I could help in a strangely roundabout way.
<nobitanobi> haha <nobitanobi> you did <turtleR> Hey – anyone there? <turtleR> Does anyone do R programming here? <oooPaul> Yo. <turtleR> Hey Paul - <turtleR> do you know how to code R ? <oooPaul> If by R you mean “Ruby” and/or “Rails”, then yes. <oooPaul> Note there’s also a #rails group if you’re more Rails-focused. <turtleR> lol – my bad …. I’m actually looking for someone that can program ‘R’ <turtleR> as in the biology code
<oooPaul> Ah… <oooPaul> Not me, then.
<turtleR> Lol – no worries <turtleR> do you think one of the other chat windows here would have someone that does? <oooPaul> Hmm, dunno. <oooPaul> Any links from the R homepage, maybe? <yoklov> hm, why is “{ +: “plus” }” a syntax error? <Okasu> hello <yoklov> hi <Okasu> http://ideone.com/IpWbZ why this happening? i just want to set first elemant of first array to bar <Okasu> not every first element of every aray <oooPaul> yoklov, are your first two quotes really backwards? <yoklov> err <yoklov> the stuff between “ and ” are the code <oooPaul> Oh, that’s just your quote. <oooPaul> +: is ambiguous. <oooPaul> If you really want a symbol key, try :+ => ‘plus’ <canton7> Okasu, you’re assigning the arrays by value… Try the block form of Array.new <yoklov> hm, i figured, do you know what exactly what it thinks it is? <yoklov> yeah, thats what i am using now <oooPaul> Yeah. { :+ => “plus” } works <oooPaul> I don’t like the hash style.
<yoklov> the { foo: bar } style? <oooPaul> Er, the “new” hash style <oooPaul> Yeah. <oooPaul> I prefer the rocketships. <oooPaul> Especially because then it’s really obvious when the key is either a symbol, hash, or variable. <Okasu> canton7: wha, i’m whant to set up every element of 5 arrays to nil <yoklov> right, but the value in my hash is a lambda <yoklov> so “:+ => ->(a, b) { a + b }” looks weird <oooPaul> { :foo => “bar” } is obviously a symbol key, { foo => “bar” } is obviously a variable, and { “foo” => “bar” } is obviously a string key. <yoklov> arrows everywhere :p <canton7> Okasu, foo = Array.new(5){ [nil]*5 } <oooPaul> Putting the lambda in there with the regular markup ISN’T weird?
<Okasu> canton7: oh, nice, thx a lot <oooPaul> You could use the word “lambda” and remove the confusion. <yoklov> right <yoklov> i was just thinking that <yoklov> the real problem is the lmabda syntax <oooPaul> Without knowing your actual problem space… Would it make more sense to use a Proc? <yoklov> isn’t the only difference what return does? <yoklov> this is a toy RPN calculator <oooPaul> Not sure, I don’t play with lambdas all that much… <oooPaul> But if that’s the only difference, seems like it might be cleaner.
<yoklov> Ah, I learned to program in scheme, iirc the difference between proc and lambda is if you use “return” in a proc it returns from the function where you’re calling it <yoklov> which is basically never what i want (not that I really ever use return) <oooPaul> I haven’t done Scheme since ’93, so…
<yoklov> haha you’ve been at it far longer than me then <oooPaul>
<hubub> evening all <hubub> managed to fix all the ruby issues I was having so just wanted to thank anyone in here that gave me assistance before <xxtjaxx> Hi! I have a problem with running a ruby app (haml) from the console it writes the the following to the console: http://paste.debian.net/155512/ when I try to run it as can be seen in the first line of the pa <yoklov> How can i figure out if a string represents a number? “foo”.to_i returns 0, which… doesn’t help me <banisterfiend> yoklov: Integer(“hello”) <yoklov> haha, thanks, I had found it though (also needed Float) <banisterfiend> yoklov: another way is: str.to_i.to_s == str <yoklov> oh that is clever <banisterfiend> yoklov: i think u secretly knew it though, deep in your heart <yoklov> haha, hardly. I like that by doing “Integer(foo) rescue Float(foo)” i can get it even if it’s a floating point number too much to use “s.to_i.to_s == s” even if it is really quite clever <yoklov> or is that bad style? <banisterfiend> yoklov: why not just do Float in the beginning <banisterfiend> Float(foo) <yoklov> hrm. you know, I hadn’t really thought about it <banisterfiend> hehe <banisterfiend> cute <yoklov> hey, so i haven’t written ruby in a while, and just wrote some code i’m planning on making into a blog post. before i go ahead and make a huge fool of myself, would anybody be willing to tell me if i’m doing <swarley> yoklov, <swarley> live 40 <swarley> raise ‘Unknown term type: #{term}’ <swarley> you need “” <swarley> to use the #{} <swarley> line* <Seuss> yoklov: that’s pretty though <yoklov> err, pretty though? <Seuss> yoklov: that’s pretty, though <swarley> yoklov, line 40 <swarley> raise ‘Unknown term type: #{term}’ <swarley> you need double quotation marks <yoklov> oh right, because of the interpolation <msch> hi guys, do you know why Object#ergo never became mainstream, unlike Object#try ? <Seuss> > – 5 2 <Seuss> ### Stack: <Seuss> 2.0 <Seuss> 5.0 <Seuss> -10.0 <Seuss> :/ <yoklov> hm. <yoklov> that should error. <Seuss> yoklov: do you have a book? <yoklov> no <Seuss> where’s your blog <Seuss> oh ok <Seuss> do you want one? <Seuss> well if you already know ruby/some other lang, it’s probably unnecessary <yoklov> yeah i know a few programming languages <yoklov> none well thouhg :p <yoklov> it really didn’t give you an error with “- 5 2″ <yoklov> ? <Seuss> nope. <yoklov> bizarre, were there things on the stack before that? <Seuss> yep. <yoklov> oh that makes sense <yoklov> what you said before is expected behavior then <Seuss> oh okay. <yoklov> reverse polish notation == postfix notation <Seuss> ok <swarley> yoklov, do you need to chomp the input? <swarley> not sure how readline behaves, i use gets <yoklov> readline is the same as gets but can throw an EOFError <swarley> oh, okay <yoklov> because i wanted to supporte it closing if the user hit ctrl-d <yoklov> for some reason. <swarley> Oh, okay <swarley> well <swarley> there is always while !$stdin.eof? <swarley> but readline is better for readability <yoklov> i had no idea that was a thing <swarley> It should be under IO <swarley> let me check <swarley> http://ruby-doc.org/core-1.9.3/IO.html#method-i-eof-3F <yoklov> i saw IO.eof? but i didn’t know that $stdin existed <yoklov> err IO#eof? <swarley> ah <swarley> it blocks though <swarley> let me see the last time i used it.. <swarley> oh you’ll want <swarley> IO#eof <swarley> no ? <swarley> return if $stdin.eof <yoklov> hm, and that doesn’t block? <fukawi2> I’m new to ruby; am I meant to add /var/lib/ruby/1.8/bin to my PATH? :-/ <swarley> fukawi2, what is the reason for that? <swarley> if its for your execution path then there should be ruby in /usr/bin <heftig> yoklov: seems unnecessarily complex <heftig> yoklov: https://gist.github.com/1764569 <yoklov> yeah? <yoklov> i intentionally didn’t want to use any reflective/metaprogramming <yoklov> … though wow, that is _much_ shorter. <swarley> yeah i cant read that one well lol * yoklov is shown up <fukawi2> swarley, to execute gems (ie, “rhc-” gems for RedHat OpenShift)… but I’ve just upgraded to debian’s testing version of rubygems and it seems they’ve moved executables to /usr/local/bin
<heftig> 1 -2 abs / <swarley> oh okay <swarley> im not sure then, it wouldnt hurt to try <yoklov> heftig: input: “3 4″ response: “3.0 4.0″ input: “+” response: “rpn_short.rb:8:in `rescue in block in
<banisterfiend> heftig: what does heftig mean in english? <banisterfiend> i assume it’s a german word <yoklov> shadoi: haha, i’m hoping to extend it to a minimal stack based programming language <shadoi> heftig = violently <hostile> shadoi: heh. <heftig> http://www.dict.cc/?s=heftig <hostile> code heftig. <shadoi> wow. <banisterfiend> heftig: but you always seemed like such a gentle boy
Feb 142012
You must log in to post a comment.