bougyman

Activity Graph

Page 1 of 10 | Next »

2019-06-03

[20:15:13] bougyman: *.net *.split

2019-05-31

[07:42:11] bougyman: Read error: Connection reset by peer

2019-05-23

[13:57:11] bougyman: zodd_: since you asked for prefernce, mine is Sequel.
[14:24:11] bougyman: https://sequel.jeremyevans.net/ you saw that, right?

2019-05-22

[14:08:05] bougyman: why do you need that?
[14:08:13] bougyman: why not just str.gsub!(regex)
[14:08:19] bougyman: if the regex doesn't match, that'll just be a noop
[14:10:00] bougyman: [1] pry(main)> str = 'foo'; str.gsub! /a/, ''; $~
[14:10:07] bougyman: [2] pry(main)> str = 'foo'; str.gsub! /f/, ''; $~
[14:10:10] bougyman: => #<MatchData "f">
[14:10:12] bougyman: damn what's with all the spacing?
[14:10:13] bougyman: But yes, yes it does.
[14:11:29] bougyman: also: don't use $~ for anything real.

2019-05-17

[16:32:36] bougyman: https://github.com/imanel/websocket-rack that's super old.
[16:32:51] bougyman: It's a dep in an app I'm taking over. Any "standard" replacement for it?

2019-05-04

[00:43:52] bougyman: Ping timeout: 250 seconds
[00:46:45] bougyman: has joined #ruby

2019-05-02

[21:12:55] bougyman: zacts: https://pine.fm/LearnToProgram/chap_00.html
[21:14:29] bougyman: zacts: The Pickaxe (the ony by Dave Thomas) is an excellent tome.
[21:14:43] bougyman: I just think it's easy and cheap (time-wise) to get through LearnToProgram first.
[21:16:31] bougyman: One caveat, for all the code in the white text boxes, type each line in pry (or irb (no, really use pry)).
[21:16:37] bougyman: Not copy/paste. Type.
[21:17:16] bougyman: pry is a better repl.
[21:17:24] bougyman: Similar in function to irb, but a lot more function.
[21:17:27] bougyman: gem i pry, yes.
[21:17:38] bougyman: then you have a binary called `pry`
[21:19:54] bougyman: Google is failing me. Once upon a time, someone did an s-exp variation of Ruby. Anyone remember that?
[21:20:24] bougyman: They lit up the ml with (((()))))

2019-04-26

[22:54:40] bougyman: Ping timeout: 268 seconds
[22:54:52] bougyman: has joined #ruby

2019-04-13

[16:49:58] bougyman: *.net *.split

2019-04-12

[12:08:25] bougyman: How can I make an object output the way pry makes it output?
[12:08:32] bougyman: I mean, I thought that was just pp, but it's not.
[12:10:03] bougyman: aha. #pretty_inspect
[12:16:48] bougyman: sure, but it's close enough. It's waht I was looking for.

2019-04-05

[15:50:03] bougyman: Ping timeout: 258 seconds
[15:50:58] bougyman: has joined #ruby

2019-04-04

[16:08:00] bougyman: google is failing me on how to convert the string "1.345e8" to a number
[16:08:15] bougyman: I swore I used something called BigNumber for this before. But I can't find that, either.
[16:08:33] bougyman: I just tried that
[16:08:46] bougyman: ArgumentError: invalid value for Integer(): "1.345e8"
[16:08:46] bougyman: [6] pry(main)> Integer '1.345e8'
[16:09:23] bougyman: => 134500000.0
[16:09:23] bougyman: [7] pry(main)> 1.345e8
[16:09:26] bougyman: I don't need the decimal place.
[16:09:41] bougyman: and i'm not gonna eval the thing.
[16:10:40] bougyman: => 134500000.0
[16:10:40] bougyman: [9] pry(main)> num.to_f
[16:10:40] bougyman: => "1.345e8"
[16:10:40] bougyman: [8] pry(main)> num = '1.345e8'
[16:10:53] bougyman: => "134500000"
[16:10:53] bougyman: [10] pry(main)> num.to_f.to_i.to_s

2019-04-03

