« Back to channel list

#ruby - 23 February 2015

« Back 1 day Forward 1 day »
[00:43:50] Cadillactica: trying to set up backbone to work with Rails - encountering an issue that I haven???t been able to get past. when I add a first handlebars template to the app/assets/templates/example.jst.hbs, I see that the rails server is trying to GET http://localhost:3000/javascripts/master.hbs.js which fails (incorrect location, incorrect file type)
[00:43:57] Cadillactica: Anybody have an idea?
[00:44:06] ericwood: Cadillactica: check out #rubyonrails or #documentcloud
[00:44:13] Cadillactica: ericwood: ok thanks
[00:44:25] ericwood: we try to stick to just non-rails stuff here :)
[00:47:12] somkera: how do you stop a nigger from drowning?
[00:47:19] havenwood: apeiros__: ^
[00:47:23] somkera: why would you stop a nigger from drowning?
[00:47:30] ChanServ: +o apeiros__
[00:50:57] apeiros__: -bbb *!~radder@ *!~fluuflu@ *!~rumitte@213.143.60.*
[00:51:02] apeiros__: -bbb *!~rumitte@213.143.61.* *!~user@173-228-80-252.dsl.static.fusionbroadband.com *!*@*ip.
[00:51:09] apeiros__: -b *!*@
[00:51:23] apeiros__: +b *!*@*
[00:51:50] apeiros_: havenwood: thanks for ping
[00:51:57] havenwood: apeiros_: thanks!
[00:53:58] phat4life: how do i make a pull request for the ruby core library
[00:56:48] havenwood: phat4life: you can make pull requests to the github repo: https://github.com/ruby/ruby
[00:57:25] havenwood: phat4life: issue tracking here: https://bugs.ruby-lang.org/projects/ruby-trunk/issues
[01:07:21] apeiros_: -o apeiros_
[02:04:48] gr33n7007h: I'm trying to save an image with: open(url) {|f| File.open("sony.jpg","w") {|fd| IO.copy_stream(fd, f) } } # IOError: not opened for reading ?
[02:10:33] gr33n7007h: nvm, IO.copy_stream args were in the wrong position :(
[02:18:26] phat4life: hmmm, is there no thread.rb on ruby trunk? I am confused as the change logs show /lib/thread.rb but i am not seeing that file
[02:19:40] Radar: Ruby is a compiled language. It's likely the file you're looking for is https://github.com/ruby/ruby/blob/trunk/thread.c
[02:23:48] phat4life: Radar: that is what was afraid of :(
[02:28:39] Senjai: phat4life: Fortunately, ruby isn't written in ruby xD
[02:29:42] phat4life: arg o well. I don;'t have time to look at c code right now
[03:11:52] shevy: how about bison lex parser .yy files!
[03:40:33] ben_vulpes: allo rubists, how does sidekiq know to run a given thing when started?
[03:53:51] Radar: ben_vulpes: That's quite a wide open question.
[03:54:05] Radar: ben_vulpes: From what I understand, it polls Redis looking for new jobs and runs them when it finds one
[03:54:15] Radar: As for implementation details, well that's in the Sidekiq source.
[04:44:58] ravenzz: good evening
[06:25:31] arup_r: sevenseacat: o/
[06:25:39] sevenseacat: arup_r: good afternoon
[06:25:52] arup_r: humm.. We won.. :)
[06:28:35] arup_r: sevenseacat: Lots of Indians I see in your country..
[06:28:56] arup_r: Yesterday's match telling something like that...
[06:30:49] arup_r: moin certainty:
[06:37:23] shevy: module Foo; class Bar <--- how to easily obtain the parent namespace from within class Bar?
[06:39:35] arup_r: > module Foo; class Bar; def namespaces ; p constants; end; end; Foo::Bar.namespaces
[06:39:40] arup_r: >> module Foo; class Bar; def namespaces ; p constants; end; end; Foo::Bar.namespaces
[06:39:41] eval-in: arup_r => /tmp/execpad-cd5c88a851c7/source-cd5c88a851c7:7: syntax error, unexpected end-of-input, expecting keyword_end (https://eval.in/292117)
[06:39:54] arup_r: >> module Foo; class Bar; def namespaces ; p constants; end; end; end; Foo::Bar.namespaces
[06:39:54] eval-in: arup_r => undefined method `namespaces' for Foo::Bar:Class (NoMethodError) ... (https://eval.in/292118)
[06:40:05] arup_r: >> module Foo; class Bar; def self.namespaces ; p constants; end; end; end; Foo::Bar.namespaces
[06:40:05] eval-in: arup_r => [] ... (https://eval.in/292119)
[06:40:14] arup_r: shevy: something like that
[06:40:38] shevy: I am using lots of things like ::Foo :(
[06:40:38] arup_r: http://ruby-doc.org/core-2.2.0/Module.html#method-c-constants
[06:40:54] shevy: or I just hardcode Foo
[06:42:21] arup_r: hardcode means?
[06:43:23] shevy: module Foo
[06:43:32] shevy: now I just changed the name of a module
[06:43:39] shevy: so I have to manually find all those instances
[06:43:43] shevy: which makes me not happy
[06:44:12] shevy: found one instance
[06:44:14] shevy: Foo.instance_eval {
[06:44:15] shevy: self.instance_eval {
[06:44:19] shevy: seems to be equivalent?
[06:46:30] arup_r: humm.. But it depends under which `self` scope you are doing... for e.x. def bar; Foo.instance_eval and def foo; self.instance_eval not same.. You are giving door keys to someone else :)
[06:47:21] shevy: in module Foo; Foo.instance_eval {}; end
[06:47:39] arup_r: Ohh... yes.. that is equal
[06:48:03] arup_r: No.. after mixin
[06:48:13] arup_r: story will be different.. :(
[06:48:53] arup_r: shevy: I'm now confused.. jhass: will help you.
[06:52:35] zly: morning :)
[07:59:37] d3_newbie: Hello, I am writing a small module on a Ruby on rails app. The module consist of visualisation I have to present using a histogram. I am using json to get the data and d3 for visualisation. I am having difficulties in accessing the json objects. Can anyone please help?
[08:30:29] shmoon_: is there a course/tutorial on ruby so that i can quickly pick it up like in an hour or so?
[08:32:40] tobiasvl: shmoon_: this maybe? https://www.ruby-lang.org/en/documentation/quickstart/
[08:32:46] tobiasvl: and this http://tryruby.org/levels/1/challenges/0
[08:34:54] shmoon_: i am on the first one ya
[08:35:11] shmoon_: problem with tryruby style is that reading the instructions and doing step by step can take a lot of time
[08:35:25] shmoon_: i have done a bit of ruby before like 3yrs ago, just need some sort of refresher :)
[09:17:47] maasha: Ruby's builtin $VERBOSE is rather dodgy, since it will be tricked by unit tests run with warnings, etc.
[09:19:21] maasha: Is there some favored scheme of outputting debug and verbose messages?
[09:29:04] maasha: I am interested in rolling my own version of $VERBOSE maybe something like this (sane?) -> https://gist.github.com/maasha/cb296925f103cbb94492
[09:50:42] shmoon_: where's the last line coming from http://pastie.org/9971602 ?
[09:54:42] canton7: shmoon_, you've got a gem in your gemfile, where you're said it should be fetched from a git repo
[09:54:46] canton7: so that's what bundler's going
[09:56:23] Fluent: Yup, pretty much running a git clone 'repo'
[09:56:43] surs: I have two files a and b. I want to find out which lines in both files share a "relevant" amount of text. The lines in b may have extra strings at the beginning, in between or at the end of the lines. the lines consist of white space separated words.
[09:56:53] surs: how do I best go about this?
[09:56:53] Fluent: I guess that's not even always true either
[09:57:21] Fluent: I would suggest learning about regular expressions
[09:57:58] Fluent: Then iterate both files in a loop and compare with a regex match that you are looking for
[09:58:00] surs: I know a little about regexp. I was thinking of trying to match sequences of words and returning the lines that match the longest sequences
[09:58:08] canton7: nah, I wouldn't go regex. Learn about the longest common subsequence problem
[09:58:31] canton7: actually it's not even that
[09:59:44] canton7: Smither Waterman Algorithm
[09:59:59] canton7: that's the one
[10:00:03] canton7: do what with word-granularity
[10:00:25] surs: I'll gladly look into that. Thank you
[10:01:07] surs: and it can be done with ruby?
[10:01:11] canton7: Levenshtein distance is the other one
[10:01:23] Fluent: Of course it can be done with Ruby
[10:01:26] canton7: that's used for spellcheck, but you're effectively doing that at the word level
[10:01:34] canton7: not sure whether that or Smith-Waterman will work better tbh
[10:01:56] canton7: they're just algorithms - you can use any turing-complete language to implement them
[10:02:06] canton7: hell, if you're motivated enough, you could probably write them in brainfuck
[10:02:30] Fluent: s/motivated/insult here/
[10:03:13] maasha: is there a way to silence specific warnings?
[10:03:33] Fluent: You could use a begin block
[10:03:35] arup_r: oki: hello
[10:04:18] strixd: is there a way to remove only the latest version of my rubygems gem from the site
[10:04:46] Fluent: I don't think so, strixd
[10:05:05] apeiros_: strixd: gem yank
[10:05:13] strixd: that will remove all?
[10:05:28] apeiros_: check its docs?
[10:05:29] Fluent: They keep gems hosted for backwards compatibility. If other people use your gem.
[10:05:35] canton7: http://guides.rubygems.org/command-reference/#gem-yank
[10:05:40] canton7: what happened to reading the docs? ><
[10:05:50] strixd: because it didn't help me
[10:05:59] canton7: "-v, -???-version VERSION - Specify version of gem to remove"
[10:06:00] strixd: I want only 1 version not the whole gem
[10:06:06] Fluent: I think you can request for them to be removed, if they have sensitive information? Least this is what I thought. Maybe yank does work, dunno
[10:06:07] canton7: seems to imply pretty clearly that you can yank a specific version
[10:06:14] strixd: o/ thanks all
[10:06:21] apeiros_: canton7: lost art.
[10:06:26] canton7: note that that hides the version, it doesn't remove it entirely
[10:06:26] apeiros_: reading in general is a lost art.
[10:06:31] apeiros_: reading backtraces
[10:06:33] canton7: so if you specifically ask for that specific version, you'll get it
[10:06:33] apeiros_: reading readmes
[10:06:34] surs: :) thanks for the tips canton7
[10:06:35] apeiros_: reading docs
[10:06:42] maasha: Ain't that a song be The Cure: The docs don't work ... ?
[10:06:58] apeiros_: who let the docs out, who, who, who???
[10:07:50] canton7: ok, "what happened to the lost art of reading more than 1 line of the docs?" ><
[10:08:49] arup_r: what is this -> >< ?
[10:09:01] Fluent: So can you completely remove a gem? Or just the last version?
[10:09:19] canton7: you can ask rubygems to hide a gem, or any specific version of a gem
[10:09:34] canton7: ... if someone has specified exactly that version, gem will still retrieve it fine
[10:09:47] canton7: ...but it won't be chosen under normal circumstances, and won't be listed by any tools
[10:10:10] Fluent: Okay, thanks.
[10:10:44] canton7: so it's the "ohshit, it's buggy" action, but it won't break people who depend on it specifically
[10:40:28] Lorn3r: newbie here
[10:41:16] Lorn3r: i finally got ruby, gems and rails setup on my linux mint machine and want to follow through the tutorial at railstutorial.com as closely as possible
[10:41:54] Lorn3r: and now i found out i got ruby1.9.3 installed, the tutorial uses 2.2.1 though
[10:42:28] Lorn3r: i installed ruby2.0 & ruby2.0-dev via apt-get, but its not the default one
[10:42:52] DefV: Lorn3r: you're better to use something like rpm or rbenv to install recent versions of Ruby
[10:42:54] Lorn3r: how do i get my linux to use the new ruby instead of the old stable one?
[10:44:09] Lorn3r: ok! these are some kind of managers for switching versions and setting up the machine to properly use it then?
[10:44:25] canton7: rvm or rbenv
[10:44:28] canton7: as DefV said
[10:47:27] Lorn3r: thank you both, reading up about rbenv :)
[10:59:20] Tomasso: what does the error "no _dump_data is defined for class Mutex" mean? it doesnt seem to come from my code
[10:59:33] Tomasso: im using ruby 1.9.3
[11:20:30] apeiros_: Tomasso: I think you'll have to give a bit more context
[11:24:36] shmoon_: aah, thanks canton7 :)
[11:32:23] Tomasso: apeiros_: yes.. I have a Proc block defined in a hash. That block is passed to the .get sinatra method as a parameter. The method the runs ok from browser, and the logs seem ok, but when I check the response I find that
[11:33:14] Tomasso: it is like if it never convert the block returned value, into the stream of data to be sent to the browser, according what i could understand
[11:38:26] apeiros: Tomasso: while a bit more information, that's still not much which actually helps me helping you.
[12:09:35] rkmylo: is it possible to initialize a global variable ($) with a (static?) class instance so as to be able to access it and modify its value from other files?
[12:12:34] apeiros: rkmylo: yes, it's possible. but globals are generally the wrong way.
[12:12:52] apeiros: use e.g. a constant instead
[12:18:15] rkmylo: @apeiros: i've tried setting a global var in env.rb like "$x = Class.new". if i call $x.foo with foo defined in Class, i'm getting "undefined method `foo' for nil:NilClass (NoMethodError)". in the use case i consider, the use of a global static class instance i think is the prefered way. any ideas why i'm getting this error?
[12:20:21] Mon_Ouie: Because $x was nil at the time when you executed $x.foo
[12:21:07] Mon_Ouie: (probably because your $x = Class.new had not yet been executed -- if it was at all)
[12:21:10] apeiros: also no, globals are (almost) *never* the preferred way.
[12:21:19] rkmylo: @Mon_Ouie: so it could be the order in which requires are read?
[12:23:11] Mon_Ouie: It could, if you use $x, the code that gives it a value needs to have been executed first
[12:24:08] Mon_Ouie: (I'm trying to avoid talking about the order in which things are "read" because it's really about which one gets executed first, not which one gets loaded first)
[13:01:44] ponga: do you guys use yield a lot
[13:02:43] avril14th: ponga: what's the question?
[13:02:50] avril14th: do you use "if" a lot?
[13:04:02] jhass: I think I use \n the most
[13:04:34] apeiros: I've tons of spaces in my code
[13:04:47] jhass: ooh, wasteful
[13:04:59] jhass: never hear of chaotic storage management?
[13:05:04] ddv: I use tons of tokens in my code
[13:05:19] apeiros: also many end's
[13:06:49] ponga: http://pastie.org/9974705 what's the difference between first and second
[13:07:13] jhass: ponga: the first one is more to type
[13:07:25] ponga: jhass: what do you mean 'more to type'
[13:07:43] jhass: if you don't pass a block to each_char, it does pretty exactly that
[13:07:55] sevenseacat: more letters.
[13:08:26] apeiros: the first one works in pre 1.9 ruby
[13:08:47] apeiros: other than that - second is better in every regard. less code, faster.
[13:09:05] sevenseacat: dear people who still use pre-1.9 ruby - stop doing that.
[13:09:07] Tomasso: apeiros: http://pastebin.com/nqCzCT0D # it doesnt run because requires things to be mocked but may be there is a concept error ?
[13:09:24] jhass: dear people who still use pre-2.0 you mean
[13:09:44] sevenseacat: i still have 1.9.3 apps, shhh.
[13:09:46] ponga: im on 2.2
[13:09:53] apeiros: ACTION still got an app running in production on 1.8.2 with rails 1.2.3
[13:14:09] cyberfab007: ok boys quick question
[13:14:25] cyberfab007: I followed these instrutctions in install ruby
[13:14:26] cyberfab007: https://gorails.com/setup/ubuntu/14.10
[13:14:38] apeiros: ok, only boys. good. no need for me to look at it then :-p
[13:14:42] DefV: apeiros: but only because 1.2.3 is such a kick-ass version nr
[13:14:53] cyberfab007: I am trying to run this command
[13:15:06] sevenseacat: yeah boys, answer the question.
[13:15:18] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.1.2/rubyscript
[13:15:41] cyberfab007: aperios I am sorry its a figure of speech :)
[13:15:46] cyberfab007: boys and girls , lol
[13:15:58] avril14th: some people include both module
[13:16:01] sevenseacat: how condescending
[13:16:02] avril14th: (even though I dont
[13:16:27] apeiros: ACTION still doesn't feel addressed :)
[13:16:42] cyberfab007: now someone in here helped me build ruby on my other server and this works fine, but now I follow those instructions and it is not work
[13:16:47] cyberfab007: ok aliens too
[13:16:54] cyberfab007: boys girls and aliens lol
[13:17:09] sevenseacat: cyberfab007: you should probably just stop now.
[13:17:42] jhass: ACTION still waits of a description of what actually fails
[13:18:20] cyberfab007: but know seriouse , if I followed those instuctions I post I should just have to change the directory path right ? script works fine from liniux command line , I am just excuting that wrapper from a php script
[13:18:52] jhass: http://rvm.io/workflow/scripting
[13:19:02] cyberfab007: looking at it
[13:21:21] cyberfab007: yegh but on my other server I am not using RVM I do not think,
[13:21:28] cyberfab007: I run the script like this
[13:22:28] cyberfab007: actually know I am it is right there
[13:22:39] cyberfab007: in the path , so I must install RVM as well
[13:23:21] cyberfab007: jhass, can you give me a link with those proper instructions
[13:23:56] jhass: I assumed you used RVM sicne you mentioned it above
[13:24:08] jhass: you likely don't have to use RVM
[13:24:17] cyberfab007: sorry , was just confused I am new to ruby
[13:24:23] cyberfab007: am really liking it tho :)
[13:24:24] jhass: ACTION still waits of a description of what actually fails
[13:25:13] cyberfab007: the script runs from the command line but not when that bash command is run from PHP and its because I do not have RVM installs
[13:26:39] jhass: maybe, maybe not
[13:26:51] jhass: impossible to tell without saying what the problem is
[13:26:56] cyberfab007: no I have this working on another server fine
[13:27:04] jhass: doesn't matter
[13:28:15] cyberfab007: the scripts works on this server too, it is just execting the script using bash command with a ruby wrapper from my php script thats not working well
[13:28:21] cyberfab007: well , I mean at all
[13:31:32] jhass: you yet have to describe your error and what you're concretely doing though
[13:33:50] cyberfab007: the error is the script does not run because I don't have RVM installed
[13:33:53] cyberfab007: I am installing
[13:34:43] sevenseacat: show us the error?
[13:35:15] jhass: sevenseacat: http://truestorieswithgill.com/wp-content/uploads/2013/09/20130915-190532.jpg
[13:36:02] cyberfab007: there error is , the command is not found cause I have do not have RVM installed
[13:44:25] cyberfab007: ok I installed the RVM , but here is my confusion
[13:44:37] ponga: what confusion
[13:44:46] ponga: reminds of me in the old days
[13:44:52] ponga: having difficulties with rvm
[13:45:05] ponga: what's up
[13:45:09] cyberfab007: this is the command I run on my other server to get the script to run
[13:45:21] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.1.2/rubyscript
[13:45:43] cyberfab007: but I don't remember what the guy did to help me to get it to run there
[13:45:45] ponga: looks more like dir address to me
[13:45:53] jhass: why not use ruby 2.1.5 or even 2.2.0 btw?
[13:46:04] ponga: yeah why not 2.1.5 or 2.2.0
[13:46:08] cyberfab007: well the server is old , I have 2.1.5 installed now
[13:46:16] ponga: cyberfab007:
[13:46:18] cyberfab007: and the script still works fine ,
[13:46:20] ponga: u go like
[13:46:26] ponga: 'ruby myruby.rb'
[13:46:28] ponga: and it runs
[13:46:34] ponga: is this what you are looking for
[13:46:51] cyberfab007: I must use the command and wrapper because I am excuting shellexe() from a php script
[13:47:06] ponga: ok that goes beyond my scope
[13:47:11] ponga: apeiros!!!!
[13:47:14] ponga: come hither
[13:48:00] cyberfab007: I'm wondering what the directory path is by default
[13:48:24] jhass: cyberfab007: rvm help wrapper I guess (don't have it installed to check)
[13:48:26] ponga: apeiros enough goat impression
[13:49:55] apeiros_: nah, this goat is unimpressed
[13:50:05] cyberfab007: jhass, I have installed now
[13:50:07] ponga: good one, actually
[13:50:11] ponga: im impressed apeiros_
[13:50:29] cyberfab007: this command is not using a wrapper tho
[13:50:49] ponga: i don even kno how wrapper works
[13:50:52] ponga: can't help
[13:50:52] jhass: cyberfab007: cool, a bit short maybe, so choose a longer one as the new one
[13:51:00] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.1.2/linkedin-scraper
[13:51:28] cyberfab007: try to guss the acronym
[13:51:31] jhass: cyberfab007: looks like a wrapper to me
[13:52:41] cyberfab007: I know, whats the default directory for RVM paths
[13:52:58] cyberfab007: I think /etc/ or somthing I am looking
[13:53:31] cyberfab007: be easy with me , I am really new to and this is the first I have ever used ,
[13:53:41] jhass: cyberfab007: you check rvm help wrapper yet?
[13:53:42] cyberfab007: it downloads the linkedin public profile data
[13:54:41] cyberfab007: jhass, yes I am reading
[13:54:59] cyberfab007: sudo passwd root
[13:55:15] jhass: oh, it was the root password?
[13:55:23] jhass: maybe use sudo and disable root login
[13:55:30] cyberfab007: my cut and past sucks , I really need to just my old egronomic key board
[13:55:46] cyberfab007: its really stick now from all the nachos
[13:56:11] cyberfab007: PATH is not properly set up, '/usr/local/rvm/gems/ruby-2.2.0/bin' is not at first place,
[13:56:26] cyberfab007: that is the waring rvm help wrappers is giving me
[13:56:52] jhass: you installed rvm as root?
[13:56:57] jhass: or as user?
[13:57:00] jhass: or as both?
[13:57:09] jhass: on your old box too?
[13:57:18] cyberfab007: humm , let me check
[13:57:25] cyberfab007: I think so is su as root
[13:57:55] jhass: but why does it live in /home/ there then, apparently?
[13:58:23] cyberfab007: on the orginall box it is point to the path above
[13:58:41] jhass: yeah, so it doesn't look like a root install
[13:58:45] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.1.2/rubyscript
[13:59:05] cyberfab007: humm no your right , so if I install as root , whats that file path
[13:59:20] jhass: and the user install is preferred, managing a system wide install is messy if you have you don't know exactly what you're doing
[13:59:38] jhass: I'd recommend to cleanse the root install and reinstall it as user
[13:59:39] jhass: https://rvm.io/support/troubleshooting
[13:59:45] jhass: check the second to last entry
[14:00:49] jhass: however the warning from above might reappear even then, I'd say it's safe to ignore it
[14:03:56] cyberfab007: I will remove and creat the user cyberfab007 again , chaing to that home directory and install RVM again
[14:14:52] cyberfab007: jhass, you there still
[14:15:07] jhass: don't care
[14:15:15] jhass: ask the channel, not specific people
[14:15:41] cyberfab007: you know we are not so pickely in #php
[14:16:34] momomomomo: cyberfab007: in general, you should ask the channel - this would be true for most channels
[14:16:49] momomomomo: cyberfab007: it keeps people from being penalized for helping others
[14:17:00] momomomomo: penalized == being constantly asked specifically
[14:18:04] cyberfab007: just reinstalling RVM under the same user as my old box
[14:18:16] cyberfab007: and was wondering if following these install instructions https://rvm.io/rvm/install
[14:18:29] cyberfab007: will give me access the the wrapper for this command
[14:18:44] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.1.2/linkedin
[14:19:03] jhass: not directly I suppose, but it's definitely the first step towards it
[14:19:09] jhass: just don't run it as root again
[14:19:21] cyberfab007: nope I creat the same user cyberfab007
[14:20:13] momomomomo: (run as root, i.e. don???t do sudo install
[14:21:22] cyberfab007: installing ............ brb
[14:39:43] harley: anyone know how i can execute cmd commands from a .rb?
[14:40:26] brb3: backticks
[14:47:19] jhass: harley: several ways, which one to recommend depends on what you're doing
[14:49:31] harley: jhass: i have a ruby function, within the function there is a loop, each iteration of the loop presents a different output, i want to use that output to create a new firewall rule
[14:50:17] jhass: so you're not interested in what the command you run outputs but at most in whether it succeeds or not
[14:50:29] jhass: I would recommend the array form of Kernel#system
[14:50:52] jhass: system(["/usr/bin/iptables", "-A", "table", ...])
[14:51:10] jhass: it returns true on success (exit code 0), else false
[14:51:46] jhass: well, change the path then ;)
[15:17:09] harley: i dont know why this happens: when i execute system(exec("echo #{somevarinrubyprogram}"). The execution of the ruby program just stops. How do I make it continue executing the rest of the ruby program?
[15:18:10] harley: it executes the command properly, but then just ends
[15:27:01] gregf_: >>system("echo \"foo\""); puts "gone past foo"
[15:27:01] eval-in: gregf_ => (https://eval.in/292360)
[15:35:05] jhass: harley: That's because Kernel#exec replaces the current process, that is it's job
[15:35:17] cyberfab007: ok so I almost got everything back to normal
[15:35:27] jhass: harley: just don't put that exec in there
[15:35:29] harley: ah ok, i simple used system, works fine noe
[15:35:36] harley: thank you
[15:36:42] cyberfab007: /home/cyberfab007/.rvm/wrappers/ruby-2.2.0/linkedin-scraper ok everything is set up but the gem is not in the directory
[15:36:53] cyberfab007: how do I creat the wrapper someone have a link ?
[15:37:03] jhass: rvm help wrapper does not explain?
[15:38:14] cyberfab007: it explains , but there are so may options I dont know which one to pick to make it like on my original server
[15:39:42] jhass: well, some random guide on the internet won't either
[15:39:55] jhass: rule of thumb is to specify as few as possible I'd say
[15:44:51] rkmylo: hi all, i'm trying to implement some tests in ruby (cucumber/watir-webdriver) and i want to define a static class that will represent a global state that all other class/page-objects can access and modify. my approach was to define a global variable in env.rb that holds an instance of the class that represents the desired state. initialization is done in env.rb as: `$state = State::Instance.new` and i'm trying to access $state from within other c
[15:44:51] rkmylo: lasses as: `x = "#{$state.some_method}"`. this results in: "undefined method `some_method' for nil:NilClass (NoMethodError)". any ideas?
[15:46:00] watmm1: I'm trying to run an Amazon Web Services script but get the following error: `require': cannot load such file -- AWS (LoadError). I have the aws and aws-sdk-core gems installed, but i don't know how to provide the correct "AWS" class. Any ideas?
[15:46:03] rkmylo: it is assumed that some_method has been defined in module State, class Instance
[15:46:42] jhass: rkmylo: your initialization is probably at the wrong point, consider a singleton pattern instead, stdlib ships it as a module
[15:46:52] cyberfab007: rvm wrapper linkedin-scraper --no-prefix
[15:47:10] cyberfab007: rvm wrapper linkedin-scraper --no-prefix
[15:48:12] rkmylo: jhass: as you also mentioned, it indeed seems like initialization is done at the wrong point, however i can't find the guidelines i need! i'll try the singleton pattern. thanks
[15:49:03] jhass: cyberfab007: your copy paste failed again?
[15:49:39] rkmylo: @jhass: well, google was a bit aggressive re ruby + singleton pattern: http://goo.gl/KcOUKD :)
[15:50:03] cyberfab007: no sorry that was the command I ran
[15:50:37] cyberfab007: this is the error
[15:50:38] cyberfab007: Unknown ruby interpreter version (do not know how to handle): linkedin-scraper.
[15:50:55] watmm1: Can someone tell me how to handle "cannot load such file" LoadError's?
[15:51:16] jhass: rkmylo: I think the Singleton module is fit for your usecase
[15:51:35] jhass: watmm1: depends what you mean by handle
[15:51:56] jhass: you want to make the require optional or they fail while you expect them to succeed?
[15:52:14] cyberfab007: when I run rvm linkedin-scraper http://id.linkedin.com/pub/isye-whiting/58/6a1/6b9
[15:52:30] cyberfab007: Unknown ruby interpreter version (do not know how to handle): http://id.linkedin.com/pub/isye-whiting/58/6a1/6b9.
[15:54:15] jhass: cyberfab007: you probably want to specify the version to use in the wrapper generation
[15:54:45] cyberfab007: who would that command look
[15:55:46] cyberfab007: ???I mean what would that command look like
[15:56:11] jhass: I don't use RVM and I can't find online docs for rvm wrapper
[15:56:13] jhass: so I don't know
[15:56:33] jhass: but I guess rvm help wrapper will explain it
[16:02:49] cyberfab007: yegh the help is not rellly helping lol
[16:04:22] jhass: I remember RVMs help pages to be fairly comprehensive
[16:13:09] DefV: werelivinginthef: where are you living? I have to know. In the floor? In the fashion capital of the world? In the fringe?
[16:13:38] jhass: must be fridge
[16:13:42] DefV: can't be
[16:13:43] DefV: too cold
[16:13:52] jhass: that's why!
[16:14:02] jhass: that's the pun, only the dead live in the fridge
[16:14:27] DefV: Google tells me it's "future"
[16:14:32] DefV: which feels awefully uninspired
[16:14:41] jhass: fridge is much better
[16:15:27] lxsameer: guys, i'm looking for a document generator which supports ruby, javascript and coffeescript do you know any ?
[16:16:08] werelivinginthef: DefV: In the future
[16:16:31] werelivinginthef: But it's open to interpretation I suppose
[16:21:52] gregf_: werelivinginthef: c'mon man dont keep us guessing. the future is a guess as well ;)
[16:22:49] jhass: cyberfab007: just installed RVM into a chroot, I find rvm help wrapper pretty clear
[16:23:23] jhass: how did you install linkedin-scraper ?
[16:24:02] cyberfab007: jhass, install it gem install linkedin scrapper
[16:25:53] jhass: without activating a specific gemset / ruby version before?
[16:26:13] jhass: that is no rvm use command?
[16:26:45] cyberfab007: yes I did not activat anything I just run that command , how do I activate with a specific gem set ?
[16:26:56] jhass: with rvm use
[16:27:28] jhass: you ran that as your regular user though?
[16:27:30] jhass: not with sudo?
[16:28:12] jhass: just trying to figure out your setup ;)
[16:33:49] cyberfab007: jhass, yes I rand a a regular user
[16:33:56] jhass: what's gem env | grep INSTALL?
[16:35:06] cyberfab007: gem env | grep INSTALL
[16:35:17] cyberfab007: - INSTALLATION DIRECTORY: /home/cyberfab007/.rvm/gems/jruby-1.7.19
[16:36:33] jhass: you installed jruby? :D
[16:36:48] cyberfab007: yes , just followed those instructions of the site
[16:36:49] jhass: rvm current gives jruby I guess?
[16:37:17] jhass: "the site"?
[16:37:31] cyberfab007: what you mean ?
[16:37:34] jhass: which site?
[16:38:31] cyberfab007: https://rvm.io/rvm/install
[16:38:38] cyberfab007: thats the instructions I use
[16:38:54] jhass: you didn't read a sentence on it I guess?
[16:39:10] jhass: those are alternatives
[16:39:18] jhass: you pick one
[16:39:53] cyberfab007: but I said in here I did not which one to pick , so I figure I install them all4
[16:40:23] jhass: if so you didn't make clear that you were talking about that
[16:40:55] jhass: I guess, anyway
[16:41:07] jhass: let's see which rubies you got
[16:41:10] cyberfab007: well to be clear you gotta know what your talking about lol , I am new to buty
[16:42:09] cyberfab007: jruby-1.7.19 [ x86_64 ]
[16:42:09] cyberfab007: ruby-2.2.0 [ x86_64 ]
[16:42:33] cyberfab007: ahh this is why I am getting the interpreter error
[16:42:45] cyberfab007: I should uninstall jruby you think?
[16:43:07] jhass: ya you don't need it
[16:43:16] jhass: so let's do rvm use 2.2 --default
[16:43:20] jhass: rvm uninstall jruby
[16:43:34] jhass: gem install linkedin-scrapper
[16:43:45] jhass: rvm wrapper 2.2 --no-prefix linkedin-scrapper
[16:48:30] rooby: why am i getting 'ArgumentError: invalid byte sequence in US-ASCII' even though I have set my locale to UTF-8 ?
[16:48:47] jhass: rooby: what are you getting that for?
[16:48:53] cyberfab007: ERROR: Error installing linkedin-scraper:
[16:48:53] cyberfab007: ERROR: Failed to build gem native extension.
[16:48:54] cyberfab007: /usr/bin/ruby2.1 extconf.rb
[16:48:54] cyberfab007: mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
[16:49:00] cyberfab007: what the hell ?
[16:49:07] cyberfab007: worked before
[16:49:10] jhass: you did the rvm use 2.2 ?
[16:49:20] jhass: and it didn't complain?
[16:49:22] cyberfab007: i set it as defauly
[16:49:31] jhass: rvm current reports it?
[16:49:46] cyberfab007: ve set my locale to UTF-8 ?
[16:49:47] cyberfab007: * sent1nel_ (~sent1nel@66.19
[16:50:04] sent1nel_: sorry, my interlulz are on the fritz
[16:50:07] preyalone: How can I get system( ... ) / ` ... ` to become aware of the same aliases and things available in my ordinary bash shell?
[16:50:18] rooby: jhass: i'm trying to run an irc bot that i got off github, i have no idea why I'm getting this, link to the error with --trace here https://gist.github.com/anonymous/9f20fb1aa8a0c7a39e1b
[16:50:22] cyberfab007: jhass, yes it reports 2.2.0
[16:50:41] jhass: preyalone: you would run your ordinary bash shell, be careful to not pass user input to it though
[16:51:16] cyberfab007: maybe I must restart ruby?
[16:51:22] cyberfab007: is that even possible lol
[16:51:22] rooby: did some googling and all answers seem to be to set locale to UTF-8
[16:51:32] jhass: cyberfab007: and you do gem install, not sudo gem install ?
[16:52:01] atmosx: I don't sudo for I am root!
[16:52:18] preyalone: jhass: What? Let me provide more context: I've got a nifty specs ruby CLI program, that I want to be able to run `nvm --version`, where nvm is an alias defined in ~/.bashrc. https://github.com/mcandre/specs
[16:52:24] jhass: rooby: and `locale` reports it correctly for all values?
[16:52:29] cyberfab007: lol , it magially worked after 5 times I try
[16:52:55] havenwood: cyberfab007: it's more likely that you're changing your commands :P
[16:53:11] jhass: cyberfab007: ^ or the context you run them in
[16:53:29] cyberfab007: jhass, now I run
[16:53:30] cyberfab007: rvm wrapper 2.2 --no-prefix linkedin-scrapper
[16:53:56] cyberfab007: Could not find file 'linkedin-scrapper' nor '/home/cyberfab007/.rvm/wrappers/ruby-2.2.0/linkedin-scrapper'.
[16:54:19] rooby: jhass: what do you mean?
[16:54:25] jhass: preyalone: so, system("/bin/bash -c 'nvm #{careful_no_userinput_here}'")
[16:54:44] jhass: preyalone: honestly, I'd consider just avoiding the alias though
[16:55:04] cyberfab007: jhass, never mind it one p inscrapper not two
[16:55:06] jhass: rooby: locale i a command you can run at your shell
[16:55:09] Volis: Hi, I'm using cygwin on Windows 8.1
[16:55:24] Volis: I get a LoadError when I call bundle install
[16:55:25] preyalone: jhass: Works for me, and this alias is nvm, an alias that I don't control, but need to handle
[16:55:31] Volis: $ bundle install
[16:55:31] Volis: C:\Ruby21-x64\bin\ruby.exe: No such file or directory -- /cygdrive/c/Ruby21-x64/bin/bundle (LoadError)
[16:55:41] havenwood: Volis: gem install bundler
[16:55:48] Volis: I did that, havenwood
[16:55:57] havenwood: Volis: Did it succeed?
[16:56:08] rooby: jhass: yes, it's all "LC_ALL=en_US.UTF-8"
[16:56:11] Volis: havenwood: $ /cygdrive/c/Ruby21-x64/bin/bundle
[16:56:12] Volis: bundle bundle.bat bundler bundler.bat
[16:56:20] Volis: You can see the contents of the directory
[16:56:23] Volis: it is there
[16:56:26] havenwood: Volis: So it's just not in your PATH it seems.
[16:56:34] jhass: rooby: link to the github repo?
[16:56:41] Volis: How do I do that, havenwood?
[16:56:59] rooby: jhass: https://github.com/chadrien/hots-irc-bot
[16:57:31] havenwood: Volis: add `/cygdrive/c/Ruby21-x64/bin` to PATH, did you build Ruby yourself?
[16:58:27] havenwood: Volis: I'd think RubyInstaller or Chocolatey would do that for you. I'd have to google how to add a dir to PATH in Win, dunno.
[16:58:31] jhass: rooby: their travis build runs only on ruby 2.2 and ruby-head, ruby 2.0 did change the default when reading source files from ascii to utf-8, it's likely that ruby 1.9 is just not supported by it, it EOLs today anyway
[16:58:35] Volis: havenwood: I had installed it from cygwin installer. I also have it installed from the Ruby for Windows installer.
[16:58:53] Volis: havenwood: Ah, alright. Thanks for your help!
[16:59:19] rooby: jhass: so upgrading ruby version should fix it?
[16:59:32] havenwood: Volis: No prob, happy hacking!
[16:59:40] jhass: rooby: I think so
[16:59:59] cyberfab007: what the hell does this mean
[17:00:00] cyberfab007: /home/cyberfab007/.rvm/gems/ruby-2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:262:in `block in fetch'
[17:00:07] preyalone: jhass: New constraint: How can I load the user's shell settings into system('...') / `...`, without explicitly calling bash, as I want this to work for cmd.exe, zsh, etc.
[17:00:21] jhass: cyberfab007: that looks like part of a backtrace, the error should be above it
[17:00:58] jhass: preyalone: no idea about cmd.exe, most UNIXes should have ENV['SHELL'] set
[17:01:10] cyberfab007: /home/cyberfab007/.rvm/gems/ruby-2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:262:in `block in fetch'
[17:01:32] cyberfab007: home/cyberfab007/.rvm/gems/ruby-2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:933:in `response_read': 999 => for -- http://id.linkedin.com/pub/wasis-kartijoso/28/762/625 (Mechanize::ResponseCodeError)
[17:01:41] jhass: cyberfab007: Please share your code on https://gist.github.com
[17:01:48] jhass: also see /topic
[17:02:45] cyberfab007: https://gist.github.com/anonymous/3bf81eff468eba8fca92
[17:02:51] ducklobster: is there a way to force a gem to be re-required?
[17:03:00] ducklobster: awesome_print seems to hook into the standard logger to add a method but
[17:03:03] cyberfab007: there it the output
[17:03:11] cyberfab007: this script worked fine earlier
[17:03:26] ducklobster: if it is required prior to the standard logger, it doesn't work
[17:03:47] jhass: cyberfab007: how about curl -v on that URL
[17:04:32] jhass: ducklobster: nothing safe
[17:05:16] ducklobster: would it be acceptable to just run the code block that adds the awesome_print method to logger again?
[17:05:18] ducklobster: i.e. https://github.com/michaeldv/awesome_print/blob/master/lib/awesome_print/core_ext/logger.rb#L19
[17:05:29] cyberfab007: jhass, request denyied , odd
[17:05:41] jhass: cyberfab007: yeah, thought something like that
[17:05:46] jhass: linkedin no longer likes you ;)
[17:05:48] preyalone: jhass: This is getting messy, I might even write a lib just for doing this
[17:06:23] jhass: preyalone: or you just make it an argument or proper config file instead
[17:06:35] cyberfab007: wierd , script works fine on my other server
[17:06:43] cyberfab007: you think its the ip ?
[17:06:50] jhass: cyberfab007: yeah, such blocks usually are IP based
[17:08:11] cyberfab007: dont understand why , I really have not run this script even once on this server
[17:08:44] cyberfab007: i did a test on linked, they let me do 60 searches a hour no problem
[17:09:04] cyberfab007: let me curl somthing else
[17:09:29] jhass: maybe your new box is in an ip range that showed abusive behavior in the past
[17:09:38] Volis: havenwood: Looks like the problem is I have two versions of ruby. The StackOverflow answer suggests that I 'nuke' one of them. What is 'nuke'?
[17:13:14] cyberfab007: thank you for all your help , the ip is blocke dI gotta put a support ticket in and do some compaing
[17:13:20] havenwood: Volis: Kill it with fire. (Delete it.)
[17:15:46] havenwood: Volis: There's a longstanding Ruby switcher for Win I've heard of called pik, or a new multi-platform one that works on Win called uru: https://bitbucket.org/jonforums/uru
[17:15:55] catsoup: maybe only delete it if you're sure you won't get the same ip next time?
[17:16:06] havenwood: Volis: ^ If you want to do switching instead of having one Ruby, your choice. One Ruby is of course a bit simpler!
[17:16:28] Volis: a lot, yes
[17:17:04] Volis: If this frustrates me anymore, I'll install this piece of shit on the virtual machine
[17:18:15] havenwood: Volis: Something like a recent Fedora really does make it pleasant: yum install ruby && gem install bundler
[17:20:35] havenwood: So is Windows getting a package manager in 10.0? https://github.com/OneGet/oneget#readme
[17:20:53] catsoup: or you could use a real os, regards
[17:21:45] workmad3: havenwood: I still feel bad for the windows 9 team
[17:22:05] havenwood: workmad3: They've been disappeared!?
[17:22:25] workmad3: havenwood: I assume the team went the way of windows 9 itself
[17:23:35] withnale_: Is there a way to load a class but avoid running the at_exit function enclosed within it, without changing that class?
[17:24:18] shevy: ewww at_exit
[17:24:23] shevy: I think you can rescue exit-events
[17:34:09] Scripore: I'm making a command line application. Is there any way to make a url link clickable?
[17:37:10] shevy: scripore that depends on the terminal you use. in gnome-terminal you can get that
[17:37:11] havenwood: withnale_: `exit!` won't run the `at_exit` or any finalizers. Looking to see if I can find a way to actually clear the `at_exit` procs.
[17:37:38] Scripore: will it work with bash?
[17:37:38] withnale_: It's ok. Found a way around it now. It wasn't the root cause of my problem
[17:37:45] havenwood: weaksauce: Ah good.
[17:38:24] shevy: scripore bash itself has no way to understand linkable-links, you really need to use a terminal that supports click-actions; gnome-terminal works for sure, I think kde konsole may also work somehow but I am unsure
[17:38:37] havenwood: I don't know of a `ObjectSpace.undefine_finalizer` equivalent for `at_exit`.
[17:38:43] Scripore: ah, okay. thank you.
[17:40:55] Cadillactica: possible to sort Ruby objects by two attributes such as Last Name (reverse order), First Name (reverse order), so that objects with same last name are sorted by first name?
[17:43:13] jhass: Cadillactica: you can pass a block to sort, or if it's your own class define <=> accordingly, see the Comparable module
[17:44:13] jhass: a quick way would be .sort_by {|x| [x.last_name, x.first_name] }, though that does many unnecessary array allocations
[17:44:56] Cadillactica: jhass: I???m familiar with that approach but how would I do the same thing, except reverse order?
[17:45:32] Cadillactica: two <=> statements inside of an array used with sort?
[17:46:40] jhass: I'd say pass a block to sort and understand what <=> returns (and thus what your block should return)
[17:49:26] timgauthier: anyone have their computer set to german who could just look at somethin for me?
[17:54:04] bhaak: Timgauthier: what OS?
[17:58:01] shevy: my computer is a natural born german
[17:58:35] shevy: I just noticed that I was using english locales anyway - german errors confuse the hell outta me :\
[18:14:13] zling: apeiros_!aperios@80-218-30-231.dclient.hispeed.ch
[18:14:38] apeiros_: that's an odd ping
[18:16:38] shevy: how annoying can a ping be zling
[18:17:11] zling: want a beep
[18:17:46] jhass: "beep" mmh, sounds like typo for "ban"? :P
[18:18:27] zling: I was there
[18:18:30] zling: m is here
[18:18:35] havenwood: zling: you seem to be trapped in a temporal distortion field
[18:18:52] zling: ~~~~~ *-__-* ~~~~~~
[18:19:32] shevy: beeps are deprecated
[18:19:45] apeiros: zling: is there an actual reason you pinged me?
[18:21:20] gregf_: zling: do you like getting banned ;)
[18:21:33] havenwood: shevy: print ?\a
[18:21:53] eval-in: jhass => "\a" (https://eval.in/292430)
[18:22:00] jhass: >> puts "\a"
[18:22:00] eval-in: jhass => ... (https://eval.in/292431)
[18:28:26] apeiros: ok, welcome on my ignore, zling.
[18:33:02] shevy: he is a spam bot
[18:33:11] shevy: just spammed a link in privmsg
[18:36:57] izzol: I have a strange problem :(
[18:37:16] izzol: kernel_require.rb:55:in `require': cannot load such file -- net/ping (LoadError)
[18:37:29] izzol: This is what I have when I???m trying to execute my code.
[18:37:44] izzol: 2.1.2 :001 > require 'net/ping'
[18:37:48] izzol: And this is from my irb.
[18:38:45] Fluent: What version of Ruby is running your programs?
[18:38:58] Fluent: It might not be the same version as your interactive ruby version
[18:39:09] Fluent: and may be looking in other locations for gems
[18:41:19] izzol: # which ruby
[18:41:29] izzol: ???/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby"
[18:41:44] havenwood: As of today... Ruby 1.9 is dead, long live 2.2!
[18:42:00] izzol: I even setup this in my first line:
[18:42:08] izzol: > head -1 monit.rb
[18:42:08] izzol: #!/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby
[18:42:39] izzol: # /usr/local/rvm/rubies/ruby-2.1.2/bin/irb
[18:42:40] izzol: 2.1.2 :001 > require 'net/ping'
[18:42:42] izzol: 2.1.2 :002 >
[18:43:03] izzol: So what can be wrong ?
[18:43:49] jhass: izzol: does ruby -r'net/ping' work?
[18:44:18] jhass: ruby -r'net/ping' -e 'puts "works"'
[18:44:46] izzol: # ruby -r'net/ping' -e 'puts "works"'
[18:45:10] Fluent: Check your load path?
[18:46:35] izzol: hmm, I don???t have anything at the $LOAD_PATH
[18:46:40] izzol: shall I setup something ?
[18:47:31] jhass: izzol: what's the exact command producing the error?
[18:47:46] izzol: /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- net/ping (LoadError)
[18:48:12] havenwood: izzol: That's the error. What are you running to get that error?
[18:48:47] Fluent: require 'net/ping' most likely
[18:49:10] izzol: require 'net/ping'
[18:49:27] Fluent: His LOAD_PATH is blank, so that's likely the issue
[18:49:32] jhass: izzol: no, how do you invoke the script containing that
[18:49:33] havenwood: izzol: Huh? In irb?
[18:49:37] Fluent: I'm not sure how to 'reset' it
[18:49:49] Fluent: In irb it works, likely failing in a script
[18:50:01] havenwood: Fluent: Right, so the question is how the script is being invoked.
[18:50:20] izzol: jhass: I???m executing it from the crontab ??? Just * * * * * /path/to/code/ruby.rb
[18:50:59] jhass: izzol: exact command please
[18:51:43] jhass: izzol: but it looks like you're using RVM, so make sure the right environment is active: https://rvm.io/deployment/cron
[18:51:50] izzol: * * * * * /home/brains99/Data/Configuration/monit/monit.rb
[18:51:51] izzol: * * * * * usr/local/rvm/rubies/ruby-2.1.2/bin/ruby /home/brains99/Data/Configuration/monit/monit.rb >> /opt/logs.txt
[18:52:13] izzol: second one should be of course /usr/...
[18:52:14] jhass: yeah, don't call into the RVM ruby directly, see above link
[18:54:33] arup_r: jhass: How many lines of code you write everyday ?
[18:55:05] jhass: I do not count
[18:55:09] jhass: and I do not code everyday
[18:55:16] havenwood: arup_r: On a good day, a negative number.
[18:56:08] izzol: ha! it???s working now
[18:56:17] izzol: thanks jhass :)
[18:56:18] havenwood: arup_r: Removing more lines than those added.
[18:56:37] arup_r: refactoring... I see
[19:08:42] arup_r: Can anybody write something there ? https://www.ruby-forum.com/topic/6873429#new
[19:12:05] havenwood: arup_r: https://www.youtube.com/watch?v=FR95rp-9Oo4
[19:12:13] havenwood: arup_r: https://github.com/jimweirich/presentation_solid_ruby
[19:18:43] arup_r: >> [*1..15].sample(random: 1..3)
[19:18:43] eval-in: arup_r => 11 (https://eval.in/292445)
[19:18:57] arup_r: what the range argument is doing there ?
[19:19:03] arup_r: I never used
[19:20:03] jhass: where did you get that from?
[19:20:17] jhass: I don't see it in the docs
[19:20:36] jhass: My suspicion is that it's just ignored if it's no rng
[19:20:51] arup_r: http://ruby-doc.org//core-2.2.0/Array.html#method-i-sample
[19:21:07] jhass: doesn't mention passing a range
[19:22:34] arup_r: doco don't have explanations
[19:22:56] jhass: rng means random number generator
[19:23:06] jhass: not range
[19:24:10] jhass: "The optional rng argument will be used as the random number generator"
[19:31:19] Aerosonic: Hey guys. I need some help with RoR.
[19:31:30] Aerosonic: I'm trying to add User.new to the database, but I am getting syntax errors. => #<User id: nil, email: nil, referral_code: nil, referrer_id: nil, created_at: nil, updated_at: nil, landing_page: nil>
[19:31:46] Aerosonic: I'm trying to do User.add <email: "example@gmail.com">
[19:31:51] Aerosonic: But it's not working.
[19:32:23] Aerosonic: (irb):103: syntax error, unexpected keyword_end
[19:33:12] havenwood: Aerosonic: The best place for Rails questions is #RubyOnRails. They require nickname registration: https://freenode.net/faq.shtml#nicksetup
[19:33:25] Aerosonic: Ah. I thought I tabbed to RoR.
[19:40:28] Jonah11_: is there an elegant way to combine "select" and "first(n)", returning the first n elements of an array that match the criterion specified in a block?
[19:40:58] jhass: so not take_while ?
[19:42:05] Jonah11_: jhass, that's my soln right now, but it involves introducing a "ret" array, and i'm not happy with it.
[19:42:35] arup_r: jhass: I'm able to explain it -- http://stackoverflow.com/a/28681822/2767755
[19:42:48] jhass: Jonah11_: huh, how so? Mind to show your current solution?
[19:42:54] Jonah11_: unless there is a way to refer to "the current result array" from within the block that i'm not aware of
[19:42:58] Jonah11_: sure, one sec
[19:45:32] Jonah11_: jhass: simple example: https://eval.in/292448
[19:46:42] jhass: Jonah11_: mmhh, I hoped to learn something about the collection you're iterating
[19:47:07] jhass: but in that you can already replace ret with a counter instead
[19:47:50] Jonah11_: jhass: there's nothing domain specific about my question. if you have a better rewrite for my example, that's all i'm looking for
[19:48:04] jhass: taken = 0; ret = foo.take_while {|item| take = taken <= 5 && wanted?(item); taken += 1; take }
[19:48:22] jhass: but I'd just chain .select & .first really
[19:48:32] jhass: throw .lazy. in if your collection is huge
[19:49:08] Jonah11_: jhass: yeah, the collection is big, so lazy will ensure the entire select doesn't run?
[19:49:22] havenwood: >> 1.upto(Float::INFINITY).lazy.select(&:even?).first 3
[19:49:22] eval-in: havenwood => [2, 4, 6] (https://eval.in/292449)
[19:49:26] havenwood: Jonah11_: ^ example
[19:49:29] Jonah11_: cool, did not know about that, that should be good
[19:49:38] Jonah11_: thanks guys
[20:14:04] rubycookie: what happens when a thread tries to acquire a mutex but it is in use?
[20:14:10] rubycookie: does it wait?
[20:14:30] rubycookie: wait/block or does the thread die?
[20:16:36] Hijiri: I'm guessing it would block, that's usually what mutexes do
[20:16:38] Hijiri: but I don't know
[20:17:10] Hijiri: there are probably methods for inspecting whether a mutex is already in use, and you could kill the tread when you find that it's in use
[20:18:05] havenwood: rubycookie: Give it a try in irb/pry: mutex = Mutex.new; Thread.new { mutex.synchronize { sleep 10 } }; sleep 0.5; mutex.synchronize { puts 'hello!'; :success }
[20:18:32] havenwood: rubycookie: (The `sleep 0.5` is just there to make sure the Thread gets the lock first.)
[20:20:27] jhass: havenwood: Thread.yield ? ;)
[20:22:00] rubycookie: havenwood: it waits
[20:22:05] rubycookie: Hijiri: thanks
[20:30:54] joshhartigan: If I???ve created a class, can I define a method for it that specifies what to do when I call `puts [objectOfThatClass]`?
[20:31:10] jhass: joshhartigan: puts calls .to_s
[20:31:22] joshhartigan: jhass: Thank you :)
[20:31:34] arup_r: Need help
[20:31:42] arup_r: what this line - https://gist.github.com/aruprakshit/80f14ec54490c9ce56fe#file-rand-rb-L11-L13 doing ?
[20:31:48] arup_r: I'm confused
[20:39:05] arup_r: Am I disconnected ? :(
[20:39:25] kalusn: arup_r: looks like he is aliasing rand to call, which ary.sample is using
[20:39:35] arup_r: That I got
[20:40:00] arup_r: but class << gen_to_int ???
[20:40:14] arup_r: what is getting cooked
[20:40:36] kalusn: arup_r: it is a way of extending the "Proc" object
[20:40:57] arup_r: singleton class ?
[20:41:13] kalusn: arup_r: it basically let's you redefine the internals of the object
[20:41:35] arup_r: Inside the Proc object ?
[20:42:03] arup_r: Do you know where it has been documented ?
[20:45:15] kalusn: arup_r: I could not find any official docs but you could take a look at http://madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html
[20:47:15] shevy: string concatenation https://pbs.twimg.com/media/B9MmNvxCQAETh6T.jpg
[20:53:20] gr33n7007h: ACTION thinks nyan-cat in pry is awesome!
[20:57:10] arup_r: kalusn: makes sense
[21:01:09] arup_r: Last Why #to_int is needed ? https://gist.github.com/aruprakshit/80f14ec54490c9ce56fe#file-rand-rb-L3
[21:07:40] arup_r: sample, internally call #to_int
[21:07:50] arup_r: that's why it has been defined
[21:10:00] Hanmac: apeiros did you see this? https://www.chillingeffects.org/notices/10416081# ;P
[21:17:25] shevy: https://www.archlinux.org/download/
[21:17:34] shevy: We have an exclusive & worldwide deal for distributing this content
[21:17:45] shevy: so they have music there
[21:41:24] Hanmac: shevy: the bad thing about LED-Traffic-Lights: http://asia.nikkei.com/Japan-Update/LED-traffic-lights-pose-unexpected-hazard
[21:43:36] shevy: such a high tech country
[21:43:44] shevy: and cracked down by nature's force
[21:43:48] shevy: be it a tsunami or simple snow
[21:55:10] timgauthier: hanmac shevy thats just an example of shitting light fixtures :P
[21:55:30] timgauthier: The truckers in Canada stopped using LED's cause they had similar problems
[21:55:41] timgauthier: I think volvo's solution was to pipe engine heat over the light lenses
[21:56:04] timgauthier: why not a super small element in the light lenses at the stoplights to have a heating element?
[22:02:23] bricker: What do you guys think is the most underused feature of Ruby?
[22:03:55] Hanmac: bricker: rails? XD
[22:04:27] havenwood: hanmac: You mean Ruby is the most underused feature of Rails. :P
[22:05:22] hoelzro: probably something like __END__
[22:06:30] Hanmac: i have seen cases where eval got overused where send would be better
[22:06:48] GaryOak_: I think dynamic dispatch in Ruby is pretty cool
[22:06:59] GaryOak_: but the use cases are limited
[22:07:05] havenwood: bricker: Kernel#abort and Kernel#warn seem underused. I fairly often see `STDERR.puts; exit 1` or whatev.
[22:07:26] havenwood: bricker: Many of the methods on Enumerable.
[22:07:34] Nilium: ACTION has largely switched to languages without dynamic dispatch because people who find dynamic dispatch cool tend to use it as the hammer for all nails.
[22:08:24] Nilium: Also because Ruby's enormous amount of gems is mostly a garbage swamp, but that's just the nature of having an open environment, I think. Same with node.js and npm (except node.js is infinitely worse than Ruby).
[22:09:05] GaryOak_: for the most part the gems get vetted, unless there is a super specific reason for them to exist
[22:09:18] GaryOak_: and only two people end up using them
[22:10:16] gr33n7007h: flip flop operator
[22:10:27] GaryOak_: that's a good one
[22:12:42] havenwood: Nilium: You can always use a curated subset of gems as your gatekeeper. https://www.ruby-toolbox.com/ or http://awesome-ruby.com/ or something you agree with.
[22:13:14] Hanmac: ACTION never needed the flip flop operator before in a use case ...
[22:13:50] GaryOak_: hence why it's underused
[22:14:03] havenwood: That's why... right. :P
[22:14:13] GaryOak_: and because it looks like a range function
[22:15:01] havenwood: It'll be gone in Ruby 3.0.
[22:15:38] havenwood: Where it'll be used roughly as much as it currently is, not at all.
[22:16:13] pipework: havenwood: You've never emulated hardware so that you can emulate software in software that's emulating hardware?
[22:16:33] havenwood: pipework: The proceeds of proceeds are no longer proceeds under the revised rules of proceeds.
[22:17:05] havenwood: pipework: :)
[22:17:14] havenwood: I guess that's about it.
[22:17:20] pipework: havenwood: Then let us proceed to proceed, so that I can proceed to proceedings that proceed in the manner befitting the proceeds appropriate for such proceedings.
[22:18:05] havenwood: pipework: Such proceedings would proceed the proceeds of proceeds as proceeds procedure change, naturally.
[22:19:03] pipework: Hm. quite procedural indeed.
[22:20:48] TTilus: proceedural even ;)
[22:22:40] pipework: TTilus: I don't get it.
[22:25:14] havenwood: I keep getting the feeling today that I've misunderstood. Then it turns out I have.
[22:26:17] centrx: Is that a pun
[22:27:12] workmad3: pipework: I have a suspicion that TTilus just attempted to correct your correct spelling with an incorrect spelling of procedural...
[22:29:25] havenwood: I thought an attempted pun. centrx: I think not a pun since both from the same Middle French, proceder.
[22:30:21] havenwood: Though maybe the meaning drifted enough to be punny?
[22:34:07] havenwood: punctum rubinus
[22:38:13] shevy: if you have a module Foo; def bla ... and several more methods. Now, bla() shall also become a class method aka Foo.bla() how would you do this?
[22:38:39] shevy: my current way is to: def self.bla() and then also define another method bla that will point to Foo.bla
[22:38:54] hoelzro: shevy: you mean you want to be able to mixin Foo and have it be a method on the mixing class, but also available as a class method?
[22:39:20] hoelzro: I thought there was something like module_function :bla for that
[22:39:43] havenwood: shevy: http://ruby-doc.org//core-2.2.0/Module.html#method-i-module_function
[22:39:51] shevy: hoelzro yeah
[22:40:01] hoelzro: http://ruby-doc.org/core-1.9.3/Module.html#method-i-module_function
[22:40:08] hoelzro: er, wrong version of Ruby =/
[22:40:09] havenwood: hoelzro: 1.9 is dead!
[22:40:12] havenwood: hoelzro: :P
[22:40:14] shevy: hmm I think there was one catch with module_function
[22:40:16] hoelzro: I heard! today, right?
[22:40:21] havenwood: hoelzro: indeed :O
[22:40:31] hoelzro: that's the version of Ruby I first learned
[22:40:37] havenwood: hoelzro: ditto
[22:41:06] havenwood: hoelzro: i started Ruby in 1.9.1 days
[22:41:37] havenwood: just in time for 1.9.2 landing
[22:41:40] hoelzro: I think I started on 1.9.3
[22:41:41] shevy: that these methods are private
[22:41:56] hoelzro: can you do module_function :bla ; public :bla?
[22:41:57] bootstrappm: i started on 1.8.7
[22:42:03] havenwood: hoelzro: i don't think so
[22:42:31] shevy: lemme test :)
[22:42:53] havenwood: shevy: compare with: extend self
[22:42:58] shevy: but just so I don't forget, I think this is the functionality I'd need, ideally in a shorter way: http://pastie.org/9976245
[22:43:04] shevy: yeah but extend self makes it for all methods in the module right?
[22:43:31] shevy: hoelzro's variant works btw
[22:43:37] shevy: though that is a bit weird haha
[22:44:02] hoelzro: def public_module_function(sym) module_function sym ; public sym end # =P
[22:44:09] shevy: http://pastie.org/9976250
[22:45:13] shevy: yeah hoelzro
[22:45:17] shevy: I want this in core now!
[22:50:31] havenwood: hoelzro: oh, nice!
[22:56:02] MatthewsFace: Hey guys, so I'm trying to capture the output of a python script within a ruby script
[22:56:22] MatthewsFace: I can't seem to capture the output with exec()
[22:56:32] MatthewsFace: the script calls the python script, and then exits my ruby script
[22:57:14] shevy: I got another question now
[22:57:48] havenwood: MatthewsFace: That's how Kernel#exec works, it replaces the current process. Check out Kernel#` docs: http://ruby-doc.org//core-2.2.0/Kernel.html#method-i-60
[22:58:49] shevy: https://gist.github.com/shevegen/220bcdfb313d89136160
[22:58:53] shevy: the two are equivalent right?
[22:58:59] shevy: (1) class << self
[22:59:04] shevy: (2) self.instance_eval
[22:59:15] shevy: I get 4x the same output, so they seem to be equivalent
[23:04:04] weaksauce: what use is a singleton method in practice?
[23:05:23] shevy: haha hanmac http://www.autoblog.com/2009/12/16/unintended-consequence-of-technology-new-led-traffic-lights-can/
[23:05:36] shevy: weaksauce you can specialize a given object at runtime
[23:05:46] shevy: like rulers and peons
[23:05:48] jfarmer: @shevy They are not equivalent.
[23:05:49] shevy: you have a ruler object
[23:05:54] shevy: jfarmer oh?
[23:06:04] shevy: and I was so happy already :(
[23:06:32] jfarmer: Run `p [self, self.ancestors]` in each block and see the difference.
[23:07:14] MatthewsFace: thanks havenwood
[23:07:16] MatthewsFace: I guess it helps if I would go look at the docs
[23:07:25] MatthewsFace: Is there a better way you suggest?
[23:07:42] weaksauce: anyone have an example of singleton usage in an opensource project?
[23:07:49] weaksauce: singleton methods*
[23:08:03] weaksauce: not the design pattern
[23:08:38] havenwood: MatthewsFace: If you want to run a command and simply return the output to STDOUT as a String, backticks should works nicely.
[23:09:13] tejasmanohar: whats the latest ruby version in 2.1.x series
[23:09:25] havenwood: tejasmanohar: 2.1.5
[23:09:38] jfarmer: @tejasmanohar https://www.ruby-lang.org/en/downloads/
[23:09:40] jfarmer: Listed there
[23:10:11] MatthewsFace: the python script is using the return function
[23:10:19] MatthewsFace: I see nothing with the backticks
[23:10:28] MatthewsFace: it either returns 0 or 1
[23:11:46] jfarmer: @MatthewsFace Really? http://cl.ly/image/3w0O2s0E3J1R
[23:12:26] jfarmer: Backticks will capture whatever the process you specify prints to STDOUT
[23:12:37] shevy: weaksauce not me, I don't need it really. if I need other behaviour I can just modify the class anyway
[23:12:38] jfarmer: You can't communicate across processes via a "return" call
[23:13:11] weaksauce: shevy that's kind of what I was curious about if there was some non obvious way that they solve some problem elegantly
[23:13:20] jfarmer: "return" in Python only means something to the Python interpreter; you have to communicate using common ground
[23:13:32] jfarmer: In this case, the larger shell environment with STDIN, STDOUT, pipes, and all the rest
[23:13:35] shevy: weaksauce that's often with ruby - some features are hard to find a use case for :)
[23:18:05] MatthewsFace: Got it, that make sense
[23:30:33] tiago: Hi, is rubygems broken on debian wheezy? I keep getting this error, when I try to download a package, with --debug
[23:30:41] tiago: Exception `Errno::EAGAIN' at /usr/lib/ruby/1.9.1/net/protocol.rb:141 - Resource temporarily unavailable - read would block
[23:30:47] tiago: I'm not running it behind a proxy
[23:33:55] shevy: "gem install foo" works for other packages?
[23:35:05] tiago: shevy: nope
[23:35:09] tiago: tried jekyll and compass
[23:35:12] tiago: let me get a log
[23:35:20] shevy: I will try jekyll
[23:36:04] shevy: works fine
[23:36:06] tiago: https://gist.github.com/ttsda/6b57045df470dc421cf8#file-gistfile1-txt
[23:36:14] shevy: gem version I have is 2.4.6
[23:36:16] tiago: it's only on my VM, it works well on my laptop
[23:36:29] tiago: I'm on 1.8.23
[23:36:39] shevy: that is old
[23:36:46] tiago: It's the one in the wheezy repo
[23:37:11] workmad3: bleh, repo version of rubygems... ancient and has been ripped apart and had the update mechanism removed
[23:37:17] shevy: well, if you wish to stick in debian then debian needs to have a way to update rubygems
[23:37:31] shevy: debian hates alternatives!
[23:37:40] tiago: there is a way
[23:37:45] tiago: an env variable
[23:37:46] jidar: just fork debian again :)
[23:37:51] shevy: if you wish to abandon the debian way: wget http://production.cf.rubygems.org/rubygems/rubygems-2.4.6.tgz
[23:40:44] tiago: thanks shevy, done
[23:40:50] tiago: it's just a VM anyway
[23:41:27] shevy: you broke out of the debian prison!
[23:41:30] tiago: $ gem --version
[23:41:40] shevy: might still not work something
[23:41:43] shevy: debian uses some weird paths
[23:41:47] tiago: going to try
[23:41:58] shevy: some /var/lib stuff
[23:42:10] shevy: one of the first things I do when I install a debian based machine is
[23:42:11] tiago: still getting the same error >_>
[23:42:12] shevy: remove all of ruby there
[23:42:25] tiago: Exception `OpenSSL::SSL::SSLError' at /usr/lib/ruby/1.9.1/openssl/buffering.rb:174 - read would block
[23:42:33] shevy: that seems another error or?
[23:42:39] shevy: looks as if you also have some problem with openssl
[23:42:41] tiago: now it's https I guess
[23:56:41] rooby: could anyone help me add a `sort_by` to an irc bot that is returning a stream list with viewer number? New to ruby and can't wrap my head around it? At the moment it returns streams along the line of "<Bot> http://www.twitch.tv/streamX (17) http://www.twitch.tv/streamY (29)", I'd like it to list them by the viewer number in ascending or descending order if someone could help?
[23:56:48] rooby: https://gist.github.com/dinkmaster/2ec629ff95c6ae448a4d
[23:58:37] havenwood: rooby: It was a Ruby 1.8 thing that's no longer nice, so drop: require 'rubygems'
[23:59:22] rooby: havenwood: alright