<c-c>
ok, I'll be sure to watch that when I have extra 30 minutes
<phaul>
you wasted a lot more already :)
<phaul>
I have to go. good luck
<c-c>
I'm not going to use monads. 8) Replying to a code paste with a video - thats basically blowing someone off.
<c-c>
Sad that I couldn't use your suggestions, but remember succint, on-topic, to-the-point
<c-c>
best accept facts: my question is broad, and its hard to provide answer to it, unles you already have a code-example.
phaul has quit [Ping timeout: 252 seconds]
<c-c>
Maslows Hammer
<c-c>
- When you've been studying/using X, all problems look like you should use X to solve them
kurko_ has joined #ruby
Frankenstein has joined #ruby
mixfix41 has quit [Quit: Lost terminal]
fredlinhares has quit [Quit: WeeChat 1.9.1]
nadir has quit [Quit: Connection closed for inactivity]
orbyt_ has joined #ruby
marmotini_ has joined #ruby
themsay has joined #ruby
<mroutis>
What's the name of this "early return" from functions, instead of nesting a lot of "if" cases?
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mroutis>
guard clauses!
Frankenstein is now known as uplime
<mroutis>
it was not a trivia, just me fighting my memory out loud
<baweaver>
yep, guard clause.
<c-c>
- that video *is* great and makes me wonder if I should monad
m27frogy has joined #ruby
<c-c>
Ah well, 4 am soon, maybe I'll go dream of eventually optionals
cxl has joined #ruby
<cxl>
Hi, I can't wrap my head around this one: is there a difference between using self or the class name: https://dpaste.de/UzcZ ?
<baweaver>
one is generic and doesn't require you renaming everything if the class name changes or you want to move it somewhere else.
<cxl>
so they are equivalent, but the first is prefered?
<baweaver>
Pretty much.
<cxl>
Or is there ever a good reason to use the class name instead of self?
ta_ has quit [Ping timeout: 252 seconds]
AJA4350 has quit [Remote host closed the connection]
blackmesa has quit [Ping timeout: 252 seconds]
ur5us has joined #ruby
<cxl>
wait, there is a difference, but I can't tell what it is. In this code: https://dpaste.de/poKn, if I replace all the User. with self., and then do User.first.remember in the rails console, it can't find the new_token method. But if I use User. as it is in the dpaste, then it works. I don't understand why that is.
<c-c>
^ its as simple IPC model as I can implement. Then again, I'm no genius so I suppose its probably still kinky.
<c-c>
- also still have funny stuff happening with .put/puts/!/flush. Seems the only way to be 100% sure the message flows into a pipe is "my_pipe.puts msg\n my_pipe.flush"
<c-c>
(thats why the put! and get! singleton methods were not used in that snippet)
themsay has quit [Ping timeout: 252 seconds]
themsay has joined #ruby
dellavg_ has joined #ruby
ua has joined #ruby
whysthatso has joined #ruby
cd has joined #ruby
phenom has quit [Ping timeout: 244 seconds]
xfbs has joined #ruby
<c-c>
s/IPC/nonblocking IPC/
clemens3 has quit [Remote host closed the connection]
<c-c>
- bah, looking at IO.select doc, looks like should read all pipes that a proc has open in read_line_nonblocking
<c-c>
hehe so don't look at the snippet, it should probably be a mixin module thing anyway
ur5us has joined #ruby
danguita has quit [Quit: WeeChat 2.2]
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
danguita has joined #ruby
danguita has quit [Client Quit]
ur5us has quit [Remote host closed the connection]
ellcs has joined #ruby
danguita has joined #ruby
jetchisel has joined #ruby
ta_ has joined #ruby
ta_ has quit [Ping timeout: 264 seconds]
GodFather has quit [Ping timeout: 244 seconds]
xfbs has quit [Quit: afk]
beefjoe has joined #ruby
phaul has joined #ruby
kapil____ has joined #ruby
mikecmpbll has joined #ruby
roshanavand has joined #ruby
xfbs has joined #ruby
ellcs has quit [Ping timeout: 264 seconds]
<c-c>
hm, maybe I should wrap that IPC code in an array with maybe. So you get IPC message-stack that only needs list of pipes and .read_next to use.
<c-c>
hnnh, that would be two-directional named pipe in ruby
<c-c>
hnghh, an asyncronous bidirectional named pipe in ruby, to be correct
tbuehlmann has quit [Ping timeout: 252 seconds]
tbuehlmann has joined #ruby
blackmesa has joined #ruby
<c-c>
yet another async bidirectional ipc lib? pipesnow? hm, maybe I could call it fiberoptic
<c-c>
hm, I wonder if thats easily confused with threading
za1b1tsu has quit [Quit: WeeChat 2.1]
djellemah has joined #ruby
* c-c
mumbles monologue and wondrs off
_whitelogger has joined #ruby
blackmesa1 has joined #ruby
blackmesa has quit [Ping timeout: 264 seconds]
beefjoe has quit [Quit: <3]
Fusl has quit [Ping timeout: 256 seconds]
DTZUZO has joined #ruby
Fusl has joined #ruby
Xiti has quit [Quit: Xiti]
wildermind has joined #ruby
GodFather has joined #ruby
<snickers>
hi, how can I do something like this in net-http?
Puffball has quit [Remote host closed the connection]
MoritaShinobu has joined #ruby
Puffball has joined #ruby
blackmesa1 has quit [Ping timeout: 252 seconds]
Xiti has joined #ruby
blackmesa1 has joined #ruby
rivalomega has joined #ruby
apparition has joined #ruby
rivalomega has quit [Ping timeout: 252 seconds]
xfbs has quit [Quit: afk]
conta has joined #ruby
_whitelogger has joined #ruby
blackmesa1 has quit [Ping timeout: 252 seconds]
themsay has quit [Remote host closed the connection]
blackmesa1 has joined #ruby
MoritaShinobu has quit [Ping timeout: 252 seconds]
AJA4350 has joined #ruby
kurko_ has joined #ruby
leah2 has quit [Remote host closed the connection]
leah2 has joined #ruby
MoritaShinobu has joined #ruby
wojnar has joined #ruby
<havenwood>
Vashy: You can use `sudo` for the system location your package chose for RubyGems, or use the --user-local flag to switch the location to your home directory.
<havenwood>
Vashy: Or install a Ruby that already has RubyGems configured for home directory installs.
rivalomega has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has quit [Ping timeout: 260 seconds]
ivanskie has joined #ruby
kurko_ has joined #ruby
GodFather has joined #ruby
venmx has quit [Ping timeout: 264 seconds]
dinfuehr_ has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
conta has quit [Quit: conta]
conta has joined #ruby
apparition has quit [Quit: Bye]
<cxl>
Vashy: looks like your rvm doesn't work well (system is using 2.3.0). Try running `rvm` and scroll back up to see if it complains about not being in path or something of the sort. If it does, you need to fix your rvm install, #rvm could be of help.
<havenwood>
Vashy: After reading cxl's comment I retract what I said above. i didn't read what you wrote carefully enough and I'm pre-coffee.
<havenwood>
Vashy: You don't need the rubygems package for RVM. Does the `rvm` command work? What's `rvm current`?
MoritaShinobu has quit [Read error: Connection reset by peer]
xfbs has joined #ruby
TheBloke has quit [Ping timeout: 252 seconds]
marmotini has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wildermind has quit [Quit: Connection closed for inactivity]
beefjoe has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
i8igmac has joined #ruby
<i8igmac>
if i run a block can i have this block return a variable
sameerynho has quit [Ping timeout: 240 seconds]
kapil____ has quit [Quit: Connection closed for inactivity]
<i8igmac>
var=stuff.each do |x| return x end
venmx has joined #ruby
<i8igmac>
or like
<i8igmac>
nvm i dont know how to ask a proper question lol
<i8igmac>
block.all? do |x| x.include?("string") end => true
<i8igmac>
i want the block to return true
<havenwood>
i8igmac: it would
<havenwood>
i8igmac: (assuming they all include the string)
<havenwood>
i8igmac: have you tried it?
<i8igmac>
um, i just used all as a example, maybe that is my problem
<i8igmac>
if any line includes the string... let me check
<i8igmac>
block.any? do |x| x.include?("string") end => true
<i8igmac>
oh, i was making a mistake with the block and nokogiri needs x.to_s.include? or it always returns false
<havenwood>
i8igmac: for your particular example, you could write: block.all? /string/
<i8igmac>
i just discovered any?
<i8igmac>
its works just fine ;-)
<i8igmac>
page.css(@href).any? do |x| if x.include?("string"); end
nadir has quit [Quit: Connection closed for inactivity]
<cxl>
Wouldn't self in that context be an instance of Foo, and it having not instance method called method1 then wouldn't it climb up to the class to look for it there?
ta_ has joined #ruby
uplime has quit [Ping timeout: 244 seconds]
<havenwood>
cxl: It isn't undefined on L11. That would return: #=> "method3 and method1"
<havenwood>
cxl: Double check with the code you're showing us?
<havenwood>
cxl: Foo.method3 #=> "method3 and method1"
<cxl>
havenwood: what am I missing? If I run that code it says undefined method method1 in the repl
<cxl>
oh my bad, it's probably tripping on L25 rather
<havenwood>
cxl: You're defining class not instance methods here.
<havenwood>
cxl: Foo.method1
<havenwood>
cxl: Foo.method2
<cxl>
but why then? on that line, wouldn't foo.method1 run the class method?
<havenwood>
cxl: Class methods are called on the class itself, not an instance of the class.
<cxl>
I thought ruby would look for a given method in the instance first, and then in the class if it can't find it.
<cxl>
and so on until it ran out of superclasses
<havenwood>
cxl: `foo` is an instance of `Foo` in your example. you can call instance methods on `foo`. you can call class methods like you've defined on `Foo`.
<i8igmac>
thanks havenwood
<havenwood>
i8igmac: not sure I helped, but no prob! any time!
ta_ has quit [Ping timeout: 252 seconds]
<cxl>
so on L11, what is `self` then? The instance?
<havenwood>
cxl: instance methods have a separate lookup than class emthods
<havenwood>
cxl: No, on line 11 `self` is `Foo`.
<havenwood>
cxl: The class Foo, just like on like 19.
<cxl>
ok, but I can't call any of these def Foo/self methods from the instance?
<havenwood>
cxl: We just use `self` instead of `Foo` in these cases so you can change the name of the class without going through and changing everywhere it's referenced.
<havenwood>
cxl: No, these are all class methods without an instance method equivalent.
<havenwood>
cxl: You can't call them on an instance, unless you do: foo.class.method1
<cxl>
so my issue is only because I thought that the pattern was look for method on instance, and then up the class and superclasses if not found, but instead it's look it up on the instance and fail if it's not there?
<havenwood>
cxl: So basically, you can't call them on the instance. They're class methods.
<havenwood>
cxl: Well, it'll look for instance methods in the class hierarchy.
<havenwood>
cxl: The book "Ruby Under a Microscope" has a good explanation of method lookup.
<cxl>
and to declare instance methods from the class, I'd have to do it in the constructor, as self.mymethod?
<phaul>
could work.. :) never used select from Ruby, but that's how I would start
<phaul>
better than busy waiting in a tight loop
<phaul>
or sleeping
<RedNifre>
hmmm, looks somewhat complicated.
mroutis has joined #ruby
<phaul>
althhough, does it even work for non socket descriptors...
<RedNifre>
I wonder if there's a simpler `tail -f bla | ruby bla.rb` solution.
<phaul>
don't know. There must be a way for the OS to wake up a process when a file is touched
* phaul
wanders off and looks up tail source code
cats has joined #ruby
nowhere_man has joined #ruby
TheBloke has joined #ruby
<phaul>
if you don't care about performance, I guess the easiest is just to sleep. old_num_bytes = 0; loop { fd = File.open(); fd.seek(old_num_bytes); fd.read; old_num_bytes = fd.pos ; sleep(some_arbitrary_time)}
<phaul>
^that's just a pseudo code about the idea. it's leaking file descriptors at this form.
aufi has quit [Ping timeout: 272 seconds]
lytol_ has joined #ruby
dellavg_ has quit [Ping timeout: 244 seconds]
<al2o3-cr>
something like this: IO.open(file) { |io| f.seek(0, :SEEK_END); loop { select [io]; line = io.gets ... }
<phaul>
just don't forget to sleep at some point :)
LiftLeft2 is now known as LiftLeft
<phaul>
the tail I looked at does use OS specific stuff for this. (kevents). so if tail does that then there is probably no good answer
<al2o3-cr>
phaul: yes, i missed the sleep but you get the point ;)
<phaul>
al2o3-cr: sure
<al2o3-cr>
=P
kn-928 has joined #ruby
xfbs has joined #ruby
Dbugger has quit [Remote host closed the connection]
RougeR has joined #ruby
clemens3 has quit [Remote host closed the connection]
RedNifre has quit [Ping timeout: 240 seconds]
RedNifre has joined #ruby
beeman has quit []
catch22 has joined #ruby
herbmillerjr has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
herbmillerjr has quit [Client Quit]
beeman has joined #ruby
blackmesa has joined #ruby
im0nde has quit [Ping timeout: 264 seconds]
blackmesa1 has quit [Ping timeout: 260 seconds]
<phaul>
RedNifre: so what does that leave you with? Are you going to implement the loop + sleep combo?
GodFather has quit [Ping timeout: 252 seconds]
* baweaver
wanders in
<baweaver>
ohai
<phaul>
howdy
ta_ has joined #ruby
nchambers is now known as uplime
ta_ has quit [Ping timeout: 252 seconds]
kn-928 has quit [Ping timeout: 240 seconds]
GodFather has joined #ruby
daemonwrangler has quit [Quit: ZNC 1.6.5 - http://znc.in]
im0nde has joined #ruby
daemonwrangler has joined #ruby
ozzloy has quit [Ping timeout: 245 seconds]
akem__ has quit [Remote host closed the connection]
akem__ has joined #ruby
ellcs has quit [Ping timeout: 264 seconds]
ellcs has joined #ruby
rivalomega has quit []
uplime has quit [Ping timeout: 252 seconds]
<RedNifre>
hmmmm...
<RedNifre>
Well, given that I'm rewriting my big ball of mud code to clean it up I guess I should do the proper 'select' solution
armyriad has joined #ruby
<RedNifre>
You see, historically I used ruby to write tiny ugly prototypes and when it got too messy I rewrote it in a different language, but now I'm trying to do it properly in ruby (because I couldn't find a better scripting language)
orbyt_ has joined #ruby
ta_ has joined #ruby
DTZUZU has joined #ruby
orbyt_ has quit [Client Quit]
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
kn-928 has joined #ruby
marmotini_ has joined #ruby
funnel has quit [Ping timeout: 245 seconds]
RedNifre has quit [Read error: Connection reset by peer]
funnel has joined #ruby
kn-928 has quit [Ping timeout: 252 seconds]
marmotini has quit [Ping timeout: 240 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
reber has quit [Remote host closed the connection]
reber__ has quit [Read error: Connection reset by peer]
TomyLobo has quit [Read error: Connection reset by peer]
RedNifre has joined #ruby
xfbs has quit [Quit: afk]
ta_ has quit [Ping timeout: 244 seconds]
uplime has joined #ruby
xfbs has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]