[14:43:05] bougyman: That's what I was just about to say
[14:43:40] bougyman: You have to keep doing an #each_key.map onto the arrays so long as the obj responds to #each_key, and just add on to the arrays. At the end, just join the array strings on dots.
[14:44:46] bougyman: [2] pry(main)> s = { "breadcrumb": { "accueil": "Home" }, "donate_form_block": { "type_text": "Text" } }
[14:44:49] bougyman: => {:breadcrumb=>{:accueil=>"Home"}, :donate_form_block=>{:type_text=>"Text"}}
[14:44:52] bougyman: [3] pry(main)> s.each_key.map { |k| a = [k]; next a unless s[k].respond_to? :key?; s[k].each_key { |ik| a << ik }; a }.map { |arr| arr.map(&:to_s).join('.') }
[14:44:55] bougyman: => ["breadcrumb.accueil", "donate_form_block.type_text"]
[14:44:57] bougyman: like that, but recursively

2019-03-28

[01:47:54] bougyman: string =~ /^cf-[0-9]{3}-(?:a|de)sc$/
[01:50:04] bougyman: [3] pry(main)> %w[cf-123-asc cf-132-desc cf-aaa-asc cf-9-desc].map { |string| !!(string =~ /^cf-[0-9]{3}-(?:a|de)sc$/) }
[01:50:07] bougyman: => [true, true, false, false]
[01:50:45] bougyman: turning it into a boolean.
[01:50:49] bougyman: instead of 0 or nil
[01:50:53] bougyman: just outputs cleaner
[01:51:12] bougyman: he said he wanted true or false
[01:51:49] bougyman: nothing, with the !!
[01:51:51] bougyman: [4] pry(main)> %w[cf-123-asc cf-132-desc cf-aaa-asc cf-9-desc].map { |string| string.match /^cf-[0-9]{3}-(?:a|de)sc$/ }
[01:51:54] bougyman: => [#<MatchData "cf-123-asc">, #<MatchData "cf-132-desc">, nil, nil]
[01:52:12] bougyman: [5] pry(main)> %w[cf-123-asc cf-132-desc cf-aaa-asc cf-9-desc].map { |string| !!(string.match(/^cf-[0-9]{3}-(?:a|de)sc$/)) }
[01:52:15] bougyman: => [true, true, false, false]
[01:52:17] bougyman: no, =~ will be more efficient.
[01:52:25] bougyman: it doesn't have to create MatchData objects.
[22:49:44] bougyman: ryouba: because awk is lightning fast at things.
[22:50:13] bougyman: ryouba: for instance, in parsing a 140G LDIF, awk takes 7 minutes. Perl: 58 minutes. Ruby: 1 hour 18 minutes.
[22:50:45] bougyman: 140G isn't even large, these days.

2019-02-28

[16:32:34] bougyman: hrm. I forgot something and google isn't helping me remember.
[16:35:51] bougyman: https://gist.github.com/bougyman/2ae6f784c582726b15f6992d2c1e3212
[16:37:41] bougyman: google points me here, which are just variations of what I'd already done: https://stackoverflow.com/questions/133357/how-do-you-find-the-namespace-module-name-programmatically-in-ruby-on-rails
[16:41:44] bougyman: phaul: I know it is.
[16:42:32] bougyman: I don't think I ever mentioned inheritance. I know the difference.
[16:42:36] bougyman: This is just namespace nesting.
[16:42:51] bougyman: and I want to know the parent namespace of a class inside that module
[16:43:41] bougyman: module Outer; module Inner; module SuperInner; class Foo; def my_parent; ...; end; end; end; end; end
[16:43:52] bougyman: I want foo's my_parent to return Outer::Inner::SuperInner
[16:44:07] bougyman: I mean, that's what it does, currently.
[17:42:49] bougyman: phaul: the parent of a child class is looking for its own namespace.
[17:42:57] bougyman: But this method is defined in its parent class.
[17:43:05] bougyman: which has a different namespace.
[17:45:23] bougyman: Module.nesting seems to always choose the parent class's namespace.

2019-02-12

[19:04:36] bougyman: Ping timeout: 240 seconds
[19:06:06] bougyman: has joined #ruby

2019-02-11

[23:46:35] bougyman: *.net *.split

2019-02-09

[02:44:28] bougyman: Ping timeout: 264 seconds
[02:46:12] bougyman: has joined #ruby

2019-01-15

[04:13:37] bougyman: and 418 is "I'm a teapot"
[04:13:54] bougyman: lemur: I have :)

2019-01-11

[22:02:27] bougyman: ddffg: I'd use a work queue for that.
[22:02:39] bougyman: so all rails does is put them on that work queue (beanstalk is nice for this)
[22:02:47] bougyman: then as many workers you want can work that queue to send the mail

2018-12-28

