« Back to channel list

#ruby - 25 December 2018

« Back 1 day Forward 1 day »
[00:05:59] donofrio: has joined #ruby
[00:23:48] donofrio: has joined #ruby
[00:24:00] nchambers: has joined #ruby
[00:28:45] donofrio: has joined #ruby
[00:34:48] nowhere_man: has joined #ruby
[00:46:39] sarink: has joined #ruby
[00:51:26] reber: has joined #ruby
[00:57:11] _whitelogger: has joined #ruby
[01:03:20] ellcs: has joined #ruby
[01:03:35] hutch: has joined #ruby
[01:13:17] Azure: has joined #ruby
[01:19:27] tdy: has joined #ruby
[01:22:49] RougeR: has joined #ruby
[01:22:53] Fusl: has joined #ruby
[01:30:42] cschneid: has joined #ruby
[01:33:52] hutch: has joined #ruby
[01:45:13] sarink: has joined #ruby
[02:01:43] AJA4350: has joined #ruby
[02:06:52] hutch: has joined #ruby
[02:12:42] Milos: has joined #ruby
[02:13:39] Swyper: has joined #ruby
[02:14:10] Swyper: https://gist.github.com/RickArora/86ea3cfc8200315812d56df069966fe9
[02:14:39] Swyper: undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b856f8
[02:14:56] Swyper: keep getting this error and I can't see how word is not defined in this context o-o
[02:15:31] Swyper: nvm its this causing the error return translated_word[0..word.length-2]
[02:24:32] roshanavand: has joined #ruby
[02:28:24] Swyper: running "string x1 x2".split.length should return 2, correct?
[02:29:36] havenwood: &>> "string x1 x2".split.length
[02:29:38] rubydoc: # => 3 (https://carc.in/#/r/5uof)
[02:30:01] havenwood: Swyper: Try in irb or pry. A repl is super handy for quickly testing expressions.
[02:30:05] ruby[bot]: irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
[02:30:32] havenwood: Swyper: Just type "irb" on your command line.
[02:30:35] ruby[bot]: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
[02:31:17] Swyper: I'm writing a large block of code and this is so confusing. lol
[02:32:29] Swyper: https://gist.github.com/RickArora/f8f910b6e9d82daf60f76c45eb7249b2
[02:32:35] Swyper: errors + my code
[02:33:34] havenwood: Swyper: Ruby has a nifty way to automatically do that index counter with #each_with_index and #with_index.
[02:33:44] havenwood: Swyper: Better yet, #map.
[02:34:02] Swyper: I know we spoke about this in the morning aswell :P
[02:34:05] roshanavand: has joined #ruby
[02:34:07] havenwood: &>> "string x1 x2".split.each_with_index.to_a
[02:34:10] rubydoc: # => [["string", 0], ["x1", 1], ["x2", 2]] (https://carc.in/#/r/5uog)
[02:34:25] havenwood: Swyper: "string x1 x2".split.each_with_index { |word, index| ... }
[02:34:51] havenwood: Swyper: Consider, for example: "string x1 x2".split.map { |word| word.reverse }
[02:35:16] Swyper: what should I consider about it? :P
[02:35:16] havenwood: &>> "string x1 x2".split.map { |word| word.reverse }.join(' ')
[02:35:17] rubydoc: # => "gnirts 1x 2x" (https://carc.in/#/r/5uoh)
[02:36:04] havenwood: Swyper: It'd work nicely with the logic flow you have.
[02:36:46] havenwood: Swyper: And you can get rid of any assignment during iteration.
[02:37:26] Swyper: other then rewriting the whole thing, is there another way to fix it with what I have atm?
[02:37:47] donofrio: has joined #ruby
[02:39:30] havenwood: Swyper: Yes. The local variable `word` is only assigned inside your `each do |word|` block, so after the block ends that variable is undefined on line 10.
[02:39:43] havenwood: Swyper: The `0..word` part here: https://gist.github.com/RickArora/86ea3cfc8200315812d56df069966fe9#file-rb-L10
[02:40:09] Swyper: ah I fixed that and post an updated gist https://gist.github.com/RickArora/f8f910b6e9d82daf60f76c45eb7249b2
[02:40:22] Swyper: along with the updated errors and uglier logic :P
[02:42:10] havenwood: Swyper: It looks like you have an issue on the last line of your method.
[02:42:57] havenwood: &>> name = 'Swyper'; name[0..name.length.size - 1]
[02:42:58] rubydoc: # => "Swyper" (https://carc.in/#/r/5uoj)
[02:43:19] havenwood: Swyper: See how nothing got cut off ^ above?
[02:43:31] havenwood: Swyper: (Zero index means one less than the size of the thing actually _is_ its last character.
[02:44:01] havenwood: &>> name = 'Swyper'; name[0..-2]
[02:44:02] rubydoc: # => "Swype" (https://carc.in/#/r/5uok)
[02:44:24] havenwood: Swyper: -1 index is the last characer
[02:44:34] havenwood: Swyper: -2 index is the second to last
[02:47:20] havenwood: Swyper: There are a variety of other ways to remove trailing spaces. Here are a few:
[02:47:21] havenwood: &>> 'remove whitespace at the end '.rstrip
[02:47:22] rubydoc: # => "remove whitespace at the end" (https://carc.in/#/r/5uol)
[02:47:38] havenwood: &>> 'remove a space at the end '.chomp(' ')
[02:47:38] rubydoc: # => "remove a space at the end" (https://carc.in/#/r/5uom)
[02:47:48] Swyper: interesting
[02:47:52] Swyper: oh thank you
[02:48:01] havenwood: A nice one in Ruby 2.5 or later is:
[02:48:05] havenwood: &>> 'remove a space at the end '.delete_suffix(' ')
[02:48:05] rubydoc: # => "remove a space at the end" (https://carc.in/#/r/5uon)
[02:48:28] Swyper: what makes that nicer then the other two you showed?
[02:49:19] havenwood: Swyper: If you want to remove all trailing whitespace, #strip is perfect.
[02:50:16] havenwood: Swyper: The #chomp method has some interesting behavior without an argument, and there isn't a prefix version. The nice thing about #delete_prefix and #delete_suffix is they each do a straightforward thing and do it quickly and well with parity.
[02:51:27] havenwood: For trailing whitespace I mean #rstrip, not #strip - typo.
[02:53:34] havenwood: Swyper: Or since you know to remove the last element no matter what, removing by index is fine too!
[02:53:57] havenwood: Swyper: There are many ways to do it in Ruby. :)
[02:54:01] Swyper: Also another question, so I'm making small scale pure ruby written apps anyway for me to deploy them on my site ( not using rails )
[02:55:25] havenwood: Swyper: There are again tons of options. You want to add Ruby to an existing webpage?
[02:55:45] havenwood: Swyper: It's a plain HTML static site?
[02:57:07] elphe: has joined #ruby
[02:57:33] havenwood: Swyper: One way that very few Rubyists ever do is to do cgi, kinda like a PHP site: https://www.mikeperham.com/2015/01/05/cgi-rubys-bare-metal/
[02:58:17] havenwood: Swyper: Most folk use a Rack app in Ruby land. You could direct certain pages to the Rack app. Rails is one of many Rack web frameworks (also called Rack adapters).
[02:58:38] havenwood: Swyper: It's worth trying making a simple Rack app. There's almost nothing to it.
[02:59:00] Swyper: http://www.rickyarora.com/ this is my site with I want to add it in their with some projects since the ones there atm are bad :P
[02:59:19] havenwood: Swyper: On of my favorite Rack frameworks is Roda: http://roda.jeremyevans.net/
[02:59:32] havenwood: Swyper: Rails and Sinatra are the most popular.
[02:59:47] tdy: has joined #ruby
[03:00:28] Swyper: interesting I'll have to look into it for sure, I'm actually going through App Academies online cirriculum and rails is something we will be learning later on and I need to get some projects up this week xD
[03:00:36] havenwood: Swyper: I'd suggest making a Roda or Sinatra app and deploying it somewhere like Heroku to get started.
[03:01:48] havenwood: Swyper: You can make a Rack app with this line:
[03:01:49] havenwood: echo "run -> _ { [200, {'Content-Type' => 'text/plain'}, ['Swyper app']] }" > config.ru
[03:02:18] havenwood: That'll ^ create a file called config.ru that's a very simple Rack app.
[03:02:42] havenwood: Install Rack with: gem install rack
[03:02:44] Swyper: thats so cool, I have a few OOP projects I will be doing coming up and I'll figure out one of those options to host it with
[03:02:46] Swyper: thank you!
[03:02:56] havenwood: Swyper: You can then run that app with: rackup
[03:03:19] havenwood: Swyper: And it'll tell you the address to see it in your browser.
[03:04:15] havenwood: Swyper: Roda just adds a routing tree to Rack, so you can easily route requests for different routes.
[03:04:51] havenwood: Swyper: And then it has plugins to add various commonly needed stuff in a web app called plugins. You cherrypick the plugins you need.
[03:05:19] havenwood: Swyper: These are all the plugins: https://github.com/jeremyevans/roda/tree/master/lib/roda/plugins
[03:05:56] havenwood: Swyper: It's nifty since you start with a dead simple Rack app, with just routing added. Then you compose the exact framework you need by grabbing just the plugins that make sense for your project.
[03:06:29] havenwood: Here's a Hello World app in a ton of different Rack frameworks: https://github.com/luislavena/bench-micro/tree/master/apps
[03:06:32] cruzo66342: has joined #ruby
[03:07:52] havenwood: Most Ruby web stuff is Rack based.
[03:07:56] donofrio: has joined #ruby
[03:08:40] havenwood: There're also popular Ruby tools to generate static sites. You can use sockets directly or cgi or that sorta thing too, but most folk use Rack.
[03:09:53] Swyper: interesting, thank you so much havenwood
[03:10:09] havenwood: Swyper: no prob, you're welcome
[03:11:27] ogres: has joined #ruby
[03:12:02] tdy: has joined #ruby
[03:16:05] clemens3_: has joined #ruby
[03:17:20] kapil____: has joined #ruby
[03:19:44] MasterAsia: has joined #ruby
[03:21:56] themsay: has joined #ruby
[03:22:57] sarink: has joined #ruby
[03:33:38] roshanavand: has joined #ruby
[03:40:17] user374747474: has joined #ruby
[03:40:23] darkhanb: has joined #ruby
[03:40:29] user374747474: having some issues with a layout
[03:43:28] sarink: has joined #ruby
[03:48:10] ur5us: has joined #ruby
[04:00:07] JoshS: has joined #ruby
[04:01:36] hays: has joined #ruby
[04:07:29] roshanavand: has joined #ruby
[04:08:46] braincrash: has joined #ruby
[04:18:15] elphe: has joined #ruby
[04:20:09] hutch: has joined #ruby
[04:39:41] houhoulis: has joined #ruby
[04:39:51] cschneid: has joined #ruby
[04:58:03] darkhanb: has joined #ruby
[05:00:57] cruzo66342: has joined #ruby
[05:09:16] d^sh: has joined #ruby
[05:27:18] cruzo66342: has joined #ruby
[05:31:57] genpaku: has joined #ruby
[05:32:40] cruzo66342: has joined #ruby
[05:40:08] paranoicsan: has joined #ruby
[05:42:14] genpaku: has joined #ruby
[05:44:20] cruzo66342: has joined #ruby
[05:52:46] rippa: has joined #ruby
[06:00:10] elphe: has joined #ruby
[06:15:11] _whitelogger: has joined #ruby
[06:21:34] cthulchu_: has joined #ruby
[06:24:29] cthu|: has joined #ruby
[06:56:38] sarink: has joined #ruby
[06:56:51] hutch: has joined #ruby
[07:10:40] ua: has joined #ruby
[07:13:20] elphe: has joined #ruby
[07:23:26] jshjsh: has joined #ruby
[07:31:01] gix: has joined #ruby
[07:32:02] tiff: has joined #ruby
[07:36:28] za1b1tsu: has joined #ruby
[07:38:35] tiff: has joined #ruby
[07:47:52] nowhere_man: has joined #ruby
[07:53:27] kapil____: has joined #ruby
[08:05:46] themsay: has joined #ruby
[08:08:18] themsay: has joined #ruby
[08:09:45] elphe: has joined #ruby
[08:22:40] elphe: has joined #ruby
[08:33:15] reber: has joined #ruby
[08:52:35] mikecmpbll: has joined #ruby
[08:53:00] phaul: has joined #ruby
[08:59:49] tdy: has joined #ruby
[09:03:58] themsay: has joined #ruby
[09:13:53] xco: has joined #ruby
[09:14:29] xco: hi i have a file with lots of lines. what i want to do is replace some text in the file (sort of edit it) this is what i have, not working and i need help https://gist.github.com/xcobar/400989355ae2e5b0068d0b0561c9f6c6
[09:31:42] roshanavand: has joined #ruby
[09:49:23] tiff: has joined #ruby
[09:51:46] conta: has joined #ruby
[09:52:23] paranoicsan: has joined #ruby
[10:10:10] sarink: has joined #ruby
[10:36:45] ellcs: has joined #ruby
[10:37:04] zapata: has joined #ruby
[10:51:27] clemens3_: has joined #ruby
[11:04:17] elphe: has joined #ruby
[11:30:36] elphe: has joined #ruby
[11:35:29] ellcs: has joined #ruby
[11:37:48] xco: has left #ruby: ()
[11:43:13] venmx: has joined #ruby
[11:43:48] lxsameer: has joined #ruby
[12:02:12] sarink: has joined #ruby
[12:07:42] Mike11: has joined #ruby
[12:18:19] elphe: has joined #ruby
[12:19:25] Guest49234: has joined #ruby
[12:30:39] elphe: has joined #ruby
[12:34:33] Nobun: has joined #ruby
[12:35:09] Nobun: hi. Any hint how to use rvm? I can't find a clear example how to use sandboxed ruby/gem installed with rvm instead of system one
[12:36:37] Nobun: I know that I should use /etc/profile.d or ~/.bashrc but it not clear how should I change it
[12:38:23] Guest49234: has joined #ruby
[12:52:37] donofrio: has joined #ruby
[13:10:02] alxd: has joined #ruby
[13:30:35] sarink: has joined #ruby
[13:49:59] Xiti: has joined #ruby
[13:56:55] AJA4350: has joined #ruby
[14:01:06] JoshS: has joined #ruby
[14:07:48] jshjsh: has joined #ruby
[14:14:21] conta: has joined #ruby
[14:39:48] elphe: has joined #ruby
[15:01:18] jottr: has joined #ruby
[15:11:02] nchambers: has joined #ruby
[15:15:39] nchambers: havenwood: that infinite range operator article is cool. i can
[15:15:54] nchambers: 't help but think of haskell's lazy evaluation while im doing it
[15:21:51] ChanServ: +o havenwood
[15:22:16] ChanServ: -o havenwood
[15:25:39] havenwood: https://www.ruby-lang.org/en/news/2018/12/25/ruby-2-6-0-released/
[15:46:34] MasterAsia: has joined #ruby
[16:01:05] yokel: has joined #ruby
[16:01:51] dinfuehr: has joined #ruby
[16:19:14] themsay: has joined #ruby
[16:39:32] themsay: has joined #ruby
[16:47:13] cruzo66342: has joined #ruby
[17:17:45] ua: has joined #ruby
[17:27:58] Doow: has joined #ruby
[17:30:16] hutch: has joined #ruby
[17:38:13] marvin2: has joined #ruby
[17:45:13] roshanavand: has joined #ruby
[17:45:57] Nicmavr: has joined #ruby
[17:47:10] darix: opensuse package is done too
[17:48:05] leah2: darix: are you going to 35c3 btw?
[17:48:34] darix: leah2: no plans for that atm
[17:48:40] darix: but a few of my coworkers are there
[17:52:01] elphe: has joined #ruby
[18:04:10] phaul: has joined #ruby
[18:11:14] tdy: has joined #ruby
[18:15:00] spacesuitdiver: has joined #ruby
[18:16:27] themsay: has joined #ruby
[18:23:40] m0w: has joined #ruby
[18:23:59] Exuma: has joined #ruby
[18:30:51] catbusters: has joined #ruby
[18:31:02] spacesuitdiver: has joined #ruby
[18:37:46] elphe: has joined #ruby
[18:46:06] ellcs: has joined #ruby
[18:54:16] elphe: has joined #ruby
[18:55:04] Swyper: has joined #ruby
[18:55:08] Swyper: https://gist.github.com/RickArora/d7b582815ba6d8170061533ecc692f69
[18:57:12] Swyper: bundler: failed to load command: rspec (/Users/Rtyer/.rbenv/versions/2.5.1/bin/rspec) SyntaxError: /Users/Rtyer/Downloads/appacademy-online-intro_debugging-b9135fa1427b 2/lib/exercises.rb:56: syntax error, unexpected keyword_end, expecting ')' end ^~~
[18:57:19] claudiuinberlin: has joined #ruby
[18:57:21] Swyper: this is the error I am getting and need some help w/it
[18:58:52] phaul: it means that there is a syntax error in that file at or around line 56.
[18:59:01] phaul: Can you paste that file?
[19:00:14] Swyper: https://gist.github.com/RickArora/fed3164ec37936395d882c02885ae53b
[19:00:17] Swyper: here you go
[19:01:19] phaul: on line 52 you open (s but only close one
[19:01:42] phaul: I meant two (s, but only close one
[19:07:07] phaul: (stick an other close paren before the .each)
[19:07:19] conta: has joined #ruby
[19:08:17] Swyper: undefined local variable or method `length' for #<RSpec::ExampleGroups::SymmetricSubstrings:0x00007fbcb5a0e9b0>
[19:08:28] Swyper: isent length supposed to be a built in method for string
[19:08:53] nchambers: has joined #ruby
[19:09:07] Swyper: def symmetric_substrings(str) symm_subs = "" # initialize a blank string str.length.times do |start_pos| # .length is the length of string starting at 1,this loop is executing based on the amount of the string length
[19:09:18] Swyper: the .length there is causing the error
[19:10:25] phaul: length is indeed an instance method of strings.
[19:10:39] phaul: &>> "Swyper".length
[19:10:42] rubydoc: # => 6 (https://carc.in/#/r/5uqk)
[19:11:40] phaul: but #<RSpec::ExampleGroups::SymmetricSubstrings:0x00007fbcb5a0e9b0> is not a string. We would need to see the rpsec files, to see what those are and why they are causing errors
[19:12:13] Swyper: https://gist.github.com/RickArora/fed3164ec37936395d882c02885ae53b
[19:12:23] Swyper: I've updated the gist with the RSpec files
[19:12:35] Swyper: symmetric_substrings(str) is the method with the error
[19:13:16] hutch: has joined #ruby
[19:15:50] elphe: has joined #ruby
[19:15:52] donofrio: has joined #ruby
[19:17:12] phaul: yeah I'm looking.
[19:17:16] Swyper: (2..(length - start_pos).each do |len| the problems here, length is not defined xD
[19:17:47] phaul: yep. makes sense
[19:26:57] TvL2386: has joined #ruby
[19:30:10] Swyper: what does << do in Ruby? google is not showing any results and typing what does greater then greater then do in ruby gives me nothing relevant :p
[19:32:35] gix: has joined #ruby
[19:40:02] Guest49234: has joined #ruby
[19:40:08] phaul: it's just an operator like many others. that means that for some type there is a method with the name << that defines some type specific behaviour
[19:40:31] phaul: usually it appends an elem at the end of a collection
[19:40:41] phaul: &ri Array.<<
[19:40:41] rubydoc: Found no entry that matches class Array class method <<
[19:40:52] phaul: &ri Array#<<
[19:40:53] rubydoc: https://ruby-doc.org/core-2.5.3/Array.html#method-i-3C-3C
[19:41:41] phaul: &ri String#<<
[19:41:41] rubydoc: https://ruby-doc.org/core-2.5.3/String.html#method-i-3C-3C
[19:41:58] phaul: and there are others
[19:42:04] rubydoc: Array#<<, IO#<<, Integer#<<, Queue#<<, SizedQueue#<<, String#<<, CSV#<<, CSV::Row#<<, CSV::Table#<<, Date#<<, IPAddr#<<, Logger#<<, OpenSSL::BN#<<,...
[19:50:41] tdy: has joined #ruby
[19:56:04] armyriad: has joined #ruby
[19:58:49] rubydoc: has joined #ruby
[19:59:18] phaul: has joined #ruby
[20:25:40] Fusl: has joined #ruby
[20:33:23] elphe: has joined #ruby
[20:44:56] darkhanb: has joined #ruby
[20:46:57] tdy: has joined #ruby
[20:59:25] spacesuitdiver: has joined #ruby
[21:01:25] nchambers: has joined #ruby
[21:02:33] cschneid: has joined #ruby
[21:34:15] ellcs: has joined #ruby
[21:43:19] prestorium: has joined #ruby
[21:46:27] cthulchu_: has joined #ruby
[21:52:06] kapil____: has joined #ruby
[22:15:04] TheBloke: has joined #ruby
[22:16:07] code_zombie: has joined #ruby
[22:18:44] spacesuitdiver: has joined #ruby
[22:19:02] cd: has joined #ruby
[22:26:44] sgen: has joined #ruby
[22:27:44] spacesuitdiver: has joined #ruby
[22:29:45] donofrio: has joined #ruby
[22:32:06] shv4: has joined #ruby
[22:33:39] shv4: has joined #ruby
[22:40:36] nowhere_man: has joined #ruby
[22:51:50] ixti: has joined #ruby
[22:52:06] spacesuitdiver: has joined #ruby
[22:53:36] donofrio: has joined #ruby
[22:56:26] englosh: has joined #ruby
[22:56:47] englosh: Hello. Does anyone here know how Ruby does the fiber context switch?
[22:57:24] shv4: has joined #ruby
[22:59:25] englosh: Does Ruby do it in assembly? If yes, is this the source? https://github.com/ruby/ruby/tree/trunk/coroutine/win32
[23:30:18] CrazyEddy: has joined #ruby
[23:37:06] tiff: has joined #ruby
[23:42:33] desperek: has joined #ruby
[23:48:36] tdy: has joined #ruby