oncall-pokemon has quit [Quit: Connection closed for inactivity]
sepp2k has quit [Read error: Connection reset by peer]
platzhirsch has joined #ruby
jcao219 has quit [Ping timeout: 260 seconds]
d0nn1e has quit [Ping timeout: 245 seconds]
ruby-lang737 has joined #ruby
Rodya_ has quit [Remote host closed the connection]
<ruby-lang737>
Hi All! Does anybody have a link or resource for an example of how we could set up a SQL based database structure to emulate something like Twitter?
Rodya_ has joined #ruby
Rodya_ has quit [Remote host closed the connection]
SuperLag has quit [Quit: pull the plug anyone?]
d0nn1e has joined #ruby
bastelfreak has quit [Disconnected by services]
johnmccabe has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bastelfreak2 has joined #ruby
cdg has quit [Remote host closed the connection]
fmcgeough has quit [Quit: fmcgeough]
benlieb has joined #ruby
jaguarmagenta has joined #ruby
tmtwd has joined #ruby
guacamole has quit [Quit: leaving]
guacamole has joined #ruby
platzhirsch has quit [Ping timeout: 260 seconds]
marr has quit [Ping timeout: 250 seconds]
bmurt has joined #ruby
bmurt has quit [Remote host closed the connection]
jaguarmagenta has quit [Ping timeout: 260 seconds]
benlieb has quit [Ping timeout: 260 seconds]
platzhirsch has joined #ruby
ruby-lang737 has quit [Ping timeout: 260 seconds]
antoniobeyah has joined #ruby
jbeeze has quit [Remote host closed the connection]
peyton_ has joined #ruby
millerti has joined #ruby
reverberations has quit [Quit: Leaving]
mifadir has quit [Quit: Leaving]
<peyton_>
Does anyone know a solution to this issue I've been having, what I do is that I set a variable in a loop but then after the loop breaks the variable don't exist. How would I go about making them hold their values after leaving the loop?
<adam12>
Break with the variable or use an instance variable. You might be able to define it outside of the loop and it will work too?
<adam12>
Show some code if necessary.
<peyton_>
Do you know if changes made to variables inside of loops carry over once the loop breaks?
<peyton_>
If so I think I have my solution. I'm trying to make a lil text based RPG sort of thing to help myself get better versed in Ruby.
<millerti>
peyton_: Assign a value to the variable before the loop. It will then get modified inside and persist.
<peyton_>
Ah, excellent. Thank you!
nankyokusei has joined #ruby
platzhirsch has quit [Ping timeout: 260 seconds]
smlocal has quit [Remote host closed the connection]
jcao219 has joined #ruby
smlocal has joined #ruby
mati_urunda has quit [Remote host closed the connection]
smlocal has quit [Remote host closed the connection]
smlocal has joined #ruby
nankyokusei has quit [Ping timeout: 248 seconds]
Rodya_ has joined #ruby
minimalism has quit [Ping timeout: 256 seconds]
minimalism has joined #ruby
sphex has quit [Read error: Connection reset by peer]
<obx>
i do have the subsystem installed, i thought about installing proper linux but with this
maattdd has quit [Ping timeout: 250 seconds]
ropeney__ has quit [Ping timeout: 256 seconds]
astrobun_ has quit [Remote host closed the connection]
Immune has joined #ruby
b0nn has joined #ruby
whathapp_ has quit [Remote host closed the connection]
whathappens has joined #ruby
<b0nn>
hi all, I'm trying to get my head around the difference between the dot operator eg. Class.method and the double colon operator, eg. Class::method. What's the difference and (for style reasons) when's the right time to use one or the other
dionysus69 has joined #ruby
astrobunny has joined #ruby
ropeney__ has joined #ruby
blackbombay has joined #ruby
whathappens has quit [Ping timeout: 258 seconds]
eljimmy has quit [Quit: This computer has gone to sleep]
djellemah has quit [Remote host closed the connection]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
<b0nn>
elomatreb: excellent, thank you
millerti has quit [Read error: Connection reset by peer]
montanonic has joined #ruby
<Disavowed>
b0nn: o/ Welcome to the dark side!
dogweather has joined #ruby
gusrub has quit [Remote host closed the connection]
<b0nn>
Disavowed: I've been looking for you!
<b0nn>
o/
blackbombay has quit [Ping timeout: 256 seconds]
Antiarc has joined #ruby
gingray has joined #ruby
djellemah has joined #ruby
<Disavowed>
b0nn: I'll PM you
dogweather has quit [Ping timeout: 260 seconds]
finisherr has joined #ruby
gusrub has joined #ruby
nankyokusei has joined #ruby
r3vDev1 has quit [Quit: Leaving.]
pawnbox has quit [Ping timeout: 252 seconds]
Devalo has joined #ruby
Macaveli has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Devalo has quit [Remote host closed the connection]
Devalo has joined #ruby
_ZerGabriel_ has joined #ruby
pawnbox has joined #ruby
xall has quit [Ping timeout: 250 seconds]
nankyokusei has quit [Ping timeout: 256 seconds]
nowhereman has joined #ruby
nowhere_man has quit [Remote host closed the connection]
saneax-_-|AFK is now known as saneax
pawnbox_ has joined #ruby
gingray has quit [Ping timeout: 260 seconds]
pawnbox has quit [Ping timeout: 252 seconds]
_ZerGabriel_ has quit []
Macaveli has joined #ruby
jeffaustin81 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
toretore has joined #ruby
<obx>
yikes yard is making my installed gem docs look really odd
CloCkWeRX has quit [Quit: Leaving.]
dogweather has joined #ruby
kn330 has joined #ruby
nelsonsar has joined #ruby
fenre has joined #ruby
nelsonsar has quit [Ping timeout: 258 seconds]
gusrub has quit []
yardenbar has joined #ruby
jcao219 has joined #ruby
Devalo has quit [Remote host closed the connection]
jgnagy has quit [Remote host closed the connection]
chazu has quit [Ping timeout: 250 seconds]
muelleme has joined #ruby
somiaj has joined #ruby
Guest43_ has joined #ruby
<somiaj>
Hello, I'm trying to build rouge with rake, bundler seems to error out. I have gem 'minitest', '~> 4.0' in the Gemfile, and bundler show minitest fails with Could not find gem 'minitest (~> 4.0)', yet according to gem list I have minitest (5.9.0) installed.
<Guest33095>
I keep getting the response "response Must upload a file"
<Guest33095>
don't know where I'm going wrong
jaguarmagenta has joined #ruby
Skydogg has left #ruby [#ruby]
jcao219 has quit [Ping timeout: 268 seconds]
tomphp has quit [Ping timeout: 245 seconds]
tomphp has joined #ruby
nemesit|znc has quit [Quit: ZNC 1.6.3+deb1 - http://znc.in]
nemesit|znc has joined #ruby
robouk has quit [Ping timeout: 246 seconds]
marxarelli|afk is now known as marxarelli
jaguarmagenta has quit [Ping timeout: 260 seconds]
<ytti>
gonna vent, apologies
<ytti>
every time i write python, i keep on thinking how inelegant it is
<ytti>
it feels like compiled language in elegancy with interpreted langauge performance
<ytti>
just now discovered def method(self, var=selft.default_value): does not work
<ytti>
you can't use self in method definition
<ytti>
you gotta do var=None):
<ytti>
if var == None:
<ytti>
var = self.default_value
<ytti>
small thing, but these kind of things keep on adding to my distaste
<ytti>
rust seems more elegant and higher level
<tobiasvl>
I've done python every day for years, and I quite like it, but yes I agree
<tobiasvl>
python always "felt" fairly low-level to me, probably mostly syntactically though
<tobiasvl>
can't quite put my finger on it
<ytti>
that would befine, if it would perform C like
<ytti>
like i don't thnk python is bad language
<ytti>
i mean we have PHP for that
tomphp has quit [Ping timeout: 248 seconds]
<tobiasvl>
yes, of course, it's not actually low-level, it just feels like I'm coding in a low-level language often
<ytti>
it's just, it really should perform really really well with how restrictive/inelegant it is
<ytti>
and the methods have hella poor standard library compared to ruby or even rust
<ytti>
i need to solve really generic and common problems in my own code
marxarelli is now known as marxarelli|afk
<ytti>
s/methods/classes/
<ytti>
sigh
<Papierkorb>
That surprises me ytti, I always heard Python was "batteries included"
xall has joined #ruby
aryaching has joined #ruby
<dminuoso>
Python isn't so bad. The reason is that Rust is really fun to play with.
<ytti>
len(obj) and sorted(list) also annoy me way more than they should
<ytti>
that fells straight up php esque
<ytti>
feels
<Papierkorb>
Currently playing with `crystal`, I really like it so far
pragmaticus has quit [Ping timeout: 260 seconds]
<Papierkorb>
It is correct that rust does not have a GC?
<dminuoso>
ytti: Python is highly inconsistent wrt to the receiver. Sometimes its receiver.message(arg), sometimes its arg.message(receiver), or in some special cases its even arg1.message(arg2, receiver)
<ytti>
Papierkorb, correct, it used to have GC pointer, but no longer
<Papierkorb>
Neat
<dminuoso>
Papierkorb: A GC is just an excuse for programmers not knowing how to write programs honestly.
<ytti>
dminuoso, ".".join(list) ....
<ytti>
Papierkorb, it's also essentially runtimeless
<ytti>
so rust is right there with C to do lowest level of stuff
<dminuoso>
Papierkorb: C++ demonstrates that automatic memory managament works flawlessly, a GC is a crazy overhead nobody really needs.
<Papierkorb>
dminuoso: I know, I did C++11/Qt for some years
matp has quit [Read error: Connection reset by peer]
<Papierkorb>
Though C++/Qt alone did it for almost two decades at this point
matp has joined #ruby
mradmacher has quit [Quit: WeeChat 1.4]
<Papierkorb>
dminuoso: Although I think the compiler knows best when you don't need something anymore, the dev should only have to "tag" variables if the compiler can't figure it out for whatever reason
tomphp has joined #ruby
<Papierkorb>
And the latter is always a work-around and not "good", the compiler failed in that moment
jaruga___ has joined #ruby
mradmacher has joined #ruby
govg has joined #ruby
<dminuoso>
Papierkorb: No the programmer knows best.
jaruga___ is now known as jaruga
jcao219 has joined #ruby
zukin has joined #ruby
<dminuoso>
Papierkorb: Compilers are not very good at understanding high level concepts.
<dminuoso>
Papierkorb: This is why it requires a complicated instrumentation suite such as valgrind to analyze memory leaks.
<Papierkorb>
Konrad invented modern computers cause he was too lazy to calculate his homework. We should learn from that if somethings annoying, we invent something for it so we can be lazy again.
<Guest33095>
my code doesn't work. I just get the response "Must upload a file"
<Papierkorb>
Compilers got really good at understanding all kinds of concepts dminuoso, rust is a good step forward, and I guess there's still "more to come"
<blackbombay>
Guest33095: it doesn't appear that it accepts a JSON payload but rather expects the same kinda post from a HTML form.
dionysus69 has quit [Ping timeout: 256 seconds]
<Guest33095>
blackbombay: Under "responses" it says "all successful API responses have the aplication/json content type" does this not mean that it accepts json?
<Papierkorb>
Guest33095: It does not
nunchuck has quit [Ping timeout: 265 seconds]
<Papierkorb>
blackbombay: it may respond with JSON, but it may only accept form data
<Guest33095>
Papierkorb: ah my bad ty
<blackbombay>
Papierkorb: wrong person :P but yeah what you said is incorrect.
<Papierkorb>
tbh, I'd expect the same, if it replies with JSON, it's reasonable to assume at first that it accepts it, but such is life ;)
<Papierkorb>
blackbombay: Wrong person² :P
<apeiros>
the world is built on x-www-form-urlencoded
<Papierkorb>
I thought it was badly encoded URL query "arguments"
<apeiros>
yupp. in the body of a post.
<apeiros>
(or put or patch or whatever else you use with a request body)
byte512 has quit [Ping timeout: 246 seconds]
conta has quit [Read error: Connection reset by peer]
aryaching has quit [Ping timeout: 265 seconds]
nikivi has joined #ruby
Tempesta has quit [Quit: See ya!]
omphe has joined #ruby
conta has joined #ruby
<blackbombay>
Papierkorb: oops, and incorrect should have been correct*
zukin has quit [Ping timeout: 268 seconds]
fenre has joined #ruby
JeroenDL has quit [Quit: JeroenDL]
cdg has joined #ruby
syf-revk has joined #ruby
byte512 has joined #ruby
<Guest33095>
Now I'm getting undefined method -_-
tulak has joined #ruby
sparch has joined #ruby
sparch has joined #ruby
sparch has quit [Changing host]
<blackbombay>
backtrace?
<blackbombay>
and the new code, too.
cdg has quit [Ping timeout: 258 seconds]
kobain has joined #ruby
nelsonsar has joined #ruby
<Papierkorb>
Guest33095: Please use gist.github.com btw
<Guest33095>
Papierkorb: anyway to make the gists anonymous?
<Papierkorb>
Guest33095: You can if you're not logged in. If you don't want to log out, use a private browsing window
<Guest33095>
Papierkorb: ty
dionysus69 has joined #ruby
Vingador has joined #ruby
Vingador has quit [Remote host closed the connection]
<Guest33095>
I'm back to getting "Must upload a file"
claudiuinberlin has quit [Ping timeout: 252 seconds]
tulak has quit [Remote host closed the connection]
tulak has joined #ruby
EdwardIII has joined #ruby
<EdwardIII>
hey, sometimes in a test i want to override a constructor, but i kinda can't because "removing `initialize' may cause serious problems". i kinda understand that hacking around with initialize in other people's classes is a bad move, but does it really matter if i do it in a few of mine just when they're under test?
<EdwardIII>
should i work on removing that error? or is it really, really always a terrible idea?
<EdwardIII>
override/stub
aryaching has joined #ruby
nelsonsar has joined #ruby
<toretore>
EdwardIII: do you have a concrete example you can gist?
<EdwardIII>
toretore: but a real world example might be an object that calls out to a 3rd party API in it's constructor
<guacjack>
Hello anyone know how to get hold of the PORT that a thin server is running on via code?
<guacjack>
It is being run via bundle exec thin -p 5569 start
Salih has joined #ruby
c355e3b has joined #ruby
yasu______ is now known as yasu
<antoniobeyah>
guacjack: what do you mean? when executed that way the port is in ARGV
conta has quit [Ping timeout: 244 seconds]
tulak has quit [Remote host closed the connection]
kimegede has joined #ruby
biberu has joined #ruby
tulak has joined #ruby
<guacjack>
Basically, the app is a Sinatra app, in one of its route i am returning JSON, and in that json i need to build up the full url of a file but when this server is running locally ie localhost:3003, i need to be able to get the port so i can build the url
Derperperd has quit [Quit: Derperperd]
conta has joined #ruby
bob_f has quit [Changing host]
bob_f has joined #ruby
<antoniobeyah>
request.port should have that info, be careful with that though because behind a web server (reverse proxy) that port will likely be represented improperly
aegis3121 has joined #ruby
GodFather has joined #ruby
<guacjack>
Exactly, which is not an ideal solution, normally i have used ENV['PORT'] before
blaxter has quit [Quit: foo]
<antoniobeyah>
you don’t want to use that at all. you would want to take in a variable that explicitly sets the self url
fenre_ has joined #ruby
krsh has joined #ruby
<antoniobeyah>
for example, your app servers normally listen on 8080 but you web servers on 443. so when you hit https://server it will forward to http://backend:8080 and the request.port would be 8080, instead your app should be rewriting the url as https://server
<antoniobeyah>
so the only real way is for your app servers to know their address. otherwise you will have to use the Host and protocol to attempt to guess the url
agit0 has quit [Ping timeout: 240 seconds]
jaguarmagenta has joined #ruby
fenre has quit [Ping timeout: 268 seconds]
<guacjack>
cool, thanks for the help mate
<guacjack>
Its just cause we have one code base for multiple environments
<guacjack>
but in our local environment sometimes we listen on different ports
<antoniobeyah>
one code base multiple environments is the way to do it. the only thing that should vary across environments is config
<guacjack>
Exactly, which is what we have, however, when running locally we sometimes run on different ports so i need to know the current PORT when the app is running
JeroenDL has quit [Ping timeout: 260 seconds]
<toretore>
EdwardIII: if you have no choice, then just do it and ignore the warning. a possible choice is to not use said class at all and implement your own that mocks the entire interface
jaguarmagenta has quit [Ping timeout: 260 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
conta has quit [Read error: Connection reset by peer]
<EdwardIII>
toretore: right-o
<EdwardIII>
i mean i guess maybe refinments are a better choice than using minitest's stub method these days anyway
<toretore>
EdwardIII: i don't really know, i'm not too into testing tbh
gnufied__ has joined #ruby
gnufied__ has quit [Remote host closed the connection]
<guacjack>
I guess it would but would involve a lot of brittle checking of environments also
JeroenDL has joined #ruby
<guacjack>
Thank you so much for your help i think I have what i need
<guacjack>
Thanks :D
<antoniobeyah>
yeah, I don’t recommend using that as I said before, but it should get you past your hurdle. prefer an config item with the url in it. good luck
drptbl has quit [Quit: My MAC has gone to sleep. zZz..]
<guacjack>
Yeah we have config items for all the other environments so i can add the url in there as they never change but for locally it doesnt really work :)
warrshrike has joined #ruby
robouk_ has joined #ruby
<warrshrike>
I'm using str.index /Node Id/ to get index at first instance of the regex match
robouk_ has quit [Max SendQ exceeded]
sepp2k has joined #ruby
<warrshrike>
I want the index for the first two matches
<warrshrike>
how can I do that?
robouk_ has joined #ruby
robouk_ has quit [Max SendQ exceeded]
robouk_ has joined #ruby
<matthewd>
request.port will respect X-Forwarded-Port, so that should always reflect how the client connected to you
<ruby[bot]>
mdvi: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<apeiros>
or well, ary[offset..-1] all to the right of offset, including offset
jcao219 has quit [Ping timeout: 258 seconds]
adavia has joined #ruby
firstdayonthejob has quit [Quit: WeeChat 1.6]
tulak has joined #ruby
SesMan has joined #ruby
<mdvi>
Can you type e.g. of the two last lines include quicksort? apeiros
<apeiros>
(got interrupted)
<apeiros>
the 2nd one: ary[0,offset] all to the left of offset, not including offset (it's ary[offset, length] and/or ary[offset..offset] with -offset meaning "length-offset")
<apeiros>
I can, but I think you should try yourself first.
bturker has joined #ruby
tulak_ has quit [Ping timeout: 268 seconds]
jhack has joined #ruby
xall has joined #ruby
tulak has quit [Ping timeout: 258 seconds]
<al2o3-cr>
mdvi: why you asking the same question in #lua?
ramortegui has joined #ruby
claudiuinberlin has joined #ruby
firstdayonthejob has joined #ruby
robouk_ has quit [Ping timeout: 260 seconds]
tulak has joined #ruby
fbt has quit [Ping timeout: 258 seconds]
<warrshrike>
herwin: It works okay in IRB
<warrshrike>
but in my code I get the same value twice
<warrshrike>
i want all of these^ in their own strings stored in an array
dionysus69 has quit [Ping timeout: 258 seconds]
<Swolbi>
Is there a specific area I can visit if I have a very simple question pertaining to a code of Ruby? I just started trying to learn it today and need some guidance on where I'm going wrong with a short program.
<Swolbi>
I don't want to post on here if this isn't the spot for it
rippa has joined #ruby
joebobjoe has joined #ruby
<matthewd>
warrshrike: I put the "Found.." line in its own slice.. if it belongs attached like that, it'll need some post-processing
ponga has joined #ruby
<matthewd>
cfl.lines.drop_while {|s| s !~ /Found a good path to sink/ }.tap(&:pop).slice_before(/^\[Node Id/).map(&:join)
kassav has quit [Remote host closed the connection]
fenre has quit [Remote host closed the connection]
Sammichmaker has quit [Read error: Connection reset by peer]
<matthewd>
cfl.lines.drop_while {|s| s !~ /Found a good path to sink/ }.tap(&:pop).slice_when {|a,b| a =~ /^-/ && b !~ /^-/ }.map(&:join)
<warrshrike>
Okay that works perfect
<warrshrike>
what did you do different in this last version?
kassav has joined #ruby
<warrshrike>
and irb says no method named pop. whats with that?
<warrshrike>
okay it works.
<matthewd>
A slightly different take on inferring the syntactic structure of what we're parsing: instead of looking for 'Node Id', it's separating them each time a line starting with '-' is followed by one that does not
<matthewd>
Swolbi: You're in the right place. Ask away.
<warrshrike>
Ah. I'll be studying these to understand them better. So which one is better to use?
<warrshrike>
If you had to choose one
joebobjoe has quit [Ping timeout: 260 seconds]
jhack has quit [Quit: jhack]
<matthewd>
It really depends on how the input data is defined, and thus what as-yet-unseen lines might look like
axisys has quit [Ping timeout: 260 seconds]
<warrshrike>
itl always be exactly the same
<matthewd>
To me, it looks like the '----' lines are intended to imply "here's more info about the previous thing". But maybe they're not always going to be there.
ledestin has quit [Ping timeout: 250 seconds]
<matthewd>
The second one would clump two Node Ids together if they didn't have a --- between them, for example
<warrshrike>
Ah so I guess il use the first
<warrshrike>
This is production code so yeah
<matthewd>
The only difference in how they handle your sample input is whether "Found" is part of the first "normal" block, or on its own
joebobjoe has joined #ruby
chouhoulis has quit [Remote host closed the connection]
<warrshrike>
Gotcha
jhack has joined #ruby
chouhoulis has joined #ruby
DaveTaboola has joined #ruby
<Swolbi>
I'm so new to this that I really don't even know how to ask lol. I think I'll just keep brainstorming for now.
Madplatypus has quit [Quit: Connection closed for inactivity]
<warrshrike>
Okay so this will strip anything before Found a good path...
<warrshrike>
What if I also want to get rid of everything after BFS is Done!
enterprisey has joined #ruby
<warrshrike>
also theres a sutble bug
harai has joined #ruby
<warrshrike>
it also takes in Found a good source path... whereas it should start with [Node Id:]
tenderlove has joined #ruby
enterprisey has quit [Max SendQ exceeded]
jhack has quit [Client Quit]
<matthewd>
You could use take_while {|s| s !~ /^BFS is done/ } instead of the tap+pop
blackbombay has joined #ruby
Swolbi has quit [Quit: Page closed]
enterprisey has joined #ruby
joebobjoe has quit [Ping timeout: 268 seconds]
statelesscode has quit [Ping timeout: 260 seconds]
statelesscode has joined #ruby
ldnunes has joined #ruby
jrafanie has joined #ruby
jrafanie has quit [Client Quit]
johnmccabe has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<warrshrike>
yeah it works now
<warrshrike>
except the first element to be extracted is bugged
<warrshrike>
it lumps two nodes togethet
enterprisey has quit [Max SendQ exceeded]
enterprisey has joined #ruby
<warrshrike>
okay that works for the first one too
rwb has quit [Ping timeout: 268 seconds]
bturker_ has joined #ruby
krsh has quit [Quit: krsh]
polishdub has joined #ruby
centrx has joined #ruby
<warrshrike>
Now whats thw elegant way to remove Found a good path... from the first result?
<matthewd>
You can just .sub it out, if you like
<matthewd>
The first entry is already going to be different from the others because it doesn't have the --- extras, so I'd expect to just handle that variation later when parsing further
bturker has quit [Ping timeout: 256 seconds]
<warrshrike>
but thatl require another line and not be fun. I did it currently with first_line.sub
Devalo has quit [Remote host closed the connection]
gnufied has joined #ruby
<warrshrike>
IMO return should be necessary. The gains in brevity don't seem enough to justify the loss of clarity
finisherr has joined #ruby
<baweaver>
If you're writing methods long enough that that's an issue you have another problem
<blackbombay>
return is nice for swift control flow, like return false if some_condition
<baweaver>
Typically style in ruby dictates that methods shouldn't exceed 10-15 lines.
<baweaver>
5 if we're going by Metz but that's a bit extreme in some cases.
saslam has joined #ruby
<warrshrike>
Respectfully disagree. I used to be into this implicit return and was actually miffed that it didn't but I now increasingly feel they made the right call in terms of it hurting clarity
amclain has joined #ruby
<warrshrike>
yeah obviously long funks are bad
jhack_ has joined #ruby
<warrshrike>
I feel it causes a cognitive dissonance when
antoniobeyah has joined #ruby
the_drow has quit [Quit: This computer has gone to sleep]
<baweaver>
Work in a more heavily functional language. You're not going to see return much of anywhere there either.
<blackbombay>
put it in the hat of subjective style
russt has joined #ruby
SCHAAP137 has quit [Quit: Leaving]
<warrshrike>
you explicity return in an IF block but then do so implicitly in the main body. Also its good to see control flow at a glance...
<warrshrike>
yeah totally subjective ofc
<baweaver>
It's my opinion that if one cannot grok ruby code without explicit returns they're not very deep into Ruby.
<domgetter>
baweaver you'll see return in Haskell a lot
finisherr has quit [Ping timeout: 256 seconds]
<warrshrike>
and as for functional languages well haskell and ml have expressions rather statements
jhack has quit [Ping timeout: 244 seconds]
aries_liuxueyang has quit [Quit: No Ping reply in 180 seconds.]
jhack_ is now known as jhack
<warrshrike>
so in that case the result is assigned and that makes sense in a mathematical way
sdwrage has quit [Quit: Leaving]
<baweaver>
domgetter: not very often in my case.
<warrshrike>
baweaver: well one CAN write ruby code without return. I was just wondering about the tradeoffs of doing so :)
<domgetter>
baweaver it was more of a joke about how monads are defined based on bind and return
aries_liuxueyang has joined #ruby
<baweaver>
Maybe
<toretore>
Just
<baweaver>
Some
<domgetter>
Burrito
finisherr has joined #ruby
finisherr has quit [Client Quit]
<baweaver>
After all though, Monads are just Monoids in the category of Endofunctors.
<toretore>
in an expression oriented language, a return should be the last expression, which also makes them useless
Salih has quit [Quit: Leaving]
Ishido has joined #ruby
railssmith has quit [Ping timeout: 248 seconds]
<baweaver>
In Ruby the most common use would be guard statements
shadowak47 has quit [Quit: ChatZilla 0.9.93 [Firefox 50.0.1/20161123182536]]
<baweaver>
def meth(x) return false unless x > 5; ... end
<toretore>
i use them sometimes too out of laziness, but if they were removed i'd be fine
<toretore>
i don't see any advantages
<warrshrike>
I really like ruby but occasionally its too slow. Any suggestion for a faster yet similar lang?
<baweaver>
define slow
<domgetter>
warrshrike how "similar"?
patarr has joined #ruby
<warrshrike>
baweaver: sometimes in competitive programming my solutions overrun the run time limit
<warrshrike>
the same algo in C runs through
<baweaver>
JRuby, Crystal
<elomatreb>
warrshrike: Crystal (crystal-lang.org) has similar syntax but is compiled, faster
jsrn_ has quit [Quit: Leaving]
<baweaver>
as far as similar: Scala
<baweaver>
as far as looking similar: Elixir
<warrshrike>
dogmetter: basically it should have clear and consice syntax. also, ruby has convenience methods for most things like str.scan etc. i dont want to be importing libraries or reimplementing basic stuff
<baweaver>
Scala
<patarr>
Hello. I've read this on some docs: "Or you may provide a custom delivery method object e.g. MyOwnDeliveryMethodClass. See the Mail gem documentation on the interface you need to implement for a custom delivery agent" Afaik Ruby doesn't have interfaces? Do they mean I have to implement every Class method in http://www.rubydoc.info/github/mikel/mail/Mail ?
<matthewd>
I think Rust fits somewhere in there too
rodferso1 has joined #ruby
SesMan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<warrshrike>
I'll look into jruby but is it really faster? and ive never heard of crystal or elixir do they have the basic funktionality?
<warrshrike>
and scala seems really verbose :/
<baweaver>
functionality*
Salih has joined #ruby
Salih has joined #ruby
Salih has quit [Changing host]
<baweaver>
Scala isn't really all that verbose for what it does
<warrshrike>
hmm what about swift or go?
<baweaver>
patarr: It doesn't. Likely they mean something to the note of it needs to implement these methods
<matthewd>
patarr: Yes, "interface" = "set of provided methods"... but you presumably only need to match whichever class they're talking about you replacing
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<patarr>
Why do people act like verbosity is a negative thing. That just screams "I work at a startup and only create new microservice and never had to maintain a large legacy codebase before"
<baweaver>
They may have some module to extend that adds the base methods.
<matthewd>
patarr: What are the "some docs" you're reading?
<toretore>
looks like the interface consists simply of `deliver!(aMail)`
Yzguy has joined #ruby
<patarr>
matthewd: ActiveMailer docs. Specifically the "delivery type". I don't want to use SMTP or file, but a third party API instead.
<patarr>
toretore: hah. Sweet.
<elomatreb>
patarr: Verbosity usually implies duplication, and duplication opens the door for inconsistencies increases room for mistakes
pragmaticus has quit [Ping timeout: 268 seconds]
<baweaver>
patarr: rather presumptuous there. Java is horrible about being verbose for no good reason.
rodfersou has quit [Ping timeout: 246 seconds]
<patarr>
elomatreb: it does not imply duplication in any way shape or form. Duplication implies bad programming and not knowing how to abstract.
rodferso1 is now known as rodfersou
Yzguy has quit [Client Quit]
<toretore>
it is useful to be specific about interfaces, and a lot of other things
<patarr>
Thank you matthewd and toretore. This was very helpful!
yardenbar has quit [Ping timeout: 265 seconds]
<domgetter>
patarr I don't think I've ever seen anything described simultaneously as verbose and concise
<baweaver>
After a point though you can reasonably infer things about aforementioned interface without explicitly saying it 10 times.
<toretore>
s/specific/explicit/
<baweaver>
being rigidly explicit about every last detail is tedious
<domgetter>
and hiding information can be confusing
axisys has joined #ruby
Salih has quit [Read error: Connection reset by peer]
dionysus69 has joined #ruby
<baweaver>
It becomes a lot cleaner though when you use a Contract like system for static typing though.
<patarr>
Sure it's tedious, but then you don't end up with syntax errors in production. lmfao
* Joufflu
duplicates mistakes cause of derpiness
<toretore>
baweaver: an interface specification would only have to be given once; the implementer then has a canonical source of truth and doesn't have to consult out of band information, or guess
<domgetter>
patarr if you're business process is allowing for syntactically malformed code to reach production, I'd say there are deeper issues there
benlieb has joined #ruby
<elomatreb>
patarr: If you have syntax errors in production I'd take a good look at your toolset
Salih has joined #ruby
Salih has joined #ruby
Salih has quit [Changing host]
<baweaver>
Yes, the external API, but not every little detail of the internal workings.
troulouliou_div2 has quit [Remote host closed the connection]
<toretore>
baweaver: of course, but that's not part of an interface spec
<baweaver>
fair enough
<baweaver>
The IO needs to be explicit
Yzguy has joined #ruby
<toretore>
in fact, that's what makes it an interface, it's the "outside"
railssmith has joined #ruby
<baweaver>
What do I put in and what do I get out. The details in the middle? Not so much.
syf-revk has quit [Quit: Leaving]
<patarr>
I have an example right here of why I would love an interface: the Mail library. It takes delivery methods of sendmail, SMTP, file, etc. But core_extensions only has smtp.rb. Where is file and sendmail? It also doesn't appear to extend any classes or include mixins.
<patarr>
toretore has let me known there is a deliver method of some kind, but I have yet to find it :(
Couch has quit [Ping timeout: 252 seconds]
<toretore>
you're right patarr, an interface would have forced the author to implicitly document it
<baweaver>
If the method was to multiply all numbers by two, it'd be kinda silly to explicitly make a new list and run them through a for loop when map would do the same.
<patarr>
toretore: aaah I'm looking at the wrong module/directory!
tuxaddicted has quit [Ping timeout: 256 seconds]
<patarr>
toretore: now with /network/delivery_methods under my belt, this should be pretty easy. I can work off of those as examples. Many thanks
fenre has joined #ruby
syf-revk has joined #ruby
flying has joined #ruby
riotjones has joined #ruby
nowhereman has joined #ruby
dviola has quit [Ping timeout: 244 seconds]
BTRE has quit [Remote host closed the connection]
ishe_ua has quit [Ping timeout: 265 seconds]
railssmith has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
synbit has joined #ruby
<warrshrike>
okay so cfl.lines.drop_while {|s| s !~ /Found a good path to sink/ }.take_while {|s| s !~ /^BFS is done/ }.slice_before(/^\[Node Id/).map(&:join)
<domgetter>
warrshrike it's a Ruby trick that the creator of Ruby regrets creating
<havenwood>
But now it exists so it is our solemn duty to use it whenever the chance arises.
jackjackdripper has joined #ruby
<patarr>
If a Ruby class is written in a "Mail" module in a library, and there is also a mail module in your application, will these clash? Or is there an implicit prefix to those modules I'm not aware of?
frozengeek____ has joined #ruby
frozengeek____ has quit [Remote host closed the connection]
SCHAAP137 has joined #ruby
<warrshrike>
oh thats an SR latch. I used to love those in college
<baweaver>
cfl.lines.drop_while { |line| line !~ /^[Node/ }[0..-3]
frozengeek____ has joined #ruby
<domgetter>
patarr if the modules have the same name, they are talking about the same module, and there can be clashes, yes.
<baweaver>
Drop lines until you find the first node, then chop off the last 2 lines
mikecmpbll has quit [Quit: inabit. zz.]
LoneHerm_ has joined #ruby
<warrshrike>
baweaver: will this also store in array ever [Node Id:]...till next Node Id
<baweaver>
Nope, still need the slice bit
frozengeek____ has quit [Read error: Connection reset by peer]
agit0 has quit [Quit: zzzZZZ….]
<warrshrike>
ah yeah was wondering that
<baweaver>
also need to escape that [ up there on my example
frozengeek____ has joined #ruby
frozengeek has quit [Ping timeout: 260 seconds]
<warrshrike>
how do you escape it?
<baweaver>
slice_after { |line| line =~ /^\[Node/ }
frozengeek____ has quit [Remote host closed the connection]
<baweaver>
backslash
frozengeek____ has joined #ruby
frozengeek____ has quit [Remote host closed the connection]
tomphp has joined #ruby
<warrshrike>
cfl.lines.drop_while { |line| line !~ /^\[Node/ }[0..-3].slice_after { |line| line =~ /^\[Node/ }
<warrshrike>
this is the final version as Envisioned by you?
frozengeek____ has joined #ruby
frozengeek____ has quit [Remote host closed the connection]
<baweaver>
something like that
<baweaver>
I'd have to run it to make sure.
<warrshrike>
okay il do that ^_^ and report back
xall has quit [Ping timeout: 252 seconds]
jhack has joined #ruby
ldnunes has quit [Ping timeout: 265 seconds]
<warrshrike>
nah this is messed up
<warrshrike>
half the thing got KO'd
careta has quit [Ping timeout: 248 seconds]
finisherr has joined #ruby
<warrshrike>
it starts from ---- Vertex id: 25057 \n", "---- The cal....
Rodya_ has quit [Remote host closed the connection]
<l33n>
ok, but then serverside, I want to access that data
tercenya has quit [Remote host closed the connection]
<l33n>
i want to take it and use it in a method generate a json and send it back
tercenya has joined #ruby
nelsonsar has quit [Ping timeout: 268 seconds]
rodfersou has quit [Quit: leaving]
ldnunes has quit [Quit: Leaving]
roshanavand has quit [Read error: Connection reset by peer]
bartek has joined #ruby
xall has quit [Ping timeout: 250 seconds]
nelsonsar has joined #ruby
Spiff_ has joined #ruby
l33n has quit [Quit: Leaving]
muelleme has quit [Ping timeout: 252 seconds]
Spiff_ has quit [Client Quit]
blackbombay has joined #ruby
conta has joined #ruby
JeroenDL has quit [Ping timeout: 260 seconds]
SpiffTR has joined #ruby
blackbom1 has quit [Ping timeout: 252 seconds]
SCHAAP137 has quit [Quit: Leaving]
mwlang has quit [Quit: mwlang]
<Joufflu>
baweaver, ok I see your answer and how you specified for 11th 12th and 13th and I tried doing something similar but it's not working http://pastie.org/10972801
kirun has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
SpiffTR has quit [Client Quit]
Yzguy has joined #ruby
<Joufflu>
mind pointing out what I'm doing wrong ?
<domgetter>
Joufflu instead of checking for 11, 12, and 13 directly, you'll want to first check if the number is 11, 12, or 13 % 100, and then check normally against %10
<domgetter>
That way, 113 will be 113th
shadowak47 has joined #ruby
TvL2386 has joined #ruby
<domgetter>
What are the possible numbers that might come into this method?
mdw has joined #ruby
biberu has quit [Ping timeout: 260 seconds]
<Joufflu>
domgetter, thanks for response; any integer
bartek has quit [Quit: Leaving]
elifoster has quit [Quit: class]
shadowak47 has quit [Client Quit]
banisterfiend has joined #ruby
conta has quit [Ping timeout: 256 seconds]
marxarelli is now known as marxarelli|afk
shadowak47 has joined #ruby
bovis has quit [Quit: leaving]
spiff1 has joined #ruby
dionysus69 has joined #ruby
ur5us has joined #ruby
dnicole_ has quit [Remote host closed the connection]
zeroDi has quit [Quit: WeeChat 1.6]
nankyokusei has joined #ruby
jhooker has joined #ruby
blackwind_123 has quit [Quit: For Sale: Intergalactic Proton Powered Electrical Tentacled Advertising Droids]
tdy has quit [Ping timeout: 260 seconds]
SCHAAP137 has joined #ruby
Joufflu has quit [Quit: Leaving]
Cohedrin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nankyokusei has quit [Ping timeout: 245 seconds]
Yzguy has quit [Quit: Bye]
axl_ has joined #ruby
axl_ has left #ruby [#ruby]
Rodya_ has quit [Remote host closed the connection]
spiff1 has left #ruby [#ruby]
axl_ has joined #ruby
Jackneill has joined #ruby
riotjones has quit [Ping timeout: 244 seconds]
jgnagy has joined #ruby
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
shadowak47 has left #ruby [#ruby]
Jackneill has quit [Max SendQ exceeded]
<patarr>
is there any way to use Net::HTTP without constantly prepending everything with Net::?
<Nilium>
There are a few but they're all very bad ideas. Just type Net:: a lot.
dionysus69 has quit [Ping timeout: 250 seconds]
Jackneill has joined #ruby
quakephil has joined #ruby
<patarr>
Why?
ponga has quit [Quit: Connection closed for inactivity]
<Nilium>
Because five extra characters is a lot better than the alternatives of moving things around or including net in something
<quakephil>
Hi all, trying to run ad-hoc SQL with parameter binding via activerecord. So far I'm pretty close with ActiveRecord::Base.connection.raw_connection.prepare and .execute but execute doesn't seem to be binding the parameters that I'm passing to it, and on top of that it returns the results as an array (whereas I need it as a hash, keyed by column names)
smlocal has quit [Remote host closed the connection]
smlocal has joined #ruby
l33n has joined #ruby
<blackbombay>
patarr: how come you're typing that a lot anyway? Net::HTTP.new/start should be as much as you have to reference that constant.
pawnbox has quit [Remote host closed the connection]
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<blackbombay>
you don't have to use the http.request() api, you can write Net::HTTP.start(host, port) { |http| http.post(), http.get(), etc }
<l33n>
ok, but still, I just want to figure out the answer to my question
<l33n>
ty blackbombay
<blackbombay>
l33n: i was responding to patarr
<l33n>
oh
bodgix has joined #ruby
futilegames has joined #ruby
<blackbombay>
im not sure about your problem. you want to render JSON from where? the network? filesystem?
tercenya has quit [Remote host closed the connection]
marxarelli|afk is now known as marxarelli
<l33n>
I want to simply take the json and render it in the browser
tercenya has joined #ruby
<l33n>
so that when I visit localhost:2345/index.html I can see the json i sent via the ajax request
davidt has quit []
Derperperd has quit [Quit: Derperperd]
<l33n>
i mean, i want to do a lot more than that, but right now I cant even do that or I dont know how
<blackbombay>
is there a reason you have wrote everything at such a low level?
last_staff has quit [Quit: last_staff]
synthroid has quit []
<l33n>
im learning
<blackbombay>
okay cool
<blackbombay>
what you have looks fine. what doesn't work?
marsjaninzmarsa has quit [Ping timeout: 248 seconds]
<l33n>
well it gets it
<l33n>
but now I want to take the json and see it when I visit localhost:2345/index.html
byte512 has quit [Ping timeout: 258 seconds]
jaruga___ has joined #ruby
bturker has quit [Ping timeout: 256 seconds]
jaruga___ is now known as jaruga
cdg has joined #ruby
SpiffTR has quit [Quit: Leaving.]
marsjaninzmarsa has joined #ruby
domgetter has quit [Ping timeout: 244 seconds]
<blackbombay>
you want to store it somewhere and see it on the index.html page?
<l33n>
yeah
marsjaninzmarsa has quit [Excess Flood]
jackjackdripper has joined #ruby
pandawhisperer has joined #ruby
smlocal has quit [Remote host closed the connection]
smlocal has joined #ruby
miqlas-H has joined #ruby
djbkd has quit [Remote host closed the connection]
riotjones has quit [Ping timeout: 244 seconds]
<blackbombay>
hm okay, i would add a path where you accept the JSON payload, then store that to disk, and make index.html an ERB template that can call File.read(path_to_json_file)
bturker has joined #ruby
marsjaninzmarsa has joined #ruby
BreakThings has quit [Ping timeout: 260 seconds]
<l33n>
blackbombay, so in the ajax request, the url would be to a specific path and create a directory serverside that matches that path? how to store to disk?
benlieb has quit [Quit: benlieb]
muelleme has joined #ruby
prestorium has quit [Quit: Leaving]
<blackbombay>
modify the server script to handle a path like "/receive_json", and in that condition use File.write() to store the json on disk, otherwise fall through to the logic you currently have for reading from public/.
<l33n>
ok
<l33n>
i shall try
bturker has quit [Ping timeout: 256 seconds]
SpiffTR has joined #ruby
User458764 has joined #ruby
mdw has quit [Quit: Sleeping Zzzzz]
TvL2386 has quit [Quit: Ex-Chat]
tomphp has joined #ruby
ta_ has quit [Remote host closed the connection]
SpiffTR has quit [Quit: WeeChat 1.5]
dnicole has quit [Remote host closed the connection]
jaruga has quit [Quit: jaruga]
dnicole has joined #ruby
claudiuinberlin has quit []
OTORelic has joined #ruby
skweek has quit [Ping timeout: 246 seconds]
SeepingN has quit [Disconnected by services]
tercenya has quit [Remote host closed the connection]
SeepingN_ has joined #ruby
rfoust has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tercenya has joined #ruby
LoneHermit has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
brendan- has joined #ruby
_sfiguser has quit [Ping timeout: 246 seconds]
bovis has joined #ruby
mooe has joined #ruby
Snowy has joined #ruby
bturker has joined #ruby
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
montanonic has joined #ruby
Ishido has quit [Quit: Roads? Where We're Going We Don't Need Roads.]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
careta has joined #ruby
jaguarmagenta has joined #ruby
LoneHermit has quit [Remote host closed the connection]
nelsonsar has quit [Remote host closed the connection]
nelsonsar has joined #ruby
cschneid_ has joined #ruby
jgnagy has quit [Remote host closed the connection]
Nicmavr has quit [Quit: ZNC 1.6.3+cygwin3 - http://znc.in]
centrx has quit []
Nicmavr has joined #ruby
syf-revk has quit [Quit: Leaving]
Nicmavr has quit [Changing host]
Nicmavr has joined #ruby
<l33n>
blackbombay, when writing this I made a .rb file that the server script logic will look for, but then how do i reference the json i passed with ajax?
codfection has quit [Remote host closed the connection]
Devalo has quit [Remote host closed the connection]
jaguarmagenta has quit [Ping timeout: 268 seconds]
yardenbar has joined #ruby
<blackbombay>
it's sent as a query string according to the gist you pasted
nelsonsar has quit [Ping timeout: 246 seconds]
<l33n>
ill do something like this in the logic File.open("public/temp.json","w")
djbkd has joined #ruby
<l33n>
or File.open("public/temp.json","w") do |f|
<l33n>
f.write(
<l33n>
but f.write( *what goes here?*
toretore has quit [Ping timeout: 250 seconds]
<blackbombay>
URI(request_uri).query
<l33n>
oh
_sfiguser has joined #ruby
<blackbombay>
it will need to be decoded.
<blackbombay>
and sending JSON as a query string is quite unusual, most web apps would accept JSON in a POST request.