[14:39:37] bougyman: i was about to mention each_with_object
[14:39:38] bougyman: [1,2,3].each_with_object([]) { |n, sum| sum.push(n) if n.odd? }
[14:40:03] bougyman: but yeah, select is better
[14:41:30] bougyman: haha, it's true.
[14:43:37] bougyman: just cause it can doesn't mean it should, though
[14:43:38] bougyman: [1,2,3].inject(0) { |sum, n| n.odd? ? sum += n : sum }

2018-12-24

[14:40:56] bougyman: That's not an interesting problem.
[14:46:20] bougyman: are you looking for all files?
[14:47:34] bougyman: Nobun: Dir.glob('**/*').select { |f| File.file? f }
[14:47:36] bougyman: try that instead.
[14:47:40] bougyman: see if it's what you want.
[14:48:27] bougyman: and then just use the select block for your comparison.
[14:48:45] bougyman: f =~ /#{xext_in}$/ instead of File.file? f
[14:49:37] bougyman: Or even just Dir.glob("**/*.#{xext_in}") probably

2018-12-19

2018-12-18

[06:20:13] bougyman: Just gotta choose plugins that fit you.
[06:20:23] bougyman: Personally I like ctrlspace.

2018-12-11

[16:00:58] bougyman: if it's bound to 0.0.0.0 it would be serving all ips.
[16:01:11] bougyman: You don't have a reverse proxy in front of it?

2018-11-28

[11:41:10] bougyman: I use a module instance variable for it.
[11:42:26] bougyman: module MyApp; def self.log; @log ||= default_log; end; def self.log=(other); @log = other; end; end
[11:42:31] bougyman: but it doesn't complain if you change it
[11:43:23] bougyman: yeah, that's the most common pattern I see
[11:44:47] bougyman: module method
[11:45:37] bougyman: it's considered good style to use .
[11:45:47] bougyman: and weird to use :: for anything other than nesting namespaces.
[11:45:52] bougyman: or accessing ... yeah
[11:46:09] bougyman: :: _works_, but it's ruby idiom to use . for calling methods, not ::

2018-11-19

[17:22:13] bougyman: AR is an orm
[17:22:17] bougyman: arel is the dsl for sql, no?

2018-11-09

[15:59:50] bougyman: Tohm3: sounds like you jumped to chapter 14 without going through chapter 1
[15:59:51] bougyman: nor any of the ones between 1 and 14

2018-10-25

[22:11:26] bougyman: https://www.serverless-ruby.org/
[22:11:29] bougyman: have you signed it yet?

2018-10-23

[17:08:20] bougyman: what's the version number?
[17:08:25] bougyman: I mean, what's an example?

2018-09-04

[21:36:04] bougyman: leitz: make a ~/.inputrc and set the vi editing mode in that.
[21:36:13] bougyman: which will work for any readline based applications
[21:53:37] bougyman: works here.
[21:53:41] bougyman: is your ruby built without readline?

2018-08-30

