Rufus has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ramfjord has quit [Ping timeout: 252 seconds]
wldcordeiro has quit [Quit: WeeChat 1.4]
ur5us has joined #ruby
wldcordeiro has joined #ruby
rodfersou|dinner is now known as rodfersou
stupidystupid has joined #ruby
cyphase has quit [Ping timeout: 248 seconds]
agent_white has quit [Quit: brb]
charliesome has joined #ruby
aryaching_ has quit [Ping timeout: 252 seconds]
JeanCarloMachado has quit [Ping timeout: 265 seconds]
stupidystupid has quit [Client Quit]
craigp has quit [Ping timeout: 272 seconds]
stupidystupid has joined #ruby
charliesome_ has joined #ruby
boogeyman has quit [Quit: bb]
Naz has quit [Ping timeout: 265 seconds]
cyphase has joined #ruby
nitric has quit [Ping timeout: 244 seconds]
tcrypt has quit [Ping timeout: 265 seconds]
cyphase has quit [Max SendQ exceeded]
boogeyman has joined #ruby
charliesome has quit [Ping timeout: 244 seconds]
ruby_ has joined #ruby
zeroDi has quit [Quit: WeeChat 1.5]
SeepingN has joined #ruby
stupidystupid has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ichkv has joined #ruby
stupidystupid has joined #ruby
Bellthoven has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jcao219 has quit [Ping timeout: 244 seconds]
jaequery has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dlam has quit [Remote host closed the connection]
symm- has joined #ruby
rodfersou has quit [Quit: leaving]
alaibe has joined #ruby
tcrypt has joined #ruby
cyphase has joined #ruby
Naz has joined #ruby
elenatanasoiu has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
someish has joined #ruby
alaibe has quit [Ping timeout: 244 seconds]
<someish>
I’m struggling with finding the best, most ruby-like way to take the linked-to array of hashes, and generate a seperate array of hashes, with unique dates, and and average minutes for each date. https://gist.github.com/saturday/dbda279ee2359409d8d0b0c34a6218fb
<someish>
Each date key contains a Date object.
Dimik has joined #ruby
elenatanasoiu has quit [Ping timeout: 244 seconds]
tvw has quit []
imightbestupid12 has joined #ruby
<imightbestupid12>
what is a good package in atom that does not highlight unused variables, instance variables, global variables, etc...
samof76 has joined #ruby
stupidystupid has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<imightbestupid12>
let's say you mistyped a variable name and you're looking everywhere for the bug but you can't find it after hours of looking through your code
stupidystupid has joined #ruby
<elomatreb>
imightbestupid12: That is very hard to do in Ruby, since an apparently missing variable could just be a method defined somwewhere else
nando293921 has quit [Ping timeout: 265 seconds]
nando294021 has quit [Ping timeout: 265 seconds]
elvin_ has joined #ruby
Silthias has quit [Ping timeout: 265 seconds]
dviola has quit [Quit: WeeChat 1.5]
craigp has joined #ruby
fmcgeough has joined #ruby
blackwind_123 has quit [Ping timeout: 265 seconds]
fmcgeough has quit [Client Quit]
<imightbestupid12>
cant
<imightbestupid12>
elomatreb: can't the plugin scan for all of the files that have 'require' in them, put all the variables in memory and then see if they exist highlight and if they don't don't highlight
<elomatreb>
Still wouldn't work reliable, since you can define methods, variables (even instance variables) dynamically through metaprogramming
ruby_ has quit [Remote host closed the connection]
xentity1x has quit [Ping timeout: 244 seconds]
ruby_ has joined #ruby
nankyokusei has joined #ruby
imightbestupid12 has quit [Quit: Page closed]
craigp has quit [Ping timeout: 272 seconds]
ruby_ has quit [Ping timeout: 265 seconds]
nankyokusei has quit [Ping timeout: 265 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ichkv has quit [Remote host closed the connection]
A_Drone has quit [Remote host closed the connection]
qba73 has joined #ruby
tonini has joined #ruby
jshjsh has joined #ruby
elenatanasoiu has quit [Ping timeout: 264 seconds]
JoshS has quit [Ping timeout: 244 seconds]
Azure|dc has joined #ruby
Azure has quit [Ping timeout: 248 seconds]
dminuoso has quit [Remote host closed the connection]
nankyokusei has joined #ruby
Silthias has quit [Ping timeout: 252 seconds]
ayonkhan has joined #ruby
nando293921 has quit [Ping timeout: 265 seconds]
nando294021 has quit [Ping timeout: 265 seconds]
blackgoat has quit [Quit: WeeChat 1.5]
conta has joined #ruby
bluOxigen has quit [Ping timeout: 252 seconds]
nankyokusei has quit [Ping timeout: 248 seconds]
bluOxigen has joined #ruby
NTrash has joined #ruby
Dobler has joined #ruby
eizua has quit [Quit: Leaving]
gizmore has joined #ruby
Contigi has quit [Read error: Connection reset by peer]
blackgoat has joined #ruby
ta_ has quit [Ping timeout: 272 seconds]
Silthias has joined #ruby
dminuoso has joined #ruby
Devalo has joined #ruby
Pupeno has joined #ruby
qba73 has quit [Remote host closed the connection]
qba73 has joined #ruby
Pupeno has quit [Read error: Connection reset by peer]
sp_ has joined #ruby
Pupeno has joined #ruby
qba73 has quit [Remote host closed the connection]
qba73 has joined #ruby
Pupeno has quit [Client Quit]
A_Drone has joined #ruby
arescorpio has quit [Quit: Leaving.]
cibs has quit [Ping timeout: 268 seconds]
stupidystupid has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jackjackdripper has quit [Quit: Leaving.]
ruby-lang702 has joined #ruby
ruby-lang702 is now known as michaelrails
Contigi has joined #ruby
cibs has joined #ruby
sandelius has joined #ruby
beauby has quit [Ping timeout: 264 seconds]
<michaelrails>
hey guys, does anybody know what algorithm Ruby uses for square roots? I used the Babylonian method and I can get it to work almost instantly when I round, but I can't get exact decimals with larger numbers in a decent amount of time
FINbit has quit [Ping timeout: 248 seconds]
<Radar>
michaelrails: Do you have some code for us to look at?
<dminuoso>
michaelrails: Whatever the underlying C library uses to implement sqrt.
<dminuoso>
For Math::sqrt at any rate.
<michaelrails>
Radar:
<michaelrails>
def sq(num) guess = (1 + rand(num)) * 1.00 until guess.round(2) == (num/guess).round(2) guess = (guess + num/guess)/2 end guess = guess.round(2) if guess != num/guess return guess end is there a better way to format on here? new to freenode
<Radar>
?gist michaelrails
<ruby[bot]>
michaelrails: https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
<lugzer>
i've tried changing to non-SSL for the sass install.. no luck
Fridtjof has quit [Ping timeout: 265 seconds]
<workmad3>
lugzer: hmm... and what version of rubygems do you have? ("gem -v")
Tempesta has quit [Quit: See ya!]
<lugzer>
2.6.7
Burgestrand has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sdothum has joined #ruby
Burgestrand has joined #ruby
Fridtjof has joined #ruby
<workmad3>
ok... no idea then :(
gregf_ has quit [Ping timeout: 240 seconds]
symm- has joined #ruby
<lugzer>
ok thanks for looking
Burgestrand has quit [Client Quit]
aidalgol has quit [Quit: zZzZzZzzz]
<hanmac>
lugzer: have you tryied to ping rubygems.org? maybe there is something with your connection
Burgestrand has joined #ruby
<lugzer>
well, my network does not allow ping, but i can normally clone from git, or install from brew...
<hanmac>
hm maybe thats the reason that your network does not allow connection to rubygems?
<lugzer>
could be.. i'll try connecting via phone and see if it makes a difference
sts_ is now known as sts
c355e3b has joined #ruby
tlaxkit has joined #ruby
<frankiee_>
hanmac, solid stack, good ol' bsd times bring them back
<frankiee_>
*mic dropped*
babblebre has joined #ruby
timmow has joined #ruby
anisha has quit [Quit: This computer has gone to sleep]
blackgoat has joined #ruby
Silthias has quit [Ping timeout: 252 seconds]
blackwind_123 has quit [Ping timeout: 252 seconds]
cored has joined #ruby
<cored>
hi
<cored>
I'm looking for a good tutorial on parsing ruby. Using whitequark parser gem
<cored>
I started with an implementation which use an AST::Processor but I don't know if that's the good approach for what I want to do; I'm not doing a transformation of the AST but just reading and counting variables at least that's what I want for now
aries_liuxueyang has quit [Quit: No Ping reply in 180 seconds.]
aries_liuxueyang has joined #ruby
Burgestrand has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
gregf_ has joined #ruby
<dminuoso>
cored: What exactly is your goal?
<dminuoso>
cored: Note that in order to understand variables properly, you need to build a lexer.
<dminuoso>
(Rubys system of recognizing a method or variable is built into the lexer rather than the parser)
<dminuoso>
Or at the very least your AST would have to maintain lexigrahpical order.
Devalo has joined #ruby
<dminuoso>
cored: Fuck me, I missed the bit that you are using whtiequark/parser
<dminuoso>
cored: Yes, AST::Processor is fine.
y2mq37 has quit [Ping timeout: 248 seconds]
pawnbox has quit [Remote host closed the connection]
CHoltk has quit [Quit: Verlassend]
pawnbox has joined #ruby
Devalo has quit [Ping timeout: 244 seconds]
Snowy has joined #ruby
zipace has joined #ruby
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #ruby
dionysus69 has joined #ruby
jaguarmagenta has quit [Remote host closed the connection]
ferr has joined #ruby
erlingur_ has joined #ruby
<cored>
dminuoso: right, I just want to count variables and constant in a Ruby source
<dminuoso>
cored: Yeah AST::Processor is fine.
<cored>
dminuoso: but I want to associate the method name in which those variables were declare
<dminuoso>
cored: If it's a method they were declared in..
<cored>
what I'm doing is just counting in the same processor
<cored>
yes if it's a method
<dminuoso>
cored: And what if its a local variable inside a block?
<cored>
but if it's a method then my desire output should be '#method_name variable, x, y, z'
xall has joined #ruby
<cored>
dminuoso: I would like to count those too
<cored>
but for now just the simple case
<dminuoso>
cored: Sounds simple enough
erlingur has quit [Ping timeout: 248 seconds]
fivmo has joined #ruby
xall has quit [Ping timeout: 265 seconds]
bumao has joined #ruby
JakFrist[WVU] has joined #ruby
nankyokusei has joined #ruby
elenatanasoiu has quit [Ping timeout: 252 seconds]
lugzer has quit [Quit: Be back later ...]
auzty has quit [Quit: Leaving]
stamina has quit [Quit: WeeChat 1.5]
lugzer has joined #ruby
samof76 has quit [Ping timeout: 265 seconds]
nankyokusei has quit [Ping timeout: 244 seconds]
jphase has joined #ruby
_sfiguser has quit [Remote host closed the connection]
beauby has quit [Ping timeout: 264 seconds]
Guest81200 has quit [Read error: Connection reset by peer]
<fbt>
Ever since I've started learning Ruby, I'm getting increasingly annoyed at how shells do loops.
<fbt>
Well, not loops, but different blocks
<dminuoso>
fbt: View it in the context of time and problem domain.
<fbt>
'for ...; do ...; done', but 'if ...; then ...; fi.
<dminuoso>
Oh that's just syntax.
<fbt>
And then case/esac
<fbt>
It's annoying
<dminuoso>
fbt: it's very clear how to close each block at least? :)
jphase has quit [Ping timeout: 244 seconds]
<fbt>
I keep ending all these in 'end' in bash now and then getting angry at it for not working :)
<dminuoso>
fbt: In Ruby it's a bit weird, how a class and if are closed with an "end" but without a "do"
<dminuoso>
or a method definition.
johnmilton has quit [Remote host closed the connection]
<dminuoso>
All languages have quirks.
<fbt>
At least it's a single keyword for all of them. But yes, Ruby is being inconsistent there too, just slightly differently
<dminuoso>
fbt: Or better yet, the fact that its determined at lexing that a variable is a variable or method?
<dminuoso>
That one bugs me every single day.
<dminuoso>
>> puts a if a = 1
<ruby[bot]>
dminuoso: # => /tmp/execpad-89f4b660e286/source-89f4b660e286:2: warning: found = in conditional, should be == ...check link for more (https://eval.in/654852)
<fbt>
But yeah, people kept telling me I would absolutely hate bash after I start writing in a “proper language”
<fbt>
And no, that's not happening.
nuck has joined #ruby
<fbt>
I've written quite a lot of bash code in ~8 years, it's a language that has its benefits.
nuck is now known as Guest35374
<dminuoso>
Yeah, it keeps jobs safe.
<dminuoso>
Because who in their right minds would learn bash nowadays.
<fbt>
:D
<dminuoso>
I mean honestly, it's an outdated tool that serves no practice purpose anymore.
JakFrist[WVU] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
practical
<fbt>
Well what I mean is it's really handy when you do a lot of work with calls to external programs. And it's everywhere.
<fbt>
And every admin knows it to an extent
<fbt>
It does allow you to shoot your foot off easily though.
<dminuoso>
Honestly? Most "administration" work that folks do who started out "being an admin" 10-20 years ago is really outdated concepts.
<fbt>
Tech changes, some ways of doing things changed. Containers are a thing now, admins and developers pretty much merged. But you still write system glue.
<fbt>
And that system glue, depending on the task, can be really awkward in something other than a shell language.
<fbt>
Or not. Tool for the job.
<dminuoso>
What kind of system glue are we talking about?
<fbt>
“Make A take slightly modified input from B and then pass it on to C” type shit.
<fbt>
Or, like, xinitrc :D
<dminuoso>
Configuration Management
<fbt>
But that's a desktop thing.
<dminuoso>
Do it in puppet.
<dminuoso>
No, its not a desktop thing, its a configuration thing.
<fbt>
No, I mean xinitrc is.
<dminuoso>
Its still a configuration issue.
<fbt>
How does puppet change the fact that xinitrc is a bunch of external calls?
<fbt>
That needs to be run on every X launch
JeanCarloMachado has quit [Remote host closed the connection]
<fbt>
If you manage it with puppet, it will still be a shell script :)
kimegede has joined #ruby
ldnunes has joined #ruby
<fbt>
Re-writing it to anything else would make it a very awkward script with a bunch of system() calls.
<dminuoso>
So what? I mean its a bad example since you correctly pointed out it's a desktop (thus user frontend) domain already - but even so, what underlying concept is used does not matter.
<fbt>
And not much benefit.
<dminuoso>
It can use bash for all I care, but that doesn't require me to know bash.
<fbt>
Well yeah, this type of stuff is mostly just a list of external calls, you don't need to know bash to read/modify them.
<dminuoso>
fbt: Mounting stuff? Configuration management. Have puppet deal with it.
<fbt>
Not good enough, that needs to get run from a hookl
<fbt>
It runs every time a package is built
<dminuoso>
What for?
nfk has joined #ruby
<fbt>
It's part of the process of creating a clean build chroot
<dminuoso>
Sounds like you want docker instead.
<dminuoso>
;)
<fbt>
I mean it's a reinventing the wheel type thing for my personal build system, but hey.
lugzer has quit [Remote host closed the connection]
<dminuoso>
Oh wait, you mean vagrant?
<dminuoso>
;)
<fbt>
Yeah, I could just use something like Jenkins (and I do), but under the hood that thing also runs shell :D
<dminuoso>
Who cares what it runs on.
<dminuoso>
Facebook uses plenty of PHP - that does not make it a technically bad website.
JeanCarloMachado has joined #ruby
<fbt>
I see that attitude as a problem honestly. I care about what is under the hood not for some elitist shit but just for the value of knowing how to modify it if needed.
gingray has quit [Ping timeout: 264 seconds]
ARCADIVS has quit [Quit: ARCADIVS]
bsrd has quit [Quit: WeeChat 1.5]
<fbt>
And systems are still ruled by C and shell.
Burgestrand has joined #ruby
<dminuoso>
Im really unsure how these two relate to each other, but fine.
bsrd has joined #ruby
<dminuoso>
fbt: And Jenkins runs on Java btw.
<fbt>
C is the language of choice for system utilities still. Shell is the glue between them.
<fbt>
I know. It also runs shell scripts.
<dminuoso>
Ah yeah.
<dminuoso>
fbt: C is the language of choice for a lot of applications. Not just system utilities.
<fbt>
Sure, but in the scope of this specific conversation I mean system utilities.
<dminuoso>
OH yeah
johnmilton has joined #ruby
johnmilton has quit [Client Quit]
lugzer has joined #ruby
<fbt>
Obviously C is not limited to coreutils or runit :D
<dminuoso>
fbt: Though as you said correctly, all "shell code" is for gluing stuff together. Nowadays we are lucky to have technologies that solve problems using domain specific languages often.
ldnunes has quit [Ping timeout: 244 seconds]
johnmilton has joined #ruby
<dminuoso>
Giving us much more expressivity and compact ways to solve problems.
<dminuoso>
Puppet connects, shell glues. ;-)
<fbt>
In many cases yes. But then you need to just launch a bunch of progmans and you end up with awkward 30 lines of Python instead of 5 in shell :D
<fbt>
programs*
<fbt>
As I've said, tool for the job.
<dminuoso>
fbt: Except, when I express that the state for a given puppet class requires a program to be running, then not only do I have this a) versioned in git, b) described and thus documented centrally, c) enforced by the puppet master but I can also reuse this d) freely
ldnunes has joined #ruby
<dminuoso>
It easily beats the "5 line shell hack".
beauby has joined #ruby
<fbt>
We had this colleague who insisted on writing monitoring plugins in Ruby. They are ugly and awkward as sin despite the idea being nice: he has this library to abstract some common stuff away and it's supposedly very clean
<fbt>
But then we do system(), system(), system(), REGEXES EVERYWHERE, system(), system()
<fbt>
And what was supposed to be a nice clean plugin ends up being horrendously awkward instead of just doing it with the tool that is good for these things.
<dminuoso>
fbt: Well it's definitely not an easy task.
<fbt>
Monitoring plugins are pretty simple things actually. Well. They are supposed to be.
<dminuoso>
The frameworks around puppet are monstreous for example. But the way you can now write your own manifests - its amazing.
<workmad3>
fbt: in the interest of fairness, I bet you've seen some pretty ugly monstrosities written in bash too :P
synthroid has joined #ruby
<workmad3>
(a.k.a. horrible code is language-agnostic)
<fbt>
workmad3, oh god yes. bash is REALLY YEASY to make ugly.
<fbt>
easy*
<dminuoso>
fbt: Any language is really easy to write horrible code in.
<fbt>
The only other popular language that is even worse at allowing you to write insanely horrific shit is Perl.
<fbt>
The shell family is a close second.
jenrzzz has joined #ruby
<fbt>
But then shells more easily allow you to do horrifyingly easy to make mistakes that are hard to debug and are very severe if exploited.
<workmad3>
fbt: the CS school grading system at my uni was written in a crazy mashup of bash, java and something else (perl I think)... it was arcane, weird, horrible code and somehow the java components were written so that they were processor-specific (as in a specific model of a processor :/ )
<dminuoso>
fbt: I think the lack of debugging facilities is one of the biggest problems.
<fbt>
And btw the people who write horrific shell scripts often turn out to be people who look down on them and refuse to learn the concepts.
<dminuoso>
fbt: I have spent the better part of the last 4 months customizing GNU GCC and GNU binutils for a custom kernel. A lot of the time was spent in autotools - which is basically a horrible stack of bash scripts generating bash code.
JeanCarloMachado has quit [Ping timeout: 265 seconds]
<fbt>
shells are *very different*. Either learn it or just don't use them!
prawnzy has joined #ruby
<fbt>
workmad3, how do you even write Java that is that architecture-specific
<dminuoso>
fbt: Honestly, try autotools for just a day. After that you will hate Bash for eternity.
<dminuoso>
Or shell in general I should say.
xall has joined #ruby
<fbt>
I've worked with autotools closely at various points in my career. They are insanely bad.
<workmad3>
fbt: I have no idea, I never got to see the code... I just heard about it when they tried to update the machines the main server for it was running on
JeanCarloMachado has joined #ruby
<dminuoso>
The only good product from autotools is make.
<dminuoso>
That one is rock solid and fine.
<fbt>
Still doesn't excuse the people who wrote the thing.
<workmad3>
dminuoso: hmm... I thought make predated autotools?
<dminuoso>
workmad3: Sure.
<dminuoso>
workmad3: well make in general.
<fbt>
Forgetting about quoting, not actually using the proper tools, assuming that they are under bash when the shebang is /bin/sh...
jenrzzz has quit [Ping timeout: 244 seconds]
<fbt>
It's horrible novice-grade mistakes that get me in autotools.
<fbt>
And yeah, make is not a part of autotools.
sp_ has joined #ruby
conta has quit [Ping timeout: 252 seconds]
conta1 is now known as conta
<dminuoso>
fbt: Honestly I was really scared, when I realized, that for example there is a shared Makefile.in that a lot of big GNU projects use. They all use a shared mixed file - it's super insane.
prawnzy has quit [Ping timeout: 265 seconds]
tyang has joined #ruby
pec has joined #ruby
<fbt>
I'm a fan of project-specific makefiles that are not generated by this insane monstrosity. It's a bit more work initially, but so much easier to debug.
<fbt>
And is more flexible in the end.
xall has quit [Ping timeout: 248 seconds]
<dminuoso>
fbt: Hand written Makefiles are great.
<dminuoso>
As I said, make is about the only useful thing in the GNU build system. :P
<fbt>
Well, those also allow you to do horrific stuff if you want to :D
raeoks has quit [Read error: Connection reset by peer]
<dminuoso>
Though nowadays I just use cmake, since it makes managing dependencies that much easier.
tyang has quit [Read error: Connection reset by peer]
<fbt>
I'm pretty sure my ruby code is horrific though.
sp_ has quit [Ping timeout: 248 seconds]
ICantCook has quit [Ping timeout: 265 seconds]
Jameser has quit [Ping timeout: 244 seconds]
edrocks has joined #ruby
<fbt>
I just don't know the ways in which it is horrific
Jameser has joined #ruby
havenwood has quit [Ping timeout: 248 seconds]
G has quit [Ping timeout: 265 seconds]
aries_liuxueyang has quit [Ping timeout: 244 seconds]
Kruppe has quit [Read error: Connection reset by peer]
havenwood has joined #ruby
havenwood has joined #ruby
guacamole has quit [Remote host closed the connection]
aries_liuxueyang has joined #ruby
G has joined #ruby
bruce_lee has quit [Ping timeout: 244 seconds]
guacamole has joined #ruby
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
Kruppe has joined #ruby
edrocks has quit [Ping timeout: 248 seconds]
elenatanasoiu has joined #ruby
eljimmy has joined #ruby
Silthias has joined #ruby
pawnbox has quit [Remote host closed the connection]
elenatanasoiu has quit [Ping timeout: 244 seconds]
pawnbox has joined #ruby
crameth has joined #ruby
crameth has quit [Remote host closed the connection]
Ropeney has joined #ruby
edrocks has joined #ruby
eljimmy has quit [Quit: This computer has gone to sleep]
eljimmy has joined #ruby
samof76 has joined #ruby
pawnbox has quit [Remote host closed the connection]
brendan- has joined #ruby
eljimmy has quit [Read error: No route to host]
pawnbox has joined #ruby
sdwrage has joined #ruby
elenatanasoiu has joined #ruby
gnufied has joined #ruby
cored has quit [Quit: WeeChat 1.5]
alexherbo2 has joined #ruby
zacts has joined #ruby
tyang has joined #ruby
matp has quit [Quit: Bye!]
Rajamaa has joined #ruby
lugzer has quit [Read error: Connection reset by peer]
bsrd has quit [Read error: Connection reset by peer]
<Burgestrand>
(granted, it typically depends on time of day, mood of developers, code size, and moon phase)
Tempesta has joined #ruby
fmcgeough has joined #ruby
bsrd has quit [Read error: Connection reset by peer]
<Burgestrand>
fbt I'm just on a short break from working so I don't have time to meaningfully nitpick at the moment, syntax-wise tabs (!) and parens on methods that don't take parameters are typically not done for Ruby (tabs more so than the parens).
<Burgestrand>
fbt additionally, most of the time we're not using `for` so much in Ruby. We use methods on collections, e.g. `workers.each(&:kill)` as opposed to `for w in workers…`
<Burgestrand>
I keep saying we, as if my opinion is part of some collective, it's not. :)
<fbt>
Yeah, when it comes to style, I'm still trying to find the things I personally like.
<fbt>
So it's all over the place.
<Burgestrand>
fbt That's completely fine. Keep in mind that when it comes to tabs and spaces, ruby developers are fairly unanimous for 2 spaces.
synthroid has quit [Remote host closed the connection]
<fbt>
I should at the very least make the project consistent, hmm.
<Burgestrand>
fbt I'd say the same thing applies to the non-usage of `for`!
<fbt>
Yeah, that's where my opinion is very much an unpopular one: tab strings everyday!
<fbt>
:D
<dminuoso>
fbt: Honestly, either use 2 spaces, or tabs.
<dminuoso>
Tabs are fine, since you can easily just adjust your editors tabwidth settings. ;-)
<fbt>
We had some very painful debates over this at various places I worked at, and the thing that works the best for large groups of people is indent with tabs and align with spaces.
<dminuoso>
It's a bit annoying when you mix tabs with spaces for aligning things tho.
<fbt>
So that everyone can set their own indentation locally and alignment works for everyone too, since it's static
matp has quit [Read error: Connection reset by peer]
<dminuoso>
fbt: Mixing them both is the worst of all.
<fbt>
Mixing for the same purpose is horrible.
<dminuoso>
fbt: Let's say you indent a method invocation with 2 tabs, and split the arguments across next 2 lines.
<dminuoso>
How do you deal with that?
<fbt>
But if you indent with tabs and align with spaces, you get a consistent look.
matp has joined #ruby
hahuang62 has joined #ruby
<Burgestrand>
Hehe, I've been on this boat before, I'm out. :)
<dminuoso>
I suppose.
<dminuoso>
fbt: In the end the most flexible solution is to simply use spaces.
DoubleMalt has joined #ruby
<dminuoso>
There is just no real advantage of tabs over spaces.
<fbt>
True, but you will find people who are really annoyed that you decided you want 4 spaces and they like 8.
<fbt>
Or 3.
<fbt>
Or 7
<dminuoso>
Good modern editors can regulate indentment with single backspace buttons even with expanded tabs.
<matthewd>
I'm pro-tabs in life, but there is a very strong convention in ruby; fighting it just doesn't make sense IMO
<fbt>
Personally, I've just decided on tabs for indentation and do this in *every* language.
xall has joined #ruby
<fbt>
Switching between languages just doesn't make any sense.
troulouliou_div2 has joined #ruby
<dminuoso>
At the end I just hate how I regularly open C code, and then have to readjust my tab width settings just because it's a mixture of spaces and tabs for every damn project out there.
<fbt>
I mean switching indentation style.
<fbt>
Hahaha you haven't seen our puppet templates.
Chau has quit [Ping timeout: 252 seconds]
<matthewd>
Well, expect complaints any time you ask people for opinions on your code
<dminuoso>
matthewd: Folks can be lucky Im not a code auditor.
<fbt>
Yeah, I'm used to indentation remarks.
<dminuoso>
:p
<dminuoso>
Comment style, that's another one.
<fbt>
People aren't usually agressive about it tho.
<dminuoso>
Linus rant a couple months ago anyone?
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<fbt>
Yeah, comments are so all over the place in virtually any codebase
<fbt>
The thing where you frame your comments with hashes? Who thought of that? It doesn't even *look* bice
<fbt>
nice*
Rajamaa has quit [Ping timeout: 244 seconds]
<fbt>
The most important thing IMO is to be consistent inside one codebase
hahuang62 has quit [Ping timeout: 265 seconds]
<dminuoso>
I just wish we had proper multiline comment support in Ruby.
JeanCarloMachado has quit [Quit: Lost terminal]
<dminuoso>
And don't get me started =begin =end
jenrzzz has joined #ruby
Rajamaa has joined #ruby
<fbt>
Yeah the whole =begin =end thing is weird
<fbt>
C-style /* */ would be nice
merlin2049er has left #ruby [#ruby]
xall has quit [Ping timeout: 244 seconds]
<dminuoso>
The silly thing is that it would be relatively trivial to patch it into the lexer.
<fbt>
But then we will have a war about the asinine alignment of the asterisks!
<fbt>
:D
<dminuoso>
Which brings us to the rant by Linus.
<fbt>
Lius is one of those people who aligns the multiline comments with asterisks, yeah :D
<fbt>
who align*
<fbt>
Linus*. Jesus what is wrong with me
jenrzzz has quit [Ping timeout: 264 seconds]
blackgoat has quit [Quit: WeeChat 1.5]
minimalism has quit [Quit: minimalism]
solars has joined #ruby
minimalism has joined #ruby
ramortegui has joined #ruby
<solars>
hey, does anyone know how to tell ruby csv to parse csv with double double quotes correctly? e.g. """Hotel Test","Zermatt""",CH_352 - in this example the first column contains Hotel Test, Zermatt
<chris2>
can i do with YAML.safe_load what safe_yaml does? i.e. ignore unknown tags?
troulouliou_div2 has quit [Ping timeout: 276 seconds]
coolboy has joined #ruby
jonyijoe has joined #ruby
jonyijoe_ has quit [Ping timeout: 265 seconds]
erlingur_ has quit [Ping timeout: 248 seconds]
emilkarl has joined #ruby
edrocks has quit [Ping timeout: 248 seconds]
rodfersou has joined #ruby
coolboy has quit [Ping timeout: 265 seconds]
boogeyman has joined #ruby
Madplatypus has quit [Quit: Connection closed for inactivity]
pwnd_nsfw` has joined #ruby
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby
dionysus69 has quit [Ping timeout: 272 seconds]
brendan- has joined #ruby
be_______ has joined #ruby
<apeiros>
solars: oy, swiss data? :D
pwnd_nsfw has quit [Ping timeout: 252 seconds]
beauby has joined #ruby
nankyokusei has joined #ruby
<apeiros>
solars: can you write the corresponding ruby array-of-strings literal? Because I don't think this is the correct way to encode in csv what you want.
<apeiros>
at least the CSV lib parses it the way I'd expect it to
rodfersou has quit [Read error: No route to host]
be_______ has quit [Remote host closed the connection]
malconis has quit [Remote host closed the connection]
malconis has joined #ruby
brendan- has joined #ruby
troulouliou_div2 has quit [Ping timeout: 276 seconds]
pawnbox_ has quit [Ping timeout: 248 seconds]
<apeiros>
my experience with csv and programmers: they fuck it up. a lot.
rodfersou has quit [Ping timeout: 265 seconds]
<apeiros>
similar to encodings. sadly.
<apeiros>
and timezones.
<apeiros>
and floats.
<lucasb_>
and... shell quotes :)
<apeiros>
I should write a book :(
nando294021 has quit [Ping timeout: 272 seconds]
nando293921 has quit [Ping timeout: 272 seconds]
<apeiros>
oh hell stay away from me with shell-outs by other programmers!
<apeiros>
that's a bloody accident waiting to happen :(
<apeiros>
sql injections are next, I guess
<apeiros>
what else is on the list? :)
Burgestrand has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nofxx has joined #ruby
<apeiros>
though, granted, sql is badly equipped for proper escaping. bind variables often only work in a very narrow scope. e.g. no bind variables for table names.
<hanmac>
yeah sql injections always reminds me at "Bobby Tables" ;P
<apeiros>
having a ' in your name can be problematic enough :-S
rodfersou has joined #ruby
abernstein has joined #ruby
Burgestrand has joined #ruby
zotherstupidguy has joined #ruby
DoubleMalt has quit [Ping timeout: 264 seconds]
dionysus69 has joined #ruby
<apeiros>
solars: google docs does it correctly for me
<apeiros>
just tested
jrafanie has joined #ruby
patarr has joined #ruby
<apeiros>
"""Test Data, quoted""",1234
Rodya_ has joined #ruby
<apeiros>
that's ['"Test Data, quoted"', '1234']
<solars>
apeiros: correcly in the sense ruby csv does you mean
<apeiros>
and that's also how it was in the document (2 cells)
<solars>
thanks for the confirmation
<apeiros>
correctly in the sense as "according to RFC", which happens to also be what (sensibly) ruby's CSV parses
<apeiros>
i.e. google docs does indeed generate standards compliant csv. no idea what you did. seems to me what you thought was 1 cell was really 2 cells.
<apeiros>
the things I remember seeing on SO btw. was issues with non-compliant csv. and some parsers will just happily process dirt. rubys does not.
<solars>
apeiros: its a bit more clear if you look at the headers which I ommited, it should be a single cell with , in the name
<solars>
apeiros: that's good to know
leitz has joined #ruby
zekriad has joined #ruby
xcesariox has joined #ruby
<dminuoso>
apeiros: It's not an issue with "sql being badly equipped", but a bad influence of PHPs mysql2_really_no_i_mean_it_safe("SELECT $interpolate FROM USERS");
<apeiros>
dminuoso: that's not what I mean
<dminuoso>
apeiros: Adapters such as JDBC have had safe interpolation for ages. ;-)
<apeiros>
dminuoso: bind variables exist, but you can't use them in all places in a query.
<matthewd>
solars: In this particular case, though, I don't see how a looser parser could do it differently. The example you showed is a well-formed CSV string with a particular meaning, which happens to differ from what you want.
<dminuoso>
apeiros: It's not as much of an issue for SQL itself, but adapters for those databases.
<apeiros>
and I don't view any form of interpolation as safe. separation of query and data (aka bind variables) is the only thing I accept as truly safe :)
hakunin has quit [Read error: Connection reset by peer]
hakunin has joined #ruby
jphase has joined #ruby
b________ has joined #ruby
jphase has quit [Remote host closed the connection]
jphase has joined #ruby
xall has joined #ruby
troulouliou_div2 has joined #ruby
Bellthoven has quit []
synthroid has joined #ruby
be_______ has quit [Ping timeout: 265 seconds]
<leitz>
What's the syntax to not match a string? The opposite of "my_string.match(/abc/)"
<apeiros>
!my_string.match(/abc/)
<hanmac>
leitz: or better use !~
edrocks has joined #ruby
<apeiros>
or since you won't get matchdata anyway, you can make it more lightweight: my_string !~ /abc/
ChiefAlexander has joined #ruby
xall has quit [Ping timeout: 264 seconds]
symm- has quit [Ping timeout: 244 seconds]
yazdmich is now known as BytesAndCoffee
<solars>
matthewd: of course, it's invalid format that is not easily detectable
<solars>
matthewd: well unless you compare header size to row size I think
<solars>
I'm in google livechat already for this issue
<dminuoso>
JustinHitla_: No. We hijack trains and sell the blinky stones.
newbie22 has quit [Max SendQ exceeded]
b________ has joined #ruby
Axl_ has quit [Ping timeout: 244 seconds]
dminuoso has quit [Remote host closed the connection]
TomyWork has quit [Ping timeout: 240 seconds]
be_______ has quit [Ping timeout: 252 seconds]
synthroid has joined #ruby
Axl_ has joined #ruby
abernstein has quit [Quit: abernstein]
jhooker has joined #ruby
Axl__ has joined #ruby
Axl_ has quit [Ping timeout: 264 seconds]
Axl__ is now known as axl_
ferr has quit [Quit: WeeChat 1.5]
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
nankyokusei has joined #ruby
saneax is now known as saneax-_-|AFK
rmn has quit [Quit: leaving]
Silthias has quit [Ping timeout: 252 seconds]
Xiti` has joined #ruby
cschneid_ has joined #ruby
armin has joined #ruby
JustinHitla_ has left #ruby [#ruby]
armin has quit [Client Quit]
axl_ has quit [Ping timeout: 248 seconds]
Pixi_ has joined #ruby
armin has joined #ruby
Xiti has quit [Ping timeout: 264 seconds]
dviola has joined #ruby
aufi has quit [Ping timeout: 244 seconds]
<yorickpeterse>
Ruby?
axl_ has joined #ruby
Oclair_ has joined #ruby
nankyokusei has quit [Ping timeout: 252 seconds]
Xiti` has quit [Ping timeout: 248 seconds]
Oclair has quit [Ping timeout: 265 seconds]
patarr has quit [Quit: patarr]
<ule>
hey guys.. is there a magic ruby method to change the value for specific keys inside a hash without looping over all the elements?
<ule>
not sure what's the best way?
patarr has joined #ruby
<ule>
I was thinking in something like: my_hash.some_function(key_a, key_b).another_function( if key_a == 'Y', key_a='yes') ...
<ule>
!ruby tap
NTrash has joined #ruby
aryaching has joined #ruby
<apeiros>
hash[key] = value
brendan- has joined #ruby
aganov has quit [Remote host closed the connection]
<hanmac>
ule: there is also Hash#store but it does not return the hash itself
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
malconis has joined #ruby
beauby has quit [Ping timeout: 248 seconds]
jonyijoe has quit [Remote host closed the connection]
valkyr1e_ has joined #ruby
h1fuelcell has joined #ruby
jonyijoe has joined #ruby
malconis has quit [Ping timeout: 264 seconds]
jonyijoe has quit [Ping timeout: 265 seconds]
ichkv1 has joined #ruby
pawnbox has joined #ruby
mark_66 has quit [Remote host closed the connection]
dminuoso has joined #ruby
synthroid has quit [Remote host closed the connection]
lacour has joined #ruby
hahuang62 has joined #ruby
amclain has joined #ruby
malconis has joined #ruby
<ule>
I know how to do this.. I'll create my code here and will show to you guys
xall has joined #ruby
<ule>
some of you always has a better solution with just one line
<ule>
:)
<ule>
I'm still thinking in C
bmurt has joined #ruby
<machty>
today i have to debug why memory usage in my ruby server has suddenly spiked. a single API endpoint query makes it spike by 200mB
<machty>
can someone confirm my understanding: a spike of 200mb does _not_ necessarily imply a leak, right?
malconis has quit [Client Quit]
<machty>
if constructing the response to this api query takes a vast amount of memory, in which time the GC collects and can't recover unreferences objects, then I should expect memory usage to jump
<machty>
and do so permanently
jsrn_ has quit [Quit: Leaving]
Rodya_ has joined #ruby
Hobbyboy has quit [Max SendQ exceeded]
valkyr1e_ has left #ruby [#ruby]
jackjackdripper has joined #ruby
Hobbyboy has joined #ruby
erlingur_ has quit [Ping timeout: 248 seconds]
patarr has quit [Quit: patarr]
FINbit has quit [Ping timeout: 265 seconds]
xcesariox has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
matp_ has joined #ruby
valkyr1e has left #ruby [#ruby]
jenrzzz has joined #ruby
cdg has joined #ruby
ChiefAlexander has quit [Remote host closed the connection]
<h1fuelcell>
If I use a class-within-class style declaration, and use an include statement in the parent class, the nested classes will not be affected by that inclusion right?
matp has quit [Ping timeout: 252 seconds]
<h1fuelcell>
Because I keep reading that nested classes are only for namespacing and will not cause any change of functionality
<dminuoso>
h1fuelcell: In a nutshell, an include inserts the parameter module into the inheritance chain of the target class.
synthroid has joined #ruby
<h1fuelcell>
and nested classes don't inherit
<dminuoso>
Correct
b________ has quit [Ping timeout: 272 seconds]
coolboy has quit [Ping timeout: 264 seconds]
duderonomy has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 265 seconds]
ChiefAlexander has quit [Client Quit]
<h1fuelcell>
So I want to use Resque::Mailer in my Rails project. That class provides an `include`able structure (it's a nested module) called Resque::Mailer. Now I need two identical classes that are different by just one setting: the name of the queue.
conta has quit [Ping timeout: 252 seconds]
<dminuoso>
h1fuelcell: Or rather to put it the other way around, when a method or constant lookup happens, it looks for the method in its own class, and any of *its* ancestors.
xcesariox has joined #ruby
<h1fuelcell>
So I went class EmailReceptionist include Resque::Mailer class InternalMailer default_queue_name="internal" end class ExternalMailer default_queue_name="external" end end
jonyijoe has joined #ruby
<h1fuelcell>
which won't work of course b/c of what we just discussed
xentity1x has joined #ruby
SteenJobs has quit [Quit: SteenJobs]
<h1fuelcell>
I initially had a couple files called InternalMailer, ExternalMailer which independently include(d) the Resque::Mailer module
<h1fuelcell>
which worked, just had duplication
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<h1fuelcell>
How do I get what I want :P
Alayde has joined #ruby
<dminuoso>
h1fuelcell: I did it as following with my worker stuff in rails: I had a namespace.rb module, and a namespace/base.rb class which set up the worker, and every namespace/worker then derived from namespace/base
fuzzyhorns has quit [Quit: Leaving.]
jcao219 has joined #ruby
<dminuoso>
h1fuelcell: That way you could define common attributes in the namespace.rb module, which the namespace/base.rb would refer if you wanted it like that.
ChiefAlexander has joined #ruby
ziprar has joined #ruby
zipace has quit [Disconnected by services]
malconis has joined #ruby
<flying>
hi guys can you help me with an exercise in ruby? :)
<flying>
it's quite difficult for me
fuzzyhorns has joined #ruby
babblebre has quit [Quit: Connection closed for inactivity]
centrx has joined #ruby
harai has joined #ruby
<dminuoso>
h1fuelcell: However, there is a tricky situation where you might feel like you have access to the outer class.
Vingador has joined #ruby
<h1fuelcell>
oho dminuoso thank you for saying that, lol I just discovered a folder full of jobs just like this in this codebase
nitric has joined #ruby
<dminuoso>
h1fuelcell: Constant lookup works as follows: First it looks whether it can find a constant anywhere in the current scope (which if you are still in the outer open class includes any constants defined in there)
<h1fuelcell>
I guess there's not much to do about the duplication
novikserg has quit [Quit: Page closed]
<flying>
a non empty zero indexed array A consisting of N integers is given. you can perform a single swap operation in array A. This operation takes 2 indexes I and J such that 0<=I<=J<N and exchanges the values of A[I] and A[J].
<flying>
the goal is to check whether array A can be sorted into non decreasing order by performing at most one swap operation.
<flying>
how can I start it?
<flying>
:(
SteenJobs has joined #ruby
Couch has quit [Ping timeout: 248 seconds]
beauby has joined #ruby
bsrd has quit [Quit: WeeChat 1.5]
Pixi_ has quit [Quit: Pixi_]
<h1fuelcell>
thanks dminuoso
abernstein has joined #ruby
Voker57|2 has joined #ruby
claudiuinberlin has quit []
<lucasb_>
flying: interesting problem. let me think for a while :)
Voker57|2 has quit [Client Quit]
<flying>
ok :)
beauby has quit [Ping timeout: 265 seconds]
<lucasb_>
one can start walking the array, from index 0
<dminuoso>
h1fuelcell: However! It's not the entire truth.
<lucasb_>
once a element is found, which is less than the previous, then a swap must be made
<dminuoso>
h1fuelcell: There is a way to directly tap into a parents class, and that's by specifying it directly.
blackwind_123 has joined #ruby
<dminuoso>
Im prepping an extensive example to show all the behavior.
lxsameer has quit [Quit: WeeChat 1.5]
dfinninger has joined #ruby
<lucasb_>
then start walking the array backwards, to find the element that must be swapped
jonyijoe has quit [Remote host closed the connection]
jonyijoe has joined #ruby
<lucasb_>
after, the swap, you continue walking from where you are at. if it reaches the end, then it only needed 1 swap
renderful has joined #ruby
<h1fuelcell>
that would be interesting to see! These things won't likely pass code review in my team though :D
<h1fuelcell>
But I'm interested to know for myself
jonyijoe has quit [Remote host closed the connection]
<hanmac>
imo this javascript table is incomplete, what about 0.0 and "0.0" ? i remember there is some discontinuity in php about that
<havenwood>
sagax: In Ruby it'd be a straight diagonal line, things only being equal to themselves - until you get to Float::NAN which isn't equal to itself or anything else.
elenatanasoiu has quit [Ping timeout: 265 seconds]
<myndzi`>
it's not inside any class/module/whatever block
dfinninger has quit [Ping timeout: 265 seconds]
beauby has quit [Ping timeout: 252 seconds]
<chrisseaton>
myndzi`: it's assigning a constant called Bar to be the same as Foo::Bar, but the :: at the start of Bar means set it at the top level
conta has quit [Quit: conta]
<chrisseaton>
if it isn't inside anything then the leading :: may be redundant, but harmless
Puffball has quit [Remote host closed the connection]
<myndzi`>
so anything that includes this file will have 'Bar' accessible
<myndzi`>
unqualified
<havenwood>
BTheOne: hi
synthroid has quit [Remote host closed the connection]
<chrisseaton>
without seeing more code, I believe so
<myndzi`>
okay, thanks :)
<myndzi`>
I can see why they might use the :: to make the intent clearer, but as I'm new to Ruby, I wasn't sure if it was doing anything 'special' -- and this is a tricky one to search!
brendan- has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
cdg has quit [Ping timeout: 264 seconds]
Robtop__ has joined #ruby
biberu has joined #ruby
shinnya has quit [Ping timeout: 272 seconds]
futilegames has quit [Quit: futilegames]
fantasticsid has quit [Ping timeout: 272 seconds]
pwnd_nsfw` has quit [Ping timeout: 248 seconds]
claudiuinberlin has quit [Remote host closed the connection]
renderfu_ has joined #ruby
Guest1973 has quit [Changing host]
Guest1973 has joined #ruby
dhk has quit [Quit: Leaving]
renderf__ has quit [Ping timeout: 244 seconds]
synthroid has joined #ruby
elifoster has joined #ruby
Guest1973 has left #ruby [#ruby]
jcao219 has joined #ruby
CHOCODARCHEVILLE has joined #ruby
nando293921 has joined #ruby
nando294021 has joined #ruby
futilegames has joined #ruby
myndzi` has quit [Quit: Page closed]
armyriad has quit [Ping timeout: 272 seconds]
ben_ has quit [Read error: Connection reset by peer]
<squarebracket>
novikserg: yeah, but for the server, not the client. I've got a Dockerfile all set up but I can't seem to figure out how to pass any host information through to it.
ben_ has joined #ruby
fantasticsid has joined #ruby
<squarebracket>
Sinatra says I can `set :base_url, 'the-url'`, but I added that above the `run Geminabox::Server` call to no effect...
tyang has quit [Ping timeout: 264 seconds]
novikserg has quit [Ping timeout: 240 seconds]
<squarebracket>
I don't really know anything about rackup though, I feel like I'm missing something obvious :\
xall has quit [Ping timeout: 244 seconds]
claudiuinberlin has joined #ruby
armyriad has joined #ruby
Macrobiotic has joined #ruby
banisterfiend has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
banisterfiend has joined #ruby
last_staff has quit [Quit: last_staff]
jcao219 has quit [Ping timeout: 264 seconds]
fantasticsid has quit [Quit: ERC (IRC client for Emacs 25.1.50.1)]
AlphaAtom has joined #ruby
CHOCODARCHEVILLE has quit [Excess Flood]
renderf__ has joined #ruby
Silthias has joined #ruby
renderfu_ has quit [Ping timeout: 264 seconds]
xall has joined #ruby
Velizar has quit [Ping timeout: 265 seconds]
futilegames has quit [Ping timeout: 244 seconds]
futilegames has joined #ruby
renderf__ has quit [Ping timeout: 265 seconds]
renderfu_ has joined #ruby
daemonwrangler has quit [Ping timeout: 252 seconds]
charliesome_ has joined #ruby
sneakers has joined #ruby
xall has quit [Ping timeout: 272 seconds]
Vingador has quit [Remote host closed the connection]
nikivi has joined #ruby
charliesome has quit [Ping timeout: 252 seconds]
futilegames_ has joined #ruby
zotherst1 has joined #ruby
futilegames has quit [Ping timeout: 272 seconds]
futilegames_ is now known as futilegames
AlphaAtom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Velizar has joined #ruby
A_Drone has joined #ruby
elvin has joined #ruby
pratch has quit [Read error: Connection reset by peer]
Robtop__ has quit [Read error: Connection reset by peer]
renderfu_ has quit [Ping timeout: 264 seconds]
spider-mario has joined #ruby
Robtop__ has joined #ruby
abernstein_ has joined #ruby
johnmilton has quit [Remote host closed the connection]
abernstein has quit [Ping timeout: 248 seconds]
abernstein_ is now known as abernstein
tyang has quit [Ping timeout: 264 seconds]
cjbischof_ has joined #ruby
a1fa has quit [Ping timeout: 265 seconds]
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
a1fa has joined #ruby
craigp has quit [Ping timeout: 264 seconds]
fuzzyhorns has quit [Quit: Leaving.]
<LyndsySimon>
I'm familiar with Object#method_mission, which is roughly equivalent to Python's object#__getattr__. Python also has object#__getattribute__ though, which intercepts method calls even if they exist. Does Ruby have an equivalent?
<apeiros>
method mission! to the method mobile! :D
<LyndsySimon>
:)
<apeiros>
LyndsySimon: no, afaik not
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
<apeiros>
if you want that kind of thing, you'll usually work with a proxy object which inherits from BasicObject and delegates
JeanCarloMachado has joined #ruby
ocbtec has quit [Quit: leaving]
<LyndsySimon>
Aww. OK, that's unfortunate then. I even tried implementing method_missing on mixin prepended to a class, which I thought might have done it.
<LyndsySimon>
Yeah, delegation might do the trick. Thanks, I'll take a look.
<LyndsySimon>
Wait, is delegate a rails-only thing?
webhat has joined #ruby
<apeiros>
i.e. if *anything* in the chain responds, no method_missing is triggered. this btw. also means that method_missing is inherently more expensive than an existing method :)
<apeiros>
delegation is a pattern.
<apeiros>
Object#delegate is a rails thing
<apeiros>
or rather, an AS thing
* LyndsySimon
nods
<apeiros>
delegation is trivial enough, but there's stuff like Forwardable in stdlib if you really need assistance ;-p
<dminuoso>
I was about to say..
<apeiros>
re trivial: def method_missing(name, *args, &block); if handle_myself? then … yourstuff … else @delegatee.public_send(name, *args, &block end end
<apeiros>
± one syntax error (like a missing ")")
emilkarl has quit [Read error: Connection reset by peer]
johnmilton has joined #ruby
jenrzzz has quit [Ping timeout: 244 seconds]
emilkarl has joined #ruby
Coldblackice has quit []
boogeyman has joined #ruby
<dminuoso>
apeiros: can you clean up #rubyonrails ?
testo3 is now known as testo
<apeiros>
pyemkey?
coolboy has quit [Remote host closed the connection]
<apeiros>
I do have ops in rails, but I don't know the bot :(
<apeiros>
no !fixcon :'(
<dminuoso>
Just toss in random bans
<dminuoso>
ban like *@*
<dminuoso>
that ought to do the trick
<apeiros>
btw., that's OT :)
charliesome_ has quit [Ping timeout: 248 seconds]
glundgren has joined #ruby
glundgren is now known as acidbyte
tyang has joined #ruby
wugy has quit []
mesamoo has joined #ruby
anisha has joined #ruby
xall has joined #ruby
abernstein has quit [Quit: abernstein]
zatherz has joined #ruby
<zatherz>
is anyone here experienced with Parslet? how could I take in a parameter in a Parslet::Transform's initialize then use it inside one of the Transform's rules?
hammond has quit [Ping timeout: 252 seconds]
<dminuoso>
zatherz: Fairly simple: Derive from Parslet::Transform, override def initialize and call super() inside
tyang has quit [Ping timeout: 264 seconds]
bebbo has quit []
<dminuoso>
?next
<ruby[bot]>
dminuoso: I don't know anything about next
* dminuoso
kicks ruby[bot]
hammond has joined #ruby
hammond has quit [Changing host]
hammond has joined #ruby
hammond has joined #ruby
hammond has quit [Changing host]
<zatherz>
dminuoso: That's funny
<zatherz>
because it's wrong.
last_staff1 has joined #ruby
<dminuoso>
zatherz: How is that wrong?
<zatherz>
Parslet::Transform runs rules in a special Context, and the self does not refer to the Parslet::Transform class instance
acidbyte has quit []
last_staff1 is now known as last_staff
nadir has joined #ruby
nikivi has quit [Quit: irc]
<dminuoso>
zatherz: Does it have to be pretty, compact and/or elegant?
elvin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
emilkarl has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elvin_ has joined #ruby
<dminuoso>
zatherz: I got at least one hacky solution in mind already. :-)
craigp has joined #ruby
<zatherz>
dminuoso: It doesn't have to be the prettiest, most compact and most elegant, but it shouldn't be the ugliest, least compact and least elegant
symm- has quit [Quit: Leaving...]
lucasb_ has left #ruby [#ruby]
kobain has joined #ruby
<matthewd>
zatherz: Isn't that what the context parameter to apply is for?
<zatherz>
`puts calltransf.apply (typetransf.apply (parser.parse ARGV[0]), :ttest => 13)`, then inside a rule `puts ttest`, errors with method not nfound
coolboy has joined #ruby
<dminuoso>
zatherz: Where is this rule defined on?
<dminuoso>
zatherz: calltransf or typetransf?
<zatherz>
CallTransform (calltransf)
<matthewd>
I'd focus on why the documented thing isn't cooperating, rather than inventing a second approach from scratch, personally
hammond is now known as lz
<matthewd>
.. you're passing it to typetransf.apply
<elastix>
I was trying to do the exercise of another user ... just for test and improve my ruby skill :)
dionysus69 has quit [Ping timeout: 264 seconds]
<elastix>
a non empty zero indexed array A consisting of N integers is given. you can perform a single swap operation in array A. this operation takes 2 indexes I and J such that 0<=I<=J<N and exchanges the value of A[I] and A[J] . the goal is to check whether array A can be sorted into non decresing order by performing at most one swap operation.
AlphaAtom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
KCmetro has quit [Quit: Leaving...]
bigkevmcd has joined #ruby
malconis has joined #ruby
fuzzyhorns has joined #ruby
bjensen82 has joined #ruby
whathappens has joined #ruby
<apeiros>
fascinating that I <= J. I'd expect I < J. Since I = J makes no sense.
<bjensen82>
I have the hash: {"foo"=>[:ffff, :fdsfds, :ffdsf], "bar"=>[1, 2, 3, 4]} which I could like to convert to the number of values as values so it would be: {"foo" => 3, "bar" => 4}.
<matthewd>
apeiros: Simplifies the degenerate case of an already-sorted list ;)
<apeiros>
matthewd: "at most one swap"
<matthewd>
"simplifies"
<apeiros>
it's valid to not swap. so I wouldn't expect to perform swap-noop
<dminuoso>
bhaak: What have you tried so far?
<apeiros>
bleh :)
<dminuoso>
err bjensen82.
<dminuoso>
Damn irssi not tab completing properly. :(
RTFM[away] has quit [Ping timeout: 252 seconds]
fuzzyhorns has quit [Client Quit]
fuzzyhorns has joined #ruby
<bjensen82>
dminuoso: well result = {}; {"foo"=>[:ffff, :fdsfds, :ffdsf], "bar"=>[1, 2, 3, 4]}.each_pair{|k,v| result[k] = v.size}, but it was hoping for a more elegant solution without the use of the temp variable
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
* apeiros
still confused why people even use .each_pair instead of .each
anisha has quit [Quit: This computer has gone to sleep]
whathappens has quit [Read error: Connection reset by peer]
blackgoat has joined #ruby
craigp_ has joined #ruby
<elastix>
how can I check that all the elements of an array are bigger than 100?
<elastix>
should I use a for loop?
whathappens has joined #ruby
<dminuoso>
elastix: Use Enumerable#any?
<matthewd>
elastix: Start by checking Array and Enumerable for the most likely-looking methods
<dminuoso>
elastix: or Enumerable#all?
<elastix>
is it a special function?
jenrzzz has joined #ruby
<dminuoso>
elastix: How about you figure it out and tell us?
cevett has quit [Read error: Connection reset by peer]
cevett has joined #ruby
ChiefAlexander_ has quit [Read error: Connection reset by peer]
LoneHerm_ has quit [Read error: Connection reset by peer]
phaza has quit [Read error: Connection reset by peer]
dviola has quit [Quit: WeeChat 1.5]
claudiuinberlin has quit []
xall has quit [Read error: Connection reset by peer]
diego2 has joined #ruby
ChiefAlexander has joined #ruby
LoneHerm_ has joined #ruby
phaza has joined #ruby
xall has joined #ruby
diego2 has quit [Changing host]
diego2 has joined #ruby
diego2 is now known as dviola
<apeiros>
hint on testing whether an array is sorted: each_cons is a nice help for that.
<elastix>
The all? method returns true if the block never returns false
<elastix>
but I need to check if there is an element greater than 100
craigp_ has quit [Ping timeout: 265 seconds]
<al2o3-cr>
elastix: detect
<apeiros>
-.-
<al2o3-cr>
ive
jenrzzz has quit [Ping timeout: 265 seconds]
<matthewd>
elastix: So what would you need to make the block do?
<apeiros>
elastix: you mean you need to test whether any? element is greater than 100?
<apeiros>
(sledgehammerhint)
<elastix>
yes I need to check if in an array there is an element greater than 100
wldcordeiro has quit [Ping timeout: 265 seconds]
airstream66 has joined #ruby
<matthewd>
elastix: Do you know how to use a block to iterate a collection?
babblebre has joined #ruby
sdwrage has quit [Quit: Leaving]
bjensen82 has quit []
bsrd has quit [Quit: WeeChat 1.5]
FastJack has joined #ruby
airstream66 has quit [Remote host closed the connection]
<elastix>
no
<elastix>
what is a collection?
lacour has quit [Quit: Leaving]
Silthias1 has joined #ruby
Pumukel has joined #ruby
<apeiros>
things which contain more than one value. common collection types in ruby are arrays, hashes and sets.
<dminuoso>
People use Set?
Silthias has quit [Ping timeout: 252 seconds]
<dminuoso>
Amazing. :o)
<matthewd>
In general: Enumerable
<apeiros>
I'd use it quite a lot if it was native and hence would beat Array's set operation performance :(
* apeiros
sadpanda
<dminuoso>
If there was a literal to make a set I would use it for sure
<dminuoso>
Perhaps we could finally make use of <>
elenatanasoiu has quit [Ping timeout: 248 seconds]
<apeiros>
yes, literals would help tremendously too :)
<dminuoso>
Though I think {1,2,3} would be fine.
<matthewd>
elastix: I'd suggest you'll get more value from going through some tutorials for now, instead of trying to tackle a challenge by yourself
* apeiros
wants 4 more literals: date/time, interval, set and orderedset
ur5us has joined #ruby
<apeiros>
s/orderedset/sortedset/
<matthewd>
elastix: I'm sure you could figure out *a* solution with a bare loop, but you'll get more benefit by building familiarity with the ruby-ish ways of approaching it
jcao219 has joined #ruby
futilegames has joined #ruby
<apeiros>
though, given that they started special casing full expressions (e.g. [a,b].max not creating an array), I'd probably also be fine with native set and `Set(1,2,3)`
<matthewd>
We could hand you the answer, but that doesn't help you learn either -- and that's surely the point of trying such a challenge in the first place
whathapp_ has joined #ruby
whathappens has quit [Read error: Connection reset by peer]
futilegames has quit [Client Quit]
<elastix>
yes I got it
<elastix>
can you help me to do that exercise?
sp_ has quit [Ping timeout: 244 seconds]
<elastix>
a non empty zero indexed array A consisting of N integers is given. you can perform a single swap operation in array A. this operation takes 2 indexes I and J such that 0<=I<=J<N and exchanges the value of A[I] and A[J] . the goal is to check whether array A can be sorted into non decresing order by performing at most one swap operation.
lxsameer has quit [Quit: WeeChat 1.5]
tyang has quit [Ping timeout: 264 seconds]
mujou has joined #ruby
xall has quit [Ping timeout: 244 seconds]
workmad3 has quit [Ping timeout: 244 seconds]
<matthewd>
If you can't do the greater-than-100 one yet, this one definitely seems too hard
alaibe has quit [Read error: Connection reset by peer]
alaibe has joined #ruby
whathapp_ has quit [Read error: Connection reset by peer]
cydrobol- has quit [Quit: oooh...what does THIS button do?]
cydrobolt has joined #ruby
cydrobolt has joined #ruby
cydrobolt has quit [Changing host]
skweek has quit [Ping timeout: 252 seconds]
<dminuoso>
matthewd: perhaps he has written a neat case that test for indices [0,0], [0,1], [0,2]... up until [100,100]
<dminuoso>
Then it's understandable.
whathappens has joined #ruby
<dminuoso>
I would probably recommend a good typing course to extend this for larger arrays.
craigp_ has joined #ruby
<elastix>
I done the greater than 100 using a for loop :)
<elomatreb>
elastix: Did you say whether order in the array was relevant?
hutch34 has quit [Ping timeout: 272 seconds]
djbkd has quit [Read error: Connection reset by peer]
djbkd has joined #ruby
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
wilba has joined #ruby
erlingur_ has quit [Ping timeout: 272 seconds]
<wilba>
hi
pwnd_nsfw has joined #ruby
<wilba>
I am trying to figure out a suitable approach to extracting information from a collection of random websites, and was wondering if you guys could help me think this through
<wilba>
What I want to do is get the name of the managing partner along with their email address. Naturally, each of these websites are different, so that makes extraction of the info more difficult.
<Radar>
wilba: hey marcamilly
Robtop__ has quit [Ping timeout: 272 seconds]
<Radar>
ltns
shinnya has joined #ruby
<wilba>
Hey Radar, ltns?
ResidentBiscuit has joined #ruby
<Radar>
google it ;)
JoshS has joined #ruby
<wilba>
ahh....long time no see, indeed.
<wilba>
yeh been a while
<wilba>
Ok, so to get the email, I was thinking of just crawling the entire site and looking for a `mailto` `a` tag....but that doesn't give me sufficient information.
nando293921 has joined #ruby
<wilba>
For starters, that will pull all the email addresses without context, and it will be hard to know which belongs to the named partner as opposed to an office admin assistant
RTFM[away] has quit [Ping timeout: 264 seconds]
hutch34 has quit [Ping timeout: 252 seconds]
<wilba>
The same thing applies to finding the name, I was thinking of searching for header tags and grabbing the text from within those header tags...but that's not sufficient enough because there are some sites that put the partners names in span tags and others that don't wrap them in any header tags at all, other than the `p` tag.
xentity1x has quit [Ping timeout: 244 seconds]
<wilba>
So what are the sorts of things I should be considering/looking at to get the info I am looking for?
hutch34 has joined #ruby
<matthewd>
wilba: ~impossible problem
<wilba>
matthewd: I feared as much :(
<elastix>
thanks:)
<elastix>
sortedArray = aArray.sort!
<wilba>
I need something like specific HTML tags or elements that I can extract, right?
<elastix>
why aArray is sorted too?
NTrash has quit [Quit: Konversation terminated!]
<matthewd>
elastix: Read the documentation
cschneid_ has quit [Remote host closed the connection]
<elastix>
ok and how can I sort in a different variables?
dminuoso has joined #ruby
jphase has joined #ruby
<matthewd>
elastix: You're not learning if you need to be handed every method name
<wilba>
any other thoughts on my challenge?
<matthewd>
elastix: It's far more important to learn how to find the method you need, than it is to get to the result
alaibe has quit [Ping timeout: 265 seconds]
<matthewd>
wilba: I think impossible just about covers it
hutch34 has quit [Ping timeout: 272 seconds]
<elastix>
but I can't find the method right for me
<matthewd>
Where have you looked?
<wilba>
elastix, what are you trying to do? i came in after you described your problem
<elastix>
I need to sort an array
<matthewd>
Which candidates have you considered, and why have you decided they're not a good fit?
<elastix>
but using another variable
<elastix>
array = 3,2,1
<elastix>
sortedarray = 1,2,3
<elastix>
I was using sortedarray = array.sort!
nankyokusei has joined #ruby
<elastix>
but it sorts also my first variable array
<wilba>
if you do that, sort! modifies array
<wilba>
just try doing array.sort
<wilba>
so sortedarray = array.sort
BTheOne has quit [Remote host closed the connection]
<wilba>
the ! modifies the variable/data structure it is acting on
<wilba>
that applies for all/most ruby methods
dminuoso has quit [Ping timeout: 265 seconds]
zeroDi has quit [Quit: WeeChat 1.5]
<elastix>
ok thanks :)
<wilba>
np
zeroDi has joined #ruby
csk has quit [Quit: Bye]
bjh13 has joined #ruby
babblebre has quit [Quit: Connection closed for inactivity]
tonini has quit [Quit: Connection closed for inactivity]
nankyokusei has quit [Ping timeout: 244 seconds]
SteenJobs has joined #ruby
hiro` has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
nando293921 has quit [Quit: Lost terminal]
hahuang62 has quit [Ping timeout: 272 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
elenatanasoiu has quit [Ping timeout: 265 seconds]
Xeago has quit [Ping timeout: 244 seconds]
Xeago has joined #ruby
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hiro`>
Hey everyone, recently reinstalled RVM, now having an annoying problem bundling or installing gems. tried to bundle in a project, kept getting an error saying that I was on 2.3 and not 2.2 as specified by the Gemfile (I wasn't). Deleted the ruby version from the Gemfile. Bundler rebuilt everything from scratch. Tried to run a console - it blew up bc the json gem doesn't exist. Tried to gem install it - that blew up 'incompatible marshal
Kero_ has quit [Ping timeout: 240 seconds]
Ebok has joined #ruby
<havenwood>
hiro`: Start by making sure you have Bundler installed with the Ruby you're using. Then sanity check with `gem which bundler` and `which bundle`.