<phaul>
I was with family today, haven't even started it
<phaul>
started bit of refactor
<phaul>
probably something for tomorrow
<phaul>
should be easy enough. thinking about it gave one of those heureka moments about design, that when you realize it you just know it's right.
<phaul>
so there was this class handling the Evaluation commands. Sending, receiving stuff and handling the bot command. many responsibilities.
<phaul>
then I realized. I just need an object that's getting a request, and has a response method and gives you a reponse. (all objects request - service - response - with single responsibility)
<phaul>
then it should be easy to generalize over sending stuff to carc in
ogres has joined #ruby
ogres has quit [Excess Flood]
ogres has joined #ruby
<al2o3-cr>
phaul: Nokogiri(open(url)).css('td').map(&:text).reject(&:empty?).join("\n").gsub(/\n\n\n/, "\n\n") then pass that to your evaluator. happy days :)
<al2o3-cr>
don't forget to error check and shit.
<phaul>
I know I'm weird but Im a firm beleiver in "sandi metz code" and shit. mainly shit. but the bot code is 100 % reek-ed
<rubydoc>
stderr: -e:2:in `<main>': uninitialized constant Ob (NameError) (https://carc.in/#/r/6egr)
<al2o3-cr>
&timmy
<rubydoc>
parser error at position 0 around `t'
<phaul>
as the grammar gets more and more complex, though, parslet scales nicely. and it's still readable
<phaul>
bunch of regexps at this scale would be simply horrendous
<al2o3-cr>
overkill imo :)
<al2o3-cr>
why? regexp matches or doesn't. simple
<phaul>
not that, the regexp itself.
<al2o3-cr>
not a chance
<phaul>
start with & then ri (or for other commands something else) then ruby class name following ruby rules then . then ruby method name following ruby method name rules
<al2o3-cr>
phaul: then use YARD::Registry then some tweaks.
<phaul>
yeah that's the thing I missed I think derpy was using, but I went down an other path
<al2o3-cr>
even so, simple ruby can sort that.
<phaul>
tbh for me parslet is really not more overhead than regexps. I was already familiar with it
<al2o3-cr>
cool beanz :)
<phaul>
during the years I wrote more compilers than programs to compile ;)
<al2o3-cr>
phaul: nice :)
<al2o3-cr>
phaul: you still sailing?
<phaul>
skipping this year, I have no money
<phaul>
will need to work. the boat is ashore in Shampton
<phaul>
such is life.. blame brexit
<al2o3-cr>
phaul: does this time out; `trap(:XCPU) { abort "expired" }; Process.setrlimit(:CPU, 5, -1); loop {}`
<phaul>
hm. I saw you executing it before. I have no idea what it does...
blackmesa has quit [Read error: Connection reset by peer]
blackmesa has joined #ruby
szulak_ has joined #ruby
Inline has joined #ruby
Dbugger has quit [Ping timeout: 264 seconds]
Pisuke has joined #ruby
MyMind has quit [Ping timeout: 244 seconds]
cristof has quit [Remote host closed the connection]
cristof has joined #ruby
cschneid has quit [Ping timeout: 245 seconds]
mangold has joined #ruby
cd has quit [Quit: cd]
mangold has quit [Ping timeout: 264 seconds]
<ytti>
phaul, Proc.new => proc, the mocha test fails, because the code on longer calls Proc class to create an instance
<ytti>
phaul, it's really mocha issue in testing
DTZUZO has quit [Ping timeout: 258 seconds]
<phaul>
I don't know. I don't know mocha. But if you link the source code you had before, you have after, and the erro message printed, I or someone else can take a look and try to help. But informal description of the issue doesn't help. The code has all the details, and the full error message also. You might think that that's all irrelevant, and it might be so, but giving as much information as possible can't hurt.
mangold has joined #ruby
duncan_bayne has joined #ruby
<duncan_bayne>
Hi :) On my system, File.stat('/tmp').writable? returns true when run under MRI 2.5.1, but false when run under JRuby 9.1.7.0. This means that Dir.tmpdir is failing under JRuby, because it thinks /tmp isn't writable.
<duncan_bayne>
I suspect I'm running into an obscure bug here, but couldn't find anything obvious.
am0123 has quit [Ping timeout: 255 seconds]
<duncan_bayne>
Has anyone seen this behaviour before?
<ytti>
¨' ~.
<ytti>
phaul, i see where you're coming from, but i think in this case just knowing mocha is 'Proc.expects(:new).returns(credentials)' and it works, and changing source code from Proc.new to proc, breaks it, is actually all the data needed to solve the problem, as it's very specific to Mocha, it is even plausible that you just can't test 'proc' with Mocha, and I'm better using Proc.new with # rubocop:disable
<ytti>
phaul, the logic why it breaks is fairly simply, code being tested is not instansiating Proc class
apparition has quit [Quit: Bye]
yokel has joined #ruby
jdawgaz has joined #ruby
Fernando-Basso has joined #ruby
duncan_bayne has left #ruby ["gives up for the night"]
Rudd0 has quit [Ping timeout: 250 seconds]
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cschneid has joined #ruby
Sembei has joined #ruby
Pisuke has quit [Ping timeout: 250 seconds]
mangold has quit [Quit: This computer has gone to sleep]
crankharder has joined #ruby
ua_ has quit [Ping timeout: 250 seconds]
darth-chatri has joined #ruby
cristof has quit [Remote host closed the connection]
cristof has joined #ruby
cristof has quit [Remote host closed the connection]
darth-chatri has quit [Quit: Leaving]
cristof has joined #ruby
ua_ has joined #ruby
szulak_ has joined #ruby
am0123 has joined #ruby
szulak_ has quit [Read error: Connection reset by peer]
cschneid has quit [Ping timeout: 246 seconds]
lucasb has joined #ruby
AJA4350 has joined #ruby
crankharder has quit [Ping timeout: 250 seconds]
crankharder has joined #ruby
cristof has quit [Remote host closed the connection]
cristof has joined #ruby
cristof has quit [Client Quit]
crankharder has quit [Ping timeout: 244 seconds]
crankharder has joined #ruby
crankharder has quit [Remote host closed the connection]
crankharder has joined #ruby
cschneid has joined #ruby
houhoulis has joined #ruby
houhoulis has quit [Remote host closed the connection]
crankharder has quit [Ping timeout: 250 seconds]
reber has quit [Remote host closed the connection]
conta has joined #ruby
conta has quit [Ping timeout: 244 seconds]
cschneid has quit [Ping timeout: 245 seconds]
sylario has joined #ruby
cschneid has joined #ruby
xco has joined #ruby
<xco>
Hi. I’m trying to generate unique usernames for users. Currently I’m using the part before the @ of their emails but to make it truly unique i’m generating some random characters (two characters) then adding it to the email
<xco>
so a user with an email like user@email.com
<xco>
will have a username like
<xco>
user_xP
<xco>
or user_9h
<xco>
etc
<xco>
i don’t like this _xx part that i’m generating
<xco>
instead i thought of something like generating a digest of the timestamp
<xco>
which will always be unique right?
<xco>
the problem with the digest is they won’t be easy to remember/memorise
<xco>
question is
<xco>
how do i generate a truly unique value
<xco>
that’s short
<xco>
and easy to remember in Ruby
<xco>
?
<canton7>
firstly, isn't being unique across your site enough? you don't need something that's globally unique - just something that doesn't already exits in your database. That's a much easier ask, as you can generate something, check if it's in your database, and if it is then generate something else
<canton7>
secondly, can't you let users pick their own usernames? I know I wouldn't want the bit at the start of my email being my username - it's got my full name in it, and I don't want to share that with random people
sariyar has joined #ruby
<xco>
i like your second point
<canton7>
also it gives people an easy way to spam me - take the username, append popular email providers
<xco>
as far as the first point is concerned. i’m trying to avoid hitting the db, since like you said, first i have to check if a username exist in the db, that might be expensive
<xco>
that’s actually what i’m doing
<xco>
and want to find ways to avoid that
<canton7>
nah, this is only done on sign-up. that's rare.
<canton7>
and doing a read on an indexed column like that is going to be *significantly* cheaper than inserting the username you finally decide on...
<xco>
very good point
<canton7>
and many times cheaper than fetching all of the information you'll need to show any page once they're logged in
<xco>
right
<xco>
thanks :)
am0123 has quit [Ping timeout: 245 seconds]
evdubs has quit [Remote host closed the connection]