Cohedrin has quit [Read error: Connection reset by peer]
icarus has quit [Quit: leaving]
Cohedrin has joined #ruby
toretore has quit [Ping timeout: 240 seconds]
<brent__>
been a while since i tried out the meta programming stuff
<brent__>
i have 2 methods that do a query with different values, whats the best way to to create some sort of method missing/send to remove duplicate code
outreach_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ineb>
i dont think that i understand. two methods with different values? that is one method with a parameter for me. :)
<brent__>
thats what I was thinking initially
<ineb>
if only these values differ
<brent__>
but then thought about using send or something to try and get keep the method names the same
<brent__>
i'll probably just go w/ the variable passed in
<ineb>
if you want to keep the methods then change them to use your new parametrized method
<ineb>
so their behaviour from the outside does not change and to get rid of code duplication
<brent__>
yeah not worried about behaviour, I guess just tryign to avoid having to change where the methods are used
<brent__>
being lazy
<ineb>
i see
ecksit has quit [Read error: Connection reset by peer]
SeepingN has quit [Disconnected by services]
SeepingN_ has joined #ruby
dar123 has joined #ruby
xenops has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
houhoulis has joined #ruby
Cyrus has joined #ruby
antoniobeyah has quit [Quit: Connection closed for inactivity]
LastWhisper____ has joined #ruby
brent__ has quit [Remote host closed the connection]
patarr has quit [Ping timeout: 268 seconds]
railswebdev has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
patarr has joined #ruby
watersoul has quit [Remote host closed the connection]
watersoul has joined #ruby
railswebdev has joined #ruby
SeepingN_ has quit [Quit: The system is going down for reboot NOW!]
ionte has quit [Ping timeout: 240 seconds]
boshhead has quit [Remote host closed the connection]
howdoi has quit [Quit: Connection closed for inactivity]
boshhead has joined #ruby
tripolisenten has quit [Ping timeout: 240 seconds]
ionte has joined #ruby
bmurt has joined #ruby
Gabemo has quit [Ping timeout: 240 seconds]
yasu has quit [Ping timeout: 240 seconds]
tripolisenten has joined #ruby
bruce_lee has quit [Read error: Connection reset by peer]
gse_ has quit [Ping timeout: 240 seconds]
gse has joined #ruby
Snickers has quit [Quit: Snickers]
syndikate has quit [Ping timeout: 240 seconds]
mooser has quit [Ping timeout: 260 seconds]
syndikate has joined #ruby
yasu has joined #ruby
patarr has quit [Ping timeout: 268 seconds]
amclain has quit [Quit: Leaving]
Channel6 has joined #ruby
Trynemjoel has quit [Ping timeout: 245 seconds]
Trynemjoel has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
patarr has joined #ruby
charliesome has joined #ruby
username1 has quit [Ping timeout: 240 seconds]
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hays>
ok the magic in that i don't understand is how sample knows how to interface with securerandom
mooser has joined #ruby
loy_aqua has quit [Quit: loy_aqua]
<PorcoRex>
But in plain English, what is this supposed to do? It doesn't seem to be too efficient because you're getting a secure random (whatever that is) and then you're looping until it matches something.
loy_aqua has joined #ruby
<PorcoRex>
I think what you want to do is probably generate any random number and generate a string that matches your criterion accordingly, without needing the loop.
mooser has quit [Remote host closed the connection]
<dminuoso>
PorcoRex: Imagine generating passwords that meet certain criteria
<dminuoso>
hays: Gotta run. If you stay around Ill explain in about half an hour
<PorcoRex>
dminuoso, yeah, seems a bit of a brute force approach.
<hays>
its late here i probably wont make it. maybe catch you later
<PorcoRex>
hays, what's your criterion for a secure random?
esObe has joined #ruby
<hays>
it is a bit of brute force
<PorcoRex>
hays, are you trying to reverse engineer a system?
<hays>
no im writing a little throwaway function to generate random password strings for databases
<PorcoRex>
Ok, but why do you need a special criterion for the passwords?
howdoi has joined #ruby
<hays>
but since its a password, i figure I want something cryptographically secure. like /dev/urandom is probably OK. openssl i trust a bit more I think
<hays>
PorcoRex: because the passwords get stored in plaintext config files with syntax limitations usually
<PorcoRex>
So it's the actual characters that are bothering you.
<elomatreb>
If you're worried about syntax I'd recommend avoiding everything but alphanumerics
<hays>
for example including a password with \ in it causes complications sometimes. as does #
<hays>
elomatreb: yeah. the thought had crossed my mind to just use base64
<elomatreb>
e.g. $ may cause interpolation in some languages
esObe has quit [Ping timeout: 240 seconds]
anisha_ has joined #ruby
<PorcoRex>
hays, how about SecureRandom.hex
<hays>
PorcoRex: SecureRandom.base64
<PorcoRex>
hays, sure. Why not?
<elomatreb>
If you just want typeable passwords that don't break syntax that seems like the best choice honestly
<hays>
I'm overthinking it. For the sake of learning something about the language
electrostat has quit [Quit: uwotm8]
jtd has joined #ruby
electrostat has joined #ruby
<hays>
the construction I came up with seemed clumsy from a language perspective. kinda repetetive
<elomatreb>
>> require "securerandom"; SecureRandom.random_bytes(1).encoding # One thing to watch out for
<PorcoRex>
I think you are hays, because what you are doing is taking a library that already has what you need and you loop on it until it gives you something that matches your regexp. And the regexp may not be that secure anyways.
<hays>
im increasing the space of the possible passwords
<PorcoRex>
In terms of characters?
<elomatreb>
The most ruby-ish way would probably be to generate an Array containg all possible characters, sample and join
<elomatreb>
Like described earlier
<hays>
in terms of possible passwords given a fixed length
mooser has joined #ruby
<hays>
elomatreb: yeah that was nice. i still don't quite understand how .sample knows how to use SecureRandom
<hays>
also i do wonder how sample works.. whether it has some wierd bias in it
<PorcoRex>
hays, ok, to be honest I think hex or base 64 is definitely the best approach. But if it weren't what I would do is take the random bytes and have a hash where each byte maps to a safe character.
nofxxx has quit [Ping timeout: 260 seconds]
<PorcoRex>
Instead of looping, that is.
<elomatreb>
IIRC sample uses the same RNG by default rand uses, so it's certainly not cryptographically secure
<hays>
PorcoRex: before I did that I would get access to the bitstream and use modulo/division to strip off the bits i needed
<hays>
elomatreb: yeah but you can pass it an rng, somehow
esObe has joined #ruby
<PorcoRex>
And since we're in the subject, you might want to get a real random number from https://www.random.org/ in order to generate your password.
<hays>
despite having somewhat different methods than the Random class
<hays>
i am definitely not trusting some website for random numbers
nofxxx has joined #ruby
<PorcoRex>
hays, you can add 2 to them! :)
<elomatreb>
hays: Both SecureRandom and Random have rand, which is enough to generate an array index from
esObe has quit [Ping timeout: 240 seconds]
<hays>
hmm.. SecureRandom.rand tells me its private
<hays>
leaves me with a lot of questions to be honest
rakm has joined #ruby
hutch34_ has joined #ruby
electrostat has quit [Quit: uwotm8]
plujon has quit [Quit: ERC (IRC client for Emacs 25.1.1)]
anisha_ has quit [Ping timeout: 240 seconds]
bronson has quit [Remote host closed the connection]
enterprisey has quit [Remote host closed the connection]
electrostat has joined #ruby
hutch34_ has quit [Ping timeout: 258 seconds]
mogaj has quit [Remote host closed the connection]
mogaj has joined #ruby
cfec0b8d has joined #ruby
anisha has joined #ruby
aufi has joined #ruby
brent__ has joined #ruby
andikr has joined #ruby
brent__ has quit [Ping timeout: 268 seconds]
mogaj has quit [Remote host closed the connection]
mogaj has joined #ruby
cagmz has quit [Read error: Connection reset by peer]
hays has quit [Remote host closed the connection]
Guest96 has quit [Remote host closed the connection]
Gabemo has joined #ruby
Guest96 has joined #ruby
<foxmask>
bonjello
mogaj has quit [Remote host closed the connection]
mogaj has joined #ruby
esObe has joined #ruby
mogaj has quit [Remote host closed the connection]
Guest96 has quit [Remote host closed the connection]
esObe has quit [Ping timeout: 260 seconds]
alazred has joined #ruby
Guest96 has joined #ruby
mogaj has joined #ruby
jusa has joined #ruby
mogaj has quit [Remote host closed the connection]
bronson has joined #ruby
<kke_>
if i have a gem installed, and it looks like lib/foo-gem.rb. then in a another project i do "require 'foo-gem'", i guess it does something else than loads foo-gem.rb from the loadpaths
alazred has left #ruby ["Leaving"]
mogaj has joined #ruby
<kke_>
i guess it loads the gemspec and activates load paths from the dependencies
<PorcoRex>
kke_, the required paths are part of each gem's gemspec file.
mogaj has quit [Remote host closed the connection]
harfangk has joined #ruby
mogaj has joined #ruby
patarr has joined #ruby
<kke_>
i have gem-a and gem-b (with runtime_dependency 'gem-a') when gem-a requires gem-b i get Gem::LoadError : unable to find a version of 'gem-a' to activate (eventhough it's obviously already loaded)
postmodern has quit [Quit: Leaving]
dlitvak has quit [Quit: Connection closed for inactivity]
chichou has joined #ruby
govg has quit [Ping timeout: 240 seconds]
<Radar>
Should've used Bundler.
chichou has quit [Client Quit]
<PorcoRex>
Did you try installing gem-a with gem install gem-a.gemspec?
<PorcoRex>
Or was it build?
patarr has quit [Ping timeout: 255 seconds]
esObe has joined #ruby
pikender has joined #ruby
<pikender>
just tried Net::FTP class and it worked to connect and execute basic commands like pwd and chdir
<pikender>
but when using `list` or `getbinaryfile` action times out
<dminuoso>
But you don't apply it to code.rb but Gemfile, and it includes a sed script.
<dminuoso>
It changes all FTP to SSH.
<PorcoRex>
I think I needed to do Net::FTP.open(HOST) {|ftp| ftp.passive = true; ftp.login }
<PorcoRex>
And then the rest.
<dminuoso>
PorcoRex: Agreed. Net::SSH looks good.
jgnagy has quit [Remote host closed the connection]
jgnagy has joined #ruby
<pikender>
@PorcoRex, I did tried above but to no gain :(
<PorcoRex>
pikender, sorry, it's old code. It worked for me back then. What error are you getting?
<pikender>
oh my bad, I was referring to your next comment ftp.passive=true :)
<kke_>
let's say my gem is called "foo-bar" but it has lib/foo_bar.rb. so i use "require 'foo_bar'", which is not the gem's name. when does the foo-bar.gemspec get loaded?
<PorcoRex>
kke_, why not make a file called lib/foo-bar.rb with the content `require "foo_bar"` in it?
<pikender>
PorcoRex, I will try your patch and share how did it go .. Thanks for sharing :)
hanmac has quit [Ping timeout: 258 seconds]
<PorcoRex>
pikender, sure, hopefully it has something useful still.
<kke_>
PorcoRex: yes i can do that but i'm wondering how the heck ruby figures out it needs to load the gemspec (since it seems to do it)
<PorcoRex>
For gems Rubygems always takes the gemspec file as a reference for things a particular gem needs.
<PorcoRex>
I'm sorry, I don't think I understand what you're trying to get at.
jcao219 has quit [Ping timeout: 268 seconds]
hanmac has joined #ruby
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
esObe has joined #ruby
j2k has joined #ruby
ddffg has joined #ruby
<kke_>
i'm trying to figure out what "activates" a gem in such a situation
mark_66 has joined #ruby
nhhc has joined #ruby
mooser has quit [Remote host closed the connection]
mikecmpbll has joined #ruby
brent__ has joined #ruby
loy_aqua has quit [Quit: loy_aqua]
<PorcoRex>
Gems are handled by Rubygems. They are installed via the "gem" (or wrapper app like "bundler"). A gem has a unique name and a gemspec file associated with it. The gemspec file contain information like what files are included in the gem and what paths should be added when requiring gems.
loy_aqua has joined #ruby
<ljarvis>
kke_: What do you mean "activates" a gem?
mikecmpbll has quit [Client Quit]
Silthias has joined #ruby
marr has joined #ruby
Silthias2 has joined #ruby
Silthias1 has quit [Ping timeout: 240 seconds]
brent__ has quit [Ping timeout: 258 seconds]
bigkevmcd has joined #ruby
Silthias has quit [Ping timeout: 268 seconds]
PorcoRex has quit [Quit: Leaving]
maattdd_ has joined #ruby
mikecmpbll has joined #ruby
Guest88__ has quit [Remote host closed the connection]
maattdd has quit [Ping timeout: 240 seconds]
djbkd has joined #ruby
kristofferR has joined #ruby
Qchmqs has joined #ruby
mim1k has joined #ruby
scrapy has joined #ruby
<scrapy>
Guys I used a module that could get website info had addons like google whois etc.
<scrapy>
Can anyone tell me the name of the module
<scrapy>
If I remember correctly it's either nodekjs or ruby
<ljarvis>
scrapy: that's awfully vague
Cohedrin has joined #ruby
<ljarvis>
you can get whois easily, but is that all you want?
mim1k has quit [Ping timeout: 258 seconds]
<scrapy>
It's basically a module that gets tons of data about websites like whois, JS libraries used, ngix or not, backend, etc
<scrapy>
It has addons for every info
<scrapy>
Kinda a grey hat one
<ljarvis>
metasploit?
<scrapy>
lol no I'm not that stupid.
<ljarvis>
:/
<ljarvis>
no idea then
<scrapy>
It's a module used for gathering information about websites. Almost all the data through multiple sources and addons
mim1k has joined #ruby
rhyselsmore has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
patarr has joined #ruby
mooser has quit [Ping timeout: 255 seconds]
stoffus has joined #ruby
raul782 has quit [Remote host closed the connection]
patarr has quit [Ping timeout: 260 seconds]
TreyG has quit [Ping timeout: 258 seconds]
charliesome has joined #ruby
TreyG has joined #ruby
Trynemjoel has quit [Ping timeout: 264 seconds]
bruce_lee has joined #ruby
biberu has joined #ruby
Trynemjoel has joined #ruby
rgtk has joined #ruby
elaptics has joined #ruby
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
rakm has joined #ruby
Emmanuel_Chanel has quit [Read error: Connection reset by peer]
rakm has quit [Ping timeout: 245 seconds]
PaulCape_ has joined #ruby
byte512 has quit [Ping timeout: 260 seconds]
bsartek has joined #ruby
PaulCapestany has quit [Ping timeout: 245 seconds]
Emmanuel_Chanel has joined #ruby
p0p0pr37_ has joined #ruby
thebigj has joined #ruby
<pavelz>
wonder why can't ruby spawn separate interpreter for a thread if gil is such problem
<thebigj>
Hello, I am non ruby programmer. My blog is based on Jekyll plugin. Recently I was trying to add one functionality which was not natively provided by the Jekyll plugin. Can someone review the customization I have written?
<thebigj>
Hello, I am non ruby programmer. My blog is based on Jekyll plugin. Recently I was trying to add one functionality which was not natively provided by the Jekyll plugin. Can someone review the customization I have written?
<thebigj>
Please help me by reviewing my PR.
<thebigj>
Thanks!
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
antoniobeyah has joined #ruby
oliv_____ has joined #ruby
Guest96 has quit [Remote host closed the connection]
Guest96 has joined #ruby
ldnunes has joined #ruby
HoierM has joined #ruby
oliv_____ has quit [Ping timeout: 260 seconds]
Vingador has joined #ruby
charliesome has joined #ruby
nadir has joined #ruby
mooser has joined #ruby
jeyraof^mbpr has quit [Quit: This computer has gone to sleep]
petruff has quit [Quit: WeeChat 1.7]
mooser has quit [Ping timeout: 240 seconds]
jdawgaz has joined #ruby
jdawgaz has quit [Client Quit]
MrBusiness3 has quit [Ping timeout: 252 seconds]
oliv_____ has joined #ruby
synthroid has joined #ruby
Verity has quit [Remote host closed the connection]
pifon has quit [Quit: Connection closed for inactivity]
<xco>
i’d like to run a few examples in irb with #tap
ltem has joined #ruby
<hxegon>
#tap is a bit confusing at first, the docs are good
<hxegon>
xco: ^
<xco>
hxegon: i can’t run the examples given :(
<xco>
wanted to test it. cause it’s really confusing me
hutch34 has quit [Quit: WeeChat 1.5]
<Phrogz>
Although I keep finding people that hate it, I love using .tap when I have to create an object that will be my return value, but I have to operate on it, first.
alazred has quit [Ping timeout: 258 seconds]
<hxegon>
Phrogz: yeah, love using it to avoid assigning tmp vars
<havenwood>
I think #let is pretty good, but folk feel like Rspec has claimed it.
<hxegon>
havenwood: excuse my ignorance, what would the practical use of that be?
<baweaver>
1.pipe(&add).pipe(&multiply)
<dminuoso>
baweaver: You mean compose() right?
chouhoul_ has quit [Ping timeout: 240 seconds]
<Phrogz>
class Object; def me; self; end; end # I want this, for those times that you have to pass a block like { |x| x }
<baweaver>
shhh
<havenwood>
hxegon: It's like mapping rather than declaring a variable and appending to it. When you're method chaining it's not too uncommon that you want to return a method called directly on the receiver.
<baweaver>
you'll scare the children
<dminuoso>
Heh.
<havenwood>
hxegon: We currently have to use an intermediate local variable.
<havenwood>
hxegon: It's nice to be able to just continue on with your chain.
<hxegon>
Phrogz: #itself is this pretty sure
jdawgaz has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
* Phrogz
rushes to the docs.
mogaj has quit [Remote host closed the connection]
<ljarvis>
havenwood: praiseth the language that shalt not be mentioned
<havenwood>
Phrogz: Yeah, they've added that. :-)
mogaj has joined #ruby
<havenwood>
ljarvis: :-D
<baweaver>
Haskell?
<Phrogz>
Hawt! I haven't followed Ruby updates since about 2.1
<ljarvis>
baweaver: haha
<baweaver>
Wait until 3
<dminuoso>
baweaver: I've been hearing this "wait until 3" for like 3 years now.
<hxegon>
Phrogz: there's tons of cool (or awful depending on who you ask) stuff lik &.
<baweaver>
lonely operator
<havenwood>
baweaver: haha, yup, exactly - i want pipe in the stdlib
<dminuoso>
baweaver: Ruby 3 will feel like Perl 5 -> 10 years too late.
<ljarvis>
a yes, the law of demeter operator
<mzo>
>> module Kernel; def under; yield self end end; 22.under { |k| k + 20 }
<Phrogz>
That discovery made me a little more OK with Ruby's methods not being first-class.
sorah___ has joined #ruby
<havenwood>
ljarvis: i thought just a block form of #itself was nice
<havenwood>
maybe that's too convoluted
<ljarvis>
Phrogz: yeah fair comment
<ljarvis>
havenwood: yeah i think that'd be fine too tbh
<ljarvis>
(for me)
bronson has quit [Remote host closed the connection]
bronson has joined #ruby
lxsameer has joined #ruby
<ljarvis>
good job ruby is monkeypatchable eh...
<ljarvis>
said nobody sane ever
* Phrogz
must be insane
<dminuoso>
ljarvis: You know the funny thing is, JS has rooted me back to earth.
<ljarvis>
meh, it has its upsides, but creates more problems than it solves imo
<dminuoso>
HOFs is all you need to customize magic.
<ljarvis>
dminuoso: JS destroys my soul in a similar way I suspect
<Phrogz>
ha
<ljarvis>
I hate few things more than JS
<dminuoso>
ljarvis: JS has been extremely pleasant for me ever since I discovered redux and started writing pure functional code left and right.
<ljarvis>
Java brings me down to earth sometimes
<ljarvis>
dminuoso: right, I do love me some functional code
synthroid has joined #ruby
<ljarvis>
tbh, Elixir comes closest to being the perfect language for me. There's only a few things I'd change if I could
<dminuoso>
ljarvis: I really want to change our Rails APIs to Phoenix. :)
<ljarvis>
and funnily enough, my own language I'm working on also has some issues I dislike because this stuff is hard :)
<ljarvis>
dminuoso: I'm a huge fan myself, and I work at a Rails shop too
niftylettuce has quit [Quit: Connection closed for inactivity]
sepp2k has quit [Quit: Leaving.]
synthroi_ has quit [Ping timeout: 258 seconds]
Cyrus has quit [Quit: WeeChat 1.7]
Guest96_ has joined #ruby
swirlsMD_ has quit [Ping timeout: 240 seconds]
<Phrogz>
ljarvis: What are your inspirations and changes for your language?
<Phrogz>
changes ~= "things that bugged you about another language that you set out as a goal to change"
anybody307249 has joined #ruby
<dminuoso>
ljarvis: The sad thing is, I have implemented a language before with basic optimizations and flow analysis already. But I don't even have a single clue how to tackle pure functional languages.
Guest96 has quit [Ping timeout: 268 seconds]
<baweaver>
Phrogz: played with the CSS of your site a bit. Look into: `font-size: 110%; line-height: 175%;` for standard font and `text-shadow: none;` for headers
alazred has quit [Ping timeout: 240 seconds]
<dminuoso>
Like, implementing seems like no real issue. But implementing them well is completely opague to mne.
<anybody307249>
does anybody know if activerecord persistence with save! works within a config/initializers/ devise auth strategy?
<ljarvis>
heh, yeah it's really tough
maattdd has joined #ruby
<ljarvis>
Phrogz: i want something like elixir but a little more terse and with first class functions
<dminuoso>
mzo: Oh wow. That's interesting.
<baweaver>
well there goes my weekend mzo
* baweaver
bookmarks
<Phrogz>
baweaver: Thanks. That site design is circa 1998, with a few patched on changes over the years (like the text shadow when it was new and hot 10 years ago).
<baweaver>
Yeah, mine needs some love: baweaver.com
<mzo>
:)
<anybody307249>
i have the user record that devise is attempting to authenticate with and im trying to persist an attribute in the devise strategy; the output of save! is true yet the data is not persisting in the database, the column is still nil
<baweaver>
mainly in form of actually writing stuff
chouhou__ has quit [Remote host closed the connection]
chouhoulis has joined #ruby
<dminuoso>
mzo: Yeah my weekend is now blocked too.
<dminuoso>
:(
maattdd_ has quit [Ping timeout: 240 seconds]
inersha has joined #ruby
SeepingN has joined #ruby
inersha has quit [Remote host closed the connection]
<dminuoso>
anybody307249: ?rails
<dminuoso>
?rails anybody307249
<ruby[bot]>
anybody307249: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
<anybody307249>
thanks ruby bot
raul782 has quit [Read error: Connection reset by peer]
anybody307249 has quit [Quit: Page closed]
<Phrogz>
ljarvis: Got anything of your language online yet?
<baweaver>
haven't seen much content on it, but there's a lot of interest in funding
<mzo>
it would be a shame if it didn't get completed
jcao219 has quit [Ping timeout: 240 seconds]
skweek has joined #ruby
<ljarvis>
Phrogz: not yet no, it's been in development for.. well, a long time. I would like to get it online soon-ish, but i've been saying that for a while :)
pwillard has joined #ruby
marr has quit [Ping timeout: 268 seconds]
sepp2k has joined #ruby
<pwillard>
New to ruby. What does the "!" mean in this context? --> user_input.downcase!
<dminuoso>
pwillard: It's part of the method name.
webopsx has joined #ruby
<dminuoso>
pwillard: Such methods are colloquially called "bang methods", and are usually used to imply that it mutates the receiver.
<LastWhisper____>
for `def content_thumbnail_url(content, width:, height:)` -- what does the `height:` mean? is it the same as height = nil ?
<dminuoso>
pwillard: However, don't assume that if there's no bang at the end that it's not mutated. Likewise some bang methods don't mutate their receiver either.
<ytti>
much like downcase? would be understood by ruby programmer to return boolean value
<dminuoso>
LastWhisper____: Almost. It's naming a keyword argument.
<ytti>
while language itself makes no promises or guarantees, they are just names
<ytti>
behaviour is out of convention
<ytti>
i.e.
<ytti>
def downcase?; end
<pwillard>
Ah. ok. that was the answer I was trying to find. quite the noob at this stage but I really like it so far
<dminuoso>
LastWhisper____: It may become more obvious if the kwarg has a default, such as def foo(bar: 1)
<ytti>
def downcase!; end
<ytti>
def downcase; end
<ytti>
are three separate methods
<LastWhisper____>
pwillard in laymans terms "mutates the receiver" means it saves the original variable/object to what downcase would transform it to be. so string = "Bob"; string.downcase; puts string; "Bob", string.save; puts string; "bob"
<LastWhisper____>
plz correct me if i'm wrong there xD
<dminuoso>
LastWhisper____: Spot on.
olivi____ has joined #ruby
nerglish has quit [Quit: nerglish]
<dminuoso>
LastWhisper____: Though, it may not be the case either.
<LastWhisper____>
exactly; but conventionally, and especially in models, that seems to be the case
<dminuoso>
LastWhisper____: There are some things that just have destructive or mutatible side-effects.
<pwillard>
I'm doing the CodeAcademy online thing as an introduction and they started using the ! without explanation.
<dminuoso>
And in Rails a ! often indicates that a method will throw an exception on error.
<dminuoso>
(And these are often paired with methods without that ! that dont throw)
<dminuoso>
Stress on "often"
<LastWhisper____>
ya i forgot this is the ruby channel
<pwillard>
I'm not sure I'm headed in the rails direction... though I like the CLI aspect of ruby so far...
<LastWhisper____>
they may not even be working with models :)
<dminuoso>
pwillard: Likewise a method name may contain a question mark, these are conventionally used as "interrogative methods" that yield a boolean.
<dminuoso>
Basically you can view them as a question, and the method will answer "true" or "false" (sometimes nil).
<dminuoso>
This concvention you can mostly actually rely onb.
mogaj has quit [Remote host closed the connection]
ski7777 has joined #ruby
<dminuoso>
pwillard: But in the end don't use a method without checking its API documentation, which should tell you what it does and what it returns. :-)
olivi____ has quit [Ping timeout: 255 seconds]
tvw has quit []
<pwillard>
sounds like a good plan to me
tristanp_ has joined #ruby
skweek has quit [Ping timeout: 255 seconds]
<pwillard>
So in a nutshell --> user_input.downcase! is saying modify variable user_input "in place".
<dminuoso>
pwillard: Maybe. Or maybe it throws an exception. Or maybe it has some non-obvious side-effects.
<dminuoso>
Or maybe it's just a dangerous method.
tristanp has quit [Ping timeout: 240 seconds]
<dminuoso>
pwillard: In the standard library I think it always means it modifies the variable in place. I think.
<pwillard>
Cool
rgtk has joined #ruby
yeticry has quit [Ping timeout: 245 seconds]
yeticry has joined #ruby
JoshS has quit [Ping timeout: 260 seconds]
<cseder>
I'm working through the ubiquitous PickAxe book (4th edt) and the more I learn the more true the "Easy to learn, difficult to Master" maxim becomes.
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hxegon>
lazyness is something I need to practice taking advantage of
<dminuoso>
cseder: You can do this with with C++17 though.
<cseder>
hxegon something about built-in functionality for infinite sequences / lazy enumerators in Ruby 2.0 +
<dminuoso>
cseder: Enumerators are basically coroutines. :-)
<dminuoso>
Well sort of.
<dminuoso>
They are generators.
<toretore>
enumerators use fibers, which are coroutines
marr has joined #ruby
Snickers has joined #ruby
<cseder>
"none of the lazy versions of the methods actually consume any data from the collection until that data is requested, and then they only consume enough to satisfy that request"
<cseder>
Ruby Magic
<hxegon>
How would you idiomatically generate triangular numbers more functionally? Not saying the code is bad, or even non-optimal, but I'm just not sure how.
<hxegon>
cseder: Ever since reading why FP matters, I've been finding any excuse I can to write lazy code.
<cseder>
hxegon Yes, it's a beautiful thing
<dminuoso>
hxegon: I dont write code anymore, I just became lazy instead.
<dminuoso>
Adding newlines and committing them to keep the commit quota.
<dminuoso>
Also I never break the CI pipeline anymore!
<hxegon>
"the functionality will be there when requested by a user, not before that"
username has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 240 seconds]
lmc has quit [Quit: Leaving...]
alazred has joined #ruby
alazred has joined #ruby
acalycine has joined #ruby
nhhc has quit [Remote host closed the connection]
hays has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jeffreylevesque has joined #ruby
<jeffreylevesque>
what does it mean @someVal ! []
<jeffreylevesque>
what does it mean @someVal != []
oliv_____ has quit [Remote host closed the connection]
<cseder>
hxegon I don't now much about FP, but I learned a little Lisp a couple of ages ago. What did you read about FP causing you to embrace FP?
oliv_____ has joined #ruby
<dminuoso>
jeffreylevesque: It means you need to get a
<hxegon>
answered my own question about functional triangular numbers cseder https://eval.in/779252
<jeffreylevesque>
dminuoso: ah ok just googled it
<hxegon>
cseder: Learning to program without side-effects in FP languages has probably halved the amount of terrible code I output
<jeffreylevesque>
guess no books
<jeffreylevesque>
are books even worth anything these days
<hxegon>
although your loop code in that case is really fine
<dminuoso>
jeffreylevesque: Yes.
<jeffreylevesque>
or is it to humor ppl like you dminuoso
<dminuoso>
jeffreylevesque: No, there's folks who thinks that people who just think books are not worth the money and time usually end up becoming horrid programmers.
<dminuoso>
But honestly I don't care because these folks don't make it into any interview worth mentioning ever.
<jeffreylevesque>
ah ok
<hxegon>
jeffreylevesque: is class var someVal not equal to an empty array?
<hxegon>
s/class/instance
<cseder>
hxegon what FP languages have you used most?
swirlsMD_ has quit [Quit: WeeChat 1.7]
<dminuoso>
jeffreylevesque: In fact I believe that books are worth more than ever because it's so easy to publish bad resources online. People with egos larger than mine have a tendency for self-proliferation.
haylon has joined #ruby
<hxegon>
cseder: clojure and haskell. I haven't used either of them for anything serious or bigger than a trivial project, but just learning how they work, how idiomatic code is written in them, is worth it for sure
<jeffreylevesque>
humans have relative emotions on things
<jeffreylevesque>
this is nice
<cseder>
hxegon Yeah, guess so. I have the Programming Erlang book from Pragmatic Programmers (Armstrong) that's waiting in my bookshelf
vuoto has joined #ruby
vizay has quit [Quit: WeeChat 0.4.2]
skweek has quit [Ping timeout: 260 seconds]
<cseder>
Containers, blocks, and iterators are core concepts in Ruby and I'm still trying to wrap my head around its uses
<hxegon>
That's another thing I'm looking forward to; checking out the actor model
<cseder>
hxegon Haven't had time to learn Erlang yet, but it sure looks interesting!
<hxegon>
cseder: also, check out elixir! To oversimplify it, it's erlang with ruby syntax
<cseder>
hxegon Will do
moei has joined #ruby
hays has quit [Ping timeout: 240 seconds]
hahuang65 has joined #ruby
outreachdan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]