« Back to channel list

#ruby - 19 July 2018

« Back 1 day Forward 1 day »
[00:00:10] k0mpa: has joined #ruby
[00:04:49] jasmith: has joined #ruby
[00:05:07] LightStalker: has joined #ruby
[00:18:41] karapetyan: has joined #ruby
[00:20:11] jhack: has joined #ruby
[00:20:12] jhack: has joined #ruby
[00:28:25] schleppel: has joined #ruby
[00:29:50] kristofers: has joined #ruby
[00:32:41] mozzarella: has joined #ruby
[00:33:23] bmurt: has joined #ruby
[00:35:35] jrafanie: has joined #ruby
[00:37:43] jaequery: has joined #ruby
[00:39:49] matcouto: has joined #ruby
[00:49:18] zapata: has joined #ruby
[00:54:26] Nicmavr: has joined #ruby
[01:04:20] nicht: has joined #ruby
[01:04:47] nicht: has joined #ruby
[01:05:37] mynameisdebian: has joined #ruby
[01:21:32] AJA4351: has joined #ruby
[01:23:52] graphene: has joined #ruby
[01:50:17] jrafanie: has joined #ruby
[02:01:32] jnollette: has left #ruby: ()
[02:08:37] jenrzzz: has joined #ruby
[02:08:38] jenrzzz: has joined #ruby
[02:16:31] Dimik: has joined #ruby
[02:18:31] white_lilies: has joined #ruby
[02:21:34] mozzarella: has joined #ruby
[02:24:15] graphene: has joined #ruby
[02:28:47] potatoe: has left #ruby: ("Textual IRC Client: www.textualapp.com")
[02:39:37] mynameisdebian: has joined #ruby
[02:43:38] vonfry: has joined #ruby
[02:44:08] wilbert: has joined #ruby
[02:49:16] kapil___: has joined #ruby
[02:55:30] j0bk: has joined #ruby
[02:55:31] j0bk: has joined #ruby
[03:00:14] cadillac_: has joined #ruby
[03:06:34] mynameis_: has joined #ruby
[03:10:30] braincrash: has joined #ruby
[03:12:08] Puppet`: has joined #ruby
[03:17:38] cadillac__: has joined #ruby
[03:18:51] rrichardsr3: has joined #ruby
[03:27:03] amar: has joined #ruby
[03:30:24] Mrgoose: has joined #ruby
[03:32:54] apeiros: has joined #ruby
[03:34:38] redlegion: has joined #ruby
[03:34:53] sauvin: has joined #ruby
[03:35:12] vonfry_: has joined #ruby
[03:35:15] Crack: has joined #ruby
[03:49:06] subroot: has joined #ruby
[03:55:01] karapetyan: has joined #ruby
[04:02:34] yokel: has joined #ruby
[04:11:13] akaiiro: has joined #ruby
[04:30:59] Kerzet: has joined #ruby
[04:31:54] charlie1: has joined #ruby
[04:32:45] pauliesaint: has joined #ruby
[04:34:48] cadillac_: has joined #ruby
[04:37:43] phate408: has joined #ruby
[04:43:50] nowhere_man: has joined #ruby
[04:44:32] Guest12924: has joined #ruby
[04:46:23] TinkerT: has joined #ruby
[04:49:12] za1b1tsu: has joined #ruby
[04:49:54] ciscam: has joined #ruby
[04:51:08] Crack: has joined #ruby
[04:59:18] bga57: has joined #ruby
[05:00:37] mynameis_: has joined #ruby
[05:01:36] za1b1tsu: has joined #ruby
[05:02:09] schneider: has joined #ruby
[05:02:38] lomex: has joined #ruby
[05:03:26] mynameisdebian: has joined #ruby
[05:09:53] jmcgnh: has joined #ruby
[05:11:29] r29v: has joined #ruby
[05:13:18] tvw: has joined #ruby
[05:22:58] pabs: has joined #ruby
[05:24:17] anisha: has joined #ruby
[05:26:50] alfiemax: has joined #ruby
[05:27:39] ur5us: has joined #ruby
[05:29:23] phate408: has joined #ruby
[05:29:26] Flabbergazta__: has joined #ruby
[05:29:31] oblak_: has joined #ruby
[05:29:39] iamdevnul: has joined #ruby
[05:29:42] scrptktty_: has joined #ruby
[05:29:45] seanh_: has joined #ruby
[05:29:48] kapowaz: has joined #ruby
[05:29:52] fury__: has joined #ruby
[05:29:55] skmp_: has joined #ruby
[05:29:56] DukeDave: has joined #ruby
[05:29:56] daxroc__: has joined #ruby
[05:30:01] afisher: has joined #ruby
[05:30:05] amitchellbullard: has joined #ruby
[05:30:07] jimeh_: has joined #ruby
[05:30:10] avdi: has joined #ruby
[05:30:10] untitaker_: has joined #ruby
[05:30:15] Travis-42_: has joined #ruby
[05:30:20] ReinH: has joined #ruby
[05:30:25] Eising: has joined #ruby
[05:30:27] tycoon177_: has joined #ruby
[05:30:28] sparc: has joined #ruby
[05:30:29] mr-robert_: has joined #ruby
[05:30:41] Chew: has joined #ruby
[05:31:00] coderphive: has joined #ruby
[05:31:00] unsymbol: has joined #ruby
[05:31:00] devlaf_: has joined #ruby
[05:31:01] WA9ACE_: has joined #ruby
[05:31:07] JJonah: has joined #ruby
[05:31:08] knowtheory__: has joined #ruby
[05:31:08] Guest21194: has joined #ruby
[05:31:14] Majost: has joined #ruby
[05:31:15] tycoon177_: has joined #ruby
[05:31:18] nowhere_man: has joined #ruby
[05:31:24] sparc: has joined #ruby
[05:31:24] sparc: has joined #ruby
[05:31:25] TvL: has joined #ruby
[05:31:29] BuildTheRobots: has joined #ruby
[05:32:25] unsymbol: has joined #ruby
[05:32:25] coderphive: has joined #ruby
[05:32:25] unsymbol: has joined #ruby
[05:32:26] coderphive: has joined #ruby
[05:32:28] BuildTheRobots: has joined #ruby
[05:32:28] BuildTheRobots: has joined #ruby
[05:32:57] Xiti: has joined #ruby
[05:33:35] Xiti: has joined #ruby
[05:34:16] kent\n: has joined #ruby
[05:34:49] DarthGandalf: has joined #ruby
[05:34:50] Lyubo1: has joined #ruby
[05:34:58] scrptktty_: has joined #ruby
[05:35:23] goez: has joined #ruby
[05:35:31] mistym: has joined #ruby
[05:35:36] bougyman: has joined #ruby
[05:35:37] mistym: has joined #ruby
[05:35:40] aspiers: has joined #ruby
[05:35:43] matthewd: has joined #ruby
[05:36:30] tuelz: has joined #ruby
[05:36:53] scrptktty_: has joined #ruby
[05:39:18] shinnya: has joined #ruby
[05:43:43] karapetyan: has joined #ruby
[05:44:25] Hanmac: has joined #ruby
[05:45:56] alfiemax_: has joined #ruby
[05:46:30] leah2: has joined #ruby
[05:47:49] vondruch: has joined #ruby
[05:52:59] zlogan2003: has joined #ruby
[05:54:42] alfiemax: has joined #ruby
[05:58:13] aupadhye: has joined #ruby
[06:02:36] Some-body_: has joined #ruby
[06:10:07] tpendragon: has joined #ruby
[06:11:54] za1b1tsu: has joined #ruby
[06:15:18] biberu: has joined #ruby
[06:17:49] jenrzzz: has joined #ruby
[06:17:50] jenrzzz: has joined #ruby
[06:19:55] almdrx: has joined #ruby
[06:21:21] suukim: has joined #ruby
[06:24:00] drale2k_: has joined #ruby
[06:25:26] jmcgnh: has joined #ruby
[06:26:03] moei: has joined #ruby
[06:26:26] LightStalker: has joined #ruby
[06:30:14] jraavis: has joined #ruby
[06:35:00] sphenxes: has joined #ruby
[06:37:29] jenrzzz: has joined #ruby
[06:37:29] jenrzzz: has joined #ruby
[06:38:29] alfiemax: has joined #ruby
[06:41:02] jraavis: has joined #ruby
[06:41:45] konsolebox: has joined #ruby
[06:42:56] jraavis: has joined #ruby
[06:44:30] jrabe: has left #ruby: ()
[06:47:46] schneider: has joined #ruby
[06:51:16] za1b1tsu: has joined #ruby
[06:52:44] aufi: has joined #ruby
[06:54:50] aufi_: has joined #ruby
[06:57:34] elphe: has joined #ruby
[06:59:02] alfiemax: has joined #ruby
[07:05:07] jimeh: has joined #ruby
[07:08:43] amar: has joined #ruby
[07:09:42] rrichard_: has joined #ruby
[07:16:28] salasrod: has joined #ruby
[07:18:44] irick: has joined #ruby
[07:20:24] alem0lars: has joined #ruby
[07:27:18] alem0lars: has joined #ruby
[07:30:16] venmx: has joined #ruby
[07:34:09] schleppel: has joined #ruby
[07:38:42] mikecmpbll: has joined #ruby
[07:40:14] conta: has joined #ruby
[07:41:04] za1b1tsu: has joined #ruby
[07:42:08] clemens3: has joined #ruby
[07:43:05] andikr: has joined #ruby
[07:46:31] reber: has joined #ruby
[07:48:06] TomyWork: has joined #ruby
[07:52:10] alfiemax: has joined #ruby
[07:56:33] jmcgnh: has joined #ruby
[07:58:22] vpenkoff: has joined #ruby
[08:07:14] za1b1tsu_: has joined #ruby
[08:07:54] anikras: has joined #ruby
[08:10:29] lubekpl: has joined #ruby
[08:18:12] Dbugger: has joined #ruby
[08:18:24] guille-moe: has joined #ruby
[08:18:52] Crack: has joined #ruby
[08:19:48] Beams: has joined #ruby
[08:20:05] amar: has joined #ruby
[08:26:45] wget: has joined #ruby
[08:26:45] wget: has joined #ruby
[08:29:54] schneider: has joined #ruby
[08:32:16] alfiemax: has joined #ruby
[08:35:21] jraavis: has joined #ruby
[08:36:26] mikecmpbll: has joined #ruby
[08:38:14] alfiemax: has joined #ruby
[08:38:53] lubekpl: has joined #ruby
[08:48:18] alfiemax: has joined #ruby
[08:48:58] sysvalve: has joined #ruby
[08:52:58] bruce_lee: has joined #ruby
[08:52:59] bruce_lee: has joined #ruby
[08:53:11] drale2k_: has joined #ruby
[08:54:38] jraavis: has joined #ruby
[08:54:41] whiteline: has joined #ruby
[08:55:36] alex``: has joined #ruby
[08:58:32] venmx: has joined #ruby
[08:59:55] spk: has joined #ruby
[09:01:26] dhollin3: has joined #ruby
[09:01:55] jottr_: has joined #ruby
[09:02:54] fury: has joined #ruby
[09:11:56] pistachio: has joined #ruby
[09:17:55] j416: has joined #ruby
[09:25:56] j416_: has joined #ruby
[09:28:49] schneider: has joined #ruby
[09:29:26] j416-: has joined #ruby
[09:31:40] amar: has joined #ruby
[09:34:29] vonfry: has joined #ruby
[09:36:55] paulsaint: has joined #ruby
[09:42:05] snickers: has joined #ruby
[09:43:43] lomex: has joined #ruby
[09:44:45] leitz: has joined #ruby
[09:49:39] jraavis: has joined #ruby
[09:58:26] karapetyan: has joined #ruby
[10:02:43] jraavis: has joined #ruby
[10:08:01] amar: has joined #ruby
[10:13:11] jottr: has joined #ruby
[10:18:14] whiteline_: has joined #ruby
[10:20:02] flips: has joined #ruby
[10:21:39] psychicist__: has joined #ruby
[10:25:30] j416_: has joined #ruby
[10:26:17] jasmith: has joined #ruby
[10:30:47] GodFather: has joined #ruby
[10:32:30] jasmith: has joined #ruby
[10:33:43] karapetyan: has joined #ruby
[10:35:55] jasmith: has joined #ruby
[10:43:00] jasmith: has joined #ruby
[10:50:20] bmurt: has joined #ruby
[11:00:39] Zaab1t: has joined #ruby
[11:03:37] apeiros: has joined #ruby
[11:04:08] petto: has joined #ruby
[11:05:17] alex``: has joined #ruby
[11:05:33] quobo: has joined #ruby
[11:06:21] tvw: has joined #ruby
[11:08:20] schneider: has joined #ruby
[11:10:02] jraavis: has joined #ruby
[11:16:22] InfinityFye: has joined #ruby
[11:20:45] graphene: has joined #ruby
[11:21:26] devlaf: has joined #ruby
[11:21:26] devlaf: has joined #ruby
[11:24:30] alex``: has joined #ruby
[11:25:26] alem0lars: has joined #ruby
[11:34:46] Nicmavr: has joined #ruby
[11:38:45] alex``: has joined #ruby
[11:40:09] shinnya: has joined #ruby
[11:42:17] jrafanie: has joined #ruby
[11:44:55] za1b1tsu_: has joined #ruby
[11:44:58] anisha: has joined #ruby
[11:46:09] milanj: has joined #ruby
[11:50:08] AJA4350: has joined #ruby
[11:53:39] jraavis: has joined #ruby
[11:57:54] augcesar: has joined #ruby
[12:01:35] jraavis: has joined #ruby
[12:05:34] Guest49450: has joined #ruby
[12:06:09] marahin: has joined #ruby
[12:07:27] synthroid: has joined #ruby
[12:09:17] Alec: So... in C++ we have this great site called cppreference.org and there's this shitty website called cplusplus.com that is a cancer you only ever click accidentally, thus keeping it high in search results. It's great because it covers syntax and it's reference material not examples followed by "but you can do this!" new examples so what you interpret is this constantly shifting conception of what it is.
[12:09:26] mikecmpbll: has joined #ruby
[12:09:33] Alec: Does Ruby have a decent reference? For the language especially.
[12:12:55] Puppet`: has joined #ruby
[12:14:15] synthroid: has joined #ruby
[12:15:55] TheBrayn: I always use https://ruby-doc.org
[12:16:27] Alec: That's probably the best I've found so far TBH
[12:22:08] yohji: has joined #ruby
[12:26:44] jtperreault: has joined #ruby
[12:27:01] milanj: has joined #ruby
[12:33:23] drale2k_: has joined #ruby
[12:34:23] apeiros: there's also rdoc.info which provides rendered docs for gems/github repos and generates on demand.
[12:42:00] elomatreb: Although these are API docs mostly. They have examples usually, but it's not a coordinated overview of the language
[12:46:20] bmurt: has joined #ruby
[12:48:45] drale2k_: has joined #ruby
[12:49:50] jasmith: has joined #ruby
[12:52:37] GodFather: has joined #ruby
[12:55:52] gnufied: has joined #ruby
[12:59:41] fmcgeough: has joined #ruby
[13:00:16] AJA4351: has joined #ruby
[13:02:03] pauliesaint: has joined #ruby
[13:02:25] synthroid: has joined #ruby
[13:09:04] jraavis: has joined #ruby
[13:18:53] DTZUZO: has joined #ruby
[13:19:14] conta1: has joined #ruby
[13:19:34] ayaz: has joined #ruby
[13:19:54] ayaz: has joined #ruby
[13:20:14] ayaz: has left #ruby: ()
[13:28:47] Alec: Sounds like someone needs to make some
[13:29:11] Rapture: has joined #ruby
[13:35:23] konsolebox: has joined #ruby
[13:41:03] quobo: has joined #ruby
[13:42:39] pauliesaint: has joined #ruby
[13:42:50] AJA4350: has joined #ruby
[13:45:04] TinkerT: has joined #ruby
[13:48:41] Mike11: has joined #ruby
[13:55:37] AJA4351: has joined #ruby
[13:57:05] User458764: has joined #ruby
[14:00:25] bmurt: has joined #ruby
[14:01:14] jraavis: has joined #ruby
[14:02:06] jrafanie: has joined #ruby
[14:03:41] spiette: has joined #ruby
[14:10:45] za1b1tsu_: has joined #ruby
[14:13:23] tcurdt: has joined #ruby
[14:15:51] nowhere_man: has joined #ruby
[14:16:47] brendan-: has joined #ruby
[14:18:12] cjohnson: has joined #ruby
[14:18:52] AJA4351: has joined #ruby
[14:20:01] Inline: has joined #ruby
[14:20:06] jraavis: has joined #ruby
[14:21:05] tcurdt: I am looking for an (ideally) functional approach to split an array into multiple subarrays where the sum of the subarray is smaller or equal than n https://gist.github.com/tcurdt/b32af4abae8ea918f68fb958b31b7b9d
[14:21:20] tcurdt: ...but I am feeling a little stuck
[14:21:26] alfiemax: has joined #ruby
[14:21:41] tcurdt: any suggestions on how to approach this?
[14:22:20] AJA4351: has joined #ruby
[14:23:48] tycoon177: konsolebox: N is used to indicate a number, which could be variable, i'm pretty sure.
[14:24:28] tcurdt: konsolebox tycoon177 exactly
[14:24:38] tcurdt: "is smaller or equal than n"
[14:24:40] alem0lars: has joined #ruby
[14:25:13] tycoon177: this seems like a fun little exercise. i'll give it a go
[14:25:20] konsolebox: tycoon177: sure, except when it's a constant factor, hence i ask
[14:25:48] tycoon177: my guess is they're wanting a function that would take n and the hash as args
[14:26:48] pauliesaint: has joined #ruby
[14:26:53] tcurdt: tycoon177 yes
[14:27:24] elomatreb: Isn't this like a dynamic programming version of knapsack?
[14:28:06] AJA4351: has joined #ruby
[14:29:48] tcurdt: you could think of it as a hash of bottles with v being the amount of water in the bottle
[14:29:55] tcurdt: you pour the bottle one by one (in order) into buckets that hold a maximum of n liters
[14:30:06] apparition: has joined #ruby
[14:30:23] tcurdt: and you want to have an array per bucket which bottle got in there
[14:30:25] Dimik: has joined #ruby
[14:30:35] tcurdt: I don't know if that abstraction helps :)
[14:31:18] elomatreb: Is there some criterion by which you want the bottles to be selected?
[14:34:48] augcesar2: has joined #ruby
[14:35:05] AJA4351: has joined #ruby
[14:35:32] tcurdt: let me write a quick iterative example :)
[14:37:37] akaiiro: has joined #ruby
[14:37:56] augcesar2: has left #ruby: ()
[14:38:07] amar_: has joined #ruby
[14:38:52] nowhere_man: has joined #ruby
[14:41:06] yohji: has joined #ruby
[14:46:08] nowhere_man: has joined #ruby
[14:47:05] Asher: has joined #ruby
[14:48:37] konsolebox: tcurdt: but what happens when the array always end up > N? like when a number is greater than N, or when two adjacent numbers sums up as > N?
[14:48:49] konsolebox: that looks like fun to solve, good luck
[14:49:10] konsolebox: try playing with enums and take_while
[14:49:58] akaiiro: has joined #ruby
[14:51:52] deadnull: has joined #ruby
[14:52:04] tcurdt: elomatreb konsolebox I've updated the gist with an imperative version https://gist.github.com/tcurdt/b32af4abae8ea918f68fb958b31b7b9d
[14:53:35] havenwood: tcurdt: src.each_with_object([]) { |a, result| result.empty? || result.last.map(&:last).flat_map(&:values).sum + a.last.values.sum > n ? result << [a] : result.last << a }.map(&:to_h)
[14:53:55] Chew: has joined #ruby
[14:56:42] AJA4351: has joined #ruby
[14:58:40] Sylario: has joined #ruby
[14:58:42] tty: has joined #ruby
[15:00:29] Mrgoose2: has joined #ruby
[15:01:18] tcurdt: havenwood hm ... that doesn't seem to work for me
[15:02:46] dviola: has joined #ruby
[15:02:51] havenwood: tcurdt: Are you on Ruby 2.4+?
[15:03:05] tcurdt: havenwood running 2.3.1p112
[15:04:24] havenwood: >> src = {:a=>{:v=>1}, :b=>{:v=>2}, :c=>{:v=>2}, :d=>{:v=>2}}; n = 3; src.each_with_object([]) { |a, result| result.empty? || (result.last.map(&:last).flat_map(&:values) + a.last.values).reduce(:+) > n ? result << [a] : result.last << a }.map(&:to_h) # tcurdt
[15:04:25] ruby[bot]: havenwood: # => [{:a=>{:v=>1}, :b=>{:v=>2}}, {:c=>{:v=>2}}, {:d=>{:v=>2}}] (https://eval.in/1039225)
[15:07:04] zlogan2003: has joined #ruby
[15:08:01] Mrgoose2: has joined #ruby
[15:09:49] tcurdt: havenwood odd .... maybe I misread ... maybe because the buckets are hashes not arrays ... (was my mistake in the gist)
[15:10:06] tcurdt: but that certainly gives me an angle to work on it
[15:10:43] tcurdt: cannot say I prefer it over the easy to understand imperative version yet :)
[15:10:45] graphene: has joined #ruby
[15:11:17] gyant: has joined #ruby
[15:11:20] konsolebox: "<tcurdt> elomatreb konsolebox I've updated the gist with an imperative version https://gist.github.com/tcurdt/b32af4abae8ea918f68fb958b31b7b9d'" didn't resolve my questioning
[15:13:03] tcurdt: konsolebox not? the bottles are poured in order
[15:13:33] tcurdt: order given by the bottles array
[15:16:02] jraavis: has joined #ruby
[15:18:22] konsolebox: bottles = [{ id: 1, liters: 4 }, { id: 2, liters: 2 }, { id: 3, liters: 2 }, ... ]; liters_per_bucket = 3
[15:18:45] konsolebox: "what happens when the array always end up > N? like when a number is greater than N, or when two adjacent numbers sums up as > N?"
[15:19:27] SeepingN: has joined #ruby
[15:19:51] za1b1tsu_: has joined #ruby
[15:21:24] tcurdt: ah ... I see what you mean ... what to do when e.g. the bottle with the least amount of water is still more than the bucket
[15:21:35] AJA4351: has joined #ruby
[15:21:39] beowuff: has joined #ruby
[15:22:01] tcurdt: adjacent numbers would not be a problem ... that would mean each bottle goes in its own bucket
[15:22:04] schneider: has joined #ruby
[15:22:44] tcurdt: but the first point is indeed something to think about
[15:23:10] samosaphile: has joined #ruby
[15:25:08] AJA4351: has joined #ruby
[15:25:25] tdy: has joined #ruby
[15:27:21] tcurdt: to handle it I would either say still that bottle goes into a single bucket ... the other water would be spilled - there just is no bigger bucket
[15:27:24] yohji: has joined #ruby
[15:27:26] tcurdt: in my scenario bottles.max > bucket is very unlikely
[15:27:30] TomyWork: can i somehow pack/unpack a 32-bit number into a string?
[15:28:00] TomyWork: i have some odd error messages from some program here, where one 32 bit number says HELP when reinterpreted as ASCII
[15:28:10] TomyWork: i wanna read the rest of the messages :)
[15:28:18] tcurdt: konsolebox but those are really good points :)
[15:28:48] apeiros_: has joined #ruby
[15:30:08] tcopeland: has joined #ruby
[15:32:08] TomyWork: %w{01001000 01000101 01001100 01010000}.map { |x| Integer("0b#{x}") }.pack('C*') # this gets me from binary bytes to a string. there has got to be some easy way to convert a fixnum into an array of bytes
[15:34:27] apeiros_: >> %w{01001000 01000101 01001100 01010000}.pack("B*B*B*B*") # TomyWork
[15:34:28] ruby[bot]: apeiros_: # => "HELP" (https://eval.in/1039291)
[15:35:19] apeiros_: if you control the array, you can also:
[15:35:21] apeiros_: >> [0b01001000, 0b01000101, 0b01001100, 0b01010000].pack("C*")
[15:35:22] ruby[bot]: apeiros_: # => "HELP" (https://eval.in/1039292)
[15:35:59] TomyWork: >> 0b01001000010001010100110001010000 # well, my input is this
[15:36:15] TomyWork: >> 0b01001000010001010100110001010000 # well, my input is this
[15:36:16] ruby[bot]: TomyWork: # => 1212501072 (https://eval.in/1039293)
[15:37:00] apeiros: you input is one integer? you sure?
[15:37:36] apeiros: most languages can't deal with arbitrarily large integers… that's why I find it unlikely and inquire…
[15:37:38] TomyWork: i think someone is using the wrong protocol on this service. this text ends up in the size field
[15:38:09] AJA4350: has joined #ruby
[15:38:30] TomyWork: it's not arbitrary, it's 32 bits
[15:38:31] apeiros: if it's *text* then it's not an integer. so what is it now?
[15:38:45] TomyWork: it's text, that ends up in an integer
[15:38:54] apeiros: that's not really clarifying things.
[15:39:00] TomyWork: basically *(int*)("HELP")
[15:39:08] apeiros: and that's not ruby :)
[15:39:29] TomyWork: my question is basically how do i do the inverse of that in ruby? :)
[15:39:30] apeiros: when you get the value, in ruby, before you apply any processing, *what class* does the value have? and how does the .inspect look?
[15:39:43] jottr: has joined #ruby
[15:39:44] TomyWork: the value is not from a ruby service
[15:39:47] apeiros: TomyWork: you don't because ruby doesn't have pointers. so that question is pointless.
[15:39:52] TomyWork: i just want to use ruby as a tool to decode it
[15:40:01] apeiros: that's utterly irrelevant.
[15:40:06] samosaphile: what does .pack and .unpack actually do? and what does C* mean?
[15:40:07] apeiros: you're having a value in ruby.
[15:40:15] TomyWork: samosaphile stands for string
[15:40:25] apeiros: samosaphile: it's to pack and unpack binary datastructures. C* means "any number of characters"
[15:40:25] TomyWork: char pointer? i dont know
[15:40:29] konsolebox: also, ruby's integers store dynamically based on endian
[15:40:51] apeiros: anyway, /me waits for a meaningful response by TomyWork
[15:41:24] TomyWork: apeiros i copypaste all the values from the log file of that other service, then put them into a ruby program
[15:41:35] apeiros: I don't care about "that other service"
[15:41:43] konsolebox: TomyWork: how about using real serialization formats like msgpack
[15:41:44] apeiros: I care about what it is when it enters your code
[15:41:52] rippa: has joined #ruby
[15:42:03] apeiros: and before you apply any processing on it at that.
[15:42:05] TomyWork: apeiros like i said, a fixnum
[15:42:13] troys: has joined #ruby
[15:42:37] apeiros: so something already applied processing on it
[15:42:39] TomyWork: 31 significant bits, usually
[15:42:45] TomyWork: yes, i copypasted it from the log file
[15:42:51] TomyWork: that is the processing i applied
[15:42:59] apeiros: >> [0b01001000010001010100110001010000].pack("N")
[15:43:13] ruby[bot]: apeiros: # => "HELP" (https://eval.in/1039295)
[15:43:14] apeiros: copy pasting doesn't turn text into fixnums.
[15:43:21] apeiros: you're wildly incoherent :)
[15:43:37] TomyWork: if i copypaste a number from a logfile into a ruby program, it is a fixnum literal
[15:44:00] apeiros: your IO is "I write code"?
[15:44:14] apeiros: so it's one-off?
[15:45:20] TomyWork: >> [0b01001000010001010100110001010000].pack("V")
[15:45:21] ruby[bot]: TomyWork: # => "PLEH" (https://eval.in/1039296)
[15:45:54] TomyWork: >> "q'#{[0b01001000010001010100110001010000].pack("V")}!"
[15:45:55] ruby[bot]: TomyWork: # => "q'PLEH!" (https://eval.in/1039297)
[15:48:29] jraavis: has joined #ruby
[15:48:46] jcarl43: has joined #ruby
[15:49:23] lucasr: has joined #ruby
[15:49:44] milanj: has joined #ruby
[15:49:47] TomyWork: "Packs the contents of arr into a binary sequence" - so a String is a binary sequence?
[15:51:37] apeiros: ruby strings are essentially byte arrays with some meta data on top (such as "encoding")
[15:52:12] bmurt: has joined #ruby
[15:52:32] fluxAeon: has joined #ruby
[15:53:25] TomyWork: i thought they were more abstract than that
[15:53:43] za1b1tsu_: has joined #ruby
[15:53:54] Puffball: has joined #ruby
[15:54:06] Megamos: has joined #ruby
[15:54:24] TomyWork: well it says "GET HELP"
[15:54:26] beowuff: has joined #ruby
[15:54:54] TomyWork: some garbled nonsense before that
[15:55:09] TomyWork: i guess the rest after it would be " I'M TRAPPED IN A PACKET FACTORY"
[15:56:53] djbkd: has joined #ruby
[15:57:22] apeiros: TomyWork: reminds me of fez
[15:57:49] fluxAeon: has joined #ruby
[15:58:34] TomyWork: i played that before i had a smartphone
[15:58:56] jraavis: has joined #ruby
[15:59:00] TomyWork: had to find a way to decode the qr code from a screenshot
[15:59:04] fluxAeon: has joined #ruby
[15:59:52] TomyWork: which is a surprisingly unusual use case
[16:02:01] TomyWork: hah, some of the other stuff looks like a TLS handshake
[16:03:22] avelldiroll: has joined #ruby
[16:05:17] GodFather: has joined #ruby
[16:06:06] jerojasro: has joined #ruby
[16:06:13] jasmith: has joined #ruby
[16:09:55] Crack: has joined #ruby
[16:11:57] User458764: has joined #ruby
[16:16:11] salasrod: has joined #ruby
[16:16:37] karapetyan: has joined #ruby
[16:18:05] BTRE: has joined #ruby
[16:24:47] GodFather: has joined #ruby
[16:29:56] pauliesaint: has joined #ruby
[16:31:11] bmurt: has joined #ruby
[16:33:03] pauliesaint: has joined #ruby
[16:33:53] \void: has joined #ruby
[16:33:57] AJA4350: has joined #ruby
[16:34:33] amar_: has joined #ruby
[16:36:15] amar_: has joined #ruby
[16:37:51] cadillac_: has joined #ruby
[16:40:18] biberu: has joined #ruby
[16:40:20] scrptktty_: has joined #ruby
[16:40:53] pauliesaint: has joined #ruby
[16:41:47] GodFather: has joined #ruby
[16:42:54] Miron: has joined #ruby
[16:44:59] cliluw: has joined #ruby
[16:47:17] pauliesaint: has joined #ruby
[16:51:30] jraavis: has joined #ruby
[16:55:18] r29v: has joined #ruby
[16:55:46] drale2k_: has joined #ruby
[16:56:45] tff^: has joined #ruby
[17:00:23] za1b1tsu_: has joined #ruby
[17:02:48] sameerynho: has joined #ruby
[17:05:33] redlegion: has joined #ruby
[17:14:28] eckhardt_: has joined #ruby
[17:14:37] redlegion: has joined #ruby
[17:15:38] jcalla: has joined #ruby
[17:16:02] SeepingN: has joined #ruby
[17:26:24] c0ncealed2: has joined #ruby
[17:28:29] mzo: has joined #ruby
[17:29:16] mensvaga: has joined #ruby
[17:30:11] mensvaga: Let's say I have 3 parameters I want to pass to sprintf, and I want to generate '%s!%s!%s'
[17:30:24] mensvaga: Or, 4 parameters: '%s!%s!%s!%s'
[17:30:39] mensvaga: Basically, I need the string '%s' joined on '!' for the number of times
[17:31:15] mensvaga: I know how I'd do it by creating an array of '%s' and join on '!' , but I'm wondering if somebody has a "one-liner" to do this
[17:32:06] alfiemax: has joined #ruby
[17:32:12] snickers: has joined #ruby
[17:32:33] guille-moe: has joined #ruby
[17:33:32] milanj: has joined #ruby
[17:34:18] mensvaga: n=3; a = []; for i in 1..n do; a.push('%s'); end; puts a.join('!')
[17:34:30] mensvaga: is there a shorter way to do this in ruby?
[17:36:20] xtsee: (['%s']*3).join('!')
[17:36:28] xtsee: is that what you're looking for?
[17:36:40] mensvaga: It parses in my head. If it works in ruby, then cool.
[17:37:25] mensvaga: perl has something similar; but it's the "x" operator
[17:37:39] mensvaga: join('!', ('%s') x 3)
[17:38:17] mzo: but why even use sprintf at this point
[17:38:31] mensvaga: The example is long, but it's valid.
[17:38:47] mensvaga: If you have something that takes positional arguments as a string with a delimiter inside of it
[17:38:55] mensvaga: and you have those arguments in an associative array
[17:39:03] mensvaga: as well as the order of those arguments in an array
[17:39:25] mensvaga: Then that's ... well, it.
[17:40:13] mensvaga: accepted_arguments = ['a' => 1, '
[17:40:32] zleap: has joined #ruby
[17:40:33] zleap: has joined #ruby
[17:42:34] mzo: instead of sprintf((['%s']*3).join('!'), a, b, c) why not just use [a, b, c].join('!')
[17:45:24] GodFather: has joined #ruby
[17:46:06] mensvaga: Good question; and the answer is I have strings like this:
[17:46:06] mensvaga: 'check_snmp_wrapper!%s!2!%s...%s...'
[17:46:32] mensvaga: I suppose I could join on the values themselves
[17:47:16] mensvaga: But, if I've already gone so far as to abstract specific parameters away in a list, I can abstract all of them
[17:47:22] mensvaga: and then avoid %s entirely
[17:50:22] amar_: has joined #ruby
[17:50:23] Eiam: has joined #ruby
[17:52:16] mensvaga: Yep. Now that I've abstracted everything I can just join on '!'
[17:55:47] graphene: has joined #ruby
[18:03:02] jenrzzz: has joined #ruby
[18:03:03] jenrzzz: has joined #ruby
[18:03:56] SeepingN: and bingo was his nameo
[18:10:42] al2o3-cr: B*I*N*G*O B*I*N*G*O B*I*N*G*O and bingo was his name o ;)
[18:13:18] iamnix: has joined #ruby
[18:14:08] alex``: has joined #ruby
[18:14:39] reber: has joined #ruby
[18:15:19] za1b1tsu_: has joined #ruby
[18:19:39] manakanapa: has joined #ruby
[18:25:11] conta1: has joined #ruby
[18:28:23] alfiemax: has joined #ruby
[18:29:36] dellavg: has joined #ruby
[18:33:04] jamesaxl: has joined #ruby
[18:36:25] cagomez: has joined #ruby
[18:38:22] elcuervo: has joined #ruby
[18:40:37] graphene: has joined #ruby
[18:44:12] ivanskie: has joined #ruby
[18:47:56] synthroid: has joined #ruby
[18:49:01] teej: has joined #ruby
[18:53:48] graphene: has joined #ruby
[18:58:46] lomex: has joined #ruby
[19:01:11] tvw: has joined #ruby
[19:01:32] GodFather: has joined #ruby
[19:01:42] lubekpl: has joined #ruby
[19:07:21] yxhuvud: has joined #ruby
[19:11:01] clemens3: has joined #ruby
[19:11:09] lomex: has joined #ruby
[19:12:51] graphene: has joined #ruby
[19:16:29] bmurt: has joined #ruby
[19:29:06] Mike11: has joined #ruby
[19:29:40] anisha: has joined #ruby
[19:30:09] amar_: has joined #ruby
[19:31:30] chisight: has joined #ruby
[19:31:54] chisight: has left #ruby: ("WeeChat 2.0")
[19:32:32] GodFather: has joined #ruby
[19:34:45] dviola: has joined #ruby
[19:36:13] anisha: has joined #ruby
[19:39:56] alfiemax: has joined #ruby
[19:42:25] drale2k_: has joined #ruby
[19:50:50] darkhanb: has joined #ruby
[19:52:51] chmurifree: has joined #ruby
[19:53:28] alfiemax: has joined #ruby
[19:55:31] VladGh: has joined #ruby
[19:56:19] karapetyan: has joined #ruby
[19:56:47] jenrzzz: has joined #ruby
[19:56:48] jenrzzz: has joined #ruby
[19:57:37] mensvaga: What's a good doc to read about creating your own gem?
[19:57:40] mensvaga: I'm looking at this: https://guides.rubygems.org/make-your-own-gem/
[19:58:11] mensvaga: But it doesn't seem to reference a command that automatically generates things, like the gemspec file
[19:58:24] mensvaga: It does reference a source tree that I can clone and modify, though. I *could* do that.
[19:59:05] VladGh: has joined #ruby
[20:01:05] VladGh: has joined #ruby
[20:05:47] mensvaga: Ah. the doc says "use bundler".
[20:09:10] Megamos: has joined #ruby
[20:10:33] VladGh: has joined #ruby
[20:11:21] venmx: has joined #ruby
[20:11:25] moei: has joined #ruby
[20:14:46] Puffball: has joined #ruby
[20:18:10] drale2k_: has joined #ruby
[20:21:21] ellcs1: has joined #ruby
[20:23:44] Dbugger: has joined #ruby
[20:28:20] jenrzzz: has joined #ruby
[20:28:20] jenrzzz: has joined #ruby
[20:41:28] gigetoo: has joined #ruby
[20:47:40] SCHAPiE: has joined #ruby
[21:01:51] baweaver: mensvaga: `bundle gem <name>`
[21:17:17] clemens3: has joined #ruby
[21:27:55] miah: https://bundler.io/v1.16/man/bundle-gem.1.html for more details
[21:28:41] nicht: has joined #ruby
[21:30:12] alem0lars: has joined #ruby
[21:33:55] tff^: has joined #ruby
[21:36:47] jerojasro: has left #ruby: ("WeeChat 1.6")
[21:40:59] ur5us: has joined #ruby
[21:43:41] Megamos: has joined #ruby
[21:45:02] karapetyan: has joined #ruby
[21:55:17] venmx: has joined #ruby
[22:02:20] carsonbaker[m]: has joined #ruby
[22:07:40] fluxAeon: has joined #ruby
[22:12:38] FernandoBasso: has joined #ruby
[22:14:26] Nicmavr: has joined #ruby
[22:16:59] catsed: has joined #ruby
[22:17:55] al2o3-cr: >> [:foo.public_send(:send, :eval, "1 if true"), ($SAFE = 1; :foo.public_send(:send, :eval, "1 if true"))]
[22:17:56] ruby[bot]: al2o3-cr: # => [1, 1] (https://eval.in/1039476)
[22:18:52] al2o3-cr: >> :foo.public_send(:send, :eval, "1 if true")
[22:18:53] ruby[bot]: al2o3-cr: # => 1 (https://eval.in/1039477)
[22:19:29] al2o3-cr: >> $SAFE = 1; :foo.public_send(:send, :eval, "1 if true")
[22:19:30] ruby[bot]: al2o3-cr: # => 1 (https://eval.in/1039478)
[22:19:39] al2o3-cr: >> $SAFE = 2; :foo.public_send(:send, :eval, "1 if true")
[22:19:40] ruby[bot]: al2o3-cr: # => $SAFE=2 to 4 are obsolete (ArgumentError) ...check link for more (https://eval.in/1039479)
[22:19:44] graphene: has joined #ruby
[22:19:46] za1b1tsu_: has joined #ruby
[22:20:29] al2o3-cr: this scares me!
[22:20:36] baweaver: Side-loading eval through send?
[22:20:57] baweaver: It's certainly clever.
[22:21:06] Hanmac: has joined #ruby
[22:21:24] al2o3-cr: this is a major issue.
[22:21:27] baweaver: clever enough that now I'm looking through any of my code for vulns
[22:24:14] dshep: has joined #ruby
[22:25:16] al2o3-cr: wow, this is DANGEROUS.
[22:26:32] milanj: has joined #ruby
[22:26:37] jxweng: has joined #ruby
[22:27:01] cats: has joined #ruby
[22:30:10] konsolebox: i hope you're being sarcastic
[22:30:51] graphene: has joined #ruby
[22:31:06] al2o3-cr: konsolebox: not in the slightest.
[22:31:32] alfiemax: has joined #ruby
[22:31:33] j416: has joined #ruby
[22:34:07] al2o3-cr: OMG this is crazy!
[22:34:12] FernandoBasso: has joined #ruby
[22:34:48] baweaver: zenspider: Doesn't brakeman catch that?
[22:35:51] konsolebox: al2o3-cr: and now you switch to legitimate sarcasm mode
[22:36:03] cats: has joined #ruby
[22:38:58] fmcgeough: has joined #ruby
[22:40:18] InfinityFye: has joined #ruby
[22:41:45] graphene: has joined #ruby
[22:47:13] salasrod: has joined #ruby
[22:47:35] jenrzzz: has joined #ruby
[22:47:36] jenrzzz: has joined #ruby
[22:52:53] al2o3-cr: konsolebox: [:foo.public_send(:send, :eval, `whoami`), ($SAFE = 1; :foo.public_send(:send, :eval, `whoami`))] # run this
[22:56:39] al2o3-cr: or any command for that matter.
[22:59:04] al2o3-cr: don't forget to double quote the backticks.
[23:00:05] white_lilies: has joined #ruby
[23:03:15] alex``: has joined #ruby
[23:04:59] al2o3-cr: konsolebox: tell me how this is not a security flaw?
[23:07:05] konsolebox: i really don't see how that is a security flaw. maybe it is if you allow public_send(:send, user_input_1, etc)
[23:07:19] konsolebox: and the only one to blame is the programmer
[23:08:06] al2o3-cr: konsolebox: of course user input, still besides the point.
[23:08:29] shinnya: has joined #ruby
[23:08:30] konsolebox: why? you can always use eval anywhere
[23:08:50] konsolebox: allowing user input as an argument to :send is ...
[23:09:04] al2o3-cr: public_send.
[23:09:28] konsolebox: and i'm talking about unsanitized input at least
[23:10:17] konsolebox: al2o3-cr: what about public_send? why would you allow public_send to send :send anyway?
[23:10:47] al2o3-cr: well, this shouldn't be possible
[23:11:18] scrptktty_: has joined #ruby
[23:11:24] mzo: has joined #ruby
[23:13:01] elomatreb: Why shouldn't it? send is a public method, after all
[23:13:08] al2o3-cr: public_send is private && send is public go figure.
[23:13:56] elomatreb: public_send isn't private?
[23:14:08] al2o3-cr: oh my friend it is.
[23:14:42] elomatreb: >> "it's not".public_send :length
[23:14:43] ruby[bot]: elomatreb: # => 8 (https://eval.in/1039483)
[23:18:25] konsolebox: regardless of how you use 'send' or any type of :send method, this what you call vulnerability is only effective if you allow allow an unfiltered user-supplied factor to define the method, regardless of the recursion.
[23:19:36] lupine: yes, because it's trivial to trace all possible sources of user input
[23:19:51] FernandoBasso: has joined #ruby
[23:19:53] elomatreb: Which probably isn't entirely uncommon, it's a convenient pattern e.g. for implementing a command-like system
[23:19:54] al2o3-cr: >> Object.public_method(:public_send) # elomatreb yep derp.
[23:19:55] ruby[bot]: al2o3-cr: # => #<Method: Class(Kernel)#public_send> (https://eval.in/1039484)
[23:19:58] jrafanie: has joined #ruby
[23:20:27] konsolebox: lupine: i'm unable to imagine a case where that can be relevant
[23:20:46] lupine: don't worry, I'm imagining it hard enough for both of us
[23:21:12] konsolebox: lupine: sure, feel free to give a legitimate example when you do
[23:21:48] kapil___: has joined #ruby
[23:21:58] al2o3-cr: i'm gonna release DumbAndDumber3 gem.
[23:22:27] konsolebox: i'm 99% sure it would just sum up to bad design of the shared function, or the application itself, because "abstraction"
[23:22:35] za1b1tsu_: has joined #ruby
[23:22:52] konsolebox: "high level abstractionz my friend"
[23:22:56] al2o3-cr: but i'll name it dd3
[23:23:28] al2o3-cr: >> Object.public_method(:puts)
[23:23:29] ruby[bot]: al2o3-cr: # => method `puts' for class `#<Class:Object>' is private (NameError) ...check link for more (https://eval.in/1039485)
[23:24:45] al2o3-cr: elomatreb: apologies, both are public otherwise it wouldn't tally.
[23:28:18] zenspider: help my old memory... is it OpenStruct that bleeds out? or... um. that other one? Idon't use either anymore
[23:28:53] baweaver: Yeah, havenwood mentioned OpenStruct polluted something
[23:28:57] baweaver: I think method cache
[23:29:49] mynameisdebian: has joined #ruby
[23:30:12] havenwood: zenspider: yup, creating OpenStructs breaks the method cache when it defines dynamic accessor methods
[23:30:18] zenspider: yeah. that too. I thought one of them was plonking off classes left and right as well
[23:30:38] zenspider: yeah. I just found that too
[23:31:07] mynameisdebian: has joined #ruby
[23:35:18] drale2k_: has joined #ruby
[23:50:16] Azure: has joined #ruby
[23:56:03] jrafanie: has joined #ruby