#ruby - 27 June 2016
« Back 1 day Forward 1 day »
[06:12:09] ruby[bot]: Neobenedict: we in #ruby do not like pastebin.com, I reposted your paste to gist for you: https://gist.github.com/4b8f096415720afe2808ea6fa9069521
[06:12:09] ruby[bot]: Neobenedict: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
[06:13:06] ruby[bot]: Neobenedict: Ubuntu installation guide for Ruby + Rails: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/
[06:20:35] No: I try to use Curses for Ruby http://ruby-doc.org/stdlib-2.0.0/libdoc/curses/rdoc/Curses.html , but I have some error message by applying the first example
[06:22:00] No: My error message is /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- curses (LoadError)
[06:25:54] No: I have tried to install the gem Curses (gem install Curses) but I have the following message : Fetching: curses-1.0.2.gem (100%)
[06:26:00] No: Gem files will remain installed in /var/lib/gems/2.2.0/gems/curses-1.0.2 for inspection.
[06:26:02] No: Results logged to /var/lib/gems/2.2.0/extensions/x86_64-linux/2.2.0/curses-1.0.2/gem_make.out
[06:28:00] Radar: No: So it failed to install Curses and that's why it can't be found when you do a require.
[06:28:03] Radar: [16:25:57] <No> mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
[06:29:03] ruby[bot]: No: Ubuntu installation guide for Ruby + Rails: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/
[06:29:29] Radar: No: That will install the Ruby headers that apt-get didn't AND ti will mean that you don't need to run `sudo gem install` to install gems.
[06:31:46] Neobenedict: gem install now seems to have frozen on Installing ri documentation for sinatra-1.4.7
[06:48:02] Radar: Is there a way to see what the full URL that a Net::HTTP::Get is going to make when you do http.request(request)?
[06:51:56] No: Radar: I think I have found the problem origin. I'm using Ruby v2.2.4 and Curves seems not be included with this version (http://ruby-doc.org/stdlib-2.2.4/) but only with the v2.0.0 (http://ruby-doc.org/stdlib-2.0.0/)
[06:56:21] crazycoder: i am not a ruby dev but i would like to give it a try. at the moment i know php, where can i find a good article to compare php vs ruby?
[07:07:52] c_nick: crazycoder: https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-php/
[07:11:36] Radar: Neobenedict: now that you've installed it following that guide, you don't need to use sudo.
[07:15:31] Radar: If you said that you wanted it available for all users initially, then you would've gotten different advice.
[07:16:33] crazycoder: c_nick, it does not say too much... is ruby running on different webservers? does it run under nginx ?
[07:17:00] dminuoso: Neobenedict: It could be as simple as rm -rf ~/.where/ever/your/ruby/went/ruby-2.3.1
[07:17:34] dminuoso: Neobenedict: local rubies are placed into ~/.rubies by default, system wide in /usr/local
[07:18:26] Neobenedict: [08:12:10] <Radar> ruby-install --system ruby 2.3.0 <- this should have been run as root, shouldn;'t it
[07:18:54] Radar: Neobenedict: ^ note what I said in that line, and how it does not mention "run this command as root" or anything like it at all.
[07:20:34] Neobenedict: /home/neo/src/ruby-2.3.0/lib/fileutils.rb:1393:in `initialize': Permission denied @ rb_sysopen - /usr/local/bin/ruby (Errno::EACCES)
[07:22:11] Neobenedict: do I need to run the full ruby-install again? or can it use all the things it already compiled?
[07:22:16] dminuoso: Neobenedict: Add your user to the group staff, and it should be accessible then.
[07:22:38] c_nick: crazycoder: Ruby can be used for Web Server, it can be used on nginx. Could you brief me your actual requirements ? is it that you want to try ruby on the Web? ideonline or some other online version? Do you want to create a web server using ruby? then Ruby on Rails or Sinatra. Do you want to learn Ruby as a programming language? you can use the docs I pointed to (not just the PHP part) What is it that we want here?
[07:24:12] Neobenedict: [08:22:10] <Neobenedict> do I need to run the full ruby-install again? or can it use all the things it already compiled?
[07:24:26] crazycoder: c_nick, yes i do 99% of times web applications. At the moment i am using PHP with CakePHP framework. It works good, but i heard Ruby is asked from companies.. so maybe it's the time to look at it
[07:25:03] dminuoso: Neobenedict: Just run it again, I'm really not sure since I have never been in this situation.
[07:26:24] crazycoder: c_nick, i do not what to create a web server...i want to create web app ( i use mariadb )
[07:26:49] dminuoso: crazycoder: In Ruby we have 2 common web frameworks, Sinatra and Ruby on Rails.
[07:28:02] dminuoso: crazycoder: Both have very different approaches and goals, so I recommend you look at them both.
[07:29:45] crazycoder: lasti things...i also heard that ruby is not very fast, it is interpreted so ...obvious. But, is there a tool to "compile it" or running it faster
[07:30:46] dminuoso: crazycoder: No. But if you are asking these questions, chances are your website is not going to be used by millions of people per day anyway, so performance really shouldn't be a factor.
[07:32:52] crazycoder: dminuoso, this is the time to look forward and leave php that has many stupid things...so the choice is between python and ruby
[07:33:07] c_nick: crazycoder: The web application framework handles many of such. So performance should not be like what you say "Slow"
[07:34:35] c_nick: crazycoder: For python try Flask or Bottle (equivalent to Sinatra) and Django (equivalent to Rails)
[07:35:41] dminuoso: crazycoder: Pick the language based on its facilities and style, not on whether "its faster than A or B"
[07:35:56] dminuoso: crazycoder: If you find that Python suits you better, then go for it - I won't stop you.
[07:35:57] crazycoder: c_nick, the problem is that i do not understand what companies is asking for..i mean...python seems to be sued widely, ruby too ?
[07:36:56] dminuoso: crazycoder: Python is more popular, but it also means you have more competition in jobs.
[07:40:36] c_nick: I have worked in C C++ Objctive C Java Python Ruby C# AIML -> Shouldn't really matter as a Developer. Its just the syntax and a little bit of time thats all!
[07:42:18] crazycoder: c_nick, yes. the dminuoso's answer is correct for job purpose....more competition less available jobs :)
[07:44:37] c_nick: crazycoder: Niche Market less available jobs :) Python Ruby are nearly similar so you should not have a tough time working on both.
[07:47:41] c_nick: most of the organizations have stupid people at the highest positions, they dont understand technology and often relate it to "can this do that?" And then comes a Developer who replies "Ofcourse it can! and it will do this in addition too at the same investment" and everybody is happy when he moves out of the company people say "Let it do what it is doing". So you will have the choice of the language ;) or manipulate your preference wherever required
[07:50:43] CausaMortis-Work: imperator, thanks for the help. Had to run yesterday but you cleared up a few things that gave me a better understanding of rbenv. greatly appreciated
[07:54:42] dminuoso: c_nick: That is not stupidity. It is a very legit question for a manager to ask "whether technology A can solve problem B".
[07:55:27] crazycoder: i am asking wrong questions too :D if i ask what language is better in #ruby and #python i can image the answers :D
[07:56:27] dminuoso: crazycoder: The only recommendation I can give you is to try them out and pick whichever feels better to you.
[07:57:42] crazycoder: dminuoso, :) the problem is the learning curve..i mean... i start today with ruby then i need to start with python too... so i can not answer that questionfor the next months
[07:59:59] crazycoder: dminuoso, i mean.. do you know java? if you know it it is "correct" to see other languages?
[08:02:35] crazycoder: dminuoso, not specific. the thing is: i would like to create web app... i know there are php, java, ruby, python etc etc etc... what companies are asking this "period" ? and...if i already know java is it stupid to look at other languages? (because with java we can do anything)
[08:04:56] crazycoder: dminuoso, yes also for assembly there is a market...just to understand how big is this market :D
[08:06:19] dminuoso: crazycoder: Surely there must be websites that allow to search the internet to find other websites that have completely biased statistics and pretty diagrams.
[08:07:29] dminuoso: That way you have a much better market value than someone who tries to pick a language because he thinks there is a high demand.
[08:07:40] c_nick: dminuoso: technology can help a project or program manager in a HUGH way which they often miss out. Ruby and Python can both solve a problem but then which is the preferred way to go about it?
[08:08:14] dminuoso: c_nick: It is necessarily not their job to be familiar with the technology. That is why communication skill are so important in jobs.
[08:09:34] sandelius: if I have Foo::Bar and do Object.send(:remove_const, :Foo) will bar also be removed or does it live in limbo somewhere?
[08:10:04] dminuoso: sandelius: Perhaps, it depends on whether there are still references. If not the GC will at some point clean it up.
[08:10:34] sandelius: dminuoso it's in some tests, I get unexpected results and that might be the cause of it
[08:11:05] crazycoder: ahahah some other crazy person did the same search http://webapps.stackexchange.com/questions/74557/how-to-search-for-python-the-programming-language-on-google-trends :D
[08:11:10] sandelius: dminuoso I get unexpected results sometimes. if I redefine the same modules again after removed.
[08:11:41] dminuoso: sandelius: Please gist some code. Unless you manually fiddle around with ObjectSpace and object IDs it should not be possible to have side effects such as you think.
[08:11:49] c_nick: crazycoder: I recommend you search on Official Wikis for Python and Ruby. All your questions should get answered.
[08:12:13] c_nick: The documentation is quite verbose. I mean literally you can grow old reading all that stuff!
[08:12:36] Developer001: Where would be the best place to learn about things like what "middleware" "presenters" "endpoints" "helpers" are, and how to organise code around these sorts of paradigms
[08:12:48] ruby[bot]: Developer001: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[08:13:50] dminuoso: Developer001: Middleware is a pretty generic term whose meaning depends on the context. It's generally "a layer between 2 things"
[08:14:20] sandelius: Developer001 here's a good article about middleware https://www.amberbit.com/blog/2011/07/13/introduction-to-rack-middleware/
[08:16:05] c_nick: dminuoso: A non technical project manager would only undertand in terms of resource and time lines and budget but they entirely depend on their resources for the choice of technology or legacy - what is being used for generations. There is not much scope for innovation or doing something different
[08:16:40] Developer001: My day job consists of writing C/C++ code that nobody besides myself will ever see or use, so I've never been exposed to much of the developer world
[08:17:09] dminuoso: c_nick: Exactly. Which is why at some point someone with a technical background will be at the table. And it is his job to use his communication skills to show why his technology is great.
[08:18:00] Developer001: Now I'm using a Grape API boilerplate to serve a RESTful API and Webserver to multiple end users.... and I have no idea what I'm doing, nor is someone with a technical background other than myself comming to save me XD
[08:18:07] dminuoso: c_nick: You cannot expect everybody until the CEO of your company to have a full technical background, so at some point someone with a technical background needs to convince someone else without that background.
[08:19:47] dminuoso: c_nick: These kinds of barriers exist everywhere within the hierarchy of a company, which is why communication skills are more important than technical expertise if you want to convince someone.
[08:20:09] dminuoso: c_nick: That by the way is also why sometimes really bad decisions are made, because people with great communication skills but shitty technical skills get to convince someone.
[08:20:39] dminuoso: So if you want to convince someone, it does not matter how good you are - just how well you can communicate.
[08:21:42] Developer001: dminuoso: I may not be involved in your discussion, but as the Managing Partner of a 15 person company - I'll kick in this, I'm a technical person (More or less. Computational Physics background), and the *only* technical person, and I one of two "CEO equivalents". This is a much worse situation. I had to convince the marketing department why a shorter domain name is better.
[08:23:25] c_nick: dminuoso: From the point of the Project Manager if I buy in to whatever my subordinates tell me without having a failr idea and just accepting their facts than I am not a good Project Manager
[08:23:55] dminuoso: c_nick: Which is why your subordinates need great communication skills to give you that idea.
[08:28:36] Developer001: If you have some spare time, a book really would be helpful. Preferably one available as an ebook
[08:29:09] dminuoso: Developer001: I would actually try #rubyonrails - your questions are fairly web development specific. :)
[08:30:13] Developer001: I just hope I don't get caught in "#ruby says go to rails, rails says go to rubt=y"
[08:30:41] Developer001: ... stupid nvidia drivers. Screen refresh rate is like 10Hz, it makes backspacing a gamble.
[08:31:03] amincd: Hi can someone explain to me why the loop scrambles the characters and doesn't output all of them? https://gist.github.com/anonymous/e1ba58da452220fa7411a49f5d3233e3
[08:34:53] Mon_Ouie: amincd: each_char already iterates over the file. When you call getbyte inside the loop, that means you skip one byte.
[08:57:16] siaw23: goor morning. i’m reading some ruby code that looks like this “(current_user.id rescue 0)”
[08:58:43] Mon_Ouie: If an exception (that is an instance of StandardException or one of its subclasses) is thrown by evaluating current_user.id, the exception is rescued and 0 is the result of the whole expression.
[08:58:54] j416: siaw23: it means, if the code before it raises an error, silence it and return 0 instead. Mostly a dumb way to do it.
[09:01:02] j416: siaw23: why dumb? Because you are ignoring the error ans assuming all is fine. In rare cases this is fine, but in most cases you can do away with it by checking elswhere that e.g. the user is valid
[09:09:33] Hanmac: siaw23: in most cases i think it its there to not do a nil? check ... because if current_user is nil then nil.id does raise a NoMethodError ... in newest ruby this would work "current_user&.id || 0"
[09:29:48] No: Radar: That's OK now for installing curses. In my case, I forgot to install ruby2.2-dev and build-essential packages
[10:10:34] kees01: Could someone help me how I can get this working? https://github.com/ruby-ldap/ruby-net-ldap/issues/275
[10:23:38] Neon: I've problems running gem and I don't know how to fix them. See https://gist.github.com/Neosublimation/5770b259cf3f04caa2cc6ad4978953f9. That output comes for each gem command.
[10:24:29] caino: hi there, i'm new to ruby... I need to start an installed ruby gem with crontab but it doesn't start... i was searching online but didn't find a real solution about this issue.... do you have any hint ?
[10:35:03] dminuoso: caino: Start with an accurate description (gists are helpful) of what you did, what you expected to happen, and what happened instead.
[10:35:47] dminuoso: Neobenedict: My instinct says that you are running mixed Ruby versions and screwed up somewhere.
[10:38:49] caino: i've installed a gem file and it's ok, then I want to run this gem periodically so i added to crontab the line 00 09 * * * /usr/bin/myexecutablegem (yes, the path is correct) but it doesn't start
[10:42:03] dminuoso: caino: Let's ignore that /usr/bin is reserved for system files (use /usr/local/ if you have custom things on your system). cron by default logs to /var/log/syslog
[10:44:16] dminuoso: caino: Also, you are using a user crontab and not running your ruby code under root, right? :-)
[10:47:11] toretore: caino: the gem "executable" isn't an executable, it's a script that must be fed to ruby, which is the executable
[11:07:24] kareeoleez: guys is there any way to work with a gem when also working with Rails? I am editing them separately but I need to push changes to gem repository and then bundle update my rails project which both take a lot of time to complete.
[11:10:42] kareeoleez: so If I change a parameter I must git add/commit/push in the gem's folder and then go to Rails -> bundle update
[11:11:05] kareeoleez: it's a long and time consuming process IF you want to test your development environment and stuff
[11:23:49] dminuoso: kareeoleez: I would say they are too tightly coupled if you are using rails to test your gem.
[11:46:08] jhass: well I guess my actual interest is running valgrind on a c ext only, but within the context of a regular program
[13:57:27] Neon: Hello, I wrote a Ruby-related question on SuperUser (StackExchange) and I already got an answer, but I'm struggling with understanding it. What's the extconf.rb and how am I supposed to be using it? Please have a look at the thread here: http://superuser.com/questions/1093954/gem-not-working-in-cygwin
[14:06:11] shevy: should this not work automatically when you install ruby via the one click installer thingy?
[14:07:58] shevy: been a long time since I was on windows, probably last time ... in 2011 or so. I remember back then that "gem" was working out of the box; I have not used cygwin though, perhaps some setup is wrong there. As far as I remember, you did not need cygwin in order to have ruby work on windows
[14:10:06] Neon: shevy: Yes, as a workaround I'm using the native Ruby and that works well. However, I experienced problems when using the native Ruby from cygwin. it appears to prefer its own Ruby version.
[14:11:20] pontiki: part of the issue is that you want to use cygwin, and rubyinstaller uses mingw. you've just comingled two different package managers, neither of which is native to windows
[14:12:25] pontiki: so you have to tell cygwin to use the alternate paths, which is what his answer is telling you to do
[14:13:27] Neon: Someone from Cygwin appears to have successfully reproduced it and it appears to be a Cygwin-related bug (from version 2.5.2 on). https://cygwin.com/ml/cygwin/2016-06/msg00378.html So probably nothing to do for you guys. Thank you anyway.
[14:36:02] UnKnOwN|: I'm a newb to ruby programming but If i could offer something/anything, I'd say maybe that 'nil' statment isnt need
[14:36:54] UnKnOwN|: could just not see the logic or reasonsing for it there... couldnt whitespace or ';' do same?
[14:39:13] UnKnOwN|: I recently had a similiar statement and the nil ended up giving problems, but indeed good job, and listen is someone else option on the nil (like I said i'ma newb to ruby)
[14:41:07] Wildfyr: i didn't bother with it, because the only exception occured when a user invoked the bot without any previous msgs
[14:46:11] Wildfyr: i could have used an existing frame-work, but for such a small project using it would have been overkill
[14:46:39] pontiki: it's not only okay to reinvent the wheel for learning, it's pretty damned necessary
[15:21:47] shevy: anyone may happen to have an already working example using readline, to highlight the given input if it matches something?
[15:22:06] shevy: for instance... if the user types "foo" it should be green colour... but if he writes "foobar" it should be in red colour
[17:25:47] wrkrcoop: https://gist.github.com/ellismarte/da974bf1d94406bd6204077ef85959db#file-gistfile1-txt-L3-L4
[17:39:18] jhass: if you just want to iterate, 1.upto(100) do |i| or perhaps even 100.times.do |i| (0-based though)
[17:54:48] kareeoleez: I Am trying to start Puma with a very simple website in a RPI and it takes ages. Is it normal ? HAs anyone tried installing Rails in a RPI ?
[17:59:37] elomatreb: kareeoleez: Rails might be a little much for a RPi I'd say, even on my quite powerful desktop rails server takes a few seconds to start
[18:04:29] Nilium: I feel like game scripting'd be more fluid with mruby than Lua, but it's also kind of hard to beat Lua and LuaJIT's performance
[18:05:24] jhass: I guess what I most dislike about lua is that they conflate map and list into a single ADT, too
[18:06:04] Nilium: I don't have too much of a problem with it. It's weird, but under the hood array-like tables and map-like tables are pretty distinct.
[18:11:17] wrkrcoop: how come this doesn’t work https://gist.github.com/ellismarte/6f0ce0c37c96fc97c11ab9822e421326#file-gistfile1-txt-L5
[18:13:34] baweaver: that and ruby methods don't work as first class functions per-se, lambdas do though.
[18:15:08] ruby[bot]: baweaver: I'm terribly sorry, I could not evaluate your code because of an error: Net::OpenTimeout:execution expired
[18:16:10] ruby[bot]: baweaver: I'm terribly sorry, I could not evaluate your code because of an error: Net::OpenTimeout:execution expired
[18:17:24] wrkrcoop: so proc calls a method on an object … got it but lambda is a block that takes an argument?
[18:17:28] baweaver: I'm still of the opinion that ruby being paren-free is a bad idea, because it prevents passing methods as functions cleanly.
[18:26:02] Developer001: I have included the twitter gem. The app runs locally, I didn't add any extra code, then I deploy to heroku, and heroku can't build it
[18:26:12] hxegon: baweaver: hold on, let me just try your code to make sure it does what I think it does
[18:54:00] dannyh: i have an array of hashes, each has has a single key and value, im trying to check and see what the uniq values are for those values
[18:54:10] dannyh: i can do it with a bunch of lines of code, was trying to see if there was a clean, simple way to do it
[19:57:22] memorasus: Hey I'm trying to convert a metasploit exploit from ruby to python but I'm having a difficult time understanding a particular part, can someone help me out?
[19:59:43] havenwood: memorasus: Share a Gist? You might have better luck in the #metasploit channel.
[20:00:36] memorasus: Here is the actual exploit https://www.exploit-db.com/exploits/16393/, I'm having a hard time understanding how the buffer works so I can rewrite it in python. I don't get what the buf[101, 6] stuff means
[20:01:32] memorasus: thanks for the suggestion, i'll try there too... I didn't know if this was more of a ruby question or metasploit specific
[20:06:23] memorasus: havenwood: so is buf[101, 6] appending 6 nops to the buffer at the offset of 101?
[20:10:17] memorasus: thanks, definitely helped, now i that i understand the login behind it...just need to figure out how to craft it lol
[20:43:17] bratchley: I know I can check after the fact and loop back but I was wanting to get it to where it refuses to accept non-integers
[21:18:18] hxegon: could you be more specific? what libraries have you tried, what are you doing specifically, etc
[21:21:10] chadwtaylor: We can do a setter method like so: "def add_language=(language) ... end" but I was wonder how to do something like this: "def languages<<(language) ... end" (I know this is illegal but wanted to illustrate an example)
[21:21:45] aegis3121: chadwtaylor I would...imagine you can just do def <<(language); languages << language; languages; end
[21:23:48] adaedra: chadwtaylor: you could define @languages =  then attr_reader :languages, which would allow to do object.languages << ...
[21:26:13] havenwood: hastur: ActionCable has some nice fallbacks but it's still rc2. Roda's websockets are a wrapper around faye-websocket at the moment: https://github.com/jeremyevans/roda/blob/master/lib/roda/plugins/websockets.rb
[21:28:43] havenwood: hastur: I think the Ruby community didn't embrace Websockets as fast as some others. There was waffling over whether Event-Stream or something else might win.
[22:13:05] diegoviola: how could I improve over this minitest spec: https://gist.github.com/diegoviola/f6906c40ee82319a64b2ace27bb43d4e
[23:29:45] CSGSJay: Looking to hire a full time developer, experience in "API, JS, PHP, MYSQL, PDO", query me right now if you're interested in a once in a lifetime opportunity