#ruby - 22 October 2017
« Back 1 day Forward 1 day »
[00:02:07] cADO: Hey guys, I'm using rails 5 and the devise gem, does some1 knows how to have two devise models with custom controllers so I can have different sign up forms?
[01:06:10] tongueroo: wondering if any rubyist can help explain how thor parses the "desc" and "method_options" to use internally later. https://github.com/erikhuda/thor/wiki
[01:07:14] tongueroo: looking at https://github.com/erikhuda/thor/blob/master/lib/thor/parser/options.rb for clues
[01:12:22] havenwood: banisterfiend: before_install: gem uninstall bundler --force --executables && gem install bundler --version 1.1.1
[01:13:10] banisterfiend: havenwood thanks, any idea why the fuck it would be installing an ancient version of bundler on travis?
[01:13:21] banisterfiend: i dontspecify version anywhere butit seems to want to isntall and old broken versino that is breaking all my specs
[01:14:18] havenwood: banisterfiend: Ah, I guess a simple `gem install bundler` gets the newer version, so removing the old one isn't actually necessary.
[01:15:29] havenwood: banisterfiend: it takes a little while extra, but i actually do a: before_install: gem update
[01:15:48] banisterfiend: yeah the weird thing is it's only using an ancient version on one ruby verson build
[01:17:41] havenwood: I figure since we actually use latest bundled and default gems in production, that updating those pre-`bundle` actually gets it the closest to prod.
[01:19:04] havenwood: Neat how they're really going all-in on default gems in 2.5: https://stdgems.org/2.5.0/
[02:03:51] banisterfiend: completely bored of learnign the ins and outs of 1000 different gems you need for web development
[02:04:40] baweaver: Rails has _nothing_ on the shenanigans you have to swing on package management there.
[02:06:20] baweaver: If you ever find yourself wanting to go stateside though, we have embedded over here ;)
[02:07:49] baweaver: Understandable. Most teams here are ~5-8, though this is the smallest company I've been at.
[02:07:58] banisterfiend: and smaller companies have less meetings, less process, less management interference
[02:08:18] banisterfiend: i think whenever a company i work for gets big i'll leave and find a smaller company again
[04:55:27] basket: iamyask: DateTime.iso8601('2017-10-24T06:00:00.00Z').strftime('%Y-%m-%dT%H:%M:%SZ') #=> "2017-10-24T06:00:00Z"
[08:33:20] Hexafox[I]: If I want to import a yml config file to be accessible from every ruby file in my program what would be the best way?
[09:11:04] apeiros: constants or places accessible from a constant (like Rails.application.secrets) are most common
[09:13:05] matthewd: A library has no business playing with globals, but it seems a pretty reasonable option for an application IMO
[09:21:53] matthewd: I guess I just don't see the fundamental distinction between globals and top-level constants: they're both globally-accessible hash tables
[09:22:46] apeiros: >> Foo = 1; module Bar; Foo = 2; class Bar; def foo; Foo; end; end; Bar::Bar.new.foo
[09:22:47] ruby[bot]: apeiros: # => /tmp/execpad-f57602297e4f/source-f57602297e4f:7: syntax error, unexpected end-of-input, expecting ke ...check link for more (https://eval.in/884480)
[09:23:00] apeiros: >> Foo = 1; module Bar; Foo = 2; class Bar; def foo; Foo; end; end; end; Bar::Bar.new.foo
[09:23:32] apeiros: "people use X wrongly, therefore we should just go ahead and use the wrong tool instead"? that argument doesn't resonate with me :)
[09:24:49] matthewd: My argument looks more like "people often don't use unique-property-of-X, therefore X and Y seem interchangeable for those use cases"
[09:25:24] apeiros: they may superficially seem, but they aren't. I can do more about constants than I can do about globals.
[09:26:24] apeiros: besides of the fact of course that every gem/application should stuff its things under a single top level constant - which isn't possible with globals.
[09:27:22] matthewd: 3rd party code isn't application code, it's library code, and as I said, has no business playing with globals
[09:29:43] apeiros: another point of you and I re application: me exploring your code. it's easier to figure what things belong to and exist for if you have the tree structure of constants vs. flat-thing globals.
[09:29:52] matthewd: I think I like the idea partly *because* libraries have no business there: it gives the application a free namespace
[09:30:43] matthewd: Sure, but we're talking about things that are intended to be globally accessible -- which to me implies they're going to get a top-level constant anyway
[09:32:22] apeiros: one gem, one library, one application - each of those should have one top-level constant and that's it. if you want to access things without the top level constant, make it a module and include it in your files.
[09:32:30] matthewd: Yes, if you're going to namespace everything you define, you're treating your application more like a library, and the rule would then apply
[09:39:15] apeiros: though rails ignored a couple of conventions even at its inception. so who knows, it might have ignored that one too.
[10:22:53] matthewd: .. which are globally accessible, but are not "global variables", which start with $
[10:23:54] matthewd: Yeah, apart from a couple that control ruby itself, they're rare in modern code
[10:24:47] Hexafox[I]: I have seen namespaced constants in rails though, one website I made had stuff like Spree::Product
[10:30:36] matthewd: (the first constant a class is assigned to is actually special, because the class remembers that as its name.. but they're still fundamentally not the same thing)
[10:34:07] matthewd: When a constant is assigned, if the value is a class and the class doesn't have a name yet, it names itself after that constant
[10:35:14] ruby[bot]: matthewd: # => /tmp/execpad-017e6f726ffe/source-017e6f726ffe:2: warning: already initialized constant A ...check link for more (https://eval.in/884517)
[10:38:17] matthewd: Okay, apparently things are a bit more subtle than I thought. But the above gives ["A", 7] on 2.4.
[10:39:22] apeiros: <pedant-mode> s/if the value is a class/if the value is a module/ (it works the same for modules and Class subclasses Module)
[10:44:56] ruby[bot]: +bbb $a:tmm88$#ruby-banned tmm88!*@*$#ruby-banned *!*@unaffiliated/tmm88$#ruby-banned
[10:44:56] ruby[bot]: ruby[bot] kicked tmm88: is not suitable for this channel, see http://ruby-community.com/pages/user_rules
[11:26:32] tyil: Im trying to run jekyll in a docker container, but I get the error "jekyll 3.5.2 | Error: Permission denied @ rb_sysopen - /dev/core"
[11:48:17] tyil: its like python in that it is an interpreted language, its like java in that it is OO
[11:49:32] tyil: depending on your needs, perl 6 might be interesting, it has ideas from a multitude of languages making it suited for many tasks
[11:55:02] zanoni: scorpiosec: for learning to program, and with ruby , many use this book: https://pine.fm/LearnToProgram/
[12:00:14] Harzilein: scorpiosec: there will be some bias when you ask in the respecive communities, don't you think?
[12:01:35] Harzilein: scorpiosec: all of perl5, python, ruby have mature collections of community-written libraries. (i'm not sure about perl6, does it have its own cpan?)
[12:01:38] tyil: perl 6 has sockets for network programming (both sync and async), grammars for parsing data (and optionally acting upon certain constructs, to create your own DSL for instance), it has interfaces to load c or python libraries if you need them, it has a c-like syntax
[12:03:03] tyil: it seems someone is working on Inline::Ruby for perl 6, so in some time it can load ruby modules too probably
[12:03:46] Harzilein: scorpiosec: like people said above, look into the introductory materials for those languages and pick one that resonates with you
[12:03:50] tyil: scorpiosec: its impossible to say which lang is "best" for you, it all depends on what style fits you
[12:06:16] tyil: for instance, generating a fibonacci sequence in ruby: http://rosettacode.org/wiki/Fibonacci_sequence#Ruby
[12:09:38] Harzilein: scorpiosec: you want a random problem? ok, i'll tell you something i made in the 90s: find formulae for blood alcohol concentration after ingesting x ml of y proof alcohol w/ blood amount estimated from body weight. then find the formula about rate of metabolized alcohol. make a dialog for entering persons w/ their body weight.
[12:09:51] tyil: scorpiosec: I mostly have perl 6 examples, I'm here just to get help on an issue I have with running a ruby application
[12:10:49] Harzilein: scorpiosec: have it determine, calculated from the metabolism rate, how drunk each person is
[12:12:45] Harzilein: scorpiosec: you'll have some i/o in there, some calculations, compound data structures, mild "system" level stuff to find the current time.
[12:15:04] Harzilein: scorpiosec: they might actually build their own from whatever they are used to
[12:17:13] Harzilein: scorpiosec: since it involves manipulating some kind of runtime or the other, you just want to have abstractions for your manipulations so you can try more things and more focused things. all mentioned languages allow you to do this. depending on the subject matter, the runtime you are trying to manipulate might be close to the metal, so you'd pick up c and any platform's assembly as a necessity.
[12:18:44] Harzilein: scorpiosec: i'd not overthink your decision, it'll be almost unavoidable to learn multiple languages
[12:22:05] Harzilein: scorpiosec: think about it like you apply the programming to a subject matter that happens to be programming. that has always be the case anyway, infosec or not.
[12:25:29] Harzilein: scorpiosec: 6502 assembly can be picked up in a weekend. both java and ruby have libraries for interpreting opcodes. write an emulator/debugger to see which part of a 6502 binary (think nes game) changes a particular memory location.
[12:26:04] Harzilein: scorpiosec: that'll be pretty close to the things you might want to figure out in an infosec capacity
[12:36:10] zanoni: if you want problems to solve, go to CodeWars, they have a ton of challenges, and support multiple languages
[12:41:51] Harzilein: i think he might have a motivation problem if he can only think of "i want to use the big boys' tools" as a goal
[15:01:48] Prutheus: Im ny gtk main window, I have a vertical box which contains some stuff and at the bottom there is a scrollable box with an horizontal box inside. But why are the buttons inside this box so big? see here https://imgur.com/hu4qbAD