« Back to channel list

#ruby - 19 January 2019

« Back 1 day Forward 1 day »
[00:02:12] crankharder: has joined #ruby
[00:02:13] jottr_: has joined #ruby
[00:30:12] Fridtjof: has joined #ruby
[00:43:14] p0s1x: has joined #ruby
[01:03:37] fredolinhares: has joined #ruby
[01:08:27] mikecmpbll: has joined #ruby
[01:10:56] Paraxial: has joined #ruby
[01:19:24] remi: has joined #ruby
[01:29:48] houhoulis: has joined #ruby
[01:38:25] uplime: has joined #ruby
[01:59:07] hutch: has joined #ruby
[02:05:22] ellcs: has joined #ruby
[02:08:10] tdy1: has joined #ruby
[02:08:33] bmurt: has joined #ruby
[02:29:49] hutch: has joined #ruby
[02:45:00] AJA4350: has joined #ruby
[02:49:52] tdy1: has joined #ruby
[03:01:49] remi: has left #ruby: ()
[03:06:57] bmurt: has joined #ruby
[03:13:12] _forage_: has joined #ruby
[03:22:04] za1b1tsu: has joined #ruby
[03:25:06] bmurt: has joined #ruby
[03:29:55] mangold: has joined #ruby
[03:35:07] orbyt_: has joined #ruby
[03:38:42] bmurt: has joined #ruby
[03:44:09] bmurt: has joined #ruby
[04:10:09] braincrash: has joined #ruby
[04:19:43] hutch: has joined #ruby
[04:25:38] Nicmavr: has joined #ruby
[04:37:23] davidw: has joined #ruby
[04:48:10] _whitelogger: has joined #ruby
[05:00:48] \void: has joined #ruby
[05:03:33] sauvin: has joined #ruby
[05:05:46] hutch: has joined #ruby
[05:21:09] _whitelogger: has joined #ruby
[05:30:37] ziyadb: has joined #ruby
[05:31:21] Avinash: has joined #ruby
[05:31:53] hurricanehrndz: has joined #ruby
[05:44:31] tdy1: has joined #ruby
[05:56:15] mroutis: has joined #ruby
[06:00:14] mroutis: stay hydrated, folks
[06:03:28] Avinash: has joined #ruby
[06:07:21] Avinash: has joined #ruby
[06:11:23] rippa: has joined #ruby
[06:30:21] Avinash: has joined #ruby
[06:33:40] dinfuehr_: has joined #ruby
[06:40:06] dinfuehr: has joined #ruby
[06:42:43] danguita: has joined #ruby
[06:47:32] arekushi: has joined #ruby
[06:49:52] nowhere_man: has joined #ruby
[07:05:25] Avinash: has joined #ruby
[07:39:08] hiroaki: has joined #ruby
[07:42:58] Avinash: has joined #ruby
[08:04:10] hutch: has joined #ruby
[08:06:05] c-c: has joined #ruby
[08:07:29] c-c: Hey how would you automate jpg to webm where each consequtive frame has -1 jpg compression quality?
[08:08:00] c-c: - So the image appears to degrade over time into jpg mosh
[08:11:16] leftylink: that sounds fun. I would consider something like running imagemagick in a loop, https://imagemagick.org/script/convert.php has the deets
[08:11:42] leftylink: and ffmpeg can probably put all the frames into a webm
[08:12:24] dellavg_: has joined #ruby
[08:15:08] ramfjord: has joined #ruby
[08:15:52] c-c: Looks like I have mini-magick package on debian...
[08:16:32] c-c: - Is mini-magick legit?
[08:21:39] tdy: has joined #ruby
[08:32:38] Avinash: has joined #ruby
[08:35:47] ramfjord: has joined #ruby
[08:40:48] reber: has joined #ruby
[08:40:51] RedNifre: has joined #ruby
[08:47:54] Avinash: has joined #ruby
[08:50:50] ellcs: has joined #ruby
[08:53:35] Fernando-Basso: has joined #ruby
[08:58:54] arekushi: has joined #ruby
[09:04:53] conta: has joined #ruby
[09:07:11] RedNifre: has joined #ruby
[09:11:40] gix: has joined #ruby
[09:28:47] mangold: has joined #ruby
[09:31:27] TaterTotMan: has joined #ruby
[09:58:38] ramfjord: has joined #ruby
[10:05:27] ramfjord: has joined #ruby
[10:06:45] Fusl: has joined #ruby
[10:09:46] themsay: has joined #ruby
[10:11:54] xco: has joined #ruby
[10:12:28] xco: Hi! what does [ints][ints] do in Ruby?
[10:12:54] xco: nevermind :)
[10:13:10] phaul: wrong language? :)
[10:13:31] up|ime: it'll give a NameError :P
[10:13:50] xco: like this?
[10:13:51] xco: [1, 2, 3][0, 1]
[10:13:58] xco: it won’t give an error
[10:14:14] phaul: slices an array
[10:14:18] phaul: &ri slice
[10:14:18] rubydoc: I found 6 entries matching method slice. Use &list slice if you would like to see a list
[10:14:24] phaul: ri Array#slice
[10:14:29] phaul: &ri Array#slice
[10:14:29] rubydoc: https://ruby-doc.org/core-2.6/Array.html#method-i-slice
[10:14:32] up|ime: more like phail
[10:16:21] phaul: I'm always confused by fake code, taking everything literarily...
[10:17:42] phaul: ?fake xco
[10:17:42] ruby[bot]: xco: Please show your real code to illustrate your problem. Using fake code often hides it or won't bring up the best possible solution.
[10:18:21] xco: i’m not writing anything at the moment, just random thoughts :D
[10:18:58] phaul: just when asking ask with runable code, ppl will take your interpretation as real code
[10:20:22] up|ime: i did the same, but in a more "i take this literal knowing it's not your problem"
[10:20:46] up|ime: easiest way to get a (11:13:48) <xco> no <xco> [1, 2, 3][0, 1]
[10:24:50] c-c: ACTION always does [1..3][0,1]
[10:24:57] c-c: one less char
[10:26:30] phaul: c-c I think you missed the splat.
[10:26:54] phaul: there goes the one char saving :)
[10:29:29] up|ime: personally i would just do [1]
[10:31:36] c-c: you could also do [0,1][1..8]
[10:33:02] phaul: &list slice
[10:33:02] rubydoc: Array#slice, ENV.slice, Hash#slice, String#slice, Symbol#slice, Ripper.slice
[10:33:46] phaul: interesting that Symbol has it.
[10:34:49] phaul: though symbol has all sorts of String ops now.
[10:38:32] blerrp: has joined #ruby
[10:42:00] blerrp: imagine an rpg (game) you have different attacks (e.g. punch, kick -- each with their own damage and other attributes)
[10:42:19] blerrp: i've defined attacks using an Attack class
[10:42:57] blerrp: but now i need to keep a collection of Attack instances (each representing a different kind of attack) for use throught the project
[10:44:39] blerrp: the Attack class has Attack.name method, and that's how they're identified
[10:45:00] blerrp: what's a good way to maintain a collection of attacks? a list doesn't seem convenient
[10:45:26] blerrp: should i make an Attacks module and define the instances of Attack in there
[10:46:16] blerrp: and access them by doing something like Attacks.punch (to give Attack.new(name: 'punch')
[10:46:27] blerrp: or is that not a good way
[10:48:04] blerrp: another way could be to build a hash of them like {punch: Attack.new(name: 'punch'), ...}
[10:48:20] blerrp: Attacks = {punch: Attack.new(name: 'punch'), ...}
[10:50:28] phaul: these are all workable approaches but they give you slightly different behaviour. you need to consider whether a single (inmutable) attack object is ok per name or you need one dynamically ( newly created ) on each lookup by name.
[10:51:27] phaul: then you can think about the interface, which is an orthogonal question. Separate class, or same class class methods for lookup by name. All can work whichever interface you like better
[10:52:16] blerrp: i wonder if group_by could be helpful
[10:52:26] blerrp: on a list of Attack instances
[10:52:35] blerrp: mabye that's all i need
[10:56:51] blerrp: moves = moves_list.group_by { |m| m.name.downcase.to_sym }
[10:56:57] blerrp: like that i guess
[10:57:04] Mike11: has joined #ruby
[10:58:04] phaul: that's fine, but is there a reason that m.name is not already a downcased sym?
[10:58:20] phaul: would simplify your program a lot..
[10:59:33] hiroaki: has joined #ruby
[11:00:23] blerrp: yeah, i'm still figuring out what will be used most often
[11:04:35] reber: has joined #ruby
[11:05:01] lxsameer: has joined #ruby
[11:08:48] blerrp: group_by is doing something weird to my objects actually
[11:12:08] za1b1tsu: has joined #ruby
[11:12:42] blerrp: https://dpaste.de/f2Jq
[11:12:55] blerrp: sup with that
[11:15:03] phaul: group_by puts an array of objects into each groups in case there are more objects to go in a group
[11:15:43] blerrp: oh, so i have to access with $moves[:punch][0]
[11:15:58] blerrp: not so great
[11:16:07] phaul: &>> (1..10).group_by(&:even?)
[11:16:09] rubydoc: # => {false=>[1, 3, 5, 7, 9], true=>[2, 4, 6, 8, 10]} (https://carc.in/#/r/61cf)
[11:17:10] phaul: are you going to have a single Attack per name?
[11:18:36] phaul: are you on 2.6?
[11:19:17] phaul: move_list.to_h { |attack| [attack.name, attack] }
[11:19:44] phaul: or move_list.to_h { |attack| [attack.name.downcase.to_sym, attack] }
[11:20:15] blerrp: awesome, thanks
[11:20:57] blerrp: and do you think that a global variable $moves_list is suitable for things like this
[11:21:23] phaul: I would avoid global vars at all cost
[11:22:03] blerrp: how would you do it considering you need it in other files that `require` the file with Move
[11:22:20] blerrp: and may use the move list in an initializer
[11:22:49] phaul: Are these attacks inmutable? Just one object per name in the entire system? Or different attack Objects per name, just not in this list?
[11:22:56] blerrp: like consider a Monster class in another file with `def initialize(name: 'Monster', stats: {:hp_max => 5}, moves: $moves[:punch])`
[11:22:58] blerrp: something like that
[11:23:52] blerrp: yeah, i was thinking one object per name globally
[11:24:04] blerrp: only one punch object
[11:25:03] phaul: let me code up something quickly that shows one idea...
[11:28:02] ellcs: has joined #ruby
[11:30:35] phaul: https://gist.github.com/43e909939a0c7bad0996a4b4e276d790
[11:36:48] phaul: but there are many ways to skin a cat
[11:37:12] blerrp: interesting
[11:39:49] phaul: one immediate advantage is that the commonality between certain attack types can easily be DRYed by moving them into a common superclass
[11:44:03] blerrp: ty phaul, i will review more
[11:48:46] themsay: has joined #ruby
[12:26:34] AJA4350: has joined #ruby
[12:29:35] uranoss: has joined #ruby
[12:35:27] lucasb: has joined #ruby
[12:57:29] raul782: has joined #ruby
[13:22:11] bmurt: has joined #ruby
[14:08:58] xrexeon: has joined #ruby
[14:10:41] xrexeon: has joined #ruby
[14:27:08] xrexeon: has joined #ruby
[14:28:45] bmurt: has joined #ruby
[14:46:07] uplime: has joined #ruby
[14:46:40] segy: has joined #ruby
[15:05:33] Nicmavr: has joined #ruby
[15:17:21] Avinash: has joined #ruby
[15:20:05] Emmanuel_Chanel: has joined #ruby
[15:29:16] orbyt_: has joined #ruby
[15:31:58] dinfuehr: has joined #ruby
[15:39:11] _whitelogger: has joined #ruby
[15:45:31] dinfuehr: has joined #ruby
[15:46:12] desperek: has joined #ruby
[15:46:30] desperek: hi; is there anybody familiar with camping? how do i make migrations?
[15:52:00] dinfuehr: has joined #ruby
[15:58:03] Fernando-Basso: has joined #ruby
[16:00:12] raul782: has joined #ruby
[16:22:45] e: has joined #ruby
[16:24:19] desperek: it's basically not running anything
[16:36:33] nowhere_man: has joined #ruby
[16:44:28] za1b1tsu: has joined #ruby
[16:47:08] hiroaki: has joined #ruby
[16:50:58] dellavg_: has joined #ruby
[16:53:32] uplime: has joined #ruby
[16:59:33] Dbugger: has joined #ruby
[17:02:42] uplime: has joined #ruby
[17:07:30] phaul: desperek: it doesn't seem like camping has a lot of traction. https://github.com/camping/camping/commits/master seems about ~20 check ins in the past 4 years. what's the appeal? If you want something small, why not roda?
[17:09:16] desperek: well, looks nice
[17:12:46] desperek: but then, camping is kinda more raily ://
[17:13:16] desperek: aaand theeen i also think of other langs
[17:17:27] d10n-work: has joined #ruby
[17:23:22] bmurt: has joined #ruby
[17:25:28] davidw: has joined #ruby
[17:36:04] Fridtjof: has joined #ruby
[17:46:18] hutch: has joined #ruby
[17:57:01] orbyt_: has joined #ruby
[17:58:14] havenwood: desperek: Camping was a neat project by _why, but I agree there are crisper options these days unless you're just exploring.
[17:58:38] desperek: oh are there
[17:59:15] havenwood: desperek: If you'd like something Rails-ish, checkout Hanami. Or if you'd like something simple that's extensible, +1 Roda.
[17:59:25] havenwood: desperek: https://hanamirb.org/
[17:59:32] havenwood: desperek: http://roda.jeremyevans.net/
[18:00:45] desperek: well camping is neato
[18:00:58] desperek: im kinda conrerned about db
[18:01:03] desperek: do i just add active record to roda
[18:01:35] havenwood: desperek: Many folk use Sequel with Roda. Sequel and ActiveRecord are the two most popular Ruby ORMs by far.
[18:02:11] havenwood: desperek: Like Roda, Sequel uses a plugin pattern. Its base is simple, but you can use plugins to compose the ORM you need.
[18:02:25] havenwood: desperek: In Roda, the base is simple and you use plugins to compose the framework you need.
[18:02:45] havenwood: desperek: https://sequel.jeremyevans.net/
[18:03:31] havenwood: desperek: If you'd like more rails, Hanami has a defined pattern: https://guides.hanamirb.org/repositories/sql-queries/
[18:03:41] desperek: well, okay. i think ill check out roda+sequel more
[18:04:12] havenwood: i do like that path. it's fun to write all the code yourself and keep it tiny.
[18:14:07] desperek: havenwood, im just a little bit confused. should i put my routing tree in .ru or .rb
[18:14:39] desperek: i guess it doesnt matter?
[18:14:59] havenwood: desperek: All Rack apps have a config.ru file (rackup file), even Rails. Typically in a Roda app you'll start with config.ru that uses the Roda app from an app.rb.
[18:15:06] havenwood: desperek: you're right, it doesn't really matter.
[18:22:32] hutch: has joined #ruby
[18:55:13] noobineer: has joined #ruby
[18:59:57] xrexeon: has joined #ruby
[19:00:53] xrexeon: has joined #ruby
[19:04:20] xrexeon: has joined #ruby
[19:41:57] tdy: has joined #ruby
[19:44:03] cthulchu: has joined #ruby
[19:48:32] ghormoon: has joined #ruby
[19:49:10] noboruma: Hi guys, is there any nice way of applying a color on string (in place) that matches a specific regex?
[19:51:58] phaul: noboruma: can you elaborate a bit more? Where do you want to see the colours? What interface are you talking about? terminal? web? neither?
[19:54:43] noboruma: phaul: woops, I should have put more detailed! I want to see those colour in terminal. I am working a CLI tool that execute some external shell commands and I would like to colourise their outputs
[19:56:33] phaul: https://github.com/sickill/rainbow an other one https://github.com/fazibear/colorize
[19:56:37] noboruma: So far I have been using a combination of grep + sed, it works but I was wondering if there was a nicer, idiomatic ruby-way for such tasks
[19:58:19] lupine: there's a gem that lets you do "foo".color(:red)
[19:59:20] lupine: I don't think I'm thinking of https://github.com/fazibear/colorize but it also exists
[20:00:19] phaul: noboruma: is printing strings (in colour) what you want? you also said in place.. which makes me wonder you need more terminal control
[20:01:11] Puffball: has joined #ruby
[20:04:17] noboruma: phaul: thank you for the links, I am checking rainbow but in my understanding, colorize "only" allow you to colorize a full string. What I want to do is colorize only certain part of a string (for instace all the numbers in red)
[20:05:09] noboruma: I was wondering if there is any regex tricks that could help?
[20:05:21] m27frogy: has joined #ruby
[20:07:48] noobineer: has joined #ruby
[20:10:09] phaul: noboruma: Im sorry I don't fully follow. You can split up a string and then apply colours to sub strings and concatenate them back together. Colour here is really nothing more that inserting a bunch of ANSI escape sequences under the hood.
[20:20:14] noboruma: phaul: yes, but my question is: what is the nicest way of achieving that (spliting+inserting) in ruby?
[20:22:13] duderonomy: has joined #ruby
[20:23:44] noboruma: I guess gsub might be the answer, thanks guys!
[20:34:52] tpanarch1st: has joined #ruby
[20:40:01] Fernando-Basso: has joined #ruby
[20:44:44] Spitfire: has joined #ruby
[20:50:57] desperek: havenwood, do you have any idea how do i know how to access session etc.?
[20:57:43] desperek: nvm i know it now
[21:01:23] raul782: has joined #ruby
[21:02:40] quipa: has joined #ruby
[21:18:09] hutch: has joined #ruby
[21:37:29] sanscoeur: has joined #ruby
[21:42:26] m27frogy_: has joined #ruby
[21:46:12] lupine: has joined #ruby
[22:00:30] tdy: has joined #ruby
[22:26:55] sonofentropy: has joined #ruby
[22:54:00] \void: has joined #ruby
[22:54:50] tdy1: has joined #ruby
[23:14:32] tdy1: has joined #ruby
[23:15:06] mr_roybot: has joined #ruby
[23:18:44] cd: has joined #ruby
[23:20:18] uplime: has joined #ruby
[23:32:12] hightower2: has joined #ruby
[23:32:34] hightower2: Hey, I 'require' a ruby file. Inside the required file, which variable or constant contains its full path?
[23:34:07] lupine: File.join(Dir.pwd, __FILE__)
[23:34:31] hightower2: great, thanks
[23:39:20] hightower2: has left #ruby: ("Leaving")
[23:39:58] havenwood: hightower2: File.expand_path(__FILE__)
[23:41:24] havenwood: lupine: If you change the working directory, Dir.pwd won't be the dir the file is in anymore, so Ii think it's better to use `File.expand_path(__dir__)` and `File.expand_path(__FILE__)`.
[23:50:46] themsay: has joined #ruby
[23:51:05] orbyt_: has joined #ruby
[23:53:05] ramfjord: has joined #ruby
[23:57:13] bmurt: has joined #ruby