« Back to channel list

#ruby - 10 May 2018

« Back 1 day Forward 1 day »
[00:00:13] alfiemax: has joined #ruby
[00:00:25] n0m4d1c: has joined #ruby
[00:05:19] Paraxial: has joined #ruby
[00:09:19] pharma_joe: has joined #ruby
[00:17:49] banisterfiend: has joined #ruby
[00:23:30] dcunit3d: has joined #ruby
[00:26:29] cagomez: has joined #ruby
[00:27:09] houhoulis: has joined #ruby
[00:28:58] alfiemax: has joined #ruby
[00:35:09] kmurphy4: has joined #ruby
[00:37:56] crankharder: has joined #ruby
[00:41:13] orbyt_: has joined #ruby
[00:51:34] postmodern_: has joined #ruby
[00:54:08] tAn: has joined #ruby
[00:58:49] crankharder: has joined #ruby
[01:01:10] alfiemax: has joined #ruby
[01:03:54] kapil___: has joined #ruby
[01:11:30] duderonomy: has joined #ruby
[01:14:07] ramfjord: has joined #ruby
[01:19:56] EXCHGR: has joined #ruby
[01:20:35] havenwood: leah2: Your question in a roundabout way resulted in a patch to TruffleRuby: https://twitter.com/eregontp/status/994326685817458693
[01:21:37] MeXTuX: has joined #ruby
[01:21:58] namidark: has joined #ruby
[01:23:59] namidark_: has joined #ruby
[01:25:31] namidark__: has joined #ruby
[01:26:30] namidark[w]: has joined #ruby
[01:26:51] namidark|tux: has joined #ruby
[01:28:07] dogweather: has joined #ruby
[01:29:19] namidark: has joined #ruby
[01:30:03] Apocalypse: has joined #ruby
[01:31:23] namidark_: has joined #ruby
[01:32:43] dcunit3d: has joined #ruby
[01:33:53] namidark__: has joined #ruby
[01:36:20] namidark: has joined #ruby
[01:41:45] dinfuehr-: has joined #ruby
[01:48:47] aether: has joined #ruby
[01:50:52] ccrow: has joined #ruby
[01:52:00] safetypin: has joined #ruby
[01:52:57] namidark: has joined #ruby
[01:54:15] gizmore|2: has joined #ruby
[01:54:55] namidark_: has joined #ruby
[01:59:10] namidark: has joined #ruby
[01:59:36] houhoulis: has joined #ruby
[02:00:03] namidark1: has joined #ruby
[02:01:16] namidark2: has joined #ruby
[02:01:47] veex: has joined #ruby
[02:02:28] namidark_: has joined #ruby
[02:05:52] namidark: has joined #ruby
[02:07:51] matcouto: has joined #ruby
[02:10:17] MeXTuX: has left #ruby: ()
[02:17:23] namidark_: has joined #ruby
[02:17:43] namidark1: has joined #ruby
[02:22:58] dogweather: has joined #ruby
[02:23:01] namidark: has joined #ruby
[02:27:16] namidark_: has joined #ruby
[02:29:27] skweek: has joined #ruby
[02:30:27] jenrzzz: has joined #ruby
[02:33:02] namidark: has joined #ruby
[02:36:01] dogweather: has joined #ruby
[02:38:47] namidark: has joined #ruby
[02:41:32] bmurt: has joined #ruby
[02:44:53] alfiemax: has joined #ruby
[02:51:43] dcunit3d: has joined #ruby
[02:51:56] namidark: has joined #ruby
[02:53:44] variable: has joined #ruby
[02:54:01] namidark: has joined #ruby
[02:56:21] yxhuvud: has joined #ruby
[02:59:48] namidark: has joined #ruby
[03:00:18] namidark_: has joined #ruby
[03:00:46] namidark: has joined #ruby
[03:01:31] yxhuvud: has joined #ruby
[03:01:59] dviola: has joined #ruby
[03:03:15] alfiemax: has joined #ruby
[03:04:53] namidark_: has joined #ruby
[03:05:13] namidark: has joined #ruby
[03:06:29] eckhardt: has joined #ruby
[03:13:23] skweek: has joined #ruby
[03:14:00] putolov: has joined #ruby
[03:14:45] putolov: Hallo, I am trying to install Ruby on my Mac OS Sierra Hight using Terminal but I have problem
[03:15:24] Radar: putolov: what's the problem?
[03:15:26] putolov: after I type 'rbenv install 2.5.1' I got an error
[03:15:31] Radar: putolov: what's the error?
[03:15:48] putolov: clang: error: unable to remove file: Operation not permitted
[03:15:49] putolov: dtrace: failed to compile script probes.d: Preprocessor failed to process input program
[03:16:23] Radar: putolov: seems to be a known issue: https://github.com/rbenv/ruby-build/issues/1061
[03:16:43] dogweather: has joined #ruby
[03:17:14] Radar: RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.5.1
[03:17:16] Radar: This might work for you
[03:17:45] orbyt_: has joined #ruby
[03:18:25] kmurphy4: has joined #ruby
[03:18:46] cagomez: has joined #ruby
[03:19:55] putolov: Radar: you mean just type RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.5.1 in Terminal and that is
[03:20:54] Radar: Read the github issue for more info
[03:23:19] putolov: Radar: I am reading. I have typed on Terminal this and now waiting what is gonna hepend.
[03:24:28] shakes: has joined #ruby
[03:24:51] tAn: has joined #ruby
[03:40:58] alfiemax: has joined #ruby
[03:43:15] putolov: Radar: It works now! Thx
[03:43:20] Radar: putolov: yay :)
[03:47:33] gix: has joined #ruby
[03:48:00] MzrE: has joined #ruby
[03:50:31] jokke1: has joined #ruby
[03:57:11] yxhuvud: has joined #ruby
[03:58:41] Ryzokuken: has joined #ruby
[04:02:58] miah: has joined #ruby
[04:03:50] putolov: Radar: one more help
[04:04:12] putolov: I have successfuly insalled all from this tutorial
[04:04:14] putolov: https://gorails.com/setup/osx/10.13-high-sierra
[04:04:40] putolov: on final steps after I have installed rails and 'rails new test_app -d mysql'
[04:05:29] putolov: I have go to: cd test_app and got the message: Required ruby-2.5.1 is not installed. To install do: 'rvm install "ruby-2.5.1"'
[04:05:41] putolov: But I have installed ruby 2.5.1
[04:05:42] Radar: putolov: it seems like you have both rvm and rbenv installed.
[04:05:50] Radar: putolov: rvm implode --force
[04:06:36] putolov: Radar: OK, this will delete rvm ?
[04:07:41] za1b1tsu_: has joined #ruby
[04:13:20] claw: has joined #ruby
[04:13:45] dogweather: has joined #ruby
[04:14:44] putolov: OK, now I have to configure yml file to connect with localhost. I have installed mysql with brew mysql ...
[04:14:57] anisha_: has joined #ruby
[04:15:47] putolov: It works, it works. ;)
[04:17:12] zenspider: has joined #ruby
[04:18:49] ur5us: has joined #ruby
[04:19:06] kent\n: has joined #ruby
[04:19:38] putolov: Radar: Thanks a lot, it was really helpful. I have spend last 4 days to make it works.
[04:25:28] dogweather: has joined #ruby
[04:31:44] psmolen: has joined #ruby
[04:35:56] marius: has joined #ruby
[04:38:26] dogweather: has joined #ruby
[04:40:48] jp: has joined #ruby
[04:41:18] jenrzzz: has joined #ruby
[04:41:18] jenrzzz: has joined #ruby
[04:45:58] alfiemax: has joined #ruby
[04:57:05] eam: has joined #ruby
[04:58:10] venmx: has joined #ruby
[05:10:16] venmx: has joined #ruby
[05:13:16] sauvin: has joined #ruby
[05:16:23] Liothen: has joined #ruby
[05:16:23] Liothen: has joined #ruby
[05:19:47] Tempesta_: has joined #ruby
[05:24:22] dogweather: has joined #ruby
[05:24:39] govg: has joined #ruby
[05:32:53] Sonar1: has joined #ruby
[05:35:07] b100s: Hi2all! I try to calculate sha256 on fly for file and got out of memory. How can I read ny chunks and avoid keep all file in memory? My gist is here: https://gist.github.com/b10s/3bdfee3cbf52de1c2dcec645ea2be1e3
[05:35:14] dogweather: has joined #ruby
[05:35:34] alfiemax: has joined #ruby
[05:38:38] eckhardt: has joined #ruby
[05:41:07] howdoi: has joined #ruby
[05:42:55] nicesignal: has joined #ruby
[05:43:55] havenwood: >> require 'digest/sha2'; sha2 = Digest::SHA2.new; sha2 << 'b1'; sha2 << '00s'; sha2.hexdigest == Digest::SHA256.hexdigest('b100s')
[05:43:56] ruby[bot]: havenwood: # => true (https://eval.in/1001880)
[05:43:56] amatas: has joined #ruby
[05:47:51] b100s: havenwood, thanks, what about Tempfile, can I avoid using it in my webserver?
[05:48:15] b100s: I would like to not rely on disk and just calculate everything on fly
[05:49:25] havenwood: b100s: Where does the tempfile come into it? I'm not quite following.
[05:49:44] b100s: in gist : )
[05:49:51] havenwood: b100s: If you need to read a file, you can use File.open to avoid the whole file in memory at once, and feed it to the digest in pieces.
[05:50:09] b100s: havenwood, everything in the gist file; I do not know other way to upload files in ruby
[05:50:32] havenwood: b100s: Typically if you want a file, but in memory, you'd use StringIO
[05:50:37] b100s: So, I need to create File and somehow get stream from sinatra?
[05:52:47] konsolebox: has joined #ruby
[05:53:01] amar: has joined #ruby
[05:53:02] jenrzzz: has joined #ruby
[05:53:02] jenrzzz: has joined #ruby
[05:53:39] bsartek: has joined #ruby
[05:54:26] tAn: has joined #ruby
[05:54:36] dogweather: has joined #ruby
[05:55:57] ARCADIVS: has joined #ruby
[05:58:33] havenwood: b100s: I guess the tempfile pattern is to avoid having the thing all in memory at once anyways. Reading lines or bytes from a tempfile and shoving them onto a digest keeps it low mem.
[05:59:16] znz_jp: has joined #ruby
[05:59:29] b100s: havenwood, heh, you can try on your local and be sure it is not : )
[05:59:43] b100s: I mean my gist
[06:00:03] havenwood: try what about it?
[06:01:01] aupadhye|food: has joined #ruby
[06:01:31] havenwood: b100s: someone else might spot what you mean more easily - it's been a while since i've used sinatra and i'm distracted atm
[06:01:52] b100s: havenwood, yeah, don't worry
[06:02:08] b100s: havenwood, I mean this one https://gist.github.com/b10s/3bdfee3cbf52de1c2dcec645ea2be1e3
[06:04:09] dogweather: has joined #ruby
[06:04:41] Junaos_: has joined #ruby
[06:08:17] ramfjord: has joined #ruby
[06:09:03] havenwood: b100s: I get a: Bad request content body
[06:10:01] b100s: havenwood, How did you run app and how did you send request?
[06:10:41] havenwood: b100s: `ruby app.rb` and the curl command in your gist
[06:10:51] havenwood: b100s: except i put the port in
[06:11:54] havenwood: b100s: ah, actually seem to work generating the dat a second time
[06:12:11] alfiemax: has joined #ruby
[06:12:32] havenwood: Content-Length: 69, err
[06:13:04] b100s: havenwood, sorry, try 'curl -v -F "file=@/tmp/output3.dat" localhost:4567/save_image'
[06:13:10] b100s: I didn't put port
[06:13:48] alfiemax: has joined #ruby
[06:13:52] havenwood: b100s: my issue might be with trying to port your dd command to bsd flags
[06:14:12] havenwood: i'll try on linux
[06:14:15] b100s: then try any random existed file : )
[06:14:42] havenwood: b100s: how big?
[06:15:06] b100s: few gigs to fill how app eat mem
[06:15:09] roamingdog: has joined #ruby
[06:15:21] b100s: s/fill/feel/
[06:15:30] b100s: s/eat/eats/
[06:16:40] havenwood: b100s: here's just over 1G
[06:16:42] havenwood: b100s: https://gist.github.com/havenwood/953d9518a9ce13712c3edfeefc50661a
[06:17:06] havenwood: b100s: that's with straight .read and a single hexdigest
[06:17:14] havenwood: i'll try a huge one
[06:17:34] b100s: and try to looks at out of ps during the uploading
[06:17:59] havenwood: i'm sure it'll be large - but not if you do it incrementally instead of reading the whole tempfile into memory
[06:19:01] conta: has joined #ruby
[06:19:55] b100s: yeah, it will
[06:20:23] b100s: and last thing which I would like to avoid is saving to the disk temp file
[06:21:15] dogweather: has joined #ruby
[06:22:04] havenwood: b100s: file.each_byte { |byte| sha2 << byte }
[06:22:32] havenwood: b100s: or: file.each_line ...
[06:22:40] havenwood: b100s: i dunno about that one, because it'll mean it being in memory, right?
[06:23:25] havenwood: b100s: shovelling it byte-by-byte or line-by-line from the tempfile should keep it out of memory
[06:23:33] roamingdog: has joined #ruby
[06:23:44] baweaver: lazy is an option.
[06:23:52] b100s: I belive you can read stream without keep it in mem
[06:24:18] roamingdog: has joined #ruby
[06:24:52] b100s: havenwood, reading stream byte-by-byte or line-by-line allow us do not save it to disk and do not keep it in mem
[06:25:06] dogweather: has joined #ruby
[06:25:09] roamingdog: has joined #ruby
[06:25:17] b100s: baweaver, what do you mean by lazy ?
[06:25:22] havenwood: b100s: i just mean proceeding from what you've shown - sure you don't need a tempfile if you never create one
[06:25:38] cschneid: has joined #ruby
[06:25:43] b100s: havenwood, do you know how to avoid creating ? : )
[06:25:54] roamingdog: has joined #ruby
[06:26:08] tuskkk___: has joined #ruby
[06:26:44] roamingdog: has joined #ruby
[06:26:47] cthulchu_: has joined #ruby
[06:27:34] roamingdog: has joined #ruby
[06:28:13] venmx: has joined #ruby
[06:29:04] plexigras: has joined #ruby
[06:29:41] alfiemax: has joined #ruby
[06:32:55] schleppel: has joined #ruby
[06:38:03] havenwood: b100s: write rack middleware to hijack it before it gets to the tempfile
[06:38:52] havenwood: b100s: you might have buffering issue, I'm not sure
[06:39:20] havenwood: b100s: they haven't made it simple for you to handle the stream yourself
[06:39:40] havenwood: b100s: what's simple, is to pull bytes or lines off the tempfile
[06:40:31] havenwood: b100s: https://github.com/rack/rack/issues/736
[06:45:57] vondruch: has joined #ruby
[06:47:21] havenwood: b100s: Rack is working as intended, and Sinatra is happy with a tempfile. ¯\_(ツ)_/¯
[06:48:20] pragmatism: has joined #ruby
[06:48:57] pelegreno: has joined #ruby
[06:53:30] amar: has joined #ruby
[06:54:10] shynoob: has joined #ruby
[06:54:35] phaul: has joined #ruby
[06:55:08] shynoob: alright brothers and sisters.. I am new to the language.. suggest me.. the nononsense way to efficiently learn ruby! thanks
[06:55:38] baweaver: Check the channel topic
[06:55:44] baweaver: There's a book list up there
[06:55:46] ciscam: has joined #ruby
[06:56:32] havenwood: shynoob: How new to Ruby are you? Do you know another programming language?
[06:56:45] havenwood: I guess you answered the first one. You're new to Ruby.
[06:57:02] shynoob: a little bit of C
[06:57:43] havenwood: shynoob: I'd suggest jumping right into tryruby.org, then look at baweaver's book list
[06:58:12] havenwood: shynoob: if you need a refresher, Chris Pine's Learn to Program is accessible - or baweaver is writing a book
[06:58:47] havenwood: shynoob: https://ruby-community.com/pages/links
[06:59:09] havenwood: shynoob: https://www.ruby-lang.org/en/documentation/
[06:59:17] havenwood: shynoob: https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-c-and-cpp/
[06:59:43] havenwood: shynoob: REPLs are really handy for quick feedback while learning. Ruby ships with IRB or you can install the Pry gem.
[06:59:44] 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.
[06:59:46] 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
[07:00:08] havenwood: shynoob: Try the tryruby.org examples in irb by typing from your terminal: irb
[07:00:11] epochwolf|2: has joined #ruby
[07:00:32] havenwood: shynoob: https://baweaver.gitbooks.io/an-illustrated-guide-to-ruby/content/
[07:00:45] shynoob: oh I see.. thanks a lot.. I was thinking about trying Codecademy.. but well.. tryruby it is
[07:00:50] baweaver: (it's still very much a WIP)
[07:01:35] dogweather: has joined #ruby
[07:01:41] havenwood: shynoob: Try Ruby doesn't take too long to finish. Excercism.io is particularly good for community feedback, once you get started.
[07:02:10] havenwood: shynoob: Feel free to ask here if you get stuck or want code feedback or ideas!
[07:04:23] shynoob: I'll be here most of the time then
[07:08:15] emilford: has joined #ruby
[07:15:24] jenrzzz: has joined #ruby
[07:15:59] reber: has joined #ruby
[07:16:09] aufi: has joined #ruby
[07:18:43] neuraload: has joined #ruby
[07:22:57] suukim: has joined #ruby
[07:23:19] dogweather: has joined #ruby
[07:27:17] jp: has joined #ruby
[07:27:27] alfiemax: has joined #ruby
[07:27:52] syndikate: has joined #ruby
[07:28:51] syndikate: has joined #ruby
[07:34:25] amatas: has joined #ruby
[07:42:21] RedNifre: has joined #ruby
[07:53:15] b100s: havenwood, thanks, will check it
[07:54:04] mikecmpbll: has joined #ruby
[07:55:42] dionysus69: has joined #ruby
[07:59:00] dogweather: has joined #ruby
[07:59:56] marr: has joined #ruby
[08:02:55] alex``: has joined #ruby
[08:04:18] hurricanehrndz: has joined #ruby
[08:05:09] dogweather: has joined #ruby
[08:05:12] kapil___: has joined #ruby
[08:06:13] ur5us: has joined #ruby
[08:08:38] kriskropd: has joined #ruby
[08:11:26] emilford: has joined #ruby
[08:11:59] cschneid_: has joined #ruby
[08:12:05] ramfjord: has joined #ruby
[08:21:10] amatas: has joined #ruby
[08:24:31] tAn: has joined #ruby
[08:26:28] tomphp: has joined #ruby
[08:29:01] Voxxit: has joined #ruby
[08:33:19] nfsnobody: has joined #ruby
[08:35:01] jamesaxl: has joined #ruby
[08:40:35] tomphp: has joined #ruby
[08:43:21] WebDawg: has joined #ruby
[08:44:51] nowhere_man: has joined #ruby
[08:45:21] karapetyan: has joined #ruby
[08:47:57] clemens3: has joined #ruby
[08:48:34] tomphp: has joined #ruby
[08:49:12] amar: has joined #ruby
[08:52:28] yohji: has joined #ruby
[08:53:13] ur5us: has joined #ruby
[08:54:12] amar: has joined #ruby
[08:54:37] amar: has joined #ruby
[08:55:20] anisha_: has joined #ruby
[08:58:19] TomyLobo: has joined #ruby
[09:02:40] Beams: has joined #ruby
[09:03:15] RougeR: has joined #ruby
[09:03:15] RougeR: has joined #ruby
[09:06:13] nfsnobody: has joined #ruby
[09:06:13] Voxxit: has joined #ruby
[09:10:12] Ryzokuken: has joined #ruby
[09:12:13] chmurifree: has joined #ruby
[09:17:37] KeyJoo: has joined #ruby
[09:20:50] aufi_: has joined #ruby
[09:22:40] tomphp: has joined #ruby
[09:31:47] karapetyan: has joined #ruby
[09:31:57] intheclouddan: has joined #ruby
[09:34:53] tomphp: has joined #ruby
[09:40:32] amatas: has joined #ruby
[09:41:03] biberu: has joined #ruby
[09:43:27] amatas: has joined #ruby
[09:43:46] vondruch: has joined #ruby
[09:44:10] dionysus69: has joined #ruby
[09:45:08] NL3limin4t0r: has joined #ruby
[09:45:19] tomphp: has joined #ruby
[09:46:19] nickjj: has joined #ruby
[09:57:27] piixal: has joined #ruby
[09:57:48] venmx: has joined #ruby
[10:00:54] za1b1tsu_: has joined #ruby
[10:05:26] aviraldg: has joined #ruby
[10:05:30] luna_x[m]: has joined #ruby
[10:05:30] jonjits[m]: has joined #ruby
[10:05:30] torarne: has joined #ruby
[10:05:30] failednoose[m]: has joined #ruby
[10:05:31] Hanma[m]: has joined #ruby
[10:05:31] iceskins[m]: has joined #ruby
[10:05:31] redlegion[m]: has joined #ruby
[10:05:31] haylon_: has joined #ruby
[10:05:31] Giphy[m]: has joined #ruby
[10:05:31] turt2live: has joined #ruby
[10:05:31] KevinMGranger: has joined #ruby
[10:05:37] nullmoose[m]: has joined #ruby
[10:05:38] zalipuha[m]: has joined #ruby
[10:05:38] velu_aon[m]: has joined #ruby
[10:06:43] kliq: has joined #ruby
[10:12:53] maufart__: has joined #ruby
[10:15:27] roamingdog: has joined #ruby
[10:19:51] conta: has joined #ruby
[10:20:09] DoubleMalt: has joined #ruby
[10:22:36] banisterfiend: has joined #ruby
[10:23:54] roamingdog: has joined #ruby
[10:25:04] tomphp: has joined #ruby
[10:26:59] amatas: has joined #ruby
[10:27:04] brianpWins: has joined #ruby
[10:28:04] apparition: has joined #ruby
[10:32:13] alfiemax: has joined #ruby
[10:37:22] Tempesta: has joined #ruby
[10:42:02] amatas_: has joined #ruby
[10:45:05] kurko_: has joined #ruby
[10:49:13] marr: has joined #ruby
[10:49:24] mostlybadfly: has joined #ruby
[10:50:28] hfp_work: has joined #ruby
[10:54:57] dogweather: has joined #ruby
[10:57:02] tAn: has joined #ruby
[10:58:28] mikeiniowa: has joined #ruby
[10:59:35] Azure: has joined #ruby
[11:03:18] ramfjord: has joined #ruby
[11:03:27] piixal: has joined #ruby
[11:05:22] dogweather: has joined #ruby
[11:09:37] dionysus69: has joined #ruby
[11:10:02] rikkipitt: has joined #ruby
[11:10:37] Cavallari: has joined #ruby
[11:13:25] AJA4350: has joined #ruby
[11:14:48] RougeR: has joined #ruby
[11:15:19] nowhere_man: has joined #ruby
[11:16:22] sepp2k: has joined #ruby
[11:16:52] dionysus69: has joined #ruby
[11:22:38] shynoob: has joined #ruby
[11:23:28] dionysus69: has joined #ruby
[11:25:18] tAn: has joined #ruby
[11:33:01] ciscam: has joined #ruby
[11:34:22] NL3limin4t0r: >> [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map { |hash| hash[:a] }
[11:34:23] ruby[bot]: NL3limin4t0r: # => [1, 3, 5] (https://eval.in/1002026)
[11:34:37] houhoulis: has joined #ruby
[11:34:55] NL3limin4t0r: Is there a cleaner way to map a certain key of an array of hashes?
[11:35:30] NL3limin4t0r: I was looking for the more object oriented style `.map(&:a)`, but that obviously doesn't work.
[11:38:07] ldnunes: has joined #ruby
[11:39:29] NL3limin4t0r: >> swp = ->(method, *args, object) { method.to_proc.call(object, *args) }; [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map(&swp.curry(3)[:[], :a])
[11:39:30] ruby[bot]: NL3limin4t0r: # => [1, 3, 5] (https://eval.in/1002029)
[11:39:48] NL3limin4t0r: But that's just more messy.
[11:41:10] tomphp: has joined #ruby
[11:41:33] DoubleMalt: has joined #ruby
[11:45:27] houhoulis: has joined #ruby
[11:45:36] alfiemax: has joined #ruby
[11:46:32] tomphp: has joined #ruby
[11:47:37] NL3limin4t0r: Guess the cleanest way is to use open structs.
[11:48:33] NL3limin4t0r: >> require 'ostruct'; [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map(&OpenStruct.method(:new)).map(&:a)
[11:48:34] ruby[bot]: NL3limin4t0r: # => [1, 3, 5] (https://eval.in/1002031)
[11:49:27] dminuoso: 13:34 NL3limin4t0r | Is there a cleaner way to map a certain key of an array of hashes?
[11:49:55] dminuoso: But yes. The solution is called lenses.
[11:51:53] apeiros: NL3limin4t0r: baweaver has a lib which helps with that
[11:53:10] roamingdog: has joined #ruby
[11:53:27] houhoulis: has joined #ruby
[11:53:55] roamingdog: has joined #ruby
[11:54:45] roamingdog: has joined #ruby
[11:55:30] roamingdog: has joined #ruby
[11:56:20] roamingdog: has joined #ruby
[11:57:11] NL3limin4t0r: dminuoso: ty, I'll look into it.
[11:57:57] houhoulis: has joined #ruby
[11:57:58] tAn: has joined #ruby
[11:59:43] VladGh: has joined #ruby
[12:07:22] duderonomy: has joined #ruby
[12:13:01] alfiemax: has joined #ruby
[12:13:08] alfiemax: has joined #ruby
[12:16:10] Liothen: has joined #ruby
[12:17:42] anisha_: has joined #ruby
[12:19:04] tAn: has joined #ruby
[12:20:05] variable: has joined #ruby
[12:20:48] ferr: has joined #ruby
[12:22:23] fyrril: has joined #ruby
[12:25:09] matled: has joined #ruby
[12:25:23] chocoelho: has joined #ruby
[12:27:46] ruby549: has joined #ruby
[12:29:59] DTZUZO_: has joined #ruby
[12:31:37] Beams_: has joined #ruby
[12:33:58] samosaphile: has joined #ruby
[12:35:19] konsolebox: NL3limin4t0r: [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map{ |hash| hash[:a] } is already the cleanest. you make it too complicated.
[12:37:59] apeiros: ACTION had Enumerable#map_aref in his utils for some time
[12:38:08] apeiros: i.e. ary.map_aref :a
[12:41:06] awx: has joined #ruby
[12:42:45] ellcs: has joined #ruby
[12:43:42] konsolebox: i'm not a fan of this, but the next "clean" solution for me would be `.map(&:[], :a)`. Someone can prepend modules to Array and Enumerable and enhance map.
[12:44:14] apeiros: that'd require patching rubys syntax itself
[12:44:22] apeiros: since block is only valid as last argument
[12:46:30] ciscam: has joined #ruby
[12:47:44] konsolebox: `.map(:a, &:[])` then
[12:48:19] tAn: has joined #ruby
[12:54:41] apeiros: konsolebox: how about htis:
[12:54:55] apeiros: >> class Array; def to_proc; proc { |ele| ele[*self] }; end; end; [{a: 1}, {a: 2, b: 3}, {c: 4, a: 5}].map(&[:a])
[12:54:56] ruby[bot]: apeiros: # => [1, 2, 5] (https://eval.in/1002079)
[12:55:25] apeiros: it's relatively in line with .map(&:property)
[12:55:52] konsolebox: apeiros: would that concept work with methods that accepts more than 1 argument?
[12:56:29] apeiros: not sure what you're asking for. methods can't take more than one block
[12:56:36] apeiros: and it always invokes #[]
[12:57:27] apeiros: if your #[] accepts multiple arguments, it works too:
[12:57:37] apeiros: >> class Array; def to_proc; proc { |ele| ele[*self] }; end; end; [[1,2,3,4,5]].map(&[2,2])
[12:57:38] ruby[bot]: apeiros: # => [[3, 4]] (https://eval.in/1002085)
[12:58:01] konsolebox: apeiros: i see
[12:58:13] ozzloy: has joined #ruby
[13:01:21] jcalla: has joined #ruby
[13:03:28] eikobear: has joined #ruby
[13:04:35] karapetyan: has joined #ruby
[13:06:43] apeiros: I also liked Integer#to_proc & Range#to_proc; I have it in my pryrc
[13:06:54] apeiros: basically ary.map(&0) is the same as ary.map(&:first)
[13:08:53] nertzy: has joined #ruby
[13:12:44] banisterfiend: has joined #ruby
[13:14:47] bmurt: has joined #ruby
[13:16:03] dogweather: has joined #ruby
[13:17:45] Uptime: has joined #ruby
[13:18:56] jcalla: has joined #ruby
[13:26:15] tAn: has joined #ruby
[13:26:17] konsolebox: apeiros: your method requires having the argument convert itself to a proc. here's what i meant about my solution:
[13:26:21] konsolebox: >> module ArrayExt; def map(*args, &blk); super(){ |e| blk.call(e, *args) }; end; end; class Array; prepend ArrayExt; end; [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map(:a, &:[])
[13:26:22] ruby[bot]: konsolebox: # => [1, 3, 5] (https://eval.in/1002137)
[13:27:38] RougeR: https://gist.github.com/CodePint/bbea0819ea28e8322a30368c22991a05
[13:27:43] RougeR: anyone got a clue why this is happening
[13:27:53] RougeR: not_null constraints failing on timestamps
[13:28:51] konsolebox: with magic, we can even a unified extension module both for Enumerable and Array. i think there's a way for the module to know its "includer".
[13:29:01] k0mpa: has joined #ruby
[13:29:32] apeiros: RougeR: rails covers AR better than ruby, hence you should ask in #rubyonrails
[13:29:41] apeiros: oh, cross-poster
[13:29:45] apeiros: ?crossposting RougeR
[13:29:45] ruby[bot]: apeiros: I don't know anything about crossposting
[13:30:08] apeiros: ?crosspost RougeR
[13:30:08] ruby[bot]: RougeR: Please do not crosspost without at least telling so and mentioning provided suggestions and their outcome in all channels. Experience shows that people don't do either, and not doing so is considered rude.
[13:30:16] RougeR: sorry apeiros
[13:30:27] RougeR: ill bear that in mind going forward
[13:31:34] RougeR: sorted it
[13:31:37] RougeR: im an idiot :)
[13:38:22] banisterfiend: has joined #ruby
[13:39:06] duderonomy: has joined #ruby
[13:39:42] Ryzokuken: has joined #ruby
[13:44:27] jottr: has joined #ruby
[13:46:28] apeiros: baweaver: I think your libraries can do that too already, what would be the equivalents with them? https://eval.in/1002145
[13:47:17] apeiros: though for .map(&:values_at.with(:a, :c)) I actually prefer Enumerable#pluck(:a, :c)
[13:47:51] NL3limin4t0r: apeiros & konsolebox thanks for your input. I like how apeiros adds the Array#to_proc method, I hadn't thought about that.
[13:51:56] skweek: has joined #ruby
[13:53:17] dminuoso: Woah you dont need that much crazy stuff :|
[13:53:31] dminuoso: All you really need is Proc#* and thats it
[13:53:37] dminuoso: As a poor mans solution:
[13:54:39] NL3limin4t0r: RougeR: You forgot to add the attributes to Gym object in the #create, but I guess you already figgered that out.
[13:55:12] RougeR: NL3limin4t0r: yeah, i was being dumb. staring at a screen too long
[13:56:26] dminuoso: Oh well I cant be arsed :|
[13:57:06] apeiros: dminuoso: that's not a poor man's solution, that's a broke man's solution ;-p
[13:57:47] dminuoso: apeiros: the main problem is
[13:57:52] dminuoso: apeiros: he's abusing map the completely wrong way
[13:57:53] apeiros: btw., I have most of this stuff in my pryrc because it makes transforming csv's quite concise
[13:57:57] dminuoso: map should preserve the structure
[13:58:07] apeiros: he? or me?
[14:01:01] dminuoso: NL3limin4t0r: https://eval.in/1002159
[14:01:51] jforceBEE: has joined #ruby
[14:02:00] duderonomy: has joined #ruby
[14:03:33] gnufied: has joined #ruby
[14:07:57] samosaphile: anyone have experience building a simple web crawler using curl? (ideally looking for spoon-feeding / hand-holding, just being honest)
[14:08:33] Rapture: has joined #ruby
[14:08:59] stairmast0r: has joined #ruby
[14:10:01] jforceBEE: samosaphile Just curious, why are you asking for advice on curl in a ruby chat?
[14:10:47] jforceBEE: One idea off the top of my head is that you will need to use bash or soemthing to create some kind of loop to crawl a web site
[14:11:10] jottr: has joined #ruby
[14:13:01] orbyt_: has joined #ruby
[14:13:29] samosaphile: dunno, was just wondering, maybe some knows or offer some kind of guidance, you never know without trying ... #curl chat is always pretty much dead, so i won't even try there
[14:14:14] NL3limin4t0r: dminuoso: That's a nice example example, but 1. You changed the structure of the array from: [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}] to [{a: [1,2]}, {a: [3,4]}, {a: [5,6]}], 2. By changing the stucture you made it more complicated, having the `at = -> i, o { o[i] }.curry` would have been enough. Good solution though.
[14:15:43] jforceBEE: makes sense. Honestly writing a crawler with curl sounds like a headache. Have you tried scrapy? Python library
[14:16:56] Asher: has joined #ruby
[14:19:14] solocshaw: has joined #ruby
[14:19:40] samosaphile: yeh, but trying to avoid using something like scrapy, it's just too big and heavy. it has all this extra baggage and functionality but for me is unecessary as what im trying to crawl is quite simple (or so i believe it to be)
[14:20:02] apeiros: why do you care about the unnecessary baggage?
[14:20:13] samosaphile: but maybe i'll just use it if no other option...
[14:20:15] apeiros: I mean, just don't use the parts you don't need.
[14:20:16] jforceBEE: Could just be too noisy
[14:20:41] apeiros: and crawling nowadays is anything but simple
[14:21:13] jforceBEE: You can search for "ruby web crawler" and there are some tuts that pop up for writing a simple web crawler. Maybe you can check them out and write one in ruby that is more lightweight
[14:21:17] apeiros: unless you're crawling sites from the last millenium, you need an engine which can actually understand the dom and let js manipulate it
[14:21:36] samosaphile: apeiros: even crawling something like this is not simple? http://gentool.net/data/zh/
[14:21:39] jforceBEE: And if you go with ruby, nokogiri is a great library for parsing DOM
[14:21:47] samosaphile: cuz that is all i need one for...
[14:22:02] apeiros: if you just want to mirror a relatively static site, wget iirc has a direct command for that
[14:22:08] apeiros: either --archive or --mirror or somesuch
[14:22:11] apeiros: and curl probably too
[14:22:22] jforceBEE: or httrack will also clone a website really good
[14:22:42] apeiros: just google for "archive website" or "mirror website"
[14:22:51] apeiros: and throw curl/wget into the mix. you should find something.
[14:23:02] jforceBEE: apeiros: good call with the mirroring. Gets the entire site at once
[14:30:45] lucasb: has joined #ruby
[14:33:52] samosaphile: has joined #ruby
[14:34:31] kmurphy4: has joined #ruby
[14:35:01] mikecmpb_: has joined #ruby
[14:39:32] dogweather: has joined #ruby
[14:39:51] tomphp: has joined #ruby
[14:41:33] banisterfiend: has joined #ruby
[14:44:05] dcunit3d: has joined #ruby
[14:47:23] synthroid: has joined #ruby
[14:56:32] rippa: has joined #ruby
[15:00:58] ferr: has joined #ruby
[15:01:23] dogweather: has joined #ruby
[15:02:17] ellcs: has joined #ruby
[15:06:08] cagomez: has joined #ruby
[15:12:37] mikecmpbll: has joined #ruby
[15:16:31] Liothen: has joined #ruby
[15:17:42] Liothen: has joined #ruby
[15:19:44] jinie: has joined #ruby
[15:21:04] tdy: has joined #ruby
[15:21:17] ramfjord: has joined #ruby
[15:22:21] dogweather: has joined #ruby
[15:24:07] cschneid_: has joined #ruby
[15:28:26] chouhoulis: has joined #ruby
[15:29:02] chouhoulis: has joined #ruby
[15:29:11] ciscam: has joined #ruby
[15:32:29] hgost: has joined #ruby
[15:32:32] tomphp: has joined #ruby
[15:33:38] cschneid_: has joined #ruby
[15:33:59] RedNifre: has joined #ruby
[15:37:49] \void: has joined #ruby
[15:37:51] karapetyan: has joined #ruby
[15:39:14] banisterfiend: has joined #ruby
[15:39:21] coriander: has joined #ruby
[15:42:12] roamingdog: has joined #ruby
[15:42:24] tomphp: has joined #ruby
[15:43:27] coriander: Hello! I'm trying to run rspec on Ubuntu 16.04 with ruby 2.3.1, but it gives the message "/usr/bin/env: ‘ruby2.1’: No such file or directory". Any Idea of how I fix this?
[15:43:37] Silthias: has joined #ruby
[15:44:00] guille-moe: has joined #ruby
[15:45:20] banisterfiend: has joined #ruby
[15:46:10] oleo: has joined #ruby
[15:47:41] oleo: has joined #ruby
[15:47:51] banisterfiend: has joined #ruby
[15:48:04] blackmesa: has joined #ruby
[15:49:22] havenwood: coriander: What command are you runnin gto run rspec?
[15:49:43] havenwood: coriander: It sounds like you don't have that command installed, or at least in front of your path, for Ruby 2.3.
[15:51:12] havenwood: coriander: Check the shebang of the command you're running, for example if it's rspec: head -n1 "$(command -v rspec)"
[15:51:20] havenwood: #=> #!/usr/bin/env ruby
[15:51:52] havenwood: coriander: Sanity check which rspec gem you're using: command -v rspec
[15:51:57] havenwood: coriander: gem which rspec
[15:53:21] schleppel: has joined #ruby
[15:53:23] RougeT430: has joined #ruby
[15:54:03] tAn: has joined #ruby
[15:54:23] coriander: command -v rspec: /usr/local/bin/rspec
[15:54:48] coriander: havenwood: command -v rspec: /usr/local/bin/rspec
[15:55:16] havenwood: coriander: and what's the first line of that file?: head -n1 "$(command -v rspec)"
[15:56:21] coriander: heavenwood: it looks empty, it just gives ">" like a prompt
[15:56:42] havenwood: coriander: wierd
[15:56:54] havenwood: coriander: which -a rspec
[15:56:58] havenwood: coriander: how many are there?
[15:57:20] havenwood: coriander: `ruby -v` and `gem -v` are as you'd expect?
[15:57:34] havenwood: coriander: Is rspec installed on the RubyGems you're currently using?
[15:57:35] coriander: heavenwood: which rspec /usr/local/bin/rspec
[15:57:37] havenwood: coriander: gem which rspec
[15:57:45] havenwood: coriander: which -a rspec
[15:57:48] havenwood: coriander: add the -a
[15:58:31] havenwood: coriander: I'm just trying to get at which Rubies have rspec installed. And whether the current rubygems has rspec installed.
[15:58:39] coriander: havenwood: which -a rspec /usr/local/bin/rspec
[15:58:44] havenwood: oh, so just one?
[15:58:54] coriander: havenwood: yeah
[15:58:54] havenwood: coriander: Is this a project with a Gemfile?
[15:59:05] havenwood: coriander: gem install bundler && bundle
[15:59:23] coriander: havenwood: yes it has a gemfile
[15:59:32] havenwood: coriander: Run: gem install bundler && bundle
[15:59:53] havenwood: coriander: (Make sure Bundler is actually installed with the current Ruby, then install the gems in the Gemfile.lock.)
[16:00:08] coriander: havenwood: gem install bundler && bundle ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
[16:00:11] baweaver: apeiros / NL3limin4t0r: Mf does: [hashes].map(&Mf[:a]) - https://github.com/baweaver/mf
[16:00:43] havenwood: coriander: How'd you install Ruby? Does `ruby -v` return the Ruby you're wanting to use?
[16:00:55] GodFather: has joined #ruby
[16:00:59] coriander: havenwood: I think so
[16:01:11] havenwood: coriander: which -a ruby
[16:01:18] havenwood: coriander: what all rubies do you have installed?
[16:01:25] havenwood: coriander: it's odd that the current gem can't find bundler
[16:01:27] coriander: havenwood: I believe I did apt install ruby
[16:01:34] havenwood: coriander: then: sudo gem install bundler
[16:01:48] baweaver: >> class Mf;def self.[](v)->t{t[v]}end;end; [{a: 1}, {a: 2, b: 3}, {c: 4, a: 5}].map(&Mf[:a]) # This is basically how it works
[16:01:50] ruby[bot]: baweaver: # => [1, 2, 5] (https://eval.in/1002257)
[16:01:59] havenwood: coriander: apt does a system RubyGems location by default, so you need sudo
[16:02:01] coriander: havenwood: which -a ruby /usr/bin/ruby
[16:02:18] havenwood: coriander: And?: ruby -v
[16:02:27] havenwood: coriander: how about?: command -v bundle
[16:02:30] baweaver: The trick is in currying the query, so + would be: def self.+(b) -> a { a + b } end
[16:02:46] coriander: havenwood: sudo gem install bundler [sudo] password for coriander: ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
[16:03:15] baweaver: Speaking of, infix operators are fun because they bind _before_ to_proc gets run
[16:03:19] havenwood: coriander: what is your gem source set to?: sudo gem sources
[16:03:24] coriander: havenwood: ruby -v ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
[16:03:34] havenwood: coriander: okay, so that's the Ruby you're meaning to use
[16:03:45] havenwood: coriander: what's the gem source?: sudo gem sources
[16:03:57] havenwood: coriander: It should be: https://rubygems.org/
[16:03:57] coriander: havenwood: command -v bundle /usr/bin/bundle
[16:04:04] baweaver: >> class Mf;def self.+(b)->a {a + b} end;end; [1,2,6,10].map(&Mf + 5) # So you can totally do this
[16:04:05] ruby[bot]: baweaver: # => [6, 7, 11, 15] (https://eval.in/1002258)
[16:04:23] coriander: havenwood: sudo gem sources *** CURRENT SOURCES ***
[16:04:30] eckhardt: has joined #ruby
[16:04:31] havenwood: coriander: then no sources?
[16:04:31] coriander: havenwood: looks empty
[16:04:39] havenwood: coriander: welp, that's why it can't find any gems!
[16:04:54] havenwood: coriander: sudo gem sources --add https://rubygems.org/
[16:05:03] havenwood: coriander: then: sudo gem install bundler
[16:05:39] coriander: sudo gem install bundler ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
[16:05:53] havenwood: coriander: check the source got added?: sudo gem sources
[16:06:25] Asher: has joined #ruby
[16:06:47] havenwood: coriander: You can add the source as an install flag, but I'd for sure get the default working. (How'd it get removed, I wonder?)
[16:07:04] baweaver: apeiros: I may have to grab values_at and other hashy functions for Xf.
[16:07:05] chocoelho: has joined #ruby
[16:07:15] havenwood: coriander: You could also try: sudo gem install bundler --source https://rubygems.org
[16:07:20] havenwood: coriander: but yeah, get the source added
[16:07:27] coriander: havenwood: sudo gem sources --add https://rubygems.org/ seems to hang
[16:07:44] havenwood: coriander: something funky is going on...
[16:08:12] coriander: havenwood: yes
[16:09:24] rouget430__: has joined #ruby
[16:10:18] coriander: havenwood: sudo gem sources --add https://rubygems.org/ Error fetching https://rubygems.org/: timed out (https://api.rubygems.org/specs.4.8.gz)
[16:10:20] mzo: has joined #ruby
[16:11:06] havenwood: coriander: assuming you'll get the same with: sudo gem install bundler --source https://rubygems.org
[16:11:20] havenwood: coriander: does the internet work otherwise?
[16:12:10] coriander: havenwood: I'm having trouble sending email through thunderbird, it might be related
[16:12:19] havenwood: coriander: seems like a networking issue going on
[16:12:54] Silthias: has left #ruby: ()
[16:13:52] coriander: havenwood: do you know where i might go for networking help?
[16:13:57] clemens3: has joined #ruby
[16:14:01] LunEyx: has joined #ruby
[16:18:10] Asher: has joined #ruby
[16:21:26] RougeT430: has joined #ruby
[16:21:45] RougeR: has joined #ruby
[16:22:44] synthroid: has joined #ruby
[16:23:22] Rapture: has joined #ruby
[16:24:41] jcarl43: has joined #ruby
[16:24:50] karapetyan: has joined #ruby
[16:24:56] jinie: has joined #ruby
[16:25:02] coriander: has left #ruby: ()
[16:26:16] alfiemax: has joined #ruby
[16:27:18] Sembei: has joined #ruby
[16:32:37] NL3limin4t0r: has joined #ruby
[16:34:13] banisterfiend: has joined #ruby
[16:35:18] kmurphy4: has joined #ruby
[16:41:32] RedNifre: has joined #ruby
[16:44:01] ramfjord: has joined #ruby
[16:44:29] emilford: has joined #ruby
[16:48:27] variable: has joined #ruby
[16:49:08] Sonar1: has joined #ruby
[16:54:24] banisterfiend: has joined #ruby
[16:55:30] mohsen_1: has joined #ruby
[16:57:01] piixal: has joined #ruby
[16:57:16] Lytol: has joined #ruby
[16:57:43] orbyt_: has joined #ruby
[16:59:34] tomphp: has joined #ruby
[17:00:40] eckhardt: has joined #ruby
[17:02:33] raynold: has joined #ruby
[17:04:15] emilford: has joined #ruby
[17:05:30] RougeT430: has joined #ruby
[17:05:44] ciscam: has joined #ruby
[17:07:35] amatas: has joined #ruby
[17:13:34] amar: has joined #ruby
[17:15:59] kirun: has joined #ruby
[17:16:11] nima_m: has joined #ruby
[17:17:20] emilford: has joined #ruby
[17:19:24] alfiemax: has joined #ruby
[17:21:50] dcunit3d: has joined #ruby
[17:22:31] dogweather: has joined #ruby
[17:22:39] dionysus69: has joined #ruby
[17:27:31] n0m4d1c: has joined #ruby
[17:33:06] mikecmpbll: has joined #ruby
[17:36:02] blackmesa: has joined #ruby
[17:38:19] Cavallari: has joined #ruby
[17:43:05] TomyLobo: there's attr_accessor to save me writing accessors. is there something to save me writing a constructor that just fills all the fields from parameters?
[17:44:03] dogweather: has joined #ruby
[17:46:29] anisha_: has joined #ruby
[17:50:06] dminuoso: TomyLobo: There's Struct
[17:50:36] dminuoso: >> a = Struct.new(:name, age); a.new("Isaac Newton", 21)
[17:50:37] ruby[bot]: dminuoso: # => undefined local variable or method `age' for main:Object (NameError) ...check link for more (https://eval.in/1002282)
[17:50:41] dminuoso: >> a = Struct.new(:name, :age); a.new("Isaac Newton", 21)
[17:50:42] ruby[bot]: dminuoso: # => #<struct name="Isaac Newton", age=21> (https://eval.in/1002283)
[17:50:46] emilford: has joined #ruby
[17:53:11] Janky: has joined #ruby
[17:53:19] postmodern: has joined #ruby
[17:55:34] ramfjord: has joined #ruby
[17:55:51] dcunit3d: has joined #ruby
[17:58:49] synthroid: has joined #ruby
[17:59:29] skweek: has joined #ruby
[18:01:57] TomyLobo: dminuoso, i did want my own methods though ^^
[18:02:35] TomyLobo: and yeah i know i can hack those in as well, but i was hoping for something like "attr_constructor :name, :age"
[18:03:38] ldepandis: has joined #ruby
[18:06:12] dminuoso: TomyLobo: Huh?
[18:06:27] dminuoso: TomyLobo: Struct.new(:name, :age) do def some_method; blah; end; end;
[18:06:40] Zaab1t1: has joined #ruby
[18:06:59] dminuoso: TomyLobo: But if you really want an attr_constructor, you could also write that.
[18:08:56] TomyLobo: ah i see. this is for a tiny script though and i really want less code, not more :)
[18:10:21] dminuoso: TomyLobo: https://eval.in/1002285
[18:10:24] dminuoso: Struct is perfect for you then.
[18:10:50] sameerynho: has joined #ruby
[18:11:21] jinie: has joined #ruby
[18:13:05] TomyLobo: >>> (LB=Struct.new(:id)).new.class
[18:13:14] TomyLobo: >> (LB=Struct.new(:id)).new.class
[18:13:15] ruby[bot]: TomyLobo: # => LB (https://eval.in/1002288)
[18:13:23] TomyLobo: ok how does it know it's LB?
[18:15:57] dminuoso: >> A = Struct.new(:a); A.method(:new).owner
[18:15:58] ruby[bot]: dminuoso: # => #<Class:A> (https://eval.in/1002289)
[18:15:58] donofrio_: has joined #ruby
[18:16:05] cliq: has joined #ruby
[18:16:28] dminuoso: asm>> class Foo; end
[18:16:29] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002290
[18:16:32] dminuoso: asm>> Foo = Class.new
[18:16:33] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002291
[18:16:42] NL_3limin4t0r: has joined #ruby
[18:17:01] ciscam_: has joined #ruby
[18:17:06] TomyLobo: asm>> A = Struct.new(:a)
[18:17:07] ruby[bot]: TomyLobo: I have disassembled your code, the result is at https://eval.in/1002292
[18:17:19] dminuoso: TomyLobo: That wont help. Struct is deeply C magical.
[18:17:31] sepp2k1: has joined #ruby
[18:17:31] Asher: has joined #ruby
[18:17:50] dminuoso: I dont know.
[18:18:20] TomyLobo: >> (AAA=BBB=Struct.new(:id)).new.class
[18:18:21] ruby[bot]: TomyLobo: # => BBB (https://eval.in/1002294)
[18:18:40] TomyLobo: >> puts (AAA=BBB=Struct.new(:id)).new.class; puts AAA.new.class
[18:18:41] ruby[bot]: TomyLobo: # => BBB ...check link for more (https://eval.in/1002296)
[18:18:41] mostly-harmless: has joined #ruby
[18:18:44] RedNifre: has joined #ruby
[18:19:03] dminuoso: Actually let me take that back what I just said
[18:19:09] RougeT430: has joined #ruby
[18:19:12] dminuoso: asm >> (AAA=BBB=Struct.new(:a)
[18:19:14] dminuoso: asm>> (AAA=BBB=Struct.new(:a)
[18:19:15] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002297
[18:19:17] apeiros: TomyLobo: there are a couple of gems which do what you ask for
[18:19:20] skweek: has joined #ruby
[18:19:23] dminuoso: asm>> AAA=BBB=Struct.new(:a)
[18:19:24] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002298
[18:19:26] apeiros: iirc one's name was fattr
[18:19:28] volix: has joined #ruby
[18:19:40] lucasb: has joined #ruby
[18:19:56] apeiros: ah, right: https://github.com/ahoward/fattr
[18:19:59] TomyLobo: >> puts def foo(x) x.new.class end; foo(Struct.new(:id)).new.class
[18:20:00] ruby[bot]: TomyLobo: # => foo ...check link for more (https://eval.in/1002299)
[18:20:21] TomyLobo: heh, i broke it
[18:20:26] sunya7a: has joined #ruby
[18:21:05] dminuoso: TomyLobo: Well it's the usual Ruby hacks
[18:21:28] tris: has joined #ruby
[18:21:30] sammi`: has joined #ruby
[18:21:32] eblip: has joined #ruby
[18:21:32] dminuoso: TomyLobo: My best guess is some japanese developer thought it would be cool if classes inspected in some intuitive fashion.
[18:21:36] dminuoso: And did some hacks
[18:24:36] alex``: has joined #ruby
[18:24:50] emilford: has joined #ruby
[18:26:55] tAn: has joined #ruby
[18:34:55] dcunit3d: has joined #ruby
[18:35:13] havenwood: TomyLobo: With 2.5.1 you can also do keyword argument structs. Coupling by name is often nicer than by position.
[18:35:38] alfiemax_: has joined #ruby
[18:36:01] havenwood: TomyLobo: Here's an example: https://gist.github.com/havenwood/4bf28bbb06f601e7013cefb13f6ab455
[18:36:11] havenwood: You just add the: keyword_init: true
[18:36:22] apeiros: anything beyond 2 arguments should be by name. and often even already with 2.
[18:37:16] apeiros: and sometimes even the first already - or would you for example know what the false means in some_obj.methods(false)? (and that's a ruby core method)
[18:37:55] havenwood: apeiros: i totally agree - if it's not clear what the one-and-only argument is, a name is far preferable
[18:38:18] havenwood: some_obj.methods private_only: true
[18:38:20] havenwood: so much better
[18:39:03] havenwood: it's easier to write code than to read it
[18:40:40] apeiros: but I have to admit, I have to force myself too to do it properly
[18:41:13] havenwood: aye, pre-kwarg habits are hard to break for me too
[18:41:18] apeiros: but true keyword args made it a lot more bearbale to me
[18:41:21] havenwood: i have to keep reminding myself
[18:44:08] apeiros: ACTION goes back to js without either kwargs, nor even syntax sugar for hashmap passing - and even less so block passing *sob*
[18:44:24] apeiros: js syntax, sooo tedious. at least they've ... and ()=>{} now.
[18:44:41] BTRE: has joined #ruby
[18:44:47] psychicist__: has joined #ruby
[18:44:55] apeiros: biggest fuckup though is "assign without explicit scope? you've got a global now, yaaaay!"
[18:51:33] pilne: has joined #ruby
[18:57:33] kmurphy4: has joined #ruby
[18:58:40] facest: has joined #ruby
[19:03:13] minimalism: has joined #ruby
[19:04:21] dminuoso: havenwood: Ultimately the real problem is lack of a type system.
[19:09:02] kapil___: has joined #ruby
[19:15:23] bmurt: has joined #ruby
[19:16:06] eckhardt: has joined #ruby
[19:22:32] emilford: has joined #ruby
[19:24:22] eikobear: has joined #ruby
[19:24:49] tomphp: has joined #ruby
[19:25:59] MzrE: has joined #ruby
[19:26:14] mostlybadfly: has joined #ruby
[19:28:36] kmurphy4: has joined #ruby
[19:30:17] chouhoul_: has joined #ruby
[19:30:25] TomyLobo: havenwood, interesting, but cant Struct just generate both?
[19:31:30] TomyLobo: possibly a performance thing ^^
[19:34:49] RougeR: has joined #ruby
[19:35:27] apeiros: TomyLobo: you mean at the same time?
[19:35:56] apeiros: that'd be a problem since how'd you distinguish between the first argument being a hash, or them being keyword args?
[19:36:04] tomphp: has joined #ruby
[19:36:30] TomyLobo: uh isnt that what **kwargs is for or am i confusing that with python now?
[19:36:33] TomyLobo: i probably am
[19:36:39] apeiros: that does not help
[19:37:02] apeiros: due to the very sad decision that foo(bar: 1, baz: 2) is a syntactical equivalent to foo({bar: 1, baz: 2})
[19:37:36] apeiros: ruby can literally not distinguish your intention in this case.
[19:37:44] TomyLobo: i think that's called cutting yourself with occams razor
[19:38:00] apeiros: I think it was just a terrible choice.
[19:38:35] apeiros: intended as a stop-gap, not realizing how it'd backfire (or rather limit disambiguity) in the future.
[19:38:43] jottr: has joined #ruby
[19:38:49] apeiros: *limit ambiguity
[19:39:08] n0m4d1c: has joined #ruby
[19:40:12] Mike11: has joined #ruby
[19:43:14] n0m4d1c: has joined #ruby
[19:46:13] roamingdog: has joined #ruby
[19:51:21] alfiemax: has joined #ruby
[19:51:55] alfiemax: has joined #ruby
[19:59:04] nofxx: has joined #ruby
[20:00:14] chmurifree: has joined #ruby
[20:06:24] alfiemax: has joined #ruby
[20:07:50] n0m4d1c_: has joined #ruby
[20:10:35] dminuoso: asm>> foo(bar: 1, baz: 2)
[20:10:36] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002362
[20:10:40] dminuoso: asm>> foo({bar: 1, baz: 2})
[20:10:51] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1002363
[20:12:40] apeiros: dminuoso: does it match your expectation?
[20:12:48] dminuoso: I had none to begin with
[20:13:29] chouhoulis: has joined #ruby
[20:20:40] jrafanie: has joined #ruby
[20:30:55] dviola: has joined #ruby
[20:32:23] tomphp: has joined #ruby
[20:36:37] Guest27: has joined #ruby
[20:38:13] chongtxtx: has joined #ruby
[20:40:36] claw: hello i am having encoding fun on windows
[20:41:08] claw: irb(main):001:0> `echo öööööö`
[20:41:08] claw: => "\x94\x94\x94\x94\x94\x94\n"
[20:41:27] claw: chcp for cmd is CP850
[20:42:01] claw: Encoding.default_external is also CP850
[20:42:59] dminuoso: claw: default_external is irrelevant here
[20:43:41] apeiros: dminuoso: um, no, it's not
[20:43:56] apeiros: ``.encoding will be cp850 due to default_external
[20:44:12] apeiros: anyway, I'll wait for the actual question :)
[20:44:56] claw: apeiros: the actual question is how to get the "ö" back into irb
[20:45:14] apeiros: claw: that depends. what encoding does your terminal application use?
[20:45:29] claw: CP850 as `chcp` says
[20:45:37] dminuoso: apeiros: What about __ENCODING__ ?
[20:45:46] apeiros: claw: try puts
[20:45:54] apeiros: as in: puts `echo ööööö`
[20:46:12] claw: __ENCODING__ == CP850
[20:47:10] claw: apeiros: well puts works somehow
[20:47:26] apeiros: claw: what you're looking at is String#inspect
[20:47:28] apeiros: I'm not quite sure on String#inspect's decision making on when to print bytes as hex escape sequences and when as their actual value. puts however will always print the value
[20:47:57] claw: nicht if i do `echo öööö > file` ; puts File.read("./file") its broken again
[20:48:04] apeiros: apparently with your current setting, it decides that \x94 (ö) is not (or may not be) a printable character and hence shows its escape sequence instead.
[20:48:04] claw: *nicht=now
[20:48:10] arup_r: has joined #ruby
[20:48:37] apeiros: what's Encoding.default_internal ?
[20:48:56] apeiros: also, what's File.read("file").encoding ?
[20:49:43] apeiros: and last but not least "broken" is not a usable description. what happens?
[20:51:46] apeiros: (I'll refrain from asking why on earth you're using anything but a unicode encoding like utf-8)
[20:52:54] claw: i think i've catched the problem
[20:52:54] claw: its powershell
[20:53:07] chouhoulis: has joined #ruby
[20:53:53] veex: has joined #ruby
[20:54:11] chouhoul_: has joined #ruby
[20:55:24] chouhoul_: has joined #ruby
[20:56:09] tAn: has joined #ruby
[20:56:24] chouhoul_: has joined #ruby
[20:56:50] orbyt_: has joined #ruby
[20:57:01] claw: also cmd. if i echo directly from cmd and the read from irb it gets messed up. when i echo from irb it works
[20:57:26] chouhoul_: has joined #ruby
[20:58:32] chouhoulis: has joined #ruby
[20:59:42] chouhoul_: has joined #ruby
[21:00:45] chouhoul_: has joined #ruby
[21:00:50] mondongo: has joined #ruby
[21:01:46] chouhoul_: has joined #ruby
[21:03:00] chouhoul_: has joined #ruby
[21:04:03] ruby[bot]: -bb hph^!*@*$#ruby-fix-your-connection *!*@ip72-195-187-57.mc.at.cox.net$#ruby-fix-your-connection
[21:04:12] chouhoulis: has joined #ruby
[21:05:27] chouhoul_: has joined #ruby
[21:06:20] chouhoul_: has joined #ruby
[21:07:15] SeepingN: has joined #ruby
[21:07:24] chouhoul_: has joined #ruby
[21:08:33] chouhoul_: has joined #ruby
[21:09:10] _aeris_: has joined #ruby
[21:09:41] chouhoulis: has joined #ruby
[21:10:40] chouhoul_: has joined #ruby
[21:11:48] chouhoul_: has joined #ruby
[21:12:55] chouhoul_: has joined #ruby
[21:13:49] jenrzzz: has joined #ruby
[21:14:25] chouhoulis: has joined #ruby
[21:15:14] chouhoul_: has joined #ruby
[21:16:14] karapetyan: has joined #ruby
[21:16:18] chouhoul_: has joined #ruby
[21:16:51] clemens3_: has joined #ruby
[21:17:42] dogweather: has joined #ruby
[21:18:01] coderphive: has joined #ruby
[21:18:30] chouhoul_: has joined #ruby
[21:19:31] chouhoulis: has joined #ruby
[21:20:42] chouhoul_: has joined #ruby
[21:21:18] eikobear: has joined #ruby
[21:21:52] chouhoul_: has joined #ruby
[21:22:00] cagomez: has joined #ruby
[21:22:20] kapil___: has joined #ruby
[21:22:52] chouhoul_: has joined #ruby
[21:24:02] chouhoul_: has joined #ruby
[21:25:16] chouhoulis: has joined #ruby
[21:26:31] chouhoul_: has joined #ruby
[21:27:23] chouhoul_: has joined #ruby
[21:28:46] chouhoul_: has joined #ruby
[21:29:32] chouhoul_: has joined #ruby
[21:30:42] chouhoulis: has joined #ruby
[21:31:41] blackmesa: has joined #ruby
[21:31:51] chouhoul_: has joined #ruby
[21:32:51] amar: has joined #ruby
[21:32:58] chouhoul_: has joined #ruby
[21:33:46] bmurt: has joined #ruby
[21:34:21] chouhoul_: has joined #ruby
[21:35:08] chouhoul_: has joined #ruby
[21:36:22] chouhoulis: has joined #ruby
[21:36:29] TinkerT: has joined #ruby
[21:37:36] chouhoul_: has joined #ruby
[21:38:36] dogweather: has joined #ruby
[21:38:37] chouhoul_: has joined #ruby
[21:39:42] chouhoul_: has joined #ruby
[21:40:39] chouhoul_: has joined #ruby
[21:41:41] chouhoulis: has joined #ruby
[21:42:56] chouhoul_: has joined #ruby
[21:44:07] chouhoul_: has joined #ruby
[21:45:08] chouhoul_: has joined #ruby
[21:46:18] chouhoul_: has joined #ruby
[21:46:31] twe4ked: has joined #ruby
[21:47:28] chouhoulis: has joined #ruby
[21:47:35] BTRE: has joined #ruby
[21:48:29] chouhoul_: has joined #ruby
[21:49:26] RougeR: has joined #ruby
[21:49:39] chouhoul_: has joined #ruby
[21:50:42] chouhoul_: has joined #ruby
[21:51:53] chouhoul_: has joined #ruby
[21:51:59] cliq: has joined #ruby
[21:52:48] chouhoulis: has joined #ruby
[21:53:58] chouhoul_: has joined #ruby
[21:54:58] chouhoul_: has joined #ruby
[21:56:08] chouhoul_: has joined #ruby
[21:57:14] chouhoul_: has joined #ruby
[21:58:21] chouhoulis: has joined #ruby
[21:58:23] ellcs: has joined #ruby
[21:59:24] chouhoul_: has joined #ruby
[21:59:41] dipnlik: has joined #ruby
[22:10:49] ramfjord: has joined #ruby
[22:11:46] GodFather: has joined #ruby
[22:13:12] ur5us: has joined #ruby
[22:14:35] twe4ked: has joined #ruby
[22:18:55] tAn: has joined #ruby
[22:20:54] karapetyan: has joined #ruby
[22:23:11] karapetyan: has joined #ruby
[22:26:58] cagomez: has joined #ruby
[22:29:44] alfiemax: has joined #ruby
[22:36:20] dogweather: has joined #ruby
[22:41:39] Tempesta_: has joined #ruby
[22:41:44] apeiros__: has joined #ruby
[22:41:45] AJA4351: has joined #ruby
[22:43:18] alfiemax_: has joined #ruby
[22:43:19] blackmesa1: has joined #ruby
[22:43:37] Sembei: has joined #ruby
[22:43:55] armando: has joined #ruby
[22:45:02] ohcibi: has joined #ruby
[22:45:27] spiette: has joined #ruby
[22:46:42] VladGh: has joined #ruby
[22:50:11] clemens3: has joined #ruby
[22:50:13] SeepingN: has joined #ruby
[22:50:14] regedit: has joined #ruby
[22:50:46] phoo1234567: has joined #ruby
[22:51:06] nibbo: has joined #ruby
[22:51:52] octomancer: has joined #ruby
[23:03:52] mostlybadfly: has joined #ruby
[23:07:22] jenrzzz_: has joined #ruby
[23:12:13] aaronm04: has joined #ruby
[23:13:02] pb122: has joined #ruby
[23:13:12] n0m4d1c: has joined #ruby
[23:13:22] cagomez: has joined #ruby
[23:15:13] n0m4d1c_: has joined #ruby
[23:18:51] karapetyan: has joined #ruby
[23:26:48] sonne: has joined #ruby
[23:27:48] cschneid_: has joined #ruby
[23:34:42] n0m4d1c: has joined #ruby
[23:35:04] ciscam: has joined #ruby
[23:35:39] c_my_nick: has joined #ruby
[23:37:46] amar: has joined #ruby
[23:39:47] MyMind: has joined #ruby
[23:40:06] duderonomy: has joined #ruby
[23:43:15] c_my_nick: does anyone know if there a plugin for rails similar to this one for django? https://github.com/groveco/django-sql-explorer
[23:43:19] c_my_nick: ive got someone claiming such a plugin exists in one of our legacy applications and i am looking for a place to start
[23:45:24] audy: c_my_nick: blazer
[23:45:30] audy: https://github.com/ankane/blazer
[23:45:34] audy: I love it. It's one of my favorite gems
[23:45:58] c_my_nick: thanks, know of any others?
[23:46:10] audy: c_my_nick: heroku has dataclips
[23:46:14] audy: those are the only ones I know of
[23:46:41] c_my_nick: hm, dont see either of those referenced in the repo...
[23:46:50] audy: c_my_nick: what about config/routes.rb ?
[23:47:16] audy: hmm maybe they're running blazer separately
[23:47:41] dogweather: has joined #ruby
[23:48:47] anjen: has joined #ruby
[23:49:46] c_my_nick: would dataclips be referenced within the application code, though?
[23:50:05] zautomata: has joined #ruby
[23:51:57] amar: has joined #ruby
[23:53:20] gil_: has joined #ruby
[23:53:20] gil_: has joined #ruby
[23:54:18] n0m4d1c: has joined #ruby
[23:56:42] audy: c_my_nick: no that's part of heroku
[23:56:54] c_my_nick: ok, thats what i thought