« Back to channel list

#ruby - 04 March 2018

« Back 1 day Forward 1 day »
[00:03:01] dmitriy_: has joined #ruby
[00:07:34] tAn: has joined #ruby
[00:20:29] arkymad: has joined #ruby
[00:33:44] d^sh: has joined #ruby
[00:37:33] jenrzzz: has joined #ruby
[00:37:33] jenrzzz: has joined #ruby
[00:43:00] hahuang61: has joined #ruby
[00:44:32] Papierkorb: has joined #ruby
[00:49:14] johnny56: has joined #ruby
[00:53:58] workmad3: has joined #ruby
[01:08:54] ResidentBiscuit: has joined #ruby
[01:09:58] PresidentBiscuit: has joined #ruby
[01:12:26] JaredR: has joined #ruby
[01:14:24] hahuang61: has joined #ruby
[01:21:48] tAn: has joined #ruby
[01:22:53] jenrzzz: has joined #ruby
[01:22:54] jenrzzz: has joined #ruby
[01:25:12] jnyw: has joined #ruby
[01:25:31] konsolebox: has joined #ruby
[01:31:54] karapetyan: has joined #ruby
[01:32:32] konsolebox: has joined #ruby
[01:34:11] apparition: has joined #ruby
[01:38:13] upinspace__: has joined #ruby
[01:41:57] arescorpio: has joined #ruby
[01:43:56] dviola: has joined #ruby
[01:44:47] upinspace__: has joined #ruby
[01:50:59] s3nd1v0g1us: has joined #ruby
[01:56:59] Puffball: has joined #ruby
[01:57:05] konsolebox: has joined #ruby
[02:07:25] pastorinni: has joined #ruby
[02:12:31] tAn: has joined #ruby
[02:17:11] ruby[bot]: -bbbb chouhoulis!*@*$#ruby-fix-your-connection chouhoul_!*@*$#ruby-fix-your-connection chouhou__!*@*$#ruby-fix-your-connection chouho___!*@*$#ruby-fix-your-connection
[02:17:13] ruby[bot]: -bbb chouh____!*@*$#ruby-fix-your-connection chou_____!*@*$#ruby-fix-your-connection *!*@50-207-64-46-static.hfc.comcastbusiness.net$#ruby-fix-your-connection
[02:18:35] goatish: has joined #ruby
[02:21:31] shinnya: has joined #ruby
[02:24:58] bauruine: has joined #ruby
[02:29:12] konsolebox: has joined #ruby
[02:34:22] dinfuehr: has joined #ruby
[02:35:34] cthulchu: has joined #ruby
[02:37:38] konsolebox: has joined #ruby
[02:43:32] hahuang61: has joined #ruby
[02:49:37] Haris: has joined #ruby
[02:49:39] Haris: hello all
[02:49:50] Haris: ruby is installing gems on centos 7. Its expecting pgsql's include files somewhere under /usr/include. pgsql put them in /usr/pgsql-9.4/include. How do I reconcile this ? I tried softlinking a single file. but then it wants to search for more files
[02:50:03] Haris: %s/put/pts/
[02:50:08] Haris: %s/put/puts/
[02:50:27] tAn: has joined #ruby
[02:51:50] havenwood: Haris: Try?: gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
[02:52:02] Haris: I'm running bundle install
[02:52:10] Haris: let me see
[02:52:19] havenwood: Haris: Is the postgresql-devel package installed?
[02:52:41] Haris: not the default for platform i.e., 9.2 from centos updates
[02:52:47] Haris: 9.4 from pg's yum repo
[02:53:42] Haris: something needs to be standardized about these paths
[02:54:22] Haris: can I just mention the includes with a switch/param rather than the whole config ?
[02:54:52] Haris: ERROR: While executing gem ... (OptionParser::InvalidOption)
[02:54:53] Haris: invalid option: --with-pg-config=/usr/pgsql-9.4/bin/pg_config
[02:55:56] havenwood: Haris: Did you add the `--` in front of `-- --with-pg-config=...`?
[02:56:07] Papierkorb: has left #ruby: ("Konversation terminated!")
[02:56:45] Haris: my bad. done now
[02:56:46] gizmore|2: has joined #ruby
[02:57:03] Haris: I thought -- pointed to current working dir
[02:57:35] elcontrastador: has joined #ruby
[03:00:09] cadillac_: has joined #ruby
[03:03:59] konsolebox: has joined #ruby
[03:05:46] armyriad: has joined #ruby
[03:15:14] zenspider: Haris: usually a plain "--" means "stop processing options"... lets the rest of the cmdline get passed down to someone else to handle
[03:15:28] aguestuser: has joined #ruby
[03:19:17] govg: has joined #ruby
[03:22:03] konsolebox: has joined #ruby
[03:28:42] konsolebox: has joined #ruby
[03:29:29] StarSeed0000: has joined #ruby
[03:35:11] hahuang61: has joined #ruby
[03:45:54] Puffball: has joined #ruby
[03:46:35] marius: has joined #ruby
[04:02:59] armyriad: has joined #ruby
[04:09:21] tAn: has joined #ruby
[04:11:18] konsolebox: has joined #ruby
[04:15:52] shaiba: has joined #ruby
[04:17:16] eckhardt: has joined #ruby
[04:19:18] konsolebox: has joined #ruby
[04:24:00] psmolen: has joined #ruby
[04:25:14] trautwein: has joined #ruby
[04:28:40] shaiba: has joined #ruby
[04:29:14] RougeR: has joined #ruby
[04:29:14] RougeR: has joined #ruby
[04:32:31] psmolen: has joined #ruby
[04:32:33] rippa: has joined #ruby
[04:33:21] konsolebox: has joined #ruby
[04:34:41] shaiba: has joined #ruby
[04:35:17] NightMonkey: has joined #ruby
[04:38:07] hahuang61: has joined #ruby
[04:43:24] konsolebox: has joined #ruby
[04:45:04] upinspace__: has joined #ruby
[04:48:57] tAn: has joined #ruby
[04:50:50] konsolebox: has joined #ruby
[04:53:34] rabajaj: has joined #ruby
[04:54:52] cthulchu_: has joined #ruby
[04:55:21] workmad3: has joined #ruby
[04:56:31] upinspace__: has joined #ruby
[05:01:50] mr_rich101: has joined #ruby
[05:09:39] GodFather: has joined #ruby
[05:16:19] hahuang61: has joined #ruby
[05:16:44] GodFather: has joined #ruby
[05:25:13] tAn: has joined #ruby
[05:38:25] totalsecond: has joined #ruby
[05:39:24] jamesaxl: has joined #ruby
[05:45:33] upinspace__: has joined #ruby
[05:50:40] upinspace: has joined #ruby
[05:50:41] pastorinni: has joined #ruby
[06:27:55] tAn: has joined #ruby
[06:32:42] moei: has joined #ruby
[06:35:00] moei: has joined #ruby
[06:36:30] Ishido: has joined #ruby
[06:38:30] hahuang61: has joined #ruby
[06:40:36] mtkd: has joined #ruby
[06:56:03] workmad3: has joined #ruby
[07:00:47] dionysus69: has joined #ruby
[07:02:21] milardovich: has joined #ruby
[07:11:34] alex``: has joined #ruby
[07:12:29] tAn: has joined #ruby
[07:24:14] leah2: has joined #ruby
[07:31:54] c0ncealed: has joined #ruby
[07:35:41] hahuang61: has joined #ruby
[07:38:54] cadillac_: has joined #ruby
[07:42:47] orbyt_: has joined #ruby
[07:42:52] Haris: has joined #ruby
[07:42:53] Haris: has joined #ruby
[07:46:16] tAn: has joined #ruby
[07:52:35] guacamole: has joined #ruby
[07:52:35] guacamole: has joined #ruby
[07:55:08] apparition: has joined #ruby
[08:06:41] jamesaxl: has joined #ruby
[08:13:06] dionysus69: has joined #ruby
[08:21:42] suukim: has joined #ruby
[08:26:39] tAn: has joined #ruby
[08:27:49] tomphp: has joined #ruby
[08:29:38] frold: has joined #ruby
[08:32:23] frold: If I have set Max chars to 5000 how do I let my output be based on that? https://pastebin.com/Q3qaPrhu
[08:32:25] ruby[bot]: frold: we in #ruby do not like pastebin.com, I reposted your paste to gist for you: https://gist.github.com/39a5965c304be01274d5b51b87431f18
[08:32:25] ruby[bot]: frold: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
[08:40:45] kapil___: has joined #ruby
[08:43:12] hahuang61: has joined #ruby
[08:44:32] apeiros: frold: I don't understand your question. do you mean how to cut a string at a specific number of characters?
[08:47:43] biberu: has joined #ruby
[08:48:44] biberu: has joined #ruby
[08:49:15] claudiuinberlin: has joined #ruby
[08:55:51] armyriad: has joined #ruby
[08:56:46] workmad3: has joined #ruby
[09:04:54] mtkd: has joined #ruby
[09:05:11] tpendragon: has joined #ruby
[09:14:33] amatas: has joined #ruby
[09:15:07] guacamole: has joined #ruby
[09:15:07] guacamole: has joined #ruby
[09:16:05] hahuang61: has joined #ruby
[09:21:40] \void: has joined #ruby
[09:21:45] desperek: has joined #ruby
[09:23:44] tAn: has joined #ruby
[09:24:16] ldepandis: has joined #ruby
[09:24:33] arkymad: has joined #ruby
[09:28:57] frold: has joined #ruby
[09:30:12] frold: I have this line: And would like to limit the output to x chars: https://gist.github.com/frold/16ee4caacf5b5ee5cf873c3bc48a311a Any ideas?
[09:31:59] apeiros: >> "some very long string"[0,5] # @ frold
[09:32:00] ruby[bot]: apeiros: # => "some " (https://eval.in/966413)
[09:37:35] arkymad: has joined #ruby
[09:39:02] frold: Thanks apeiros - but it seems like the limit is also set else where in the script to a max of 250 - because I can reduce it to eg 50 chars but not have more then 250 even then set to 5000
[09:41:03] faces: has joined #ruby
[09:54:23] tAn: has joined #ruby
[09:55:08] mtkd: has joined #ruby
[09:57:13] marr: has joined #ruby
[10:05:04] schneider: has joined #ruby
[10:06:16] tAn: has joined #ruby
[10:06:18] red_menace: has joined #ruby
[10:06:26] bigblind: has joined #ruby
[10:06:53] red_menace: has left #ruby: ("bye bye...")
[10:09:20] phaul: has joined #ruby
[10:11:08] n008f4g_: has joined #ruby
[10:14:41] mjolnird: has joined #ruby
[10:16:43] dionysus69: has joined #ruby
[10:19:20] mtkd: has joined #ruby
[10:20:07] sidx64: has joined #ruby
[10:20:16] jenrzzz: has joined #ruby
[10:26:00] ^mtkd: has joined #ruby
[10:27:57] mtkd: has joined #ruby
[10:36:52] ^mtkd: has joined #ruby
[10:37:09] hahuang61: has joined #ruby
[10:38:01] mtkd: has joined #ruby
[10:45:04] goatish: has joined #ruby
[10:52:42] tAn: has joined #ruby
[10:53:40] tvw: has joined #ruby
[10:54:12] d^sh: has joined #ruby
[10:57:31] workmad3: has joined #ruby
[11:08:04] n13z: has joined #ruby
[11:15:09] hightower: has joined #ruby
[11:18:33] Papierkorb: has joined #ruby
[11:19:59] tAn: has joined #ruby
[11:20:25] Papierkorb: has left #ruby: ("Konversation terminated!")
[11:20:31] tolland: has left #ruby: ("WeeChat 0.4.3")
[11:20:54] milardovich: has joined #ruby
[11:29:00] nowhereman_: has joined #ruby
[11:32:00] sameerynho: has joined #ruby
[11:36:52] soniya29: has joined #ruby
[11:36:53] soniya29_: has joined #ruby
[11:39:08] keithy: has joined #ruby
[11:43:20] hahuang61: has joined #ruby
[11:46:56] sidx64_: has joined #ruby
[11:52:17] konsolebox: has joined #ruby
[11:55:55] AJA4350: has joined #ruby
[12:02:12] kapil___: has joined #ruby
[12:03:33] schneider: has joined #ruby
[12:11:43] John_Ivan: has joined #ruby
[12:11:43] John_Ivan: has joined #ruby
[12:13:48] faces: has joined #ruby
[12:28:16] tAn: has joined #ruby
[12:28:19] drewmcmillan: has joined #ruby
[12:34:49] hahuang61: has joined #ruby
[12:34:53] tAn: has joined #ruby
[12:40:15] schneider: has joined #ruby
[12:41:07] chromis: has left #ruby: ()
[12:41:09] lemonpaul: has joined #ruby
[12:41:36] emilford: has joined #ruby
[12:42:11] lemonpaul: Good time for all. How to get previous element in array while iterate through it with each method?
[12:43:02] qyliss: lemonpaul: Use each_cons
[12:44:04] lemonpaul: Ok, good. Thanks.
[12:45:44] Haris: has left #ruby: ()
[12:55:02] lemonpaul: How to get last index of element in array?
[12:55:05] apeiros: a qyliss, btw. re "irc channels to hang out" -> #ruby-offtopic. even if it's often quite low traffic
[12:55:15] apeiros: lemonpaul: index or element?
[12:55:24] apeiros: ary.last for last element. ary.size - 1 for last index
[12:55:48] lemonpaul: like methon index, but not first
[12:56:12] apeiros: &ri Array#rindex
[12:56:12] `derpy: http://ruby-doc.org/core-2.4.1/Array.html#method-i-rindex
[12:56:18] apeiros: ^ like that?
[12:56:40] qyliss: apeiros: thanks!
[12:56:41] lemonpaul: Yes, like that. Thanks
[12:58:11] workmad3: has joined #ruby
[13:03:28] milardovich: has joined #ruby
[13:05:44] drewmcmillan: has joined #ruby
[13:06:03] lemonpaul: And last question. If I want to slice elements from index 'start' to the end which range should I use? [start..-1]?
[13:06:38] 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
[13:06:42] apeiros: oh well…
[13:06:45] 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.
[13:09:17] desperek: would something.(hello.there) work?
[13:10:35] apeiros: desperek: the syntax is valid
[13:10:42] apeiros: but "work" depends on so many things
[13:10:53] schneider: has joined #ruby
[13:14:51] apeiros: for it to "work", `something` must evaluate to something which responds to #call, and can be invoked with one argument. hello must evaluate to something which responds to there. and that just means the whole expression evaluates.
[13:15:40] hahuang61: has joined #ruby
[13:16:15] bmurt: has joined #ruby
[13:18:47] conta: has joined #ruby
[13:18:54] dionysus69: has joined #ruby
[13:19:39] bigblind: has joined #ruby
[13:32:10] houhoulis: has joined #ruby
[13:39:29] amelliaa: has joined #ruby
[13:41:27] desperek: can i have something like IS EQUAL TO x OR y apeiros ?
[13:41:40] desperek: rather than IS EQUAL TO x OR IS EQUAL TO y
[13:43:12] apeiros: [x,y].include?(a)
[13:44:22] desperek: apeiros, i found out that x == (a || b) doesnt crash
[13:46:58] phaul: desperek: but probably does something different from what you intended
[13:47:10] desperek: phaul, how so?
[13:47:12] desperek: let me check
[13:47:50] desperek: oh, is it XOR?
[13:48:07] joe_from_maine: has joined #ruby
[13:48:19] Mon_Ouie: >> a = 3; b = 4; a || b
[13:48:20] ruby[bot]: Mon_Ouie: # => 3 (https://eval.in/966432)
[13:48:37] apeiros: desperek: a || b is evaluated first
[13:48:40] Mon_Ouie: ^ i.e. in this case it will be the same as x == a
[13:49:03] apeiros: and it will evaluate to the first non-nil, non-false value, amd to b otherwise.
[13:49:17] apeiros: and then `x == ` will be tested against that
[13:49:46] apeiros: so yes, it doesn't crash. it also doesn't do what you want. just as phaul said.
[13:50:05] desperek: apeiros, so include is the way?
[13:50:14] apeiros: no. it's just one way.
[13:50:29] apeiros: for two values, I'd prefer `x == a || x == b`
[13:50:51] apeiros: it's IMO easier to grok at first read.
[13:51:44] desperek: it also interprets it differently
[13:52:01] desperek: but include approach is better for my application tbh
[13:52:05] apeiros: both work exactly the same
[13:52:31] desperek: apeiros, but i mean, can i have like d == a if d = something.can.be.nil
[13:52:53] apeiros: apart from it not making sense, yes
[13:53:45] loyaqua: has joined #ruby
[13:53:47] desperek: apeiros, eh, i have a relation, which is tested against a relation that can be nil
[13:54:00] desperek: thats more rails problem but still
[13:54:28] apeiros: you may want to reread the code in your question
[13:54:41] apeiros: because that code certainly makes no sense. and probably is unrelated to the problem you just described.
[13:55:22] apeiros: and == doesn't care about nil. neither does include? care about values in the array being nil (or the value passed to it)
[13:55:36] desperek: apeiros, but relation does
[13:55:45] apeiros: relation is not ==
[13:56:13] apeiros: you seem to be confusing things. but I can't tell you more if you keep xy'ing
[13:57:08] desperek: or, whatever
[13:57:09] ruby[bot]: https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
[13:57:17] desperek: (['moderator','admin'].include?(d.permission) || record.user == user) if d = user.roles.find_by(division: record.division) apeiros
[13:57:22] desperek: this is how it looks so far
[13:57:49] desperek: so, d is a division, which can also be nil
[13:58:10] desperek: if it's nil then calling permission on it will raise error
[13:58:12] apeiros: why'd you have an expression on the left side of the if which does nothing?
[13:58:24] apeiros: do_nothing if condition # <-- makes no sense
[13:58:50] desperek: apeiros, it returns true or false
[13:59:15] desperek: doing some policies .-.
[13:59:32] apeiros: seriously, rewrite that code to something actually read- and understandable
[13:59:42] Fusselgesicht: has joined #ruby
[14:00:06] desperek: apeiros, eh, i should go for php mode
[14:00:28] apeiros: you mean if it's an ugly language, it doesn't matter if the code's ugly too?
[14:00:50] yadnesh: has joined #ruby
[14:00:57] phaul: blah if condition ==> condition && blah is more readable if you want to return something like that
[14:01:27] desperek: oh, didnt know that
[14:01:43] apeiros: user.roles.exists?(division: record.division, permission: ["moderator", "admin"])
[14:01:51] apeiros: also magic strings, bad.
[14:02:19] apeiros: phaul: though with an assignment I'd vote for two statements instead of trying to be clever.
[14:02:34] phaul: apeiros: agreed
[14:02:52] apeiros: I omitted the record.user clause
[14:02:58] apeiros: record.user == user || user.roles.exists?(division: record.division, permission: ["moderator", "admin"])
[14:03:11] apeiros: and then I'd factor those parts into methods
[14:03:42] apeiros: record_owner? || <has_privileges>?
[14:03:52] apeiros: (find a better name for has_privileges)
[14:06:42] apeiros: and the record.user relation is probably misnamed (named after the type of the relation instead of the semantics). I bet it should be record.owner # => <User>
[14:07:11] apeiros: rails really shouldn't provide defaults there. I've seen soooo many misnamed relations.
[14:07:26] desperek: eh, should i refractor it then
[14:07:30] desperek: or refactor
[14:10:55] hndk: has joined #ruby
[14:11:44] konsolebox: has joined #ruby
[14:16:51] yadneshk: has joined #ruby
[14:22:01] yadneshk: i have created simple block in a class. i am trying to call the block from the function which has the same name as the block but its not working
[14:22:08] yadneshk: here is the link to code https://gist.github.com/yadneshk/b9efa89679958f72da20b71f24e05282
[14:23:13] konsolebox: has joined #ruby
[14:24:45] apeiros: yadneshk: https://gist.github.com/yadneshk/b9efa89679958f72da20b71f24e05282#file-blocks-rb-L6 wants a class method
[14:25:11] apeiros: yadneshk: also note that there's a Kernel#test which you probably call there
[14:26:03] yadneshk: apeiros, so i shouldn't name my functions test?
[14:26:20] apeiros: well, in this case it'll add to the confusion
[14:26:44] apeiros: otherwise, nothing speaks against calling your method `test`
[14:28:56] yadneshk: apeiros, i am newbie to ruby. i still dont understand the error. i have changed the name of my function. here's link https://gist.github.com/yadneshk/b9efa89679958f72da20b71f24e05282
[14:30:11] apeiros: yadneshk: please gist the error you get too (even though I know what it is)
[14:30:41] apeiros: ("add file" and add it as a separate file)
[14:31:54] emilford: has joined #ruby
[14:32:18] yadneshk: apeiros, updated .try refreshing the link
[14:32:41] apeiros: ok. so lets take it apart.
[14:32:55] apeiros: ./blocks.rb:6:in `<class:Myclass>': undefined method `getblock' for Myclass:Class (NoMethodError)
[14:33:24] apeiros: so this tells you it happens on line 6. it tells you that there is no method `getblock` for the object Myclass (which is an instance of class)
[14:34:02] yadneshk: apeiros, so what do i do to fix it?
[14:34:05] apeiros: what you do on line 6 is essentially `self.getblock`, and `self` in line 6 is Myclass. i.e. you do `Myclass.getblock`
[14:34:17] yadneshk: apeiros, ok
[14:34:20] apeiros: see the difference between `Myclass.new.getblock` and `Myclass.getblock`?
[14:34:32] apeiros: well, "fix" depends on "what should it do?"
[14:36:11] Azure|dc: has joined #ruby
[14:37:01] yadneshk: apeiros, i am learning to create blocks. i am calling the function getblock so i want the puts statement executed
[14:37:17] apeiros: ok. why are you calling it in the class body?
[14:38:00] hahuang61: has joined #ruby
[14:38:10] apeiros: `class Foo; …class body of class Foo is here…; end`
[14:40:15] yadneshk: apeiros, i didn't understand what you said
[14:42:06] apeiros: do you know what a class body is?
[14:46:56] yadneshk: apeiros, all functions are written inside the class body, the lines of code written between class <class_name> till end is class body
[14:47:20] apeiros: the last part is correct. you can define methods outside of class bodies too, though
[14:47:32] apeiros: (also, use the term "method". ruby barely has any functions)
[14:47:58] apeiros: ok, so https://gist.github.com/yadneshk/b9efa89679958f72da20b71f24e05282#file-blocks-rb-L3-L8 is the class body of your class "Myclass"
[14:48:15] apeiros: now do you still not understand my question "why do you call getblock within the class body"?
[14:48:22] yadneshk: apeiros, yes correct
[14:48:56] emilford: has joined #ruby
[14:49:17] yadneshk: apeiros, you are taking about line 6 to 8 right?
[14:51:16] yadneshk: apeiros, is that a call? I thought that it is how we create block and then call that block from a method having same name
[14:51:31] apeiros: no. you're calling the method "getblock" and pass it a block.
[14:52:00] milardovich: has joined #ruby
[14:53:09] yadneshk: apeiros, yield will call the block having same name as the function in which it was written right?
[14:53:28] apeiros: blocks don't have names
[14:53:34] apeiros: and yield will just call the block passed to the method
[14:54:17] apeiros: https://gist.github.com/apeiros/ef042a0888fd35fbf450f0b34c498a5c would be a working example
[14:54:46] Papierkorb: has joined #ruby
[14:55:29] ryzokuken__: has joined #ruby
[14:55:50] yadneshk: ACTION is checking the link
[14:56:44] Papierkorb: has left #ruby: ("Konversation terminated!")
[14:59:20] yadneshk: apeiros, so where is this helpful? because i could also write the statement inside method instead of block
[15:00:15] apeiros: in so many places that it's difficult to find a good start
[15:00:20] apeiros: example 1, each:
[15:00:26] yadneshk: ACTION now thinks that ruby may be more complicated that python
[15:00:36] apeiros: [1,2,3].each do |x| …do something with each item… end
[15:00:59] apeiros: just invoking a block multiple times. in this case with a container, calling it for every element
[15:01:16] apeiros: example 2, sort - provide a strategy to the sorting algorithm:
[15:02:01] apeiros: people.sort { |a,b| a.first_name <=> b.first_name } # though, in almost all situations where I pass a block to sort, I prefer sort_by
[15:02:24] apeiros: people.sort_by { |person| person.first_name } # sort the people array by the first name - note how I do not have to actually implement a sorting algorithm
[15:02:46] apeiros: invoke code delayed (using a gem which actually supports this - not core ruby):
[15:02:58] apeiros: after(3.minutes) do puts "hey, 3 minutes are over" end
[15:03:17] apeiros: there's plenty more use cases.
[15:03:25] yadneshk: apeiros, i get the point that it's very helpful xD
[15:03:35] apeiros: and yes, all of them can be solved without blocks. but blocks provide a very convenient way to solve those things.
[15:03:37] logoscoder: has joined #ruby
[15:04:55] schneider: has joined #ruby
[15:05:03] yadneshk: apeiros, how many years has it been you are using ruby? just asking
[15:05:17] apeiros: it = me? :D
[15:05:36] apeiros: note sure. more than a decade.
[15:05:55] emilford: has joined #ruby
[15:06:05] yadneshk: apeiros, holy ****. looks like i was talking to a pro!!
[15:06:42] apeiros: given that I earn my money by writing ruby, that statement is correct ;-)
[15:08:11] yadneshk: apeiros, it's been only 2 days since i have started learning ruby. Any advices on how i should proceed ?
[15:08:43] apeiros: not really. everybody learns differently. for me, I like having a project and then work on that.
[15:09:56] yadneshk: apeiros, ok i will trouble you with a last question. I am using this to learn ruby https://www.tutorialspoint.com/ruby/ . Tell me is it good or not?
[15:10:10] apeiros: I haven't used it, so I can't tell, sorry.
[15:11:33] yadneshk: apeiros, alright. can you point me some resources for ruby?
[15:11:42] ruby[bot]: You can find a list of recommended books at http://ruby-community.com/pages/links
[15:11:48] apeiros: also take a look at the books in the topic
[15:11:53] Zaab1t: has joined #ruby
[15:13:34] karapetyan: has joined #ruby
[15:13:35] yadneshk: woah !! ruby[bot] talks ? cool
[15:14:06] yadneshk: i thought that you were an actual bot ruby[bot] xD
[15:14:47] yadneshk: apeiros, no way man
[15:14:55] apeiros: ?bot yadneshk
[15:14:55] ruby[bot]: apeiros: I don't know anything about bot
[15:15:09] apeiros: ?justabot yadneshk
[15:15:10] ruby[bot]: yadneshk: I'm just a bot. You don't need to address me.
[15:17:13] yadneshk: anyways, thanks apeiros
[15:18:22] bigblind: has joined #ruby
[15:18:48] alex``: has joined #ruby
[15:18:53] Zaab1t: has joined #ruby
[15:19:43] Zaab1t: has joined #ruby
[15:20:28] Zaab1t: has joined #ruby
[15:27:10] emilford: has joined #ruby
[15:33:13] karapetyan: has joined #ruby
[15:37:36] hahuang61: has joined #ruby
[15:47:10] milardovich: has joined #ruby
[15:52:44] emilford: has joined #ruby
[15:54:51] tomlukeywood: has joined #ruby
[15:56:01] tomlukeywood: How would i split a string into sections of characters?
[15:56:01] tomlukeywood: so for example splitting a string 100 characters into an array containing 20, 5 character strings.
[15:56:44] apeiros: tomlukeywood: str.scan(/.{,5}/m)
[15:56:57] tomlukeywood: apeiros: perfect ty!
[15:59:02] chouhoulis: has joined #ruby
[16:03:53] alex``: has joined #ruby
[16:03:54] al2o3-cr: /.{5}/ or it'll give you 21 elements
[16:05:00] antoine1: has joined #ruby
[16:05:58] ryzokuken__: has joined #ruby
[16:10:53] apeiros: oh, right. .{1,5}
[16:11:22] apeiros: .{5} is fine if you know your string will always have a length with a multiple of 5
[16:11:32] apeiros: (or if you want to skip the last odd n chars)
[16:12:13] Barrt: has joined #ruby
[16:14:38] karapetyan: has joined #ruby
[16:18:30] jottr: has joined #ruby
[16:26:02] chouhoulis: has joined #ruby
[16:29:12] drewmcmillan: has joined #ruby
[16:34:31] sidx64: has joined #ruby
[16:37:56] sidx64_: has joined #ruby
[16:41:14] desperek: apeiros, how can i check if arrays have similar part?
[16:41:24] desperek: [0,1],[1,2] -> true
[16:41:42] apeiros: how do you determine "similar"?
[16:42:19] milardovich: has joined #ruby
[16:42:50] desperek: apeiros, as for, well, if one array contains part of another one
[16:43:08] desperek: like, [0,1] and [1,2] both have 1 so they return true
[16:43:17] apeiros: but in your example, the left array does not contain the right array…
[16:43:27] hahuang61: has joined #ruby
[16:43:32] desperek: https://stackoverflow.com/questions/3941945/array-include-any-value-from-another-array
[16:43:35] apeiros: neither does the right array contain the left
[16:43:37] desperek: apeiros, not whole, just a part
[16:43:47] apeiros: &ri Array#&
[16:43:47] `derpy: http://ruby-doc.org/core-2.4.1/Array.html#method-i-26
[16:43:58] apeiros: ^ that's intersection, will give you all common elements
[16:44:08] guacamole: has joined #ruby
[16:44:09] guacamole: has joined #ruby
[16:44:18] Vile`: has joined #ruby
[16:46:48] itp_student|2401: has joined #ruby
[16:47:07] Ryzokuken: has joined #ruby
[16:49:04] bonhoeffer: has joined #ruby
[16:49:28] bonhoeffer: it looks like I can't use ' in %x[curl foo] -- is that true?
[16:50:05] bonhoeffer: getting lots of syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
[16:50:05] bonhoeffer: ....0.3282.186 Safari/537.36' -H 'Accept: text/html,application...
[16:50:29] apeiros: ' can be used in %x
[16:50:47] apeiros: %x{echo 'hallo'} # => "hallo\n"
[16:50:50] ericmathison: has joined #ruby
[16:51:04] apeiros: if you have syntax errors, then because you made mistakes. not because you used ' in %x
[16:51:43] workmad3: has joined #ruby
[16:53:32] itp_student|1913: has joined #ruby
[16:53:36] phaul: apeiros: are the channel bots documented anywhere? I mean the list of bots and their commands?
[16:53:46] ruby[bot]: You can find an overview of my commands at http://ruby-community.com/ruboto/commands
[16:53:55] bonhoeffer: apeiros, thanks --- that helps
[16:56:27] phaul: apeiros: thanks, is @ruby[bot] all or are there others?
[16:57:06] apeiros: there's also derpy, which provides docs. just `&ri arg` (like cmd line ri)
[16:57:25] orbyt_: has joined #ruby
[16:57:26] apeiros: though adaedra wanted to add that to ruboto (ruby[bot])
[16:57:46] soniya29: has joined #ruby
[16:57:48] phaul: ok thanks
[16:57:53] apeiros: in general, bots are allowed as long as they a) don't conflict with ruby[bot], and b) don't violate any channel rules (like no spamming etc.)
[16:58:04] soniya29_: has joined #ruby
[16:59:21] phaul: asm>> 1+1
[16:59:22] ruby[bot]: phaul: I have disassembled your code, the result is at https://eval.in/966467
[16:59:40] naftilos76: has joined #ruby
[17:02:40] itp_student|1913: has joined #ruby
[17:05:06] ResidentBiscuit: has joined #ruby
[17:05:57] itp_student|1913: has joined #ruby
[17:07:10] cthulchu_: has joined #ruby
[17:07:21] hahuang61: has joined #ruby
[17:08:41] itp_student|1913: has joined #ruby
[17:10:57] itp_student|1913: has joined #ruby
[17:12:44] suhdood: has joined #ruby
[17:13:17] tomlukeywood: has left #ruby: ()
[17:16:05] itp_student|1913: has joined #ruby
[17:19:57] itp_student|1913: has joined #ruby
[17:21:58] bonhoeffer: is there a way to get a multiline string %Q[] without newlines -- or just do a replace on that string for "\n"
[17:22:33] bonhoeffer: oh -- I guess %W[]
[17:22:52] karapetyan: has joined #ruby
[17:23:34] ptx0: has joined #ruby
[17:24:39] bonhoeffer: with .join(' ') of course
[17:24:56] itp_student|1913: has joined #ruby
[17:28:48] apeiros: I tend to use "" \ for that
[17:28:57] itp_student|1913: has joined #ruby
[17:30:02] apeiros: bonhoeffer: https://gist.github.com/apeiros/88d890a8aa9b019a9e17f0f04e9b7b35
[17:31:39] itp_student|1913: has joined #ruby
[17:34:12] Ryzokuken: has joined #ruby
[17:37:15] guacamole: has joined #ruby
[17:37:15] guacamole: has joined #ruby
[17:38:43] itp_student|1913: has joined #ruby
[17:41:06] BTRE: has joined #ruby
[17:41:25] itp_student|1913: has joined #ruby
[17:42:43] hahuang61: has joined #ruby
[17:45:46] karapetyan: has joined #ruby
[17:45:51] itp_student|1913: has joined #ruby
[17:46:06] cdg: has joined #ruby
[17:47:18] PMS: has joined #ruby
[17:48:18] Barrt: has joined #ruby
[17:49:07] dmitriy_: has joined #ruby
[17:52:35] tildes: has joined #ruby
[17:54:03] itp_student|1913: has joined #ruby
[17:55:48] bonhoeffer: thanks apeiros
[18:00:56] itp_student|1913: has joined #ruby
[18:01:54] guacamole: has joined #ruby
[18:01:54] guacamole: has joined #ruby
[18:02:24] helpa: has joined #ruby
[18:04:11] bigblind: has joined #ruby
[18:04:34] itp_student|1913: has joined #ruby
[18:04:34] bonhoeffer: i'm trying to scan a file for a match -- in ruby: perl -lne 'print $1 if /NOTETHREADUID=(\d+)\&/' raw.txt
[18:04:47] bonhoeffer: of course that only produces one match
[18:06:19] bonhoeffer: i'm trying to scan a file for all matches
[18:07:40] cdg: has joined #ruby
[18:08:41] roelof: has joined #ruby
[18:09:23] roelof: Is there another free alternative to ruby monk. When I want to visit the site I see a certificate error
[18:11:07] itp_student|1913: has joined #ruby
[18:12:43] apeiros: bonhoeffer: that line might work exactly as that by just replacing `perl` with `ruby` :)
[18:12:51] apeiros: not sure about the -l, tho
[18:13:23] apeiros: bonhoeffer: anyway, how does your try in ruby look like?
[18:13:55] bonhoeffer: apeiros, i'll check out -- is that a site to try online
[18:14:20] bonhoeffer: i almost have exactly what i want with: egrep -o 'NOTETHREADUID=([0-9]+)\&' raw.txt
[18:14:24] guacamole: has joined #ruby
[18:14:24] guacamole: has joined #ruby
[18:14:30] bonhoeffer: but the whole string shows, not the match
[18:14:32] hahuang65: has joined #ruby
[18:15:38] bonhoeffer: ruby -ne 'print $1 if /NOTETHREADUID=([0-9]+)\&/' raw.txt <-- works for first match
[18:17:52] apeiros: first match on one line? or first match in the whole file?
[18:17:53] bonhoeffer: ruby -ne 'print $1 if /NOTETHREADUID=([0-9]+)\&/' raw.txt <-- works for first match
[18:18:22] bonhoeffer: my line finds the first match in the file, but I'm looking for all matches
[18:18:38] apeiros: ruby -ne should not stop on the first match
[18:18:59] itp_student|1913: has joined #ruby
[18:21:57] itp_student|1913: has joined #ruby
[18:23:25] guacamole: has joined #ruby
[18:23:25] guacamole: has joined #ruby
[18:26:02] alip: has joined #ruby
[18:26:20] alip: Encapsulate application's business logic (Service Object)
[18:26:24] alip: https://github.com/AliSepehri/peafowl
[18:26:42] alip: Let me know if you have any feedback
[18:28:15] guacamole: has joined #ruby
[18:28:15] guacamole: has joined #ruby
[18:30:36] milardovich: has joined #ruby
[18:34:32] itp_student|1913: has joined #ruby
[18:34:37] hahuang61: has joined #ruby
[18:34:41] suhdood: has joined #ruby
[18:35:48] dviola: has joined #ruby
[18:37:04] rrutkowski: has joined #ruby
[18:37:39] pmcgee: has joined #ruby
[18:38:09] itp_student|1913: has joined #ruby
[18:38:31] jxv: has joined #ruby
[18:39:04] aufi: has joined #ruby
[18:41:49] rrutkowski: has joined #ruby
[18:43:01] itp_student|1913: has joined #ruby
[18:45:53] larissa: has joined #ruby
[18:48:52] itp_student|1913: has joined #ruby
[18:52:57] itp_student|1913: has joined #ruby
[18:53:29] cr3: has joined #ruby
[18:58:00] itp_student|1913: has joined #ruby
[19:02:26] John_Ivan: has joined #ruby
[19:07:05] itp_student|1913: has joined #ruby
[19:08:24] itp_student|1913: has joined #ruby
[19:08:33] jottr: has joined #ruby
[19:12:04] itp_student|1913: has joined #ruby
[19:14:52] ltem: has joined #ruby
[19:15:12] guacamole: has joined #ruby
[19:15:12] guacamole: has joined #ruby
[19:16:48] drewmcmillan: has joined #ruby
[19:19:23] hahuang61: has joined #ruby
[19:22:24] antoine1_: has joined #ruby
[19:23:55] xfbs: has joined #ruby
[19:24:05] itp_student|1913: has joined #ruby
[19:27:55] antoine1: has joined #ruby
[19:29:39] DTZUZO: has joined #ruby
[19:33:39] itp_student|1913: has joined #ruby
[19:34:42] StarSeed0000: has joined #ruby
[19:36:35] rybu: has joined #ruby
[19:38:23] itp_student|1913: has joined #ruby
[19:41:36] cadillac_: has joined #ruby
[19:44:16] cthulchu_: has joined #ruby
[19:44:57] rrutkowski: has joined #ruby
[19:46:36] ldepandis: has joined #ruby
[19:50:00] guacamole: has joined #ruby
[19:50:01] guacamole: has joined #ruby
[19:54:41] mniip: has joined #ruby
[19:55:15] itp_student|1913: has joined #ruby
[19:56:55] raynold: has joined #ruby
[19:59:31] jxv: has joined #ruby
[20:03:49] itp_student|1913: has joined #ruby
[20:06:24] vutral|kali: has joined #ruby
[20:06:25] vutral|kali: has joined #ruby
[20:07:43] itp_student|1913: has joined #ruby
[20:10:16] tomphp: has joined #ruby
[20:10:44] bigblind: has joined #ruby
[20:11:08] SirFunk: has joined #ruby
[20:11:40] mynameisdebian: has joined #ruby
[20:13:55] schneider: has joined #ruby
[20:14:37] jnollette: has joined #ruby
[20:16:53] dtzuzu: has joined #ruby
[20:18:15] sidx64: has joined #ruby
[20:18:35] milardovich: has joined #ruby
[20:19:43] guille-moe: has joined #ruby
[20:20:20] John_Ivan: has joined #ruby
[20:20:58] itp_student|1913: has joined #ruby
[20:22:05] enigman: has joined #ruby
[20:22:25] vutral|kali: has joined #ruby
[20:22:25] vutral|kali: has joined #ruby
[20:24:03] idiocrash: has joined #ruby
[20:26:36] sidx64: has joined #ruby
[20:28:27] s3nd1v0g1us: has joined #ruby
[20:29:57] itp_student|1913: has joined #ruby
[20:34:28] hightower: has joined #ruby
[20:38:59] itp_student|1913: has joined #ruby
[20:39:58] minimalism: has joined #ruby
[20:40:56] hahuang61: has joined #ruby
[20:44:05] eckhardt_: has joined #ruby
[20:44:42] brucebag: has joined #ruby
[20:44:43] brucebag: has joined #ruby
[20:45:13] SirFunk: has joined #ruby
[20:49:27] cdg: has joined #ruby
[20:49:57] itp_student|1913: has joined #ruby
[20:49:58] guacamole: has joined #ruby
[20:52:48] jxv: has joined #ruby
[20:54:50] itp_student|1913: has joined #ruby
[20:58:25] jnollette: has joined #ruby
[21:08:54] caoraivoso: has joined #ruby
[21:11:36] hahuang61: has joined #ruby
[21:11:46] roelof: has joined #ruby
[21:12:13] roelof: What is the best free resource to learn ruby with challenges ?
[21:17:54] dtzuzu: has joined #ruby
[21:21:18] guacamole: has joined #ruby
[21:21:18] guacamole: has joined #ruby
[21:21:42] jottr: has joined #ruby
[21:24:31] John_Ivan: has joined #ruby
[21:24:32] John_Ivan: has joined #ruby
[21:25:38] nowhere_man: has joined #ruby
[21:29:06] tomphp: has joined #ruby
[21:34:02] Dimik: has joined #ruby
[21:35:10] itp_student|1913: has joined #ruby
[21:35:22] DTZUZO: has joined #ruby
[21:38:57] itp_student|1913: has joined #ruby
[21:43:57] itp_student|1913: has joined #ruby
[21:47:54] larissa: has joined #ruby
[21:50:20] itp_student|1913: has joined #ruby
[21:50:24] goatish: has joined #ruby
[21:52:49] jottr: has joined #ruby
[22:00:12] bigblind: has joined #ruby
[22:00:57] yaiyaichu: has joined #ruby
[22:02:11] ElDoggo: has joined #ruby
[22:04:16] itp_student|1913: has joined #ruby
[22:07:25] daemonwrangler: has joined #ruby
[22:11:56] c0ncealed: has joined #ruby
[22:13:00] milardovich: has joined #ruby
[22:15:27] itp_student|1913: has joined #ruby
[22:16:00] kapil___: has joined #ruby
[22:21:01] itp_student|1913: has joined #ruby
[22:23:09] yaiyaichu: has joined #ruby
[22:25:23] itp_student|1913: has joined #ruby
[22:29:39] Mkop: has joined #ruby
[22:30:04] jxv: has joined #ruby
[22:35:03] itp_student|1913: has joined #ruby
[22:37:07] itp_student|1913: has joined #ruby
[22:38:42] tAn: has joined #ruby
[22:39:41] hahuang61: has joined #ruby
[22:41:55] dtzuzu: has joined #ruby
[22:46:54] ogres: has joined #ruby
[22:47:56] Matthew1: has joined #ruby
[22:49:57] itp_student|1913: has joined #ruby
[22:55:24] yaiyaichu: has left #ruby: ()
[22:56:02] rrutkowski: has joined #ruby
[22:56:16] itp_student|1913: has joined #ruby
[22:59:36] itp_student|1913: has joined #ruby
[22:59:47] AJA4350: has joined #ruby
[23:07:56] cdg: has joined #ruby
[23:10:53] jxv: has joined #ruby
[23:10:55] itp_student|1913: has joined #ruby
[23:14:13] jenrzzz: has joined #ruby
[23:14:13] jenrzzz: has joined #ruby
[23:15:25] DTZUZO: has joined #ruby
[23:18:27] mtkd: has joined #ruby
[23:19:32] konsolebox: has joined #ruby
[23:25:48] tomphp: has joined #ruby
[23:33:55] itp_student|1913: has joined #ruby
[23:35:02] hahuang61: has joined #ruby
[23:36:57] itp_student|1913: has joined #ruby
[23:38:02] RougeR: has joined #ruby
[23:38:02] RougeR: has joined #ruby
[23:39:57] itp_student|1913: has joined #ruby
[23:40:51] eckhardt_: has joined #ruby
[23:46:24] tAn: has joined #ruby
[23:46:47] bigblind: has joined #ruby
[23:47:12] tAn: has joined #ruby
[23:47:57] tAn: has joined #ruby
[23:48:48] tAn: has joined #ruby
[23:49:06] GodFather: has joined #ruby
[23:49:22] itp_student|1913: has joined #ruby
[23:49:31] nowhereman_: has joined #ruby
[23:50:29] tAn: has joined #ruby
[23:51:55] tAn: has joined #ruby
[23:52:08] itp_student|1913: has joined #ruby
[23:56:12] ResidentBiscuit: has joined #ruby
[23:56:18] jenrzzz: has joined #ruby
[23:56:18] jenrzzz: has joined #ruby
[23:59:55] Barrt: has joined #ruby