« Back to channel list

#ruby - 25 October 2013

Forward 1 day »
[03:59:27] Flashmasterson: https://gist.github.com/Flashmasterson/7149274
[04:00:21] sevenseacat: so is that ticket the same ticket as you're calling in the first gist?
[04:01:05] Radar: https://gist.github.com/radar/7149283
[04:01:07] Radar: Works for me
[04:01:18] Radar: Flashmasterson: Try putting the code in a ruby file and running it
[04:01:24] Radar: If it still doesn't work, gist that file
[04:02:22] sevenseacat: not really weird, i cant see where you';re defining the methods on the same instance that you're calling all the print code on
[04:03:41] Flashmasterson: https://gist.github.com/Flashmasterson/7149315
[04:04:07] Radar: That's the error.
[04:04:11] Radar: But it isn't the file?
[04:04:15] Radar: [15:01:19] <Radar> If it still doesn't work, gist that file
[04:04:22] Radar: Following instructions is hard. Let's go shopping.
[04:04:36] sevenseacat: you arent defining the methods on the same object you're calling printing things o
[04:05:56] Flashmasterson: sevenseacat: i'm not sure i understand, you mean it's ticket = Object.new versus ticket.rb ?
[04:06:03] Flashmasterson: sevenseacat: i'm very new to this stuff
[04:06:33] sevenseacat: in one set of code you defined a bunch of methods on an object, and then in the other code you created a new object and expected all those methods to be available.
[04:06:57] bnagy: I would totally pay $5.50 to see Mark Twain
[04:07:46] |jemc|: only if he was playing his old stuff
[04:07:48] Radar: Flashmasterson: show us ticket.rb please.
[04:07:52] Flashmasterson: sevenseacat: ok i get that, so it's now a matter of me seeing how black is connecting the two in that section of the book
[04:08:11] bnagy: |jemc|: yeah that shit with skrillex was lame
[04:08:47] Flashmasterson: Radar: Flashmasterson
[04:08:47] Flashmasterson: why isn't this ticket object https://gist.github.com/Flashmasterson/7149215
[04:08:47] Flashmasterson: returning as      This ticket is for: Author's reading, at Town Hall, on 01/02/03.///The performer is Mark Twain.///
[04:08:47] Flashmasterson: The seat is Second Balcony, row J, seat 12, and it costs $5.50.    ?  
[04:09:04] Radar: Flashmasterson: you didn't define any methods for that ticket object.
[04:09:13] sevenseacat: ding ding ding
[04:09:18] Radar: Flashmasterson: defining methods in IRB will not make them magically available in your scripts
[04:09:24] Radar: Flashmasterson: You need to define them in the programs themselves!
[04:10:56] Flashmasterson: Radar: ah ok, black didn't specify to use ruby or irb, so i split it
[04:11:15] sevenseacat: where exactly is this?
[04:11:39] Flashmasterson: section 2.2 of the well grounded rubyist
[04:11:56] Radar: Flashmasterson: Ok. When you're running a Ruby program you need to set up all the code in the one file.
[04:12:16] Radar: IRB is a completely isolated environment. It's useful for testing out code and that's it.
[04:12:31] sevenseacat: "save all of the code to a file called ticket.rb"
[04:12:31] Radar: In the one file you can require other files which set up more code...
[04:12:34] sevenseacat: nothing in there about irb
[04:12:59] Flashmasterson: or text editor though, so i got confused
[04:13:19] Flashmasterson: programming is a place to be easily confused
[04:13:27] sevenseacat: you need to be told that to save code to a file called ticket.rb, you need to open your text editor?
[04:13:40] sevenseacat: and create file called ticket.rb?
[04:14:12] Flashmasterson: man… i went to college for music, this is so opposite of the world i know. easy.
[04:15:06] Flashmasterson: even if i laid out the simplest way to transpose an viola melody for you, you'd screw it up
[04:33:44] Flashmasterson: ok so i created this gist https://gist.github.com/Flashmasterson/7149471 as Object.new, then ran this gist https://gist.github.com/Flashmasterson/7149475
[04:34:15] Flashmasterson: but the result is still this gist https://gist.github.com/Flashmasterson/7149479
[04:37:05] bnagy: Flashmasterson: you need to read some very, very basic stuff and then come back
[04:38:11] bnagy: I think a lot of the ruby code in Zed Shaw's ruby the hard way is non-idiomatic, but at least it starts you at absolute zero
[04:38:18] bnagy: or Learn to Program maybe
[04:38:36] Flashmasterson: bnagy: ok well i don't have money for more books right now
[04:38:46] Flashmasterson: so maybe you can be nice
[04:38:49] bnagy: both free afaik
[04:38:53] bnagy: hardway is online
[04:39:26] Flashmasterson: so what do you do here then?
[04:39:51] bnagy: help those that help themselves?
[04:40:12] Flashmasterson: buying this book and spending 10 days on chapter one isn't helping myself?
[04:40:37] bnagy: for which I receive a handsome stipend and my name in the newpaper, plus an annual parade
[04:41:00] bnagy: I don't know what book you've got
[04:41:15] bnagy: but some stuff starts out with too much assumed knowledge
[04:41:16] Flashmasterson: the well grounded rubyist
[04:41:25] |jemc|: Flashmasterson: IRC as a whole is a pretty harsh and unforgiving place - the people in this channel are very patient and helpful by comparison. They've given you some good advice, and in exchange you've endured a little sarcasm but please try not to take it personally.
[04:41:26] jrobeson: that's above your pay grade.
[04:42:05] Flashmasterson: great. a lot of people from here recommended that i buy it as the best beginners book
[04:42:17] Flashmasterson: and here i am, trying to take people's advice
[04:42:35] jrobeson: a beginner who already knows the basics of coding i think
[04:42:45] jrobeson: that is.. a ruby beginner.
[04:43:12] byprdct: Hello all. Question. If run someobject.public_methods and it provides me with a list of available methods to use on that object how do I can I figure out how to use each method for that object? (little documentation online for the methods)
[04:43:59] bnagy: byprdct: afaik all you can use is show_source - you can get arity I think, but not really much more
[04:44:14] jrobeson: byprdct, ri <Class::method> is one way to get the docs
[04:44:17] byprdct: wow that kind of sucks
[04:44:18] |jemc|: byprdct: a helpful console tool is ri
[04:44:20] bnagy: cause we're pretty flexibly typed
[04:44:42] byprdct: ahh perfect thanks jrobeson
[04:44:47] jrobeson: and on the console with pry you can get the docs IN the console byprdct
[04:44:47] byprdct: thanks bnagy
[04:45:05] byprdct: pry? is that like a pretty print?
[04:45:12] bnagy: sorry I thought you meant programmatically :/
[04:45:13] jrobeson: it's an irb replacement
[04:45:35] byprdct: ok looking into it now - thanks so much guys :)
[04:45:49] jrobeson: Flashmasterson, it's hard for people to judge what people mean when tehy say they are beginners. when i first learned to code. i didn't just use one resource. i bounced around a lot
[04:46:16] jrobeson: i think you will still find that book quite useful even if isn't your ONLY resource
[04:47:35] Flashmasterson: alright well it's free so that's cool. thanks
[04:50:00] byprdct: just seen your post |jemc| thank you going to check it out
[04:52:42] |jemc|: yeah ri is basically a console-based browser for the documentation data generated by Rdoc
[04:53:14] |jemc|: so the info you see when you type 'ri Array' in a terminal is basically the same as what you get from online sources like 'http://www.ruby-doc.org/core-2.0.0/Array.html'
[04:53:46] |jemc|: 'ri Array' gives you general info about Array, as well as a list of methods it takes
[04:54:45] |jemc|: and from there you can view info about an individual method by typing something like 'ri Array#delete_at'
[04:55:33] |jemc|: by default, your ruby installation will store this documentation data for every gem you install
[05:01:01] |jemc|: heh. I think we've been probed
[05:42:45] pen: I'm getting errors when I am writing my own debugger: warning: variable $KCODE is no longer effective
[05:42:57] pen: how do I supress this warning
[05:43:02] pen: or eliminates it
[05:45:00] rjhunter: pen: are you referencing $KCODE in your own code?
[05:45:12] pen: rjhunter: no, i'm using TracePoint in ruby 2.0.0
[05:52:27] rjhunter: pen: Ruby emits that particular warning when something tries to read $KCODE -- see if you can figure out where exactly
[05:52:45] rjhunter: (writing $KCODE is a different warning)
[05:53:02] pen: rjhunter: how do I find that out?
[05:53:28] pen: rjhunter: I never got this warning before, somehow it is starting to appear, all I did is enable TracePoint
[05:54:50] rjhunter: pen: the warning itself probably describes which file and line is triggering the read
[05:55:14] pen: rjhunter: yea, the line that I call enable
[05:55:14] rjhunter: >> puts $KCODE
[05:55:14] eval-in: rjhunter => /tmp/execpad-51a4c69c320b/source-51a4c69c320b:2: warning: variable $KCODE is no longer effective ... (https://eval.in/57293)
[05:56:21] pen: rjhunter: that's weird
[05:56:25] DanBoy: i read they did away with that in 1.9
[05:56:30] bnagy: are you using the built-in 2.0 TracePoint, or the old gem?
[05:56:42] pen: bnagy: 2.0 TracePoint
[05:56:56] pen: i'm also getting warning: variable $= is no longer effective
[05:57:08] bnagy: can you create a short repro?
[05:57:44] pen: bnagy: it's a vim plugin with ruby binding
[05:58:16] pen: bnagy: I don't know if I can recreate this easily, but I can try to upload the repo to github
[05:58:52] bnagy: if you can unstick the ruby code from vim and still see the issue, that would be good info
[06:00:55] pen: https://github.com/pencilcheck/bucket.vim
[06:01:30] pen: bnagy: well, before I move to vim, I never think I have this issue before
[06:08:26] bnagy: huh.. well nothing jumps out as obviously stupid, sorry
[06:08:42] bnagy: can you use your bucket stuff in irb etc?
[06:10:04] zipper: Could anyone send me a link to an article that explains how to add directories to $LOAD_PATH
[06:10:46] bnagy: $: << '~'
[06:10:59] bnagy: but don't, it's code smell
[06:11:20] zipper: bnagy: say what?
[06:11:41] bnagy: modifying load path is usually a sign of doing something wrong
[06:12:18] zipper: well what if I want to require a file in the same directory?
[06:12:24] mark06: how can I delete all occurrences of a substring from a string? something more elegant than gsub(foo, '')
[06:12:27] zipper: what do you advise I do?
[06:12:33] mark06: slice will remove only first occurrence
[06:12:37] bnagy: zipper: use require_relative
[06:12:56] zipper: bnagy: is that really better practice?
[06:13:08] bnagy: >> "voodoo".delete 'oo'
[06:13:08] eval-in: bnagy => "vd" (https://eval.in/57294)
[06:13:19] bnagy: zipper: yes.
[06:14:10] bnagy: mark06: ^^
[06:15:55] zipper: bnagy: uh why do you think the following would fail when tried in irb:
[06:16:03] zipper: ` $LOAD_PATH << /home/urbanslug/code/ruby/rails/koans/RoughWork/ `
[06:16:23] zipper: Yet that is a valid path?
[06:16:28] mark06: bnagy: it does not accept a regex
[06:16:44] bnagy: mark06: you said substring :)
[06:17:09] bnagy: zipper: probably you forgot to put it in quotes
[06:17:10] rjhunter: bnagy: I'd go the other way -- I'd prefer making sure the load path is set up properly (ideally, outside of code) and using plain `require`.
[06:17:15] mark06: bnagy: sorry, actually regex is for case insensitive, so any way to delete do that?
[06:17:40] mark06: bnagy: gsub(/foo/, "") is so ugly you know :)
[06:17:40] bnagy: mark06: I would use gsub /oo/i, ''
[06:17:53] rjhunter: bnagy: I'd be interested to hear your opinion in more depth sometime
[06:18:44] bnagy: rjhunter: modifying an interpreter-wide global instead of using a require_relative, which has been introduced for that _exact reason_ is overkill and dangerous
[06:19:10] bnagy: although the danger is unlikely to be a real-world issue - ie if they can pollute local dirs you have worse issues
[06:19:34] bnagy: and if you're loading relative stuff SO OFTEN then it should probably just be a gem anyway
[06:19:35] mark06: bnagy: I think I'll give up on lowercase, it's a currency symbol, "R$", I think people don't usually type "r$"
[06:20:29] mark06: bnagy: and the string should not have more than one occurrence, so no problem crashing if so
[06:35:48] zipper: Is initialize a private mathod by default?
[06:35:56] mark06: thanks all
[06:36:58] bnagy: >> String.private_methods.include? :initialize
[06:36:59] eval-in: bnagy => true (https://eval.in/57295)
[06:43:12] zipper: bnagy: please have a look: http://pastebin.com/Vp3bbBjA
[06:45:25] bnagy: you probably want to expose @car_type with something like arr_reader :car_type, then check car.car_type == "Toyota"
[06:46:38] zipper: So uh where exactly is the problem? Is that method private? I'm sorry I didn't understand your paste.
[06:47:07] zipper: googles arr_reader
[06:48:18] bnagy: sorry attr_reader, was a typo
[06:48:33] bnagy: you should never call initialize directly
[06:49:34] CaptainJet: The only reason to call initialize directly is if you're overwriting #new
[06:50:13] zipper: Man I see people doing it all over these learn ruby things
[06:55:37] zipper: bnagy: uh same error despite adding attr_reader :car_type
[06:55:43] zipper: see this: http://pastebin.com/Vp3bbBjA
[06:56:39] zipper: sevenseacat: http://www.tutorialspoint.com/ruby/ruby_classes.htm
[06:58:04] sevenseacat: theyre not calling initialize directly
[06:58:34] bnagy: zipper: you have to actually do both things I said, not just half of it :)
[07:00:19] zipper: bnagy: check where exactly? I doubt that is something I can learn from a google search.
[07:00:36] zipper: sevenseacat: look under `Custom Method to create Ruby Objects :`
[07:01:02] sevenseacat: yes, they are *defining* an initialize method
[07:01:05] bnagy: assert_equal "Toyota", car1.initialize <- use car_type not initialize
[07:01:06] sevenseacat: they are not *calling* it directly
[07:03:07] zipper: bnagy: ah! I see what you mean
[07:03:31] zipper: because attr_reader created a new method called car_type implicitly, right?
[07:05:50] zipper: sevenseacat: ah! now I get what you mean!
[07:06:27] zipper: I was so focused on getting it to work I didn't quite undertsand what you meant by dib't call initialize. I understood it as don't declare.
[07:10:50] pen: bnagy: hey
[07:11:23] pen: bnagy: Yes, but as I said earlier, it doesn't happen before and I'm confounded.
[07:16:27] zipper: Why's Poignant Guide to Ruby: http://mislav.uniqpath.com/poignant-guide/
[07:16:49] sevenseacat: i didnt much like that
[07:17:16] popl: sevenseacat: it's probably ok if you're someone with add
[07:17:19] zipper: bnagy: ha! I have a very funny thing to tell you.
[07:17:35] zipper: You know what Swahili is? It's a language. A language that people speak.
[07:17:39] zipper: The language has the word bangi which sounds similar to bnagy
[07:18:07] popl: bnagy is Swahili for "curmudgeon"
[07:18:25] zipper: bnagy: Now ask me what bangi means
[07:20:19] zipper: popl: do you know swahili
[07:21:09] popl: zipper: jambo means hello
[07:21:50] popl: Does knowing a few words in Swahili mean that one knows Swahili?
[07:21:58] zipper: Ok brb to tell you what that guy's name means and probably why he would hardly get through airports in parts of Africa without getting thoroughly searched.
[07:22:11] zipper: popl: ever been to Africa?
[07:22:17] zipper: Where in Africa?
[07:22:33] popl: I just read a lot about African cultures.
[07:22:37] popl: I'm a nerd.
[07:24:01] zipper: popl: I'm Kenyan In Kenya All Kenyan.
[07:25:08] popl: I had a roommate who was from Côte d'Ivoire.
[07:25:55] zipper: popl: I doubt they speak Swahili though. It's an east and central african language.
[07:26:28] zipper: Anyway bangi means weed and I've been thinking about it ever since I joined this channel.
[07:26:38] popl: I thought we were talking about our links to Africa. I did not suggest they spoke Swahili. :)
[07:26:47] popl: They spoke French, really.
[07:26:53] popl: And English of course.
[07:26:57] popl: Very good English.
[07:27:41] popl: I knew someone once who spoke Xhosa. That's a neat language.
[07:28:30] zipper: That is cool.
[07:51:24] Sharetel: Hi, while starting Redmine, I am getting this error: /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query': Mysql2::Error: Unknown table engine 'InnoDB': SHOW CREATE TABLE `issue_relations` (ActiveRecord::StatementInvalid). Please can someone help me on this?
[08:16:16] Vaibhav_Rajput: Can someone please help me out with this http://stackoverflow.com/questions/19565775/ruby-create-subprocesses-based-on-max-subprocesses-limit
[08:18:49] zipper: What is the relevance of the inspect method? Why not just use to_s?
[08:19:56] bnagy: Vaibhav_Rajput: I'd check out grosser/parallel on github, that will do process pools for you
[08:20:36] bnagy: zipper: they're different
[08:20:58] bnagy: inspect gives you the 'closest to internal' representation
[08:22:30] zipper: ACTION moves on to learning about fixnum
[08:25:08] Vaibhav_Rajput: bnagy, How it is efficient to use it?
[08:26:08] bnagy: uh.. efficient?
[08:27:19] Vaibhav_Rajput: bnagy, for example I wanted to create 100 processes, at a time i can execute only 10 process if any of the processes among 10 complete its work or job is done then only it should create another process
[08:27:48] bnagy: yeah, that's what the gem does
[08:28:43] bnagy: you can also do it with threads, if you use jruby or rubinius
[08:30:39] Vaibhav_Rajput: bnagy, I am really not getting it. Can you tell me how I can configure it for my problem?
[08:32:02] bnagy: the docs on the github are pretty clear, dude
[08:33:23] bnagy: Parallel.each( list_of_stuff, in_processes: 10 ) {|thing| #do stuff}
[08:33:55] bnagy: there's another one people use called Peach, I think
[08:34:46] bnagy: https://github.com/schleyfox/peach but I think it's threads only, so not so hot for MRI
[08:35:23] Vaibhav_Rajput: bnagy, Dude, It is pretty easy. I understood now. Thanks man.
[08:36:40] Vaibhav_Rajput: bnagy, I am going with parallel.
[08:36:55] Vaibhav_Rajput: grosser parallel.
[08:37:24] bnagy: I have used it a lot, seems to work pretty well.
[08:37:59] bnagy: mainly use native java threadpools now
[08:45:57] zipper: uh what type is a word that starts with a colon?
[08:46:03] zipper: e.g. array = [:peanut, :butter, :and, :jelly]
[08:46:52] supreme__: Hi, can someone help recommend a good and simple algorith for calculating tredning topics? say topic A has 10 hits but they all happend 60 minutes ago and there is topic B which has 8 hits but all happend in last 5 minutes, then topic B is "hotter/trendier"
[08:47:03] Senjai: zipper: :peanut.class :P
[08:47:05] supreme__: but need to understand the time thing, alternatives and how it effects
[08:47:11] supreme__: but should be simple no overkill
[08:47:22] zipper: Senjai: thanks
[08:47:28] zipper: sevenseacat: thanks
[08:47:57] supreme__: I get the hits over real time (streaming)
[08:48:31] Senjai: supreme__: I'd suggest picking up a book. http://www.manning.com/marmanis/
[08:49:12] Senjai: books solve everything
[08:49:42] popl: Senjai: dyslexia?
[08:49:52] supreme__: Senjai: nice book, thanks. but it did not include just this that I requested
[08:50:52] Senjai: supreme__: Well, we can't exactly sit here and design an algorithm completely for you. Make an attempt, try, show your output, and give us an example of what your output should hope to look like
[08:51:12] Senjai: popl: Some ebooks can be programmatically read :P
[08:51:19] Senjai: popl: e.g. text to speech.
[08:51:22] zipper: How can I get the index of an element after entering the element of the array? e.g array = [12, 11, 100] How can I enter 100 and get it's index?
[08:51:50] bnagy: supreme__: you want to weight recent hits more highly. Recent -> small number of seconds ( miliseconds whatever ) ago
[08:52:35] bnagy: supreme__: so look at ways to make small numbers big and big numbers small, eg 1/x or a_large_number -
[08:52:56] bnagy: or, like a million other ways
[08:53:20] bnagy: I imagine this is a well covered area on teh googlez
[08:53:25] Senjai: zipper: hmm? array[2] == 100
[08:53:51] zipper: Senjai: no not like that
[08:53:53] bnagy: [12,11,100].index 100
[08:54:00] bnagy: >> [12,11,100].index 100
[08:54:00] eval-in: bnagy => 2 (https://eval.in/57332)
[08:54:05] zipper: I mean if I didn't know what it's index was
[08:54:21] Senjai: bnagy: too awesome :P
[08:54:55] supreme__: bnagy: exactly. but what is this type of algorith called so I can read up on?
[08:55:11] supreme__: I understand that I need a "rate"
[08:55:15] bnagy: 'arithmetic'
[08:55:42] zipper: bnagy: on point
[08:56:05] zipper: bnagy: lol
[08:57:51] bnagy: or like hits_last_minute + hits_last_five / 2 + hits_last_hour / 4 + ...
[08:58:01] bnagy: I'm just makin shit up off the top of my head
[08:59:35] Senjai: You could even do a weighted proporiton, e.g. 20% of the weight from total hits, 40% of weight from hits in the last hour, 20% from number of commnets, 20% of weights from the last 10 minutes
[08:59:43] Senjai: and order by the weight :)
[09:00:00] Senjai: again, making shit up :p
[09:08:22] supreme__: Senjai: ye I could just make shit up but I rather use a standard algorith
[09:08:41] Senjai: supreme__: It's subjective. So there is no "right" answer
[09:08:52] supreme__: Senjai: I know, the algoriths does not "work" either
[09:09:06] Senjai: supreme__: huh?
[09:09:11] supreme__: what I mean is
[09:09:20] supreme__: tredning topics can never be correct or wrong as you say
[09:09:23] supreme__: it depends on the algorith
[09:09:28] supreme__: but they are better and worse :)
[09:11:03] Senjai: supreme__: Google is your friend
[09:11:04] Senjai: supreme__: http://stackoverflow.com/questions/787496/what-is-the-best-way-to-compute-trending-topics-or-tags
[09:11:15] Senjai: http://stackoverflow.com/questions/9283856/deciding-and-implementing-a-trending-algorithm-in-django
[09:12:04] Senjai: http://www.ignitesocialmedia.com/twitter-marketing/trending-on-twitter-a-look-at-algorithms-behind-trending-topics/
[09:12:08] Senjai: need I go on?
[09:12:30] Senjai: http://www.michael-noll.com/blog/2013/01/18/implementing-real-time-trending-topics-in-storm/
[09:12:50] sevenseacat: sif google anything
[09:12:59] Senjai: sevenseacat: sif?
[09:13:29] supreme__: Senjai: the number of different ways todo this is not a problem :)
[09:13:40] supreme__: but like the storm one etc is a bit complex for my situation
[09:13:46] Senjai: supreme__: Then uhh.. Why are you asking it?
[09:13:48] supreme__: but I am looking at "moving average" now
[09:14:02] Senjai: supreme__: uhh.. kay
[09:14:04] supreme__: Senjai: I asked for a simple way.
[09:14:49] Senjai: supreme__: simple and algorithm rarely find themselves in the same sentence ;)
[09:14:57] supreme__: but think I found it in the moving average algo
[09:15:01] bnagy: might want to weight a MA
[09:15:15] bnagy: [XXXXX ] and [ XXXXX] are the same
[09:16:04] supreme__: bnagy: but moving average does take time into account right?
[09:16:11] supreme__: so they are not worth the same right?
[09:16:22] bnagy: in a normal MA they're the same
[09:16:31] bnagy: until values start dropping off
[09:16:33] supreme__: like look at this
[09:16:38] supreme__: https://github.com/pgte/moving-average
[09:16:40] supreme__: this is for node tho
[09:16:46] supreme__: but it takes time into account
[09:17:58] Senjai: Supposedly.
[09:18:44] bnagy: yeah that weights
[09:19:03] supreme__: then I can study that code
[09:19:07] supreme__: not much code
[09:19:11] supreme__: that is what I mean with simple
[09:19:43] bnagy: copying something == simple. OK, I understand.
[09:19:50] supreme__: haha nah nah
[09:19:54] Senjai: bnagy: Made me lol
[09:19:56] supreme__: I will use ruby so no copy paste
[09:20:06] supreme__: but now I can read on wiki about "ma" and "mv"
[09:20:11] Senjai: supreme__: That is just a moving average calculation, thats not an algorithm for trending topics
[09:20:16] supreme__: and look at code implementation to understand and write my own
[09:20:34] Senjai: supreme__: converting that to ruby would take what, a minute?
[09:21:14] supreme__: Senjai: what is missing then?
[09:21:27] supreme__: I got a stream of data coming in for topics
[09:21:29] supreme__: using this algo
[09:21:31] supreme__: plotting on a graph
[09:21:44] supreme__: should be enough for most popular at "time" given a MA value
[09:22:33] bnagy: right, beerz
[09:22:43] supreme__: MA uses to "smooth" it out, right?
[09:23:35] Senjai: supreme__: I feel like you should actually learn what you're talking about. copy and pasting code snippits only go so far, and that will not by itself satiate what would be a modern trending algorithm
[09:24:10] supreme__: Senjai: who ever said I would copy and paste that code and use it, stop assuming things.
[09:24:15] Senjai: like you say 'x' is too complicated for me. Well x might be the right solution, the fact you say its complicated just means "I don't get it and I don't want to figure it out"
[09:24:23] supreme__: neither you or I come up with these algorithms
[09:24:42] supreme__: probaly some greek guy 300 years ago, my job is to find what ways there is, weight them and use one that is good for my case
[09:24:57] supreme__: it's not to complicated for ME per se, just for this given situation
[09:25:10] supreme__: Senjai: I have never said that, you assume that, and it's wrong
[09:25:19] Senjai: supreme__: Okay, tell me how it is too complicated for this situation
[09:26:11] supreme__: I don't want to use something big like Storm for htis
[09:26:26] supreme__: I will either use nodejs with websockets or eventmachine
[09:26:38] supreme__: with websockets aswell..
[09:26:52] supreme__: and use some algo for smoothen the hits out over time
[09:26:55] supreme__: and plot on a graphg
[09:26:59] supreme__: that is my use case
[09:27:09] Senjai: supreme__: Uhm, you dont need to use storm. You can impliment that in any language.
[09:27:14] supreme__: setting up a machine using storm etc just for this, is not worth my time to invest etc
[09:27:45] supreme__: Senjai: storm is a computation system that does 100 things, I want to make 1 thing, why build 99 things I don't need?
[09:28:03] zipper: Ruby has these data structures I never heard of called ranges. This is weird.
[09:28:03] supreme__: that is not to say it's to difficult, it's just more complex then it needs to be
[09:28:19] supreme__: for the given situation
[09:28:52] supreme__: have to eat now :) back later, I appriciate the discussion
[09:29:32] zipper: Ruby has these data structures I never heard of called ranges. This is weird.
[09:31:26] Senjai: zipper: Not really. (1..5) is a range from 1 to 5 inclusive
[09:31:42] Senjai: (1..5).to_a produces [1,2,3,4,5]
[09:32:50] zipper: Senjai: so what's the use of a range?
[09:33:19] zipper: To make it easier for one to come up with an array?
[09:33:21] Senjai: zipper: (1..5).each {|x| print x},
[09:33:28] Senjai: or check if a number is within a range
[09:33:32] zipper: or with a range of values?
[09:33:43] Senjai: e.g. if 1 <= x <= 50
[09:34:03] Senjai: zipper: see http://ruby-doc.org/core-2.0.0/Range.html
[09:34:23] zipper: Senjai: I was reading that
[09:38:05] Senjai: zipper: Ranges are tons of fun, in irb try ("hello".."zzzzz").to_a :P
[09:38:53] Senjai: >> ("hello".."zzzzz").to_a.size
[09:38:54] eval-in: Senjai => [FATAL] failed to allocate memory (https://eval.in/57333)
[09:39:08] Senjai: 8604504 :P
[09:41:20] Senjai: >> size=0; ("hello".."zzzzz").each {|x| size += 1}
[09:41:22] eval-in: Senjai => (https://eval.in/57334)
[09:41:36] Senjai: >> size=0; ("hello".."zzzzz").each {|x| size += 1}; print size
[09:41:38] eval-in: Senjai => (https://eval.in/57335)
[09:41:39] heftig: >> ("hello".."zzzzz").each.size
[09:41:39] eval-in: heftig => nil (https://eval.in/57336)
[09:41:42] heftig: >> ("hello".."zzzzz").each.count
[09:41:44] eval-in: heftig => (https://eval.in/57337)
[09:42:04] Senjai: time limit exceeded
[09:42:17] zipper: I got this as size: 8604504
[09:42:29] Senjai: zipper: Yea, I was just trying to get eval-in to do it
[09:43:21] zipper: Senjai: wow it's looking really cool
[09:43:42] zipper: It looks like I'm scrolling sideways when I'm scrolling up
[09:44:05] heftig: >> "hello".tr("a-z","0-9a-z")
[09:44:05] eval-in: heftig => "74bbe" (https://eval.in/57339)
[09:44:35] heftig: >> "zzzzz".tr("a-z","0-9a-z").to_i(36) - "hello".tr("a-z","0-9a-z").to_i(36)
[09:44:35] eval-in: heftig => 31231523 (https://eval.in/57340)
[09:46:05] zipper: Basically arrays here are like lists. They don't have to hold a specific type.
[10:20:50] helperW: I Just installed RoR. http://rubyonrails.org/download
[10:21:03] helperW: I went to localhost:3000 but nothing is happening What can be wrong
[10:21:10] tobiasvl: #rubyonrails
[10:21:42] helperW: In my folder I did: rails new Application but now there are some setup files etc but the app is stil l not running.
[10:21:54] tobiasvl: please go to #rubyonrails
[10:22:27] helperW: I can't join that chan.
[10:23:22] tobiasvl: /msg nickserv register PASSWORD EMAIL
[11:12:45] zipper: What are such things called in ruby: a5 = Array.new (15) {|e| e*e}
[11:12:56] canton7: the { ... }?
[11:13:02] zipper: the part in the brackets is what I want to understand
[12:16:57] weirdpercent: I have a string "Session Date: March 23rd 2013Lxxxx, Axx, Bxxxxxxxx, Pxxxxxxx, Axxxxxxxx, Pxx, Axxxx, Dxxx, Kxxxxx, Mxxxxxxxx", I want to use a regex to match where 2013 and Lxxxxx meet but I don't know how to phrase it
[12:26:42] _br_: weirdpercent: Not sure what you want to do. You mean this ? /Session Date: .+ [0-9]+[a-z]+ 20[0-9]+/
[12:27:52] _br_: try rubular, helpful for learning a bit about regex.
[12:46:01] gnul0ver: fellow rubist
[12:47:12] gnul0ver: So does anyone in here make any money with Ruby"
[12:47:42] armanm: gnul0ver: what up?
[12:48:08] armanm: gnul0ver: lots of money to be made. Depends on the idea
[12:48:34] gnul0ver: facebook was on ruby
[12:48:45] gnul0ver: at one time
[12:49:42] I_am_female: gnul0ver: when was that?
[12:49:48] I_am_female: I think you're lying.
[12:49:56] _br_: Facebook? No, php.
[12:50:09] armanm: I don't think it was ever on Ruby. Ruby wasn't that great then
[12:50:16] armanm: _br_ agreed
[12:50:18] gnul0ver: witter is built on Ruby on Rails
[12:50:18] gnul0ver: facebook uses PHP primarily, but also relies on "C++, Java, Python and Erlang"
[12:50:20] lupine: facebook was php
[12:50:23] lupine: twitter was ruby
[12:51:00] gnul0ver: well there writer component was built on ruby on rails.
[12:51:32] _br_: Doesn't really matter anyway. Good companies will rely on a variety of languages and tools.
[12:51:40] weirdpercent: I have a string "23rd 2013Lxxxx," and I want to insert a newline between the 2013 and Lxxxx, how do I phrase the regex in the gsub?
[12:51:42] gnul0ver: i think they use Java
[12:52:18] armanm: gnul0ver: where are you going with this?
[12:52:21] _br_: weirdpercent: I already postet that for you.
[12:52:41] gnul0ver: i was just wondering what language did facebook used if it was ror
[12:53:04] _br_: ror is just a framework.
[12:53:13] gnul0ver: just like .net
[12:53:58] weirdpercent: _br_ I saw that regex did match, but HOW do you insert a newline, what is the operator that signifies between \d\d\d\d & \w+?
[12:54:47] _br_: gnul0ver: .net is more, includes eg. CLR
[12:54:50] maasha: I am messing around with mixins and not getting it to work: https://gist.github.com/maasha/d596b1d955ff34d7137a
[12:55:14] maasha: It silently fails
[12:56:11] gnul0ver: i've been learning ruby
[12:56:22] gnul0ver: I came from the C++ .net
[12:56:29] _br_: weirdpercent: match for it and gsub the match data with whatever you want
[12:57:17] _br_: maasha: A good way to learn is to e.g. attach pry debugger and step through your code to see whats going on
[12:57:19] gnul0ver: _br_: you can build a time machine with Ruby's Build in date class. ;)
[12:57:39] _br_: Time machine ? :)
[12:58:28] gnul0ver: so what is the most Useful class in ruby
[12:58:33] maasha: _br_: I was indeed wondering how to debug this.
[12:59:32] _br_: gnul0ver: Most useful? How would one measure that?
[12:59:38] gnul0ver: www.ruby-lang.com/documentation
[12:59:52] gnul0ver: i was just museing
[13:00:29] maasha: _br_: thought, I think that since this is small test code a debugger would be overkill. I am failing something mentally
[13:00:30] weirdpercent: _br_ but the data matches a pattern, maybe what I want to do can't be done with regex. gsub isn't what I need, I need to replace that section of the string with a duplicate containing a newline there
[13:00:48] gnul0ver: maasha: try to unit test mode
[13:01:34] hanmac: hm i think Enumerable is one of the most useful ones ;P
[13:01:47] weirdpercent: Enumerable is bread and butter
[13:02:15] _br_: maasha: I'm not quite sure what this exercise of "Inception" style Mixins is supposed to do, hence my Pry debugger comment.
[13:02:18] gnul0ver: syntactical sugar.
[13:03:08] cout: inception-style?
[13:03:24] cout: (I never saw the movie so I have no clue what that means)
[13:03:50] maasha: _br_: I have a toolbox of modules and classes that I would like to be able to include with a simple "require 'toolbox'". However, namespace should be provided - and will need to be able to do mixins.
[13:03:55] gnul0ver: If you use Ruby On Rails there is a technique to prevent crackers from using the sq-injection method on your website.
[13:05:22] gnul0ver: _br_: are you talking about Modules ?
[13:05:47] gnul0ver: Mixing classes with Modules
[13:06:44] gnul0ver: maasha: name your modules with different name spaces to avoid a name space collision.
[13:07:21] gnul0ver: A.namespace
[13:07:25] gnul0ver: B.namespace
[13:07:43] _br_: weirdpercent: You mean something like this ? "Session Date: March 23rd 2013Lxxxx, Axx, Bxxxxxxxx, Pxxxxxxx, Axxxxxxxx, Pxx, Axxxx, Dxxx, Kxxxxx, Mxxxxxxxx".gsub( /Session Date: .+ [0-9]+[a-z]+ 20[0-9]+/ ) { "#{$&} | " }
[13:07:48] maasha: gnul0ver: so I want one module to be my working namespace. And then a couple of embedded modules for mixins.
[13:08:16] hanmac: there is also some funny parameter for Kernel#load ;D
[13:08:48] gnul0ver: Yes You should declare the module on the top before you start including class.
[13:08:55] hanmac: shevy: did you know the difference between load "path" and load "path", true ? ;P
[13:08:59] weirdpercent: _br_ yes, that question mark is that part of the line?
[13:09:25] _br_: you confuse me.
[13:09:50] _br_: Just open irb or pry or whatever and play with it, its not that hard.
[13:10:01] weirdpercent: "like this ?" that question mark ok thank you very much
[13:10:04] maasha: gnul0ver: did you see my gist?
[13:10:06] gnul0ver: http://www.tutorialspoint.com/ruby/ruby_modules.htm
[13:10:25] gnul0ver: masha i don't know if that would help u
[13:11:31] gnul0ver: #!/usr/bin/ruby
[13:11:31] gnul0ver: require "support"
[13:11:31] gnul0ver: class Decade
[13:11:31] gnul0ver: include Week # I think week is another Method from another class
[13:11:37] maasha: gnul0ver: thanks. I also have the ruby cookbook here, but the examples there are not working for what I am trying.
[13:12:18] gnul0ver: im trying to learn ruby myself
[13:12:33] hanmac: gnul0ver: the first line is wrong, use "#!/usr/bin/env ruby"
[13:12:46] gnul0ver: that's from a website
[13:12:57] hanmac: then the website is shitty
[13:13:02] gnul0ver: so then it's a typo
[13:13:14] gnul0ver: i found a typo on the Ruby's Manual Book
[13:13:24] I_am_female: hanmac: what should it read?
[13:13:57] maasha: hanmac: what is the problem with that hashbang line?
[13:14:47] maasha: hanmac: oh, I misread. "#!/usr/bin/env ruby" is the way to go
[13:14:50] gnul0ver: http://www.rubyist.net/~slagell/ruby/examples.html typo. Written by the big guy him self
[13:14:50] _br_: Its the old form. Rubyists often jump around with ruby vm's hence env is easier to maintain.
[13:15:27] hanmac: I_am_female &maasha: the reason: "#!/usr/bin/ruby" does not work with rvm, rbenv, or self compiled ruby … so when you do "ruby script.rb" and "./script.rb" it runs in different rubies because env uses the $PATH variable
[13:16:02] maasha: hanmac: exactly
[13:17:27] d4heyDU: is there a short way to make [:a, :b, :c], this turns it into a string array
[13:17:29] d4heyDU: >> %w{:a :b :c}
[13:17:30] eval-in: d4heyDU => [":a", ":b", ":c"] (https://eval.in/57355)
[13:18:59] tobiasvl: you don't think [:a, :b, :c] is short enough?
[13:19:02] juan_: d4heyDU, something like this? %w{:a :b :c}.join ' '
[13:19:58] d4heyDU: juan_: well, I want the items in the final array to be symbols, [:a, :b, :c]
[13:20:10] tobiasvl: >> [:a, :b, :c]
[13:20:10] eval-in: tobiasvl => [:a, :b, :c] (https://eval.in/57356)
[13:20:20] tobiasvl: you want to skip the … commas?
[13:20:28] maasha: So this last line in test.rb works as intended: https://gist.github.com/maasha/d596b1d955ff34d7137a
[13:20:32] d4heyDU: yes, i want to skip the commas
[13:20:39] tobiasvl: >> %i(a b c)
[13:20:40] eval-in: tobiasvl => [:a, :b, :c] (https://eval.in/57357)
[13:20:48] tobiasvl: just learned that myself by googling ;)
[13:21:08] maasha: However, I dont understand why method hello is not being replaced when I call the Include Mixin1 ?!?
[13:22:06] d4heyDU: tobiasvl: awesome, thanks! I could have googled but I like the interaction
[13:22:56] hanmac: maasha look at the difference between "include" and "prepend"
[13:23:39] hanmac: >> module A; end; class B;include A;end; B.ancestors
[13:23:39] eval-in: Hanmac => [B, A, Object, Kernel, BasicObject] (https://eval.in/57362)
[13:23:47] hanmac: >> module A; end; class B;prepend A;end; B.ancestors
[13:23:48] eval-in: Hanmac => [A, B, Object, Kernel, BasicObject] (https://eval.in/57363)
[13:24:25] hanmac: maasha: for method calling #ancestors is important
[13:27:42] maasha: prepend. hmmm. another novelty to me :o) - I wouldnt say ruby is a nice small language
[13:27:57] maasha: ruby is a nice language - but small, no
[13:28:38] poseid: the André MÜller ... how would I transcode that to Andre Muller with Ruby 2.0 ?
[13:28:45] hanmac: maasha: its because include cant overwrite an method which is defined in the same class in which the module is included … prepend can
[13:29:01] poseid: the old code Iconv.iconv('ascii//translit', 'utf-8',
[13:29:37] maasha: hanmac: prepend gives the effect I was looking for! very nice! but its so new that its not even syntax hilighted correctly in vi!
[13:29:55] hanmac: >> "André Müller".tr("éü","eu")
[13:29:55] eval-in: Hanmac => "Andre Muller" (https://eval.in/57364)
[13:30:04] maasha: oh it is.
[13:30:11] maasha: its not a keyword but a method on Object?
[13:31:00] hanmac: maasha: hm no prepend if defined in module, i think you miss interpret it with extend … (and PS: include is not a keyword, iven if vi thinks that)
[13:31:25] maasha: hanmac: Oh. wow.
[13:31:35] poseid: hanmac, cool, thanks
[13:31:51] maasha: hanmac: thanks. now I can safely say its beer oclock :o)
[13:40:39] hanmac: good that i didnt tell him how prepend, include, extend works when its done on both the class and the singleton_class of the object of the class ,P
[13:40:51] Amnesia: does anyone over here know a good source which explains how the ruby interpreter works under the hood?
[13:41:19] Banistergalaxy: Google "Ruby under the microscope"
[13:41:24] Amnesia: Banistergalaxy: ty
[13:42:12] Amnesia: Banistergalaxy: people keep talking 'bout "the ruby VM" but in my understanding /usr/bin/ruby is just a binary that translated source code to machine code^^
[13:45:41] Banistergalaxy: Amnesia then you need to read that book ;)
[13:45:52] Amnesia: hm, 360 pages is quite a lot though:P
[13:48:01] lupine: Amnesia, it needs at least that many pages to fix your misconceptions
[13:48:18] swingha: Hi, sorry for my english, i try to create a scripts manager, i explain with examples: https://gist.github.com/anonymous/5778a2dda80ec349e8bc
[13:48:38] swingha: If someone could give me some idea ? Thanks
[13:50:47] eject_ck: how can I check why gem install failing ? http://pastebin.com/HHNv7bR9
[14:01:43] I_am_female: All killer no filler
[14:17:55] _br_: eject_ck: Seems ri or rdoc stuff is failing try installing with e.g. --no-ri --no-rdoc
[14:24:34] _br_: swingha: Whats the point of this? Is this some kind of rspec replacement?
[14:25:44] _br_: swingha: Or is this a "fancy" wrapper around require / Object.send(:remove_const, :Foo) ?
[14:48:23] swingha: _br_, yes a wrapper around require/load for add scripting support to my main app.
[14:48:40] swingha: _br_, and i want to write scripts in a shell-like syntax.
[14:53:59] _br_: swingha: shell like syntax in ruby? Hm
[14:54:41] swingha: _br_, just a simple syntax, example: i want to associate callbacks to events, i do: register(:type) do ...
[15:13:53] mojjojo: how to share variables between functions in a ruby class?
[15:14:06] mojjojo: so to make them public and not private to each function
[15:14:11] sweeper: mojjojo: use instance attributes
[15:14:28] sweeper: for bonus points, initialize them
[15:14:32] sweeper: before use
[15:14:56] mojjojo: and not self.myvar, what is the difference?
[15:15:20] sweeper: mm, 'attributes' is the wrong word, my bad
[15:15:29] volty: @myvar is is and instance variable, attr_xxx is a 'attribute' / attr_accessor defines a self.myvar and self.myvar= methods
[15:15:52] sweeper: http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
[15:22:55] _br_: I have a chain of modals with prev, next and cancel buttons. How can I detect if a modal is just closing because its opening a new modal or closing because the user clicked on the background ? Event wise its always hide, hidden right?
[15:23:06] _br_: ups wrong channel, sorry
[15:24:15] mojjojo: in ruby class everythin is inherited from superclass including attr_accessors and initialize method?
[15:25:01] capncrunch4me: why would I be getting errors if I run a ruby script from cron vs by hand?
[15:25:04] capncrunch4me: getting: `require': cannot load such file -- memcached (LoadError)
[15:25:20] sweeper: mojjojo: yep
[15:25:34] sweeper: mojjojo: but you can override all the things, as well as call super
[15:25:37] volty: capncrunch4me: because of the difference of load path
[15:25:56] capncrunch4me: what is a resolution here?
[15:26:13] sweeper: capncrunch4me: bundle install most likely
[15:26:22] sweeper: ohwait, I read back
[15:26:43] capncrunch4me: so that isn't the solution?
[15:26:44] sweeper: if you're running from cron, you maybe be using a different ruby/env
[15:26:55] volty: solution is to 1) fix root env RUBYLIB 2) explicit path
[15:27:10] mojjojo: and how do I call the function in the same class defined as def func , is it func() ?
[15:27:27] sweeper: mojjojo: yes
[15:27:47] capncrunch4me: how would I tell?
[15:28:24] volty: google for setting env variables with bash
[15:28:50] volty: (probably /etc/profile, ~/.bash_profile -- or similar
[15:28:57] capncrunch4me: we used rvm plus the memcached gem
[15:29:33] volty: first of all you should determine the privileges needed to run that cron
[15:30:09] volty: (not always have to be root -- it depends on what you access, what you run etc etc )
[15:44:22] capncrunch4me: tried export ruby path
[15:46:05] capncrunch4me: set path to /usr/local/rvm/gems/ruby-1.9.3-p448 still can't find it
[15:46:07] capncrunch4me: grr, frustrating
[15:52:33] _br_: when you execute the cron script what does "type rvm" say? Shell function or path?
[15:59:25] micho: hello. Is there any reason, about which I have no idea, why it: http://pastebin.com/WfB8eucs doesn't work?
[16:02:28] matti: I wonder.
[16:02:49] matti: How does one make 0755 in ERB render as-is, instead of its integer value?
[16:06:14] heftig: matti: 0755 is an integer
[16:06:38] heftig: is you want to have it as-is, use "0755"
[16:11:24] matti: heftig: I am not talking about it being a Fixnum.
[16:11:44] matti: I suppose it cannot be helped.
[16:13:53] jonathancutrell: Hey folks - I'm trying to capture a variable from osascript that I'm running via ruby's `system'
[16:14:17] jonathancutrell: the command looks like: system('osascript', '-e' 'display dialog "Question to get answers from" buttons {"No", "Yes"}')
[16:14:58] jonathancutrell: It's easy enough in AppleScript on its own, but this is inside a ruby script of course, so I need to pass that variable back.
[16:28:23] havenwood: jonathancutrell: usually you use backticks (%x) when you care about the result
[16:28:37] jonathancutrell: havenwood: Makes sense.
[16:28:41] jonathancutrell: havenwood: Thank you.
[16:28:44] havenwood: jonathancutrell: guess you could do it manually with exec: pid = fork { exec('osascript', '-e', 'display dialog "Question to get answers from" buttons {"No", "Yes"}') }; Process.wait pid
[16:28:54] havenwood: jonathancutrell: or maybe look at IO.popen
[16:29:17] havenwood: ^ exec is verbose of course, but should work
[16:33:03] ph88: anyone experience with phusion passenger here ?
[16:34:31] micho: hello. Is there any reason, about which I have no idea, why it: http://pastebin.com/WfB8eucs doesn't work?
[16:34:53] micho: I use datamapper (on #datamapper I got no reply)
[16:39:13] perplexa: hi, when i have a class 'x' with 2 dicts 'a' and 'b' and i have a variable 'c' that holds either a or b, can i somehow access x.a or x.b depending on what's in c without using if/else? something like x.eval(c)?
[16:40:56] apeiros: perplexa: I assume you mean *object*, not *class* and I assume you mean you have 2 methods, 'a' and 'b'
[16:41:16] perplexa: i have attr_accessors.
[16:41:17] apeiros: perplexa: if so then see Object#send. c = 'a'; x.send(c)
[16:41:23] apeiros: attr_accessors are methods
[16:41:40] perplexa: i just wanted to keep the question short
[16:41:40] apeiros: then why did you say it?
[16:42:18] perplexa: because you're taking the piss about terminology despite understanding perfectly fine what i'm asking :)
[16:42:33] apeiros: perplexa: ok, next time I'll just ignore you.
[16:43:10] apeiros: if it's too much of a bother for you to use correct terminology then I'm not interested in even trying to help you.
[16:43:45] perplexa: like if i didn't know an object is an instance of a class? ;p
[16:43:53] perplexa: so i'm not allowed to refer to the class itself? :)
[16:43:59] apeiros: perplexa: not all objects are classes
[16:44:02] perplexa: nvm, this is stupid
[16:44:10] apeiros: your question made no sense the way you asked it.
[16:44:19] perplexa: but you got it?
[16:44:32] perplexa: pretty sure it could have been worse
[16:44:38] perplexa: anyways, thanks for helping
[16:44:48] apeiros: yes, keep orienting yourself towards how you could do it even worse
[16:44:58] apeiros: seriously, wtf is wrong with you?
[16:45:10] apeiros: you get told the right terminology, you get help, and you're acting like an ass about it.
[16:45:19] apeiros: learn the f'ing terminology and use it.
[16:45:24] perplexa: i said thanks, f*ckwit
[16:45:31] perplexa: ignore me, be done
[16:45:36] perplexa: i'll do the same, have a nice evening
[16:46:13] apeiros: apeiros kicked perplexa: insults
[16:46:23] apeiros: +b perplexa!*@*
[16:48:38] apeiros: what an ass.
[16:51:13] havenwood: ph88: Some, what's your Passenger question?
[16:51:58] havenwood: micho, oh he left
[16:52:28] havenwood: well, it was of course `user` the method each time being a different instance of User
[16:53:29] sweeper: obviously a python user
[17:33:49] Renich: I want to write a little command line tool; to consume an API
[17:34:05] Renich: that said, I like MVC and I think it could be applicable but I don't want to over complicate
[17:34:09] Renich: any recommendations?
[17:34:29] wuest: Renich: MVC for a little cli tool? Sounds overcomplicated.
[17:34:42] MrZYX: mvc is a design pattern, it's just often misused as an architecture pattern
[17:35:15] Renich: wuest: yeah, but I don't want to have a kilometric file; I'd like to have things separated
[17:35:30] wuest: Separation != mvc
[17:35:37] Renich: since there are a ton of possibilities to the API I am to consume.
[17:35:52] Renich: wuest: yes; I agree. I just mentioned it to add context.
[17:36:21] Renich: any recommendations?
[17:36:57] wuest: My recommendation, if you're thinking a lot about architecture, layout, &c? Go read Design Patterns in Ruby. It's got lots of information on A: how to think about design patterns from GoF, and B: how that thinking translates in an idiomatic way into the Ruby world
[17:38:03] wuest: If purchasing a book isn't in the cards, go look at how other cli applications tend to be laid out. Experiment. Find ways that work and make sense to you.
[17:38:08] Renich: wuest: thanks, I will
[17:40:33] Renich: wuest: is it still relevant; the book? It's 2007
[17:42:14] momomomomo: Renich: http://www.slideshare.net/hyfather/crafting-beautiful-cli-applications-in-ruby
[17:42:32] Renich: thanx, momomomomo
[17:43:40] attomos: oh yeah, I can talk now
[17:47:33] Renich: momomomomo: great stuff on the slides
[17:48:04] momomomomo: agreed, good luck
[17:48:13] Nogbit: Give this one a shot, actual code to work with https://practicingruby.com/articles/building-unix-style-command-line-applications?u=dc2ab0f9bb
[17:48:24] momomomomo: Nogbit: there are examples on the slide deck
[17:48:44] Nogbit: not a complete solution like I linked to
[18:00:13] havenwood: FukUmist: Welcome to #ruby. Can i place your order?
[18:04:34] Akuma: hello, I'm encountering some issues with substrings and encoding. For some reason the encoding of the substring becomes CP850 while the original string is UTF-8
[18:05:32] Akuma: when I try to encode he substring by doing x = y[0,5].encode('UTF-8') I get an error saying that utf8 and cp850 are not compatible
[18:21:23] apeiros: Akuma: you're saying that y.encoding == Encoding::UTF_8 and y[0,5].encoding != Encoding::UTF_8?
[18:30:01] nsxt: are there any libraries for analyzing fluctuations in graph data? i'm not looking to plot anything, rather looking to analyze what _would_ look like a line chart if i plotted a series of values
[18:36:25] Akuma: aperios: yes
[18:36:55] apeiros: Akuma: can you provide a short demo code including output?
[18:37:17] Akuma: sure, gimme a sec
[18:38:27] apeiros: Akuma: can you run this? http://pastie.org/8430517
[18:40:11] Akuma: here is the code: http://pastebin.com/KfTpcCnd
[18:41:35] Akuma: your code shows this: [#<Encoding:UTF-8>, #<Encoding:UTF-8>, #<Encoding:UTF-8>]
[18:41:57] apeiros: ok, can you paste the precise exception you get with your code?
[18:43:21] MrZYX: can you also post Encoding.default_internal and Encoding.default_external?
[18:43:34] Akuma: here is the output: http://pastebin.com/yfmyQXP1
[18:44:10] MrZYX: and lst.encoding
[18:44:11] Akuma: line 162 would correspond to this: nln += "#{field};"
[18:45:10] apeiros: Akuma: btw., unrelated to your issue - you should use the CSV stdlib library
[18:45:22] MrZYX: and nicer variable names :P
[18:45:24] apeiros: makes your code simpler and your output probably more correct ;-)
[18:46:55] Akuma: default external shows CP850
[18:47:04] Akuma: Default internal shows nothing
[18:47:50] apeiros: Akuma: you're probably reading input then and since default_external is CP850, so will be the result of that reading be CP850
[18:47:52] Akuma: apeiros: good to know, I didn't know there was such a thing, I'll probably use it for my next CSV project, this one is more of a one time conversion use
[18:48:28] apeiros: either change default_external or read with explicit encoding argument. e.g. File.read(path, encoding: 'utf-8')
[18:49:13] Akuma: I'm currently doing File.open(filename)
[18:49:34] apeiros: same argument there. File.open(filename, encoding: 'utf-8')
[18:49:53] Akuma: let me give that a try
[18:51:46] Akuma: apeiros: the file open argument did the trick
[18:51:56] Akuma: Thanks a lot, I greatly appreciate it
[18:53:15] apeiros: Akuma: another btw. - foo.each do |x| puts x end --> you can just do `puts foo` instead
[18:53:40] apeiros: line 94-96 in your pastie --> puts nlst
[18:54:22] apeiros: and line 100-104, just File.write(of, nlst.join(''))
[18:54:37] apeiros: (might need the encoding argument too btw.)
[18:54:58] Akuma: puts will print on screen?
[18:55:06] apeiros: puts is almost the same as print
[18:55:19] apeiros: yes, it prints on screen
[18:55:33] Akuma: still getting acquainted with ruby
[18:55:36] apeiros: additionally it appends a newline to the output if none is present. and it can print an array of strings directly.
[18:57:45] Banistergalaxy: Apeiros Sup Swiss guy
[18:58:04] apeiros: Akuma: http://pastie.org/8430563 - alternative way to write your line 37-49
[18:58:04] Akuma: Thanks for the tips
[18:58:24] apeiros: whoops, without the ==
[18:58:54] apeiros: Akuma: http://pastie.org/8430568 - and even a bit shorter
[18:59:18] apeiros: Banistergalaxy: too much work. finally going back to work a bit on my C parser for EPT
[18:59:28] apeiros: Banistergalaxy: what about you? enjoying your new gig? :)
[19:00:05] Akuma: hehe, lots of habits from other languages, trying to mimic the same. It seems Ruby does have simpler ways to achieve lots of things
[19:00:24] Akuma: apeiros: Thanks a lot for your help,
[19:00:33] apeiros: Akuma: no problem, you're welcome ;-)
[19:00:37] Banistergalaxy: Just signed contract, have to fly to nyc next month, but it's good in theory, good pay, can work where/when I want etc
[19:00:48] apeiros: Akuma: yes, it sometimes takes a bit of unlearning in order to use ruby to its fullest.
[19:10:04] apeiros: anybody know where Data_Make_Struct is defined?
[19:19:20] Tearan: Hey ya… why would x.split.reverse.join(" ") drop punctuation. How do I fix that
[19:20:07] |jemc|: apeiros: it's a macro in ruby.h
[19:20:26] Tearan: I tont understand that. Explain it to me like I'm 5
[19:20:41] |jemc|: apeiros: or rather, in /usr/include/ruby/ruby.h
[19:20:53] apeiros: |jemc|: thanks, I forgot to tell that I found it :(
[19:21:02] Tearan: oh.. never mind..
[19:21:24] apeiros: I thought it was a function and was really curios how it allowed to pass a type
[19:24:25] Hanmac: apeiros: in my bindings i have helper functions around that ... so you can do that: Type *ptr = wrap<Type*>(Rvalue); (where wrap is a template with specifications)
[19:24:34] eval-in: zipper => 5 (https://eval.in/57399)
[19:24:58] zipper: Ha! So happy I made the bot interpreat ruby.
[19:25:02] |jemc|: Tearan: post your input and output
[19:25:07] |jemc|: in a pastebin
[19:25:10] |jemc|: "What's wrong? Anything?".split.reverse.join(" ")
[19:25:14] zipper: I wish the python bot did that.
[19:25:18] Hanmac: apeiros: and because in most functions you need something like self -> cself i have a macro named _self which does that for you
[19:25:18] |jemc|: >> "What's wrong? Anything?".split.reverse.join(" ")
[19:25:19] eval-in: |jemc| => "Anything? wrong? What's" (https://eval.in/57400)
[19:46:14] mark06: any idea how to detect if stdout is mintty?
[19:47:51] Tearan: Booo IRB lies
[19:52:01] ludar: hi im a python progammer and i want to start learn a ruby also.. whats is the best sites for this ? thank you
[19:52:23] mark06: String#encoding lies too: http://bugs.ruby-lang.org/issues/9016
[19:52:37] markisonfire: ludar: http://ruby.learncodethehardway.org/
[19:52:52] markisonfire: there are tons of awesome resources, though
[19:52:53] mark06: yeah, programming MF!
[19:53:11] ludar: thank you
[19:53:21] |jemc|: ludar: when I came over from python, I found it helpful to pick a somewhat difficult and complex python project I had done and try to port it to ruby, learning each analogous technique as needed
[19:53:40] ludar: sounds great
[19:53:52] ludar: thank you
[19:53:54] |jemc|: over time, I also learned ruby idioms to replace my python idioms I was familiar with, changing my mindset as well
[19:54:00] jkamenik: ludar: you can also try http://rubykoans.com/
[19:54:23] ludar: thank you very much guys!
[19:56:17] shevy: |jemc| do you still write python?
[19:57:06] shevy: ludar, I think when it comes down to it, the best is to really just start to write small ruby scripts, and buildup from there. start with simple things, if you used python, try to find to do something similar in ruby, but more OOPish perhaps
[19:57:23] |jemc|: shevy: basically only for sublime text plugins - I've come to appreciate the ruby way in most projects that don't require python for some other reason
[19:58:33] ludar: what is the mean diffrent between python and ruby as lang?
[19:59:36] |jemc|: other than syntax differences, main conceptual difference is probably monkey-patching
[19:59:41] volty: google ruby vs python
[19:59:53] |jemc|: also ruby does nto have multiple inheritance, but has mixins, a slightly different concept
[20:00:19] Hanmac: ludar: https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/
[20:00:20] volty: it is not that easy to transfer what you have in your head
[20:00:40] ludar: main* im sorry
[20:00:57] |jemc|: also, investigate blocks/Procs in Ruby; much more powerful and interesting than python's lambdas
[20:01:13] |jemc|: python's lambdas are all but useless, imo
[20:06:11] shevy: ludar the philosophy
[20:08:03] Hanmac: ludar i see ruby often as pythons evil twin sister ;P
[20:13:07] |jemc|: yeah, if you're familiar with the python easter egg of typing 'import this' in a repl
[20:13:19] |jemc|: where it prints the philosophy of python
[20:13:29] |jemc|: many of those rules get regularly broken in ruby
[20:13:33] |jemc|: for better and for worse
[20:16:09] volty: or for good or for evil, in the superlative degree of comparison only
[20:19:06] volty: ah - it was from «The Tale of Two Langs", from V. Trollens :)
[20:19:14] blitz: if you have a list of [a,b,c] whats the easiest way to call a.merge(b.merge(c))
[20:20:31] flops: blitz: Do you mean a join() ?
[20:21:01] Hanmac: blitz: i think a,b,c are Hash, so try this: [a,b,c].inject({},:merge)
[20:21:04] volty: then define merge
[20:21:14] blitz: yeah, inject that's right
[20:21:42] Hanmac: PS: you may need to reverse the Array order if they are not in the right one
[20:22:00] volty: or shuffle ?
[20:22:15] Senjai: I'm really bad with text manipulation, how can I turn a string of strings into an array of strings? e.g. "\"public\"" -> ["public"]
[20:22:23] Senjai: or "\"public\"\"www\"" -> ['public', 'www']
[20:23:23] Senjai: that was easy
[20:23:33] Senjai: String.scan
[20:24:36] Senjai: fyi cross post from #ruby-lang
[20:25:37] RubyPanther: .split(/\a"|""|"\z/) looks really awesome though
[20:26:13] RubyPanther: like an alien in a helmet, cheering
[20:27:13] apeiros: \A instead of \a
[20:27:19] apeiros: interesting idea
[20:27:59] volty: what about split /(^") | ("\s*") | ("\s*$)/ ?
[20:28:14] volty: -> final /x missing
[20:28:39] apeiros: personally I prefer the scanning method. easier to allow for escaped quotes IMO.
[20:30:21] RubyPanther: oh yeah, thanks for debugging my alien
[20:30:53] unstable: What is a good way to pick a software project/bug/feature to work on?
[20:31:02] unstable: There are too many choices, I'm not sure how to pick.
[20:31:10] apeiros: unstable: one you use yourself
[20:31:11] unstable: (I want something ruby related, which is why I'm asking in here)
[20:31:22] RubyPanther: unstable: you scratch the one that itches the most
[20:31:24] apeiros: personal interest/scratching one of your own itches is always a good motivator
[20:31:51] unstable: hmm, I agree with that. Though basically everything I want I have.
[20:31:58] unstable: wrt software
[20:32:56] flops: unstable: I'm pretty certain you are using some software which you think you could make better ;)
[20:33:06] RubyPanther: unstable: a project I'd love to see is one to get MRI compiling on android using the google compiler
[20:34:00] flops: unstable: Or go to the github page of a project you like and use and start tinkering with it
[20:34:05] devbug: For some reason http://pastie.org/pastes/8428490/text?key=fpwvx7ceft6qqjo4gdkwq doesn't match -MT
[20:34:28] devbug: It matches -M, -MM, and > fine
[20:34:31] devbug: but not -MT
[20:35:41] flops: How can I empty/delete a database I created with ActiveRecord through camping?
[20:35:42] matti: How does one handle thread safety from C extension? I have a library that is not thread safe.
[20:39:33] Hanmac: matti i think its complicated ... i mean if the lib is not thread-safe, then the binding cant be easy thread-safe (all my bindings are not thread-safe :/ )
[20:40:06] RubyPanther: matti: http://media.pragprog.com/titles/ruby3/ext_ruby.pdf you basically just need to learn about the global lock, and make a couple API calls at the right time
[20:40:44] apeiros: RubyPanther: oh, dave made that available for free?
[20:40:50] RubyPanther: The end result is that you avoid needing real thread safety because of the lock
[20:41:00] RubyPanther: Yeah, it's their free chapter :) yay
[20:41:14] apeiros: nice! thanks for that link :)
[20:42:56] matti: RubyPanther: I've added NOGVL wrapper functions for anything IO related, and it works very nicetly.
[20:43:16] Hanmac: matti & apeiros & RubyPanther isnt that mosty https://github.com/ruby/ruby/blob/trunk/README.EXT ?
[20:43:27] matti: RubyPanther: But, now I want to make sure that when people call methonds from the same object using the same underlying C bindings, they will not be corrupted.
[20:44:17] matti: RubyPanther: I could even use Mutex.new, but I don't know how to add @mutex.synchronize to existing methods from C code on the fly on the Ruby side.
[20:44:50] RubyPanther: matti: make sure you need it before adding a mutex
[20:46:24] |jemc|: yeah, it can be tempting to throw mutexes all over the place thinking you're creating safety, but its easy to create deadlock that way
[20:46:53] RubyPanther: Hanmac: it's a good reference, but it doesn't give a high level explanation
[20:47:47] Hanmac: some day, my bindings will be also good references ;D
[20:55:31] dfrank: hi guys. I'm learning ruby on rails, here's very little example of the ruby model code: pastey.org/view/raw/c9c8b7f1 I can't find explanation of such syntax: "validates :title, uniqueness: true" Is this method call, or ...? I know that ruby allows to omit parentheses, but this case seems not to be a method call. Just in case, I have tested: added parentheses, but it wasn't helped.
[20:55:42] dfrank: *it didn't help
[20:55:43] dfrank: So, could you please point me where can I read about it?
[20:56:09] Xeago: dfrank: it is a method call on the class
[20:56:22] flops: http://edgeguides.rubyonrails.org/active_record_validations.html
[20:56:30] Xeago: as you might or might not now, any code anywhere is evaluated as soon as it is parsed
[20:56:40] |jemc|: :title is the first argument, uniqueness:true is a keyword argument
[20:56:45] Xeago: >> class Foo; puts "bar"; end;
[20:56:46] eval-in: Xeago => bar ... (https://eval.in/57402)
[20:57:03] Xeago: s/now/know
[20:57:49] dfrank: but I tried to add parentheses, it leads to syntax error: validates (:title, uniqueness: true)
[20:58:01] apeiros: dfrank: it's equivalent to: validates(:title, {:uniqueness => true})
[20:58:16] apeiros: dfrank: yes, don't put a space in front of the parens.
[20:58:31] apeiros: foo(bar) != foo (bar)
[20:59:08] apeiros: (I think 1.8 was less picky in that regard?)
[20:59:16] Xeago: apeiros: not that I know
[20:59:38] dfrank: apeiros: oh, thanks
[20:59:47] dfrank: thanks guys!
[21:00:02] apeiros: hi there Xeago! :)
[21:00:24] Xeago: foo (:foo, :bar)
[21:00:25] Xeago: (irb):13: warning: don't put space before argument parentheses
[21:00:28] Xeago: either it is irb catching that
[21:00:33] Xeago: or ruby being lenient
[21:00:40] Xeago: hi apeiros :)
[21:00:57] Xeago: just got home, quit tipsy/drunk form the afterwork :)
[21:01:07] flops: Xeago: def hello; puts "hi"; end \n hello () ArgumentError
[21:01:08] Xeago: definitely satisfied with today :D
[21:02:12] ShawnMcCool: i have a folder with 2 subfolders, src/ and test/, in my src/ folder i have a file todo.rb src/todo.rb. if i go to the src folder and do 'irb' and try to require 'todo' it says that it can't infer base path
[21:02:15] ShawnMcCool: what should i do?
[21:02:35] |jemc|: require_relative
[21:02:45] apeiros: ShawnMcCool: irb -Isrc
[21:02:53] apeiros: (that's a capital i, not lowercase L)
[21:03:33] apeiros: ShawnMcCool: common name for the library is 'lib' btw., not 'src'
[21:03:41] apeiros: cf. rubygems
[21:04:17] Xeago: mind elaborating on this problem?
[21:04:23] ShawnMcCool: so if i'm just creating some domain logic to play with ruby, i'd put my code in lib/ not in src/
[21:04:28] Xeago: shouldn't irb jsut find it in ./todo.rb?
[21:04:37] Xeago: not caring in which directory it is in?
[21:05:55] apeiros: Xeago: require/load is always relative to the dirs in $LOAD_PATH (unless you explicitly use an absolute path or use a './' prefix)
[21:10:20] atmosx: %w{01 02 03 04 05 06 07 08 09 10 11 12} <-- can I turn this values into numbers somehow automatically? Instead of text?
[21:10:28] atmosx: s/numbers/integers
[21:11:56] apeiros: atmosx: map
[21:12:15] apeiros: atmosx: but since it's a literal, just use []
[21:12:39] lupine: well, he'd need commas too
[21:12:45] apeiros: oh noes! :)
[21:12:55] lupine: I'd probably do (1..12).to_a
[21:13:15] atmosx: lupine: that makes sense heh
[21:13:27] atmosx: hmm I need 01
[21:13:45] lupine: then you don't want fixnums, you want strings
[21:13:52] lupine: or... something
[21:14:26] Hanmac: a = *1..12
[21:14:53] atmosx: okay then I'm ok I guess
[21:15:05] atmosx: ACTION it's an old helper method lol
[21:15:16] lupine: you can always ensure the fixnum is displayed as "01" in your output logic, of course
[21:15:25] lupine: but in number terms, 01 and 1 are identicxal
[21:15:36] apeiros: 09 and 9 aren't
[21:15:41] lupine: indeed :)
[21:15:52] lupine: 09 isn't even valid is it?
[21:15:55] atmosx: I'll leave it as a sring
[21:15:58] apeiros: yupp, 09 would raise
[21:16:00] atmosx: will work anyway
[21:16:01] lupine: SyntaxError: (irb):1: Invalid octal digit
[21:16:09] lupine: 010 and 10 are not the same
[21:16:15] apeiros: which makes 09 pretty different from 9 ;-)
[21:16:58] apeiros: yeah, 010 would work and be different in value. but 010 wasn't in his code, while 08 and 09 are.
[21:17:07] apeiros: (hence I pointed that out)
[21:37:01] d4heyDU: does anyone use bitwise very often in practice? I'm just curious, I was learning about bitwise operations on numbers last night
[21:37:09] d4heyDU: >> 12 & 14
[21:37:09] eval-in: d4heyDU => 12 (https://eval.in/57410)
[21:37:15] apeiros: d4heyDU: in ruby it's rather rare
[21:38:00] |jemc|: d4heyDU - only common ruby use I can think of is when dealing with C APIs that have bit flags
[21:38:21] d4heyDU: interesting, I'm sure there are some clever uses for it
[21:38:53] d4heyDU: I remember seeing ryan bates use it in a rails cast for setting admin permission levels
[21:38:58] apeiros: |jemc|: in some cases when you want to optimize something they can help too
[21:39:07] apeiros: e.g. fast/small set types
[21:39:10] |jemc|: you can use the bitwise & operator in arrays - but it's not really doing a bitwise operation - just a mnemonic
[21:39:13] |jemc|: >> [3, 4, 6] & [3, 2, 1, 4]
[21:39:13] eval-in: |jemc| => [3, 4] (https://eval.in/57411)
[21:39:46] d4heyDU: |jemc| yeah for sure
[22:23:08] milardovich: Hi guys, I'm having problems with a conditional value
[22:23:26] milardovich: if a == @class.b then works perfectly, but if a <= @class.b then doesn't
[22:23:32] milardovich: I have no idea what I'm doing wrong
[22:24:06] |jemc|: put your code and the output in a pastebin
[22:25:26] ctp: Howdy. Anyone has an idea how to remove the first element of that array and append a new one at the end _in one expression_. ["S", "S", "F", "F", "S", "S", "F", "S", "S", "F"].shift would remove the first one, ["S", "S", "F", "F", "S", "S", "F", "S", "S", "F"].push("S") would append one. but how to combine both?
[22:26:41] havenwood: milardovich: Does your class include Comparable?: http://ruby-doc.org/core-2.0.0/Comparable.html
[22:26:54] apeiros: ctp: push returns the array, call shift on it. but IMO it's ugly, just keep it two separate instructions.
[22:27:22] milardovich: havenwood, ohh no, it doesn't
[22:27:56] |jemc|: ctp: there's also (below), but combining push and shift is cleaner
[22:28:00] |jemc|: >> a=[1,2,3]; a=a[1..-1]+[4]
[22:28:00] eval-in: |jemc| => [2, 3, 4] (https://eval.in/57418)
[22:28:23] |jemc|: >> a=[1,2,3]; a=a[1..-1] << 4
[22:28:23] eval-in: |jemc| => [2, 3, 4] (https://eval.in/57419)
[22:29:20] |jemc|: although your requirement about being in 'one expression' isn't as specific as you think it is
[22:30:34] ctp: ok, got it, a simple foo.push("S").shift does its work :) thanks
[22:31:16] Akuma: hello, if I define an array x=Array.new(10), define some values for this array in a file, (file1.rb) and do a require 'file1' in a file2, will I be able to access the values of the array x in file 2 defined in file1?
[22:31:22] apeiros: ctp: um, yeah, which is what I said. still I think it's ugly.
[22:31:47] ctp: apeiros: yeah it is :)
[22:32:30] apeiros: Akuma: if you define the variable as `x`, then on. lowercase variables are local variables. the "local" part in the name means what it says ;-)
[22:32:36] |jemc|: Akuma: locals do not cross files
[22:33:06] |jemc|: Akuma: you can make it a global with $x, but there is often a better way to do what you want
[22:33:08] apeiros: you can use constants (start with an uppercase letter) to share objects across files.
[22:33:16] apeiros: ACTION hits |jemc| with a stick
[22:33:25] |jemc|: yeah, constants is often the better way, I was about to refer to
[22:33:34] |jemc|: ACTION ducks
[22:33:36] apeiros: don't use globals. really. it's best to just pretend they don't exist (except for the predefined ones)
[22:34:13] Akuma: I see, I'll check how I can work around this
[22:34:13] |jemc|: well, you have to know about the devil before you can resist his temptations
[22:34:17] Akuma: Thank you
[22:34:20] havenwood: Poof, what are these globals you're talking about. Fairy tales I tell ya!
[22:34:25] havenwood: ACTION goes merrily about his day.
[22:35:13] havenwood: I had to double check to make sure it still was. >.>
[22:35:21] |jemc|: ignorance of bad design patterns doesn't make you subconsciously use good ones
[22:35:27] apeiros: saturday here
[22:35:55] apeiros: |jemc|: true
[22:36:10] apeiros: |jemc|: but you suggested using a bad pattern :)
[22:36:55] |jemc|: I was using it as a segue to bring up constants
[22:37:27] |jemc|: if only I had a higher words per minute!
[22:38:27] |jemc|: speaking of devilish globals
[22:39:10] havenwood: >> password = global_variables.join
[22:39:10] |jemc|: anyone know if there are any plans to make thread-local versions of the post =~ vars $1, $2, etc?
[22:39:10] eval-in: havenwood => "$;$-F$@$!$SAFE$~$&$`$'$+$=$KCODE$-K$,$/$-0$\\$_$stdin$stdout$stderr$>$<$.$FILENAME$-i$*$?$$$:$-I$LOAD_PATH$\"$LOADED_FEATURES$VERBOSE$-v$-w$-W$DEBUG$-d$0$PROGRAM_NAME$-p$-l$-a$1$2$3$4$5$6$7$8$9" (https://eval.in/57423)
[22:39:27] havenwood: They'll never guess my password, muahaha. >.>
[22:39:41] |jemc|: yeah, if they never look at the irc logs :P
[22:40:27] havenwood: |jemc|: mmm, i'll put a #reverse on the end
[22:40:32] havenwood: dash, now you know my tricks!
[22:40:46] |jemc|: but yeah, the fact that Threads exist and $1, $2, $3 exist as standards in the same language just baffles me
[22:40:52] |jemc|: it's just asking for trouble
[22:41:18] apeiros: |jemc|: $1 etc. are not truly globals
[22:41:27] apeiros: which makes things in some regards worse…
[22:41:31] apeiros: but they're thread local
[22:41:35] |jemc|: oh really?
[22:41:42] |jemc|: I thought I tested it and found otherwise
[22:41:45] |jemc|: well, good
[22:41:45] apeiros: they're even stack-frame local iirc
[22:42:14] apeiros: whatever they are, their scoping is rather, um, lets say 'uncommon'
[22:42:33] ShellFu: hey all. Im trying to reduce the complexity of a piece of code here. Id like some thoughts >http://pastebin.com/e29h9W3a< Im thinking perhaps a recursive method, but since im not a professional programmer I thought you guys could smack me around a bit :)
[22:42:34] |jemc|: well, I'm happier that they're a special case than being trou globals
[22:42:48] gr33n7007h: i = 1.0/0; (1..i).each {|n| puts n}
[22:42:56] ShellFu: It can be copied directly into irb
[22:43:05] ShellFu: to see the desired result
[22:44:31] havenwood: gr33n7007h: 1.upto(Float::INFINITY) { |n| puts n }
[22:52:09] heftig: ShellFu: no need for that inject
[22:52:12] heftig: ShellFu: Hash[string.split(',').map{|s|k,*v=s.split('^');[k,v.empty??nil:Hash[v.map{|x|x.split("=")}]]}]
[22:52:17] heftig: just a small improvement
[22:54:16] ShellFu: Any improvement is good :) I appreciate the input. Trying to get some of these harder to understand lines broken down.
[22:54:18] havenwood: :P 1.upto(Float::NAN) { |n| puts n }
[22:58:20] havenwood: >> Float::MAX * 1.000000000000009
[22:58:20] eval-in: havenwood => Infinity (https://eval.in/57427)
[22:58:38] havenwood: >> Float::MAX * 1.0000000000000001
[22:58:38] eval-in: havenwood => 1.7976931348623157e+308 (https://eval.in/57428)
[22:58:45] havenwood: The point of inflection...
[23:00:33] |jemc|: that brightened my day
[23:00:50] |jemc|: (which is almost over, as far as work is concerned)
[23:01:39] havenwood: FRIDAY! \o/
[23:03:48] |jemc|: Time.now * 1.0000000000000001 == Workweek::MAX
[23:16:14] unstable: wow, ruby p247 has been around for awhile now
[23:16:29] testr0n: if i want to write an irc bot in ruby, what is the best way to go about this? use a pure ruby gem, or use a ruby gem which uses a C irc implementation?
[23:16:52] |jemc|: IRC is not hard to implement
[23:16:58] |jemc|: so you don't need C
[23:17:08] MrZYX: I can recommend cinchrb
[23:17:14] |jemc|: there are 3 or 4 gems floating around
[23:17:18] MrZYX: I wouldn't base the choice on the implementation details
[23:17:40] testr0n: fair points
[23:17:46] testr0n: what would you base the choice on MrZYX ?
[23:17:53] MrZYX: a nice API
[23:17:57] |jemc|: or you can have fun with sockets and do it yourself for some nice fun
[23:19:01] MrZYX: and maybe the feature set, if you need more esoteric ones
[23:19:17] shevy: who is good with minitest and can recommend a tutorial for it
[23:20:29] |jemc|: shevy, coming from another testing framework or coming new to TDD?
[23:20:37] shevy: totally new here
[23:21:05] shevy: it's also an area that seemed hard to learn because it is not very exciting :(
[23:22:24] testr0n: MrZYX ok reading the docs for cinch. it's plugin system seems odd
[23:22:32] testr0n: https://github.com/cinchrb/cinch#plugins
[23:22:44] dominikh: testr0n: odd how?
[23:22:46] testr0n: is that good code? specifically, the "match" deal, etc
[23:23:11] testr0n: plugins are only fired up when they match to an incoming message?
[23:23:25] MrZYX: sure, Ruby APIs do such things all the time
[23:23:47] dominikh: every message gets matched against all registered matchers, and on a match, the methods will be called
[23:24:07] |jemc|: shevy: a little googling isn't really yielding any tutorials that I actually like the style of, but
[23:24:24] testr0n: how would you make a plugin which handled a dcc chat request, or session, or file transfer? etc
[23:24:27] |jemc|: http://mattsears.com/articles/2011/12/10/minitest-quick-reference is a decent starting point
[23:24:31] testr0n: there is no 'message' to match here
[23:24:35] |jemc|: but the style is.. meh
[23:24:57] |jemc|: anyway, just practice writing your tests before you write your actual code
[23:25:02] dominikh: testr0n: of course there is. DCC initiations are plain PRIVMSGs with escape sequences
[23:25:19] |jemc|: with the tests guiding the feature set as you go
[23:25:32] dominikh: (DCC SEND is already implemented in Cinch itself though. CHAT etc are not, but can easily be done as plugins)
[23:25:34] shevy: |jemc| ok
[23:25:58] testr0n: dominikh oh interesting
[23:26:05] |jemc|: the main idea being that it sucks to write tests later - it's pretty boring
[23:26:06] shevy: |jemc| I always want to head-start with writing code first :(
[23:26:19] shevy: hahaha yeah... I can see that
[23:26:30] |jemc|: and, if you think about it
[23:26:39] |jemc|: you're often writing psuedo tests as you go
[23:26:53] |jemc|: implementing a feature, then running your code to make sure it works
[23:26:59] dominikh: testr0n: NB that besides "match" there's also listen_to, which can listen to specific events without doing any pattern matching, e.g. to notice all JOINs, or artifical events like :dcc_send, which Cinch emits when it detected an incoming DCC SEND
[23:27:00] |jemc|: before moving on to the next thing
[23:27:09] dominikh: testr0n: c.f. http://rubydoc.info/gems/cinch/Cinch/DCC/Incoming/Send for that in particular
[23:27:23] |jemc|: the trick is to have the discipline to make those little tests a permanent fixture that you can run later
[23:27:24] dominikh: testr0n: but really, Cinch was written to be very flexible in implementing features on top of it
[23:27:55] testr0n: dominikh thank you, great explanations. it's sounding very strong
[23:27:58] |jemc|: because if all your features have tests, you can be confident as you move forward that your code won't regress and introduce bugs
[23:28:08] dominikh: testr0n: and in case it wasn't obvious, I'm the author ;)
[23:28:26] testr0n: do you actively maintain it?
[23:28:48] |jemc|: so for every feature, write a test, and for every bug fix that had no test, write a test
[23:28:58] dominikh: testr0n: I'm not actively developing any features etc anymore, but I fix bugs that need fixing and coordinate patches that others might contribute
[23:29:28] testr0n: yea, good enough. i just need some basic abstracted hooks to pull on and bugs to be fixed
[23:29:33] testr0n: don't need continual flow of new features
[23:29:37] |jemc|: minitest/spec is big on syntax sugar and ease of use to try and make it easier to have the discipline to write tests as you go
[23:29:59] dominikh: yeah, it's mostly "done" with regard to features
[23:30:24] testr0n: dominikh i've been doing c/objc for 5 years, did ruby before that, but rusty. what's the quickest way from a fresh mac os x terminal i can get cinch installed and a base bot running connected to my freenode dev channel?
[23:30:38] testr0n: if you don't mind me asking. feel no pressure to hand hold
[23:30:42] |jemc|: and imo the difference between spec tests and unit tests in this context is really just a syntactical difference - although in its history is a conceptual difference, I use spec tests for 'unit' tests because I like the syntax sugar
[23:30:44] shevy: In general things must work with "gem install <name>"
[23:31:07] shevy: so judging from the name, "gem install cinch" ought to work
[23:31:13] dominikh: testr0n: gem install cinch; ruby /whereever/the/examples/are/basic/hello.rb ;) I'm not an OSX person.
[23:31:22] |jemc|: and the more sugarry your tests are, the more they are self documenting, which is a significant thing
[23:31:29] shevy: |jemc| hmm
[23:32:05] unstable: What is a simple way to find out if a string contains only letters?
[23:32:20] |jemc|: there are probably many who disagree with me about the spec/unit thing though
[23:32:32] |jemc|: hence the 'imo'
[23:34:39] shevy: |jemc| I think I will try to rewrite my first game written in ruby and use minitest from the get-go
[23:35:34] |jemc|: yeah, it'll be weird at first but become second nature hopefully
[23:35:34] ib: hmm, mac os x comes with an old ruby. what's the cleanest way to put latest ruby 2 on os x?
[23:35:50] |jemc|: rvm is what most mac users use
[23:35:56] |jemc|: installed through brew
[23:36:16] ib: so long of a process to set up a dev env :P
[23:36:59] |jemc|: yeah, especially when apple doesn't give you a package manager...
[23:37:04] dominikh: install 1.9 while you're at it; I have no idea if Cinch works with 2 :P – there was some issue once that was due to a bug in Ruby 2 and I have no idea if it's fixed. nobody else reported problems with Cinch on Ruby 2 though, but maybe that's because nobody is using that combination.
[23:37:29] ib: lame :/
[23:37:33] shevy: unstable, perhaps compare the length, and if not the same, you assume that it does not contain only letters, perhaps see:
[23:37:35] shevy: >> "123abc".gsub(/[a-z]/i,'')
[23:37:35] eval-in: shevy => "123" (https://eval.in/57429)
[23:37:46] dominikh: (specifically it was a bug in the Queue class)
[23:39:03] ib: damn, 1.8 is too old to use
[23:39:17] dominikh: 1.8? yes, very much so
[23:42:04] MrZYX: dominikh: I do run cinch under 2 for some time now
[23:42:20] MrZYX: didn't notice any increased hangs or crashes
[23:42:35] testr0n: no /increase/ of hangs or crashes, hmm
[23:42:41] testr0n: doesn't sound encouraging :P
[23:42:50] MrZYX: the ones I have are through some plugins ;)
[23:43:02] testr0n: the code itself quality MrZYX ?
[23:43:07] testr0n: and don't mind that dominikh is right here
[23:43:51] MrZYX: I initially recommended you cinch, I wouldn't do that if I'm not convinced of its quality
[23:43:52] dominikh: if you don't like Cinch, your only other option is to write your own library, as the other ones are even worse ;)
[23:44:13] testr0n: ok i'll try it
[23:44:36] testr0n: i sure hope its dcc functionality works well, i want to set up a file server
[23:46:08] dominikh: the DCC SEND works very well (both sending and receiving files, even receiving from clients that implement the "spec" poorly). other DCC features you will need to implement yourself
[23:46:46] unstable: shevy: "hello" =~ /[a-z]/ would this work?
[23:46:48] dominikh: even though I do have to admit that receiving is better tested than sending, so if you discover any bugs, report them.
[23:46:52] testr0n: what other dcc features would i need to implement for example?
[23:47:01] dominikh: testr0n: no idea, which ones do you want :)
[23:47:16] testr0n: do you mean domain specific stuff like handling file selection + serving?
[23:47:17] dominikh: unstable: that checks that there is at least one letter in the string.
[23:47:46] dominikh: testr0n: that's not DCC features, that's application logic :) but there's a plethora of DCC features, such as CHAT, WHITEBOARD and some others probably nobody uses
[23:48:00] testr0n: whoa, whiteboard? odd
[23:48:25] dominikh: yeah, not something a bot needs.
[23:51:45] shevy: unstable hmm don't think so... what are the characters that should not be included?