[03:25:48] bougyman: there has to be a better way to do this.
[03:26:06] bougyman: without #inject-ing a hash to store the path iterator
[03:26:09] bougyman: [25] pry(main)> path.to_s.split('/').inject({files: [], path: []}) { |a, e| defa = Pathname.new(a[:path].join('/')).join("#{e}/default"); (a[:files] << defa) if defa.exist? ; a[:path] << e; a }[:files]
[03:26:09] bougyman: => #<Pathname:foo/bar/baz>
[03:26:09] bougyman: [24] pry(main)> path
[03:26:20] bougyman: => [#<Pathname:foo/default>, #<Pathname:foo/bar/default>, #<Pathname:foo/bar/baz/default>]
[03:26:24] bougyman: works, but I hate it.
[03:32:34] bougyman: path.descend.map { |e| d = e.join('default'); d.exist? ? d : nil }.compact
[03:32:36] bougyman: much better
[04:43:28] bougyman: Radar: thanks, got to that.
[04:43:35] bougyman: I knew inject was just all wrong
[04:47:19] bougyman: no it doesn't
[04:47:34] bougyman: need to .reverse, then
[04:57:22] bougyman: no, it's right
[04:57:24] bougyman: I want descend

2018-08-22

[13:57:08] bougyman: Ping timeout: 255 seconds
[13:59:37] bougyman: has joined #ruby

2018-08-16

[16:05:05] bougyman: benzrf: example?

2018-07-27

[14:39:38] bougyman: I don't understand the question.
[14:39:53] bougyman: you have a string "foo" as a variable?
[14:40:11] bougyman: If so, you could do { foovar.to_sym => 'bar' }

2018-07-20

[00:07:16] bougyman: *.net *.split
[00:15:33] bougyman: has joined #ruby

2018-07-19

[05:31:10] bougyman: Ping timeout: 276 seconds
[05:35:36] bougyman: has joined #ruby

2018-07-18

[05:16:31] bougyman: *.net *.split
[05:35:19] bougyman: has joined #ruby

2018-07-12

[00:34:20] bougyman: same ruby version?

2018-07-06

2018-06-25

[21:20:15] bougyman: dminuoso: nil

2018-06-01

[03:44:47] bougyman: *.net *.split
[07:47:37] bougyman: has joined #ruby

2018-05-29

[02:47:15] bougyman: *.net *.split
[02:48:08] bougyman: has joined #ruby

2018-05-07

2018-05-04

[05:15:43] bougyman: *.net *.split
[05:15:55] bougyman: has joined #ruby

2018-04-25

[12:25:54] bougyman: *.net *.split
[12:27:26] bougyman: has joined #ruby
[15:01:25] bougyman: *.net *.split
[15:03:10] bougyman: has joined #ruby

2018-03-05

[16:01:14] bougyman: modules are used for that.
[16:01:31] bougyman: well, closest thing to prototyping a method that ruby has.

2018-02-27

[02:48:41] bougyman: Ping timeout: 256 seconds
[02:55:51] bougyman: has joined #ruby

2018-02-20

[19:17:50] bougyman: I get it. That's why I don't use it.

2018-02-16

[18:56:51] bougyman: that's really a matter of opinion.
[18:56:58] bougyman: I would recommend: none.
[18:57:16] bougyman: #anythingbutrails is my hashtag
[18:58:19] bougyman: simple solutions for simple problems.
[18:58:25] bougyman: Not everything has to be a kitchen sink
[19:12:08] bougyman: type1team: if you're looking for an easy way to accomplish SEO, you're searching for a unicorn.

2018-01-18

[01:55:16] bougyman: *.net *.split
[01:55:30] bougyman: has joined #ruby

2017-12-23

[16:16:33] bougyman: Ping timeout: 248 seconds
[16:19:50] bougyman: has joined #ruby

2017-12-22

[23:06:58] bougyman: Ping timeout: 264 seconds
[23:46:39] bougyman: has joined #ruby

2017-12-07

[14:48:18] bougyman: *.net *.split
[14:54:22] bougyman: has joined #ruby
[21:43:05] bougyman: *.net *.split
[21:48:19] bougyman: has joined #ruby
[22:37:00] bougyman: *.net *.split
[22:42:09] bougyman: has joined #ruby

2017-11-30

[14:58:30] bougyman: I prefer Pathname for these things, Bish
[14:58:35] bougyman: >> Pathname('/sys/class/net').children.detect { |w| w.children.map(&:basename).map(&:to_s).include? 'wireless' }
[14:58:38] bougyman: => #<Pathname:/sys/class/net/wlo1>

2017-11-22

[01:04:05] bougyman: the Hash.new(0) is used all over our code when the hash is comprised of counters.
[01:13:16] bougyman: RickHull: how could you get burned by it for counters?
[01:14:03] bougyman: ah, understood.
[01:14:06] bougyman: Yes, only ints.
[01:14:14] bougyman: But for ints I do think it fits the use case perfectly.

2017-11-17

[17:42:14] bougyman: % perl -e 'print -1>>8;'
[17:42:15] bougyman: 72057594037927935%
[17:42:20] bougyman: ruby -e 'puts -1>>8'

2017-11-15

[01:49:20] bougyman: and then some don't.
[01:49:24] bougyman: like Sequel.

2017-11-13

[23:10:06] bougyman: RickHull: rubocop hates that.

2017-11-11

[02:14:45] bougyman: @foo = bar is pretty obvious
[02:14:51] bougyman: even if you aren't familiar with ruby

2017-11-02

[19:40:25] bougyman: validations of what?
[19:41:24] bougyman: There are a few ways i've seen.
[19:41:35] bougyman: Contracts, Design By Contract, is one I liked.
[19:41:55] bougyman: But validating input still happens before being handed off to the contracted method.

2017-10-16

[13:37:42] bougyman: { } that much faster

2017-10-07

2017-09-24

[04:44:33] bougyman: these are complex questions which require a lot more information about your architecture and app.
[04:45:01] bougyman: perhaps better asked in #rubyonrails, too