znz_jp has quit [Remote host closed the connection]
dfucci has quit [Ping timeout: 260 seconds]
DaRock has joined #ruby
znz_jp has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
Emmanuel_Chanel has joined #ruby
ur5us has joined #ruby
ur5us_ has quit [Ping timeout: 264 seconds]
bamdad has joined #ruby
<cloud69>
I'm trying to live stream some tweets using TweetStream, Active Job and Sidekiq. But how come `TwitterStreamerJob.perform` doesn't seem to get executed? At least I'm not getting any tweets or errors. https://gist.github.com/cloud69420/7819235ce14bcac832290669888aa1b0
gix has quit [Ping timeout: 264 seconds]
philCryo has joined #ruby
philCryo has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Diabe? tkwi w szczegó?ach]
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
ur5us_ has joined #ruby
DaRock has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 272 seconds]
DaRock has joined #ruby
chouhoulis has quit [Remote host closed the connection]
ivz_hh has quit [Read error: Connection reset by peer]
<Bish>
yeah but how do i know that none else creates /tmp/image_cache
<Bish>
i mean, i can't just "pollute" "namespace" like that do i?
<pwnd_sfw>
are they multiple processes of the same application? Maybe tmpdir isn't the right place
rapha has joined #ruby
<rapha>
hey all
<rapha>
is there a simple way of making invisible characters (whitespace and others) in a string, visible?
<rapha>
okay, i should add: without changing the visible ones ... i.e., i don't mean to turn the string into a list of unicode codepoints - more like: if it's ASCII, keep it as it is, otherwise, show the codepoint
Jonopoly has quit [Quit: WeeChat 2.9]
Emmanuel_Chanel has joined #ruby
<cloud69>
fippy_: Nice, never used it before but looks just like bindings.pry? Anyway how do I byebug this active job code? Everything looks fine in the Sidekiq and Redis consoles. But my Twitter streaming can't be working because I haven't entered the proper credentials yet.
<cloud69>
nevermind! seems i can comment out the sidekiq line in application.rb in order to see the results in my console
charrit69 has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
TCZ has joined #ruby
baojg_ has joined #ruby
baojg has quit [Ping timeout: 264 seconds]
ntt has joined #ruby
<ntt>
Hi, I'm having a strange problem with encoding. I have a table in utf8mb4 and I have to convert one field in iso-8859-1. So I'm trying "MyModel.find(1).field.encode('ISO-8859-1', 'UTF-8', :invalid => :replace, :undef => :replace, :replace => '')", but the result is "Giudizio ordinario civile - 1°". if I do the same but with puts before, I obtain "Giudizio ordinario civile - 1°" (without the wrong char). Please, how can I solve?
<ntt>
I need to save the correct version in a var
Mikaela has joined #ruby
chouhoulis has joined #ruby
chouhoulis has quit [Ping timeout: 265 seconds]
mistergibson has quit [Read error: Connection reset by peer]
<Bish>
you could write a method "isoify" with that :D
banisterfiend has joined #ruby
Rudd0 has quit [Ping timeout: 265 seconds]
supercoven has quit [Ping timeout: 240 seconds]
Milos has quit [Ping timeout: 272 seconds]
<Glumetu>
if i compose the name of an variable using .gsub how can i assign a value of that variable? player = "shirt_color_new".gsub("color" , "blue")
<Glumetu>
shirt_blue_new = 221AB4
<Glumetu>
or player = 221AB4 ?
derpadmin has quit [Remote host closed the connection]
Milos has joined #ruby
TCZ has quit [Quit: Diabe? tkwi w szczegó?ach]
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
charrit69 has quit [Ping timeout: 240 seconds]
andornaut has quit [Remote host closed the connection]
william1_ has quit [Ping timeout: 256 seconds]
Milos has quit [Ping timeout: 260 seconds]
dcunit3d has joined #ruby
Milos has joined #ruby
stryek has joined #ruby
TCZ has joined #ruby
dcunit3d has quit [Ping timeout: 260 seconds]
baojg has joined #ruby
wallace_mu has joined #ruby
ChmEarl has joined #ruby
dcunit3d has joined #ruby
baojg_ has quit [Ping timeout: 264 seconds]
akem has joined #ruby
<splud>
Have some code in ruby which runs as a standalone script. however, need to require that into another script - and these are downloaded with a command, so when the first script is actually require'd into another (literally a wrapper to iterate a procedure), the wrapper will have out of necessity defined some of the classes the second script will also define (for when it'd have been running standalone). Logging and reporting status type stuff. Note
<splud>
that the wrapper itself is having to download the second script, so can't outright require it up front - it's not on the filesystem.
<splud>
what is a suitable way to define a class or function only if not already defined - or would encapsulating it in a exception handler be the approach?
<splud>
Oh, also needs to run across a grossly wide variety of ruby versions - back to 1.87 or so.
charrit69 has joined #ruby
<splud>
Glumetu - player would be "shirt_blue_new"
<splud>
you might read up on "eval()"
<adam12>
Glumetu: Sometimes if you're making dynamic variables you might want a Hash. What's the rest of your code look like?
<adam12>
splud: unless defined?(SomeClass); class SomeClass; end; end
<splud>
note also that eval isn't going to instantiate a variable - you can't eval("broken = array[]')
charrit69 has quit [Ping timeout: 240 seconds]
braincrash has quit [Ping timeout: 240 seconds]
charrit69 has joined #ruby
ivz_hh has joined #ruby
<Glumetu>
tyvm for answering i'm just a noob and try to compose the name of a variable and try to assign to it the value of another variable
<adam12>
Glumetu: There's lots of places to improve this Ruby code, but maybe this gets you unstuck?
plant_enjoyer has quit [Quit: Leaving]
<Glumetu>
going to be here for a long time trying to improve :) Thank you for youre time
<adam12>
Glumetu: You almost always want a Hash in this case. Using local_variable_set and local_variable_get is not ideal. But I can't figure out what you're ultimate goal is so we'll roll with it.
<adam12>
(Hash or other higher order Object)
<Glumetu>
that was the ultimate goal ... some of the variables in first group to get in the end the values from second group
Schmitze333 has quit [Ping timeout: 260 seconds]
Schmitze333 has joined #ruby
Schmitze` has joined #ruby
Schmitze333 has quit [Ping timeout: 264 seconds]
Schmitze` has quit [Ping timeout: 240 seconds]
noctux has joined #ruby
cloud69 has quit [Quit: Connection closed for inactivity]
Schmitze` has joined #ruby
greypack has joined #ruby
Schmitze` has quit [Ping timeout: 260 seconds]
Glumetu has quit [Quit: Glumetu]
Rudd0 has joined #ruby
<noctux>
hmm, I have to proxy a larger class and override only very few, specific methods, so I came up with using method_missing. However, as the Proxy should pass as the object itself, I also hooked kind_of? like this: https://paste.xinu.at/Bgtn5g/ Is there a better/more standardized way of doing that? or will this soluton most likely blow up somewhere (sory, I'm not too familiar with ruby)
<adam12>
noctux: SimpleDelegator or DelegateClass from stdlib would be similar.
<adam12>
noctux: I'm not sure about patching kind_of?, but generally patching is_a? and similar can have strange effects.
<adam12>
noctux: You could always mixin a module too.
<noctux>
adam12: yeah, I'm currently looking into how DelegateClass/SimpleDelegator respond to kind_of?
wallace_mu has quit []
TCZ has quit [Quit: Diabe? tkwi w szczegó?ach]
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
<noctux>
ah, ok, so none of the delegation variants actually hook kind_of? by default...
<noctux>
yeah, sure, hooking kind_of is really not that great an idea (because .class will still not match, and its hierarchy is off), but it should work in my context. I'll go with SimpleDelegator+patching kind_of? in that case, I guess
dorian has quit [Remote host closed the connection]
charrit69 has quit [Quit: Konversation terminated!]
philCryo has joined #ruby
lucasb has joined #ruby
Schmitze` has joined #ruby
Hanma[m] has joined #ruby
<leftylink>
hmm. always thought kind_of was such a weird name, don't you?
<leftylink>
I can understand `Circle.new.is_a?(Shape)`. a circle is a shape, sure. but what about `Circle.new.kind_of?(Shape)`... should I think of it as "a circle is kind of like a shape" or something
<leftylink>
hmmmmmmmmmmmmmmmmmmmmmmmmmmmm
BrianWGray has joined #ruby
<leftylink>
oh no I see
<leftylink>
"a circle is a kind of shape"
<leftylink>
how have I been using Ruby for years and years and not realised that
<leftylink>
my goodness
<leftylink>
learn something new every day
impermanence has joined #ruby
brainfunnel has quit [Quit: whoops]
weaksauce has joined #ruby
<apotheon>
leftylink: Where are you getting Circle and Shape?
<leftylink>
an easily recognisable example where one thing might be a subclass of another
weaksauce has joined #ruby
<apotheon>
okay
paydro has quit [Ping timeout: 240 seconds]
BTRE has quit [Remote host closed the connection]
dorian has joined #ruby
Schmitze` has quit [Quit: ERC (IRC client for Emacs 27.1)]
william1_ has quit [Ping timeout: 264 seconds]
howdoi has joined #ruby
BTRE has joined #ruby
htmnc has joined #ruby
lechner has joined #ruby
<htmnc>
is this the appropriate channel to ask questions about RSpec? I'm having an issue trying to ``require`` Ruby standard libraries purely when running stuff through RSpec but not when running the file directly or ``load``-ing into pry/irb
<lechner>
Hi, Why does this command in irb not produce an array with three bugs, please? "Merge subindices for orig sources with multiple tarball components. (Closes: #970750, #971597, #972567)".scan(/Closes:\s+(?:Bug)?#(?:(\d{4,8})\b)(?:,?\s*(?:Bug)?#(?:(\d{4,8})\b))*/i)
<htmnc>
adam12, yep! do I need to add the library to that gemfile?
<htmnc>
lechner, I think he was responding to me, sorry
<lechner>
htmnc: i'm sorry. always too eager
william1_ has joined #ruby
TomyWork has quit [Remote host closed the connection]
<htmnc>
:) no worries lechner
<adam12>
htmnc: What are you requiring that fails?
<adam12>
htmnc: and do you have a stack trace?
<adam12>
lechner: Great example of why multi-line regexps are so nice. ;)
<htmnc>
adam12, require "primes", specifically. I'm not allowed to share the gemfile or anything like that but my code is literally just defining a function prime? within a file and, while I've done it in other ways, just as a matter of exercise I wanted to just return Primes:prime?
<adam12>
htmnc: What version of Ruby?
<htmnc>
adam12, the error is expected no Exception, got #<NameError: uninitialized constant Prime>
<htmnc>
2.5.1, rspec ver 3.2.0
<htmnc>
the code is literally require 'prime' at the top of the file and then def prime?(num)\n return Prime::prime?(num)\nend
<adam12>
htmnc: definitely `prime` and not `primes? You've used both interchangably
<htmnc>
yeah sorry prime? is the function
<htmnc>
it works fine if I run it in irb/pry via load
<adam12>
htmnc: But for the require. Are you requiring `prime` or `primes`?
<adam12>
htmnc: Can you share the stacktrace for the exception?
<htmnc>
require "prime", to be specific
<htmnc>
omg
<htmnc>
I think it's because the first line of the prime_rspec is require "prime" which loads my prime.rb
<adam12>
LOL.
<htmnc>
is there a way to specify that I want to require the standard lib ver? omg
<htmnc>
or to unclutter the namespace? that's sort of hilarious
<adam12>
Your better off not cluttering the namespace.
<htmnc>
yeah, I mean, the rspec was given to me
ur5us has joined #ruby
<htmnc>
maybe it was specifically to avoid people being clever like this LOL
<adam12>
In this case, the $LOAD_PATH has the path for your prime.rb ahead of the stdlib prime.rb.
<htmnc>
yep
<adam12>
What's in your prime.rb? Maybe you can just rename it to something else
<adam12>
Unless you're defining Prime there, which in that case.....
dfucci has quit [Remote host closed the connection]
<htmnc>
nah, like, the rspec for the exercise I was given specifically wants us to work with a local lib/prime.rb to define our own prime? function
<htmnc>
I'm not defining Prime like the module though anywhere
<htmnc>
just a method prime?, also correction method, not function
<adam12>
htmnc: Ahh. In that case, lib/your_module/prime.rb, module YourModule; module Prime; def self.prime(n); ::Prime.prime?(n)
<htmnc>
oooo cool! thanks
<adam12>
Add lib to $LOAD_PATH then `require 'your_module/prime'`. No chance of clobbering.
<htmnc>
appreciate it :)
<adam12>
htmnc: Cheers.
roshanavand_ has joined #ruby
orbyt_ has joined #ruby
roshanavand has quit [Ping timeout: 256 seconds]
roshanavand_ is now known as roshanavand
<adam12>
lechner: Hard to understand with everything all clobbered in one, but I think someone intended for part of the regexp to match repeatedly, and it doesn't. Growing out the regexp fixes it, but without knowing enough of the rest of the possible patterns, it's too hard to say what a fix would be. https://rubular.com/r/ey7kMpL72kxZKH
bocaneri has quit [Remote host closed the connection]
<lechner>
adam12: actually, i was able to make it work as intended but i do not understand the function of * in scan, and when nil appears too. is there a doc?
<adam12>
lechner: Technically match might have been more suitable.
william1_ has quit [Client Quit]
william1_ has joined #ruby
william1_ has quit [Client Quit]
<lechner>
does that avoid th need to flatten too?
william1_ has joined #ruby
<adam12>
lechner: I'm not sure. I think they used `scan` because it might be multiple lines/repeats of `Closes: #11111`. So maybe `scan` is fine.
<adam12>
lechner: nil is likely a bug in the regexp. I would of expected something like /Closes:\s+(regexp_to_match_id)+/, where the match group is repeated and only matches, is never nil. That's kind of there, but part of the match is repeated twice, and there's a bunch of non-capturing groups.
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
Takumo has quit [Quit: WeeChat 2.8]
ur5us has quit [Ping timeout: 264 seconds]
ellcs has joined #ruby
akem_ has joined #ruby
ivz_hh has quit [Remote host closed the connection]
ivz_hh has joined #ruby
summerisle_ is now known as summerisle
summerisle has quit [Quit: In my vision, I was on the veranda of a vast estate, a palazzo of some fantastic proportion.]
summerisle has joined #ruby
SeepingN has quit [Ping timeout: 246 seconds]
reaVer has quit [Ping timeout: 256 seconds]
reaVer has joined #ruby
r29v has joined #ruby
<lechner>
adam12: is there an error in this one, as an example? "970750 971597 972567".scan(/(\s*\d+)*/)
<lechner>
okay, ikind of figured that out, but is it possible to combine this form of multiple matching with an asterisk, or is match better for that?
<adam12>
lechner: match would be better for that. scan repeats the pattern multiple times, collecting the Array (or Array of Arrays if you have a capture group).
<adam12>
lechner: It might not work for multiple scenarios of `Closes #100\nCloses#200`. You'd have to check.
<lechner>
so scan is like the /m switch in Perl?
<adam12>
lechner: I'm not sure, but I'd guess it's the same as Ruby's `/m` switch.
<lechner>
now i do a match first and the use scan. it works great except if there is no match. j think i need a conditional
<adam12>
lechner: match accepts a block. so match(pattern) do |m|
<adam12>
lechner: It makes the regexp case-insensitive, so it would match `closes:` or `CloSes:` or whatever.
<lechner>
so why |m| instead of /m
<adam12>
lechner: Ah. Well in this case, |m| is a block argument, not a regexp modifier like /m or /i.
<adam12>
lechner: you could call it anything, like |match| or |mtch| or |foo|. It just makes a closure where MatchData is available in the block only if it matches.
<adam12>
(like a conditional but without the `if` part)