« Back to channel list

#ruby - 05 August 2017

« Back 1 day Forward 1 day »
[00:00:50] ragnar: am I doing something wrong here or does it just take a few minutes to get replies?
[00:01:55] SeepingN: try a few hours, some times
[00:02:36] SeepingN: it's hard to prepend data to a file. I imagine you always have to rewrite everything. or the filesystem itself might.
[00:07:39] digitalnomad: has joined #ruby
[00:08:41] kies: has joined #ruby
[00:10:17] hutch34: has joined #ruby
[00:10:46] impermanence: has joined #ruby
[00:24:04] t00r: has joined #ruby
[00:24:57] t00r: Hey guys! I'm new in ruby and I'm trying to parse a json to a array without success here
[00:25:52] t00r: here is the code: https://pastebin.com/d26rW4c7
[00:25:54] ruby[bot]: t00r: we in #ruby do not like pastebin.com, I reposted your paste to gist for you: https://gist.github.com/b9b66d8c91f2991c5b8931d057d2ef41
[00:25:56] ruby[bot]: t00r: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
[00:27:55] cadillac_: has joined #ruby
[00:28:14] nopolitica: has joined #ruby
[00:28:41] havenwood: t00r: Are you getting?: {"error"=>"Out of memory"}
[00:29:24] havenwood: t00r: hash == {"error"=>"Out of memory"} #=> true
[00:29:32] t00r: havenwood: nope, I got the data as well, but I can format to use the values one by one
[00:29:45] havenwood: t00r: What is the value of `hash` when you run the code you linked?
[00:30:14] t00r: I you paste it on paste bin one second please
[00:31:16] t00r: https://pastebin.com/uqXXtdmJ here
[00:31:17] ruby[bot]: t00r: as I told you already, please use https://gist.github.com
[00:31:53] havenwood: t00r: I take it that's the value of `response` not `hash` then?
[00:31:53] ResidentBiscuit: has joined #ruby
[00:32:14] t00r: I would like to use each value individually
[00:32:26] acalycine: has joined #ruby
[00:32:39] t00r: havenwood: I think so
[00:32:51] havenwood: t00r: Look at the value of `hash` in the code you're running.
[00:32:55] havenwood: t00r: p hash
[00:33:24] havenwood: t00r: Look at `hash.keys` and see what the keys are.
[00:33:42] jenrzzz: has joined #ruby
[00:33:42] jenrzzz: has joined #ruby
[00:33:43] havenwood: t00r: Look at `hash.values` if you don't care about hte keys.
[00:34:10] havenwood: t00r: If you show us what `hash` is and what you want, I'm sure we can show you some solutions.
[00:34:28] t00r: havenwood: hash.values Out of memory
[00:34:54] havenwood: t00r: Is `hash` then?: {"error"=>"Out of memory"}
[00:35:21] t00r: Sorry if I could not be clear :)
[00:36:12] t00r: havenwood: My problem is this, I can return a messy array. I'd like to know how I can have key and value separately
[00:36:53] t00r: havenwood: I'm not a native english speaker and my english is a work in progress (-_-)'
[00:37:52] t00r: havenwood: but that last link that I send have the messy array that I got here
[00:40:02] cagomez: has joined #ruby
[00:41:34] gusrub: has joined #ruby
[00:47:44] beauby: has joined #ruby
[00:53:11] impermanence: has joined #ruby
[00:53:14] dviola: has joined #ruby
[00:53:26] nowhere_man: has joined #ruby
[00:54:18] impermanence: arr.sort_by(&:some_attribute) some_attribute are Integers. Is there an idiomatic way to make the order descending?
[00:54:25] yabbes: has joined #ruby
[00:54:36] impermanence: I tried *-1 but no love
[00:55:02] impermanence: and reverse is not right
[01:02:42] HoierM: has joined #ruby
[01:08:09] jenrzzz_: has joined #ruby
[01:10:54] howdoi: has joined #ruby
[01:17:19] hutch34: has joined #ruby
[01:17:48] domgetter: has joined #ruby
[01:21:24] beauby: has joined #ruby
[01:21:57] digitalnomad: has joined #ruby
[01:23:28] ResidentBiscuit: has joined #ruby
[01:24:29] Mon_Ouie: has joined #ruby
[01:27:02] SeepingN_: has joined #ruby
[01:29:23] bruno-: has joined #ruby
[01:30:19] gizmore|2: has joined #ruby
[01:33:11] acalycine: has joined #ruby
[01:33:11] acalycine: has joined #ruby
[01:38:53] acalycine: has joined #ruby
[01:38:53] acalycine: has joined #ruby
[01:40:00] jackjackdripper: has joined #ruby
[01:43:07] Bock: has joined #ruby
[01:51:11] __Yiota: has joined #ruby
[01:56:45] Dimik: has joined #ruby
[01:57:30] GinoMan: has joined #ruby
[01:58:15] ecuanaso: has joined #ruby
[02:00:10] hkdsun: has joined #ruby
[02:01:08] jenrzzz: has joined #ruby
[02:01:53] mim1k: has joined #ruby
[02:02:07] hutch34: has joined #ruby
[02:04:52] __Yiota: has joined #ruby
[02:08:04] duderonomy: has joined #ruby
[02:08:58] tacoboy: has joined #ruby
[02:09:48] FahmeF: has joined #ruby
[02:19:56] beauby: has joined #ruby
[02:21:57] ramfjord: has joined #ruby
[02:33:32] ecuanaso: has joined #ruby
[02:37:46] bmurt: has joined #ruby
[02:39:01] maryo: has joined #ruby
[02:49:20] apparition47: has joined #ruby
[02:58:48] ecuanaso: has joined #ruby
[03:00:09] cadillac_: has joined #ruby
[03:14:27] cahoots: has joined #ruby
[03:24:39] jphase: has joined #ruby
[03:42:48] opekktar: has joined #ruby
[03:46:33] dviola: has joined #ruby
[03:46:39] ShekharReddy: has joined #ruby
[03:47:28] gix: has joined #ruby
[03:47:30] charliesome: has joined #ruby
[03:47:55] kculpis: has joined #ruby
[03:51:11] knight33: has joined #ruby
[03:52:13] robnester: has joined #ruby
[04:02:26] mim1k: has joined #ruby
[04:02:27] opekktar_: has joined #ruby
[04:03:08] segy_: has joined #ruby
[04:07:00] segy: has joined #ruby
[04:11:46] segy_: has joined #ruby
[04:19:46] opekktar: has joined #ruby
[04:19:47] digitalnomad: has joined #ruby
[04:24:45] opekktar: has joined #ruby
[04:30:19] mtkd: has joined #ruby
[04:34:03] go|dfish: has joined #ruby
[04:40:33] dcunit3d: has joined #ruby
[04:47:29] jphase: has joined #ruby
[04:52:26] __Yiota: has joined #ruby
[04:58:10] icarus: has joined #ruby
[05:03:12] icarus: has joined #ruby
[05:10:24] beauby: has joined #ruby
[05:14:00] bambanx: has joined #ruby
[05:14:30] chimkan: has joined #ruby
[05:14:58] pootiscoder: has joined #ruby
[05:17:19] charliesome: has joined #ruby
[05:27:28] Silthias: has joined #ruby
[05:28:58] chimkan: has joined #ruby
[05:31:21] jenrzzz: has joined #ruby
[05:31:21] jenrzzz: has joined #ruby
[05:35:01] djbkd: has joined #ruby
[05:37:29] cagomez: has joined #ruby
[05:37:53] vuoto: has joined #ruby
[05:48:46] jenrzzz: has joined #ruby
[05:48:46] jenrzzz: has joined #ruby
[05:49:36] dcunit3d: has joined #ruby
[05:54:27] ahrs: has joined #ruby
[05:56:58] icarus: has joined #ruby
[06:01:55] TomyLobo3: has joined #ruby
[06:01:56] jackjackdripper: has joined #ruby
[06:02:52] mim1k: has joined #ruby
[06:06:54] nicolai86: has joined #ruby
[06:13:34] jphase: has joined #ruby
[06:14:27] maryo: has joined #ruby
[06:14:57] alex``: has joined #ruby
[06:17:10] KeyJoo: has joined #ruby
[06:20:55] opekktar: has joined #ruby
[06:28:53] dcunit3d: has joined #ruby
[06:29:04] chmurifree: has joined #ruby
[06:30:40] vuoto: has joined #ruby
[06:34:57] zacts: has joined #ruby
[06:37:01] djbkd: has joined #ruby
[06:54:27] mabus44: has joined #ruby
[06:56:01] beauby: has joined #ruby
[06:56:11] jphase: has joined #ruby
[07:06:37] ramfjord: has joined #ruby
[07:09:28] noe: has joined #ruby
[07:13:32] vuoto: has joined #ruby
[07:15:02] govg: has joined #ruby
[07:16:16] Silthias1: has joined #ruby
[07:16:26] yabbes: has joined #ruby
[07:20:51] gusrub: has joined #ruby
[07:22:05] ramfjord: has joined #ruby
[07:30:13] _whitelogger: has joined #ruby
[07:37:34] ramfjord: has joined #ruby
[07:37:59] ltem: has joined #ruby
[07:39:10] maryo: has joined #ruby
[07:40:27] acalycine: has joined #ruby
[07:40:27] acalycine: has joined #ruby
[07:42:02] allisio: has joined #ruby
[07:42:53] nofxxx: has joined #ruby
[07:48:43] impermanence: has joined #ruby
[07:52:47] moei: has joined #ruby
[07:53:04] ramfjord: has joined #ruby
[07:53:20] cagomez: has joined #ruby
[07:54:07] bb010g_: has joined #ruby
[07:56:46] beauby: has joined #ruby
[07:58:42] Silthias: has joined #ruby
[08:03:25] mim1k: has joined #ruby
[08:07:37] noe: has joined #ruby
[08:07:59] rabajaj: has joined #ruby
[08:08:29] ramfjord: has joined #ruby
[08:09:01] impermanence: has joined #ruby
[08:18:12] _whitelogger: has joined #ruby
[08:18:44] opekktar: has left #ruby: ()
[08:24:01] ramfjord: has joined #ruby
[08:24:22] inkky[m]: has joined #ruby
[08:27:27] hutch34: has joined #ruby
[08:27:41] InfinityFye: has joined #ruby
[08:28:16] impermanence: has joined #ruby
[08:28:19] rivalomega: has joined #ruby
[08:29:31] sspreitz: has joined #ruby
[08:30:59] marr123: has joined #ruby
[08:34:29] MasterAsia: has joined #ruby
[08:34:39] MasterAsia: To find days since a model has been created in rails
[08:34:53] MasterAsia: I'm doing (Date.today - created_at.to_date).to_i
[08:35:11] MasterAsia: why is the to_date necessary for created_at?
[08:35:23] MasterAsia: it is a datetime according to my schema
[08:35:35] MasterAsia: but gets instantiated as a activesupport:timewithzone class
[08:36:51] pygospa: has joined #ruby
[08:39:30] ramfjord: has joined #ruby
[08:43:25] Ryzokuken: has joined #ruby
[08:43:36] yxhuvud: please go to #rubyonrails for rails related questions.
[08:44:18] dcunit3d: has joined #ruby
[08:44:24] jinie_: has joined #ruby
[08:45:47] FahmeF: has joined #ruby
[08:48:01] moeabdol: has joined #ruby
[08:48:14] pootiscoder: has joined #ruby
[08:48:48] impermanence: has joined #ruby
[08:50:25] pootiscoder: has joined #ruby
[08:52:26] beauby: has joined #ruby
[08:54:57] ramfjord: has joined #ruby
[08:57:06] lele: has joined #ruby
[09:02:31] mim1k: has joined #ruby
[09:03:20] lxsameer: has joined #ruby
[09:09:36] yabbes: has joined #ruby
[09:10:24] ramfjord: has joined #ruby
[09:11:34] pootiscoder: has joined #ruby
[09:12:05] vuoto: has joined #ruby
[09:16:42] foooobear: has joined #ruby
[09:18:56] dionysus69: has joined #ruby
[09:22:05] pabs: has joined #ruby
[09:22:31] anisha: has joined #ruby
[09:25:50] ramfjord: has joined #ruby
[09:38:57] dcunit3d: has joined #ruby
[09:40:57] opekktar: has joined #ruby
[09:41:15] high_fiver: has joined #ruby
[09:41:17] ramfjord: has joined #ruby
[09:52:51] WeiJunLi: has joined #ruby
[09:56:36] mjolnird: has joined #ruby
[09:56:46] ramfjord: has joined #ruby
[09:57:01] pygospa: has joined #ruby
[09:57:40] cagomez: has joined #ruby
[10:06:07] bb010g_: has joined #ruby
[10:12:26] ramfjord: has joined #ruby
[10:47:18] conta: has joined #ruby
[10:47:29] Tempesta: has joined #ruby
[10:49:16] Tempesta: has joined #ruby
[10:57:14] cveron: has joined #ruby
[10:58:11] MarkBilk: has joined #ruby
[10:59:50] cagomez: has joined #ruby
[11:00:31] Emmanuel_Chanel: has joined #ruby
[11:04:00] BTRE: has joined #ruby
[11:06:45] rgr: has joined #ruby
[11:08:48] beauby: has joined #ruby
[11:09:51] impermanence: has joined #ruby
[11:21:05] __Yiota: has joined #ruby
[11:22:19] ramfjord: has joined #ruby
[11:25:31] impermanence: has joined #ruby
[11:36:13] _whitelogger: has joined #ruby
[11:40:51] skdjas: has joined #ruby
[11:41:09] domgetter: has joined #ruby
[11:42:41] dlitvak: has joined #ruby
[11:43:28] acalycine: has joined #ruby
[11:43:28] acalycine: has joined #ruby
[11:45:55] impermanence: has joined #ruby
[11:48:43] ctp: has joined #ruby
[11:57:01] Emmanuel_Chanel: has joined #ruby
[11:57:54] selim: has joined #ruby
[12:01:32] impermanence: has joined #ruby
[12:03:08] alex``: has joined #ruby
[12:04:08] mabus44: has joined #ruby
[12:14:40] phinxy: has joined #ruby
[12:19:25] kahra: has joined #ruby
[12:21:51] t-recx: has joined #ruby
[12:21:57] impermanence: has joined #ruby
[12:24:47] mim1k: has joined #ruby
[12:27:58] hutch34: has joined #ruby
[12:30:12] cadillac_: has joined #ruby
[12:31:17] beauby: has joined #ruby
[12:32:43] nowhere_man: has joined #ruby
[12:33:32] melkor: has joined #ruby
[12:34:23] melkor: I am trying to build ruby2.3.4 and when I run make, it says that prefix is /usr, but I ran ./configure --prefix=/path/to/where/I/want
[12:34:52] charliesome: has joined #ruby
[12:35:47] evie_hammond: has joined #ruby
[12:37:34] impermanence: has joined #ruby
[12:38:54] melkor: odd, it worked finally. Not sure what I did differently.
[12:42:51] kahra: has joined #ruby
[12:42:55] HoierM: has joined #ruby
[12:55:21] apparition47: has joined #ruby
[12:56:49] glaux: has joined #ruby
[12:57:57] impermanence: has joined #ruby
[12:58:56] glaux: has left #ruby: ()
[12:59:10] glaux: has joined #ruby
[13:00:34] seybo: has joined #ruby
[13:03:34] moeabdol: has joined #ruby
[13:04:07] moeabdol: has left #ruby: ()
[13:13:35] impermanence: has joined #ruby
[13:21:34] gr33n7007h: has joined #ruby
[13:28:37] Ryzokuken: has joined #ruby
[13:32:08] andrzejku: has joined #ruby
[13:33:53] melkor: It appears my vps doesn't have enough memory to run ./passenger-install-apache2-module. Is there anything I can do?
[13:33:59] impermanence: has joined #ruby
[13:36:53] bmurt: has joined #ruby
[13:43:31] beauby: has joined #ruby
[13:43:40] digitalnomad: has joined #ruby
[13:57:10] _whitelogger: has joined #ruby
[13:57:27] _sfiguser: has joined #ruby
[13:58:09] segy: has joined #ruby
[13:59:21] darix: melkor: you are sure it can run your app under passenger afterwards?
[14:01:34] faraco: has joined #ruby
[14:01:39] bruno-: has joined #ruby
[14:01:44] mim1k: has joined #ruby
[14:06:39] bruno-: has joined #ruby
[14:07:14] faraco: Hi guys, I have a good background in Python and fairly small in Perl. I use them both usually for commandline utils/text parsing and simple web development. Let's say I want to scrape web pages and do GUI development, what Ruby offers in terms of gems and what Ruby is generally suited for? I'm not really 'trendy' person, which I use tools only when I need it. I want to give ruby a try and want to get some insights from the ruby devs.
[14:09:03] faraco: In Python, for web scraping, I got scrapy and beautifulsoup, and for packet processing, I can use scapy. What Ruby offers in this case?
[14:09:58] impermanence: has joined #ruby
[14:11:41] bruno-: has joined #ruby
[14:13:33] nowhere_man: has joined #ruby
[14:13:51] mim1k: has joined #ruby
[14:14:29] duderonomy: has joined #ruby
[14:14:52] faraco: nevermind I guess
[14:16:04] sepp2k: has joined #ruby
[14:16:43] bruno-: has joined #ruby
[14:18:17] jphase: has joined #ruby
[14:19:54] gr33n7007h: faraco: web scrpaing (nokogiri) packet processing (packetfu) just my two bits
[14:20:21] hutch34: has joined #ruby
[14:21:14] faraco: thanks, I never knew that gem is in existence. I should look more harder..
[14:21:43] bruno-: has joined #ruby
[14:22:24] sleepee: has joined #ruby
[14:24:58] apeiros: faraco: mechanize for scraping (builds up on nokogiri)
[14:25:36] impermanence: has joined #ruby
[14:26:01] faraco: mechanize? That's cool. I'm familiar with Perl's WWW::Mechanize too. This is great.
[14:26:15] apeiros: quite likely it's inspired by that
[14:27:09] bruno-: has joined #ruby
[14:27:23] Ryzokuken: has joined #ruby
[14:27:24] faraco: then I just need to learn ruby quite a bit more thoroughly since the libraries I need are available and I don't have to write on by myself. Thank you.
[14:28:11] ltem: has joined #ruby
[14:28:19] faraco: anyway, I believe most ruby devs are on Mac. On linux, what is the 'good' way to get the ruby interpreter and the toolchains setup?
[14:28:59] apeiros: I use rvm. there's a couple of people advocating other tools. chruby and rbenv iirc are popular options
[14:29:00] faraco: using package manager on linux doesn't seems great because they need super user access. I had to 'su gem install blah' everytime..
[14:29:30] apeiros: yeah, all three options I named install ruby and gems in userspace
[14:29:36] mim1k: has joined #ruby
[14:29:42] apeiros: no need for root :)
[14:29:46] faraco: apeiros: thanks so much. :)
[14:32:10] bruno-: has joined #ruby
[14:33:16] tAn: has joined #ruby
[14:37:45] bruno-: has joined #ruby
[14:39:25] avelldiroll: has joined #ruby
[14:41:29] rgr_: has joined #ruby
[14:42:10] mim1k: has joined #ruby
[14:46:01] impermanence: has joined #ruby
[14:46:07] bruno-: has joined #ruby
[14:47:33] mahlon: has joined #ruby
[14:48:09] ged: has joined #ruby
[14:49:45] avelldiroll: has joined #ruby
[14:50:05] noname1: has joined #ruby
[14:50:10] ncthom91: has joined #ruby
[14:59:10] avelldiroll: has joined #ruby
[14:59:23] acalycine: has joined #ruby
[14:59:23] acalycine: has joined #ruby
[15:00:28] mim1k: has joined #ruby
[15:01:38] impermanence: has joined #ruby
[15:02:21] leandrobighetti: has joined #ruby
[15:03:11] alex``: has joined #ruby
[15:04:20] opekktar: has joined #ruby
[15:05:54] vad4r: has joined #ruby
[15:06:59] rgtk: has joined #ruby
[15:07:49] GodFather: has joined #ruby
[15:16:43] avelldiroll: has joined #ruby
[15:17:06] bruno-: has joined #ruby
[15:17:14] deduped: has joined #ruby
[15:17:33] tom69: has joined #ruby
[15:17:44] mim1k: has joined #ruby
[15:20:44] leandrobighetti: has joined #ruby
[15:21:24] beauby: has joined #ruby
[15:22:01] impermanence: has joined #ruby
[15:22:11] mustaffa__: has joined #ruby
[15:23:13] avelldiroll: has joined #ruby
[15:27:41] mim1k: has joined #ruby
[15:28:36] tom69: has joined #ruby
[15:29:22] romankapitonov: has joined #ruby
[15:29:38] bruno-: has joined #ruby
[15:29:45] digitalnomad: has joined #ruby
[15:31:36] FahmeF: has joined #ruby
[15:34:44] bruno-: has joined #ruby
[15:35:55] nopolitica: has joined #ruby
[15:37:39] impermanence: has joined #ruby
[15:39:42] bruno-_: has joined #ruby
[15:40:07] romankapitonov: has joined #ruby
[15:46:49] impermanence: has joined #ruby
[15:48:21] mim1k: has joined #ruby
[15:50:20] http_GK1wmSU: has joined #ruby
[15:52:28] vuoto: has joined #ruby
[15:52:44] http_GK1wmSU: has left #ruby: ()
[15:57:45] Guest76729: has joined #ruby
[15:57:45] Guest76729: has joined #ruby
[16:00:08] vuoto: has joined #ruby
[16:00:09] acalycine: has joined #ruby
[16:01:00] hutch34: has joined #ruby
[16:04:01] mim1k: has joined #ruby
[16:04:28] mabus44: has joined #ruby
[16:05:06] vuoto: has joined #ruby
[16:12:37] InfinityFye: has joined #ruby
[16:14:37] knight33: has joined #ruby
[16:15:15] bruno-_: has joined #ruby
[16:19:07] jackjackdripper: has joined #ruby
[16:19:19] romankapitonov: has joined #ruby
[16:20:28] cdg: has joined #ruby
[16:25:50] digitalnomad: has joined #ruby
[16:33:40] impermanence: has joined #ruby
[16:34:40] impermanence: What is the best way to compare object arrays and remove duplicates based on a shared attribute? I think using group_by(&:attr) and something else?
[16:35:24] romankapitonov: has joined #ruby
[16:36:53] Ryzokuken: has joined #ruby
[16:39:28] swills: has joined #ruby
[16:43:07] tedL: has joined #ruby
[16:43:41] AxelAlex: has joined #ruby
[16:45:39] swills: has joined #ruby
[16:45:39] swills: has joined #ruby
[16:50:51] hutch34: has joined #ruby
[16:51:27] leandrobighetti: has joined #ruby
[16:52:14] AxelAlex: has joined #ruby
[17:00:52] acalycine: has joined #ruby
[17:00:52] acalycine: has joined #ruby
[17:04:03] runescape07rsps: has joined #ruby
[17:08:59] ascarter: has joined #ruby
[17:10:19] AxelAlex: has joined #ruby
[17:12:00] rvca: has joined #ruby
[17:22:00] Ryzokuken: has joined #ruby
[17:33:14] VladGh: has joined #ruby
[17:36:40] Azure: has joined #ruby
[17:37:35] rgtk: has joined #ruby
[17:37:46] vuoto: has joined #ruby
[17:38:12] cdg_: has joined #ruby
[17:38:59] cdg_: has joined #ruby
[17:39:01] bruno-: has joined #ruby
[17:45:48] eightlimbed_: has joined #ruby
[17:48:49] romankapitonov: has joined #ruby
[17:49:52] jphase: has joined #ruby
[17:57:17] leandrobighetti: has joined #ruby
[17:59:09] dviola: has joined #ruby
[18:01:39] acalycine: has joined #ruby
[18:02:09] mim1k: has joined #ruby
[18:03:50] minimalism: has joined #ruby
[18:12:53] hutch34: has joined #ruby
[18:13:00] vuoto: has joined #ruby
[18:17:03] Sammichmaker: has joined #ruby
[18:17:03] Sammichmaker: has joined #ruby
[18:21:47] jonathan_: has joined #ruby
[18:23:35] mustaffa__: has joined #ruby
[18:30:43] millerti: has joined #ruby
[18:31:05] jrabe: has joined #ruby
[18:32:42] goyox86_: has joined #ruby
[18:33:27] romankapitonov: has joined #ruby
[18:33:43] ych: has joined #ruby
[18:34:15] mim1k: has joined #ruby
[18:36:02] all_thr9: has joined #ruby
[18:36:20] all_thr9: has left #ruby: ()
[18:37:09] rgtk: has joined #ruby
[18:39:05] bruno-: has joined #ruby
[18:42:17] mustaffa__: has joined #ruby
[18:42:18] workmad3: has joined #ruby
[18:47:19] workmad3_: has joined #ruby
[18:47:59] mim1k: has joined #ruby
[18:49:46] vuoto: has joined #ruby
[18:52:16] workmad3: has joined #ruby
[18:52:52] nadir: has joined #ruby
[18:53:09] meadmoon: has joined #ruby
[18:54:39] nobitanobi: has joined #ruby
[18:55:50] chouhoulis: has joined #ruby
[19:02:20] acalycine: has joined #ruby
[19:02:20] acalycine: has joined #ruby
[19:02:20] vuoto: has joined #ruby
[19:02:56] yokel: has joined #ruby
[19:04:14] mabus44: has joined #ruby
[19:04:18] goyox86_: has joined #ruby
[19:05:30] vuoto: has joined #ruby
[19:11:27] baweaver: &ri Enumerable#uniq
[19:11:28] `derpy: http://ruby-doc.org/core-2.4.1/Enumerable.html#method-i-uniq
[19:11:30] baweaver: impermanence
[19:11:33] baweaver: block argument
[19:12:21] impermanence: baweaver: I've made some headway. I'm spinning up a gist as I'm stuck on a particular part.
[19:14:28] Asher: has joined #ruby
[19:14:38] bruno-: has joined #ruby
[19:14:53] nobitanobi: has joined #ruby
[19:18:29] nobitanobi: has joined #ruby
[19:19:45] dionysus69: has joined #ruby
[19:22:14] Axsuul: has joined #ruby
[19:22:57] patr0clus: has joined #ruby
[19:23:28] nobitanobi: has joined #ruby
[19:23:34] mim1k: has joined #ruby
[19:23:44] sleepee: has joined #ruby
[19:25:56] patr0clus: has joined #ruby
[19:26:53] impermanence: baweaver: https://gist.github.com/anonymous/fd78c03e3bbec97cb5dc7959a97b9def
[19:30:08] patr0clus: has joined #ruby
[19:30:21] hutch34: has joined #ruby
[19:30:47] chihhsin: has joined #ruby
[19:33:16] baweaver: impermanence: give me a sec. Also name your gists .rb, gives syntax highlighting. Not a big deal for now
[19:34:00] impermanence: baweaver: oh, wow, I didn't know that about naming gists. cool :)
[19:34:07] baweaver: your syntax is wrong around 12
[19:34:10] baweaver: you need an end there
[19:34:25] baweaver: Also line 8 is not needed
[19:34:56] baweaver: ruby methods don't use { } to denote boundries
[19:35:00] baweaver: they use def name ... end
[19:35:09] baweaver: Not Scala ;)
[19:35:21] baweaver: or C or Javascript or...
[19:35:36] baweaver: anyways, not the point, just don't surround your methods in {}
[19:35:42] impermanence: ha! I didn't even notice that ;)
[19:36:05] baweaver: Also select returns an array for which the condition is true
[19:36:40] baweaver: >>C=Struct.new(:name,:category); C.new('test', 'one')
[19:36:41] ruby[bot]: baweaver: # => #<struct C name="test", category="one"> (https://eval.in/841949)
[19:36:47] baweaver: ok good, testing something
[19:37:08] PaulCapestany: has joined #ruby
[19:37:27] baweaver: >>C=Struct.new(:name,:category); [C.new('test', 'one'), C.new('foo', 'one'), C.new('bar', 'two')].select { |c| c.category == 'one' }
[19:37:28] ruby[bot]: baweaver: # => [#<struct C name="test", category="one">, #<struct C name="foo", category="one">] (https://eval.in/841950)
[19:37:41] baweaver: Don't use Structs like that, just needed a cheap class to demonstrate
[19:38:02] hkdsun: has joined #ruby
[19:38:36] ecuanaso: has joined #ruby
[19:38:50] baweaver: So now line 8 is gone, and line 9 becomes: companies.select { |x| x.category == company.category && x != company }.sort_by(&:capital).reverse
[19:38:57] baweaver: with line breaks preferably
[19:39:13] baweaver: the delete_if can be combined with the select as the: && x != company
[19:40:02] conta: has joined #ruby
[19:40:05] impermanence: yes I see that now, wow
[19:40:06] baweaver: also throw a uniq on the end if you want.
[19:40:14] baweaver: that'll prevent dupes
[19:40:58] impermanence: in other words: ...reverse.uniq ?
[19:42:14] baweaver: though it'd be rather odd for there to be duplicates except for the recommending company
[19:42:36] baweaver: Have you heard of testing yet?
[19:42:42] kahra: has joined #ruby
[19:43:31] impermanence: I am familiar with literally just the very basics: minitest, assert_equal, etc.
[19:43:48] baweaver: You might start using some of it to verify that your code works as expected
[19:43:58] baweaver: Look into Guard as well which will run them on file changes
[19:44:13] baweaver: ie: foo.rb changing triggers a run of foo_spec.rb
[19:44:29] impermanence: I will do that
[19:44:38] baweaver: Nice to get fast feedback on things
[19:44:49] baweaver: you can even tie it into mac notifications to get an alert for them
[19:49:45] workmad3: has joined #ruby
[19:52:16] mim1k: has joined #ruby
[19:54:02] impermanence: I updated my first method with your changes :) much easier to read!
[19:57:24] Hanmac: has joined #ruby
[19:57:27] icarus: has joined #ruby
[20:00:06] nopolitica: has joined #ruby
[20:00:14] airdisa_: has joined #ruby
[20:03:05] acalycine: has joined #ruby
[20:03:05] acalycine: has joined #ruby
[20:05:17] impermanence: baweaver: any thoughts on my second method?
[20:12:47] mim1k: has joined #ruby
[20:13:32] FahmeF: has joined #ruby
[20:13:37] cdg: has joined #ruby
[20:18:18] mim1k: has joined #ruby
[20:23:23] impermanence: baweaver: I feel like this should be close: backed_companies.each_with_index { |val, idx| all_companies.select { |x| val.category == x.category && val != x }.sort_by(&:capital).reverse.uniq }
[20:23:58] mtkd: has joined #ruby
[20:27:29] t-recx: has joined #ruby
[20:29:25] acalycine: has joined #ruby
[20:31:30] opekktar: has joined #ruby
[20:35:31] rvca: has joined #ruby
[20:36:02] acalycine: has joined #ruby
[20:37:44] kahra_: has joined #ruby
[20:38:21] MrBusiness: has joined #ruby
[20:39:25] ncthom91: has joined #ruby
[20:41:57] digitalnomad: has joined #ruby
[20:46:46] apeiros: impermanence: why each_with_index? you don't use the index.
[20:47:22] impermanence: apeiros: I'll show you what I am using now, which is just each b/c you're right :)
[20:48:15] apeiros: also, each_* returns backed_companies, so the result in your block is thrown away.
[20:48:47] apeiros: and one thing regarding the performance of your code: you go through all companies once for every backed_company. that's n*m. you could do it in n+m (go through all backed_companies once and go through all companies once)
[20:49:32] apeiros: say you have 100 backed companies and 10000 companies, that's 1_000_000 times the block invoked vs. 10_100, or a ~100x speed up.
[20:50:06] impermanence: apeiros: ah...hm. could you show me the code difference? I can not visualize that in code, sorry.
[20:50:11] apeiros: (though, in the n+m variant, the block for the n iterations will differ from the one for the m iterations, so it's not really possible to compare iterations 1:1)
[20:50:33] eightlimbed_: has joined #ruby
[20:51:37] apeiros: require 'set'; backed_categories = backed_companies.map(&:category).to_set; all_companies.select { |company| backed_categories.include?(company.category) }.sortandstuff
[20:52:51] apeiros: depending on what you do I'd do it even differently. but this is strictly the code you gave improved.
[20:53:14] apeiros: oh, might have to do `result - backed_companies`, since your block seems to throw those out too.
[20:54:23] impermanence: apeiros: yes, it does. I'm spinning up a gist right now with a short block showing my attempt
[20:55:21] apeiros: I wonder why your all_companies has duplicates in it to begin with, though
[20:58:03] impermanence: apeiros: https://gist.github.com/jonassteinberg1/754eb85bc427a3b9b7a3781258ea4dce
[20:58:30] apeiros: impermanence: pro-tip - array of objects is a pleonasm
[20:58:37] apeiros: there are no arrays of non-objects in ruby ;-)
[20:59:00] impermanence: apeiros: mm...that is enlightening.
[21:00:15] apeiros: yeah, ok, uniq seems superfluous then.
[21:00:40] apeiros: just (all_companies.select { … } - backed_companies).sort_by(&:capital)
[21:01:08] apeiros: and that'll be n+m instead of n*m
[21:02:04] chouhoulis: has joined #ruby
[21:03:20] impermanence: apeiros: is it possible to do without set?
[21:03:21] Murda: has joined #ruby
[21:03:42] apeiros: you can use a hash instead.
[21:03:56] apeiros: a set is really just a hash (literally, it's implemented via hash) without values
[21:11:25] impermanence: aperios: okay, so how I would delete elements from the array being returned if they are also found in backed_companies?
[21:11:38] impermanence: apeiros: is there a way to chain a method to do that?
[21:11:45] impermanence: apeiros: this is what I have so far:
[21:12:02] apeiros: ?tabnick impermanence
[21:12:03] ruby[bot]: impermanence: pro-tip - use tab completion for nicks. avoids typos in nicks.
[21:12:21] apeiros: that's the `- backed_companies` part.
[21:12:31] apeiros: >> [1,2,3,4,5] - [2,4]
[21:12:33] ruby[bot]: apeiros: # => [1, 3, 5] (https://eval.in/841957)
[21:12:53] apeiros: works with any properly programmed class (namely it has proper #hash and #eql? methods)
[21:13:24] impermanence: apeiros: ah, I see...
[21:14:00] impermanence: apeiros: wait, where is the - backed_companies part? I don't see it in the original part.
[21:14:17] apeiros: 22:53 apeiros: oh, might have to do `result - backed_companies`, since your block seems to throw those out too.
[21:14:21] apeiros: 23:00 apeiros: just (all_companies.select { … } - backed_companies).sort_by(&:capital)
[21:14:41] impermanence: apeiros: tab completing now :) yes, I see it, thank you.
[21:16:25] apeiros: for reference, #hash and #eql? are normally based on identity. they're used to determine whether two objects should be treated as the same key in a hash.
[21:16:39] impermanence: apeiros: oh, okay.
[21:16:40] apeiros: e.g "foo" and "foo" are two different objects, but they're the same hash key.
[21:17:13] impermanence: apeiros: I must be missing something. above you show: (all_companies.select { … } - backed_companies).sort_by(&:capital)
[21:17:38] impermanence: apeiros: what are the parentheses around (all_companies ... backed_companies) ?
[21:17:49] apeiros: just that, parens
[21:17:58] apeiros: without them, sort_by would only affect backed_companies.
[21:18:10] apeiros: (a - b).sort # sort the return value of `a - b`
[21:18:21] apeiros: a - b.sort # sort b, subtract it from a
[21:18:44] apeiros: a - b.sort # sort b, subtract *the result* from a (small clarification to what I wrote above)
[21:19:39] impermanence: apeiros: where should I begin that parens set at?
[21:20:09] apeiros: think about what you want to be sorted.
[21:20:12] apeiros: around that.
[21:20:41] ltem: has joined #ruby
[21:21:00] apeiros: you can also just work with assigning intermediate results to variables and split your code to more lines.
[21:21:10] apeiros: makes probably more sense at your current level of knowledge.
[21:21:11] sepp2k1: has joined #ruby
[21:22:55] impermanence: apeiros: one sec
[21:23:19] apeiros: I'll be playing soon, so my replies might get more sporadic anyways ;-)
[21:25:14] kkiero: has joined #ruby
[21:27:56] ledestin: has joined #ruby
[21:28:52] impermanence: apeiros: I just did your line - backed_companies :)
[21:34:04] mustaffa__: has joined #ruby
[21:36:16] nopolitica: has joined #ruby
[21:38:39] icarus: has joined #ruby
[21:42:27] mim1k: has joined #ruby
[21:42:51] kkiero: has left #ruby: ()
[21:45:20] melkor: has joined #ruby
[21:45:47] d33pb00k-GK1wmSU: has joined #ruby
[21:47:57] d33pb00k-GK1wmSU: has left #ruby: ()
[21:51:17] selim: has joined #ruby
[21:55:13] iomotoko: has joined #ruby
[21:55:33] opekktar: has joined #ruby
[21:57:50] nobitanobi: has joined #ruby
[21:57:52] mim1k: has joined #ruby
[21:59:55] cagomez: has joined #ruby
[22:00:31] opekktar: has joined #ruby
[22:04:04] belmoussaoui_: has joined #ruby
[22:14:17] mim1k: has joined #ruby
[22:15:14] Murda: has joined #ruby
[22:20:13] minimalism: has joined #ruby
[22:32:01] rapha: is it possible (and how?) to run a shell command in ruby inside a thread and to also kill it again?
[22:33:02] apeiros: yes. various ways. the ultimate tool is Kernel#spawn.
[22:33:13] rapha: ultimatr sounds good
[22:33:14] apeiros: the simpler tools are `` (backticks) and popen.
[22:33:25] apeiros: well, ultimate also means "might drown you in options" :)
[22:33:29] rapha: i know about the backticks - but how to _end_ the process?
[22:33:45] apeiros: ah, right, no access to the pid
[22:34:01] apeiros: spawn then. popen won't give that either.
[22:34:18] rapha: apeiros: or would it end upon Thread#kill if the backticks are inside the Thread#new block?
[22:35:54] eam: rapha: so, point of order. None of these run "inside a thread"
[22:36:03] eam: they all fork and exec -- and mixing that with threads is probably a bad idea
[22:36:19] matthewd: Mixing that with threads is just fine
[22:36:21] eam: or at least, fraught with peril and implementation-specific odd behaviors
[22:36:27] eam: matthewd: naaaaah
[22:36:36] rapha: i just thought of threads because i want to do stuff after i start the process and then end the process once i'm done doing stuff.
[22:36:38] matthewd: Though with spawn, you won't need to
[22:36:59] rapha: ACTION wanders off to the docs
[22:37:47] eam: rapha: you may want to deal with the subprocess async, rather than use threads
[22:38:18] eam: quick overview of fork/thread issues: http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
[22:38:35] rapha: oh cool, thanks!
[22:39:34] rapha: without having read that yet ... spawn does return the pid. so all should be fine. except if i want to see the spawned process's stdout i guess
[22:39:54] mim1k: has joined #ruby
[22:40:32] eam: you can give spawn a descriptor for stdin/out
[22:41:04] eam: that'll give you popen-ish behavior
[22:41:14] eizua: has joined #ruby
[22:41:17] rapha: i'll stop asking stupid questions now and just try to get it working and maybe come back with better questions
[22:42:01] eam: here's a maybe better article, describing why go banned fork https://thorstenball.com/blog/2014/10/13/why-threads-cant-fork/
[22:42:01] bruno-: has joined #ruby
[22:42:21] rapha: why go banned fork?
[22:42:24] rapha: that does not parse...
[22:42:36] eam: article explains it, but in short: mixing forks and threads is dangerous
[22:42:47] rapha: oh! not go, Go+
[22:43:04] rapha: s/+/! ... still learning the Swiss keyboard layout
[22:43:19] rapha: ACTION got himself an X200 with a Swiss keyboard
[22:45:03] cagomez: has joined #ruby
[22:53:39] cagomez: has joined #ruby
[22:54:49] nobitanobi: has joined #ruby
[22:55:39] mim1k: has joined #ruby
[22:57:22] digitalnomad: has joined #ruby
[23:00:33] rapha: http://rubyforadmins.com/reading-growing-files <- really cool
[23:12:30] mim1k: has joined #ruby
[23:13:51] runescape07rsps: has joined #ruby
[23:15:11] opekktar: has joined #ruby
[23:18:30] ssplatt: has joined #ruby
[23:19:00] impermanence: has joined #ruby
[23:24:19] kies: has joined #ruby
[23:24:45] ssplatt: I’m trying to use some data from the nfl fantasy football api, so i made a wrapper object and methods. they work in irb but when i call them in my web app i keep getting “undefined method `[]' for nil:NilClass”
[23:25:36] ssplatt: @nfl.get_players_details(@lineup.qb_id)["players"][0] gives that error. removing the [0] makes it go away, but then i can’t process the data correctly because it’s a hash in a list
[23:26:00] ssplatt: is there any reason why @nfl.get_players_details(@lineup.qb_id)["players"][0] would work in irb but not the web app?
[23:29:18] rapha: so i spawned a new process and have its pid now. i can wait for it to end or i can end it. but how do i tell it to pause? (i.e. as if i was pressing Ctrl-Z in the terminal and then did "fg" to resume it)
[23:32:48] alveric4: has joined #ruby
[23:33:25] apeiros: ctrl-z probably signals the app
[23:33:34] apeiros: so find the signal, then Process.kill to send that signal
[23:34:02] apeiros: no, silly me
[23:34:09] nobitanobi: has joined #ruby
[23:34:16] apeiros: doesn't ctrl-z just background the job?
[23:34:27] matthewd: Yeah, sigstop/sigcont
[23:35:09] rapha: No, it pauses it and backgrounds it, both
[23:35:18] apeiros: ok, then what was the command to background an app? o0
[23:37:58] impermanence: Suppose I have a method that takes a lambda as an argument. This lambda has two parameters itself. Is it possible for me to access the lambda's parameters inside the method?
[23:58:44] ascarter: has joined #ruby
[23:59:40] apeiros: impermanence: no. and that'd be bad design anyway.