<al2o3-cr>
gitter1234: can you quickly test this: Municipality.find_by_numeric_code!(key[/^0/] ? key.oct : key.to_i)
<al2o3-cr>
i can't of a good way of doing it at the moment.
drincruz has joined #ruby
fratis has quit []
<al2o3-cr>
or does it work if you switch to varchar.
<gitter1234>
looks intense :) i switched the database field to string since its a string in the json and also it feels more right/semantic, as the numeric code is a gov't assigned number. trying it out now..
tau has quit [Ping timeout: 246 seconds]
drincruz has quit [Ping timeout: 246 seconds]
<gitter1234>
al2o3-cr: yes!!!!
<al2o3-cr>
gitter1234: awesome! :)
<gitter1234>
al2o3-cr :)
<gitter1234>
i think i see what you did there.. nice
fratis has joined #ruby
fratis has quit [Read error: Connection reset by peer]
fratis has joined #ruby
fratis has quit [Client Quit]
al2o3-cr has quit [Quit: WeeChat 2.8]
al2o3-cr has joined #ruby
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
lesha has quit [Ping timeout: 256 seconds]
ChmEarl has quit [Quit: Leaving]
DTZUZU_ has joined #ruby
DTZUZU has quit [Ping timeout: 264 seconds]
DTZUZU_ has quit [Quit: WeeChat 2.8]
DTZUZU has joined #ruby
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #ruby
DTZUZU has quit [Client Quit]
DTZUZU has joined #ruby
sagax has quit [Remote host closed the connection]
gnufied has quit [Ping timeout: 246 seconds]
sagax has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
jenrzzz has quit [Quit: Lost terminal]
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
gitter1234 has quit [Quit: Connection closed for inactivity]
mheld has quit [Quit: Connection closed for inactivity]
fuDwitc has joined #ruby
_whitelogger has joined #ruby
fuDwitc has quit [Ping timeout: 258 seconds]
fuDwitc has joined #ruby
fuDwitc has quit [Ping timeout: 246 seconds]
cliluw has quit [Quit: Leaving]
sauvin has joined #ruby
fuDwitc has joined #ruby
fuDwitc has quit [Ping timeout: 256 seconds]
renich has quit [Quit: renich]
gix- has quit [Ping timeout: 265 seconds]
akem_ has joined #ruby
deimos_ has quit [Quit: leaving]
akem has quit [Ping timeout: 256 seconds]
cnsvc_ has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
deimos_ has joined #ruby
conta has joined #ruby
imode has quit [Ping timeout: 256 seconds]
cnsvc_ has joined #ruby
Archenoth has joined #ruby
Mawile has quit [Ping timeout: 246 seconds]
kinduff has quit [Read error: Connection reset by peer]
conta has quit [Quit: conta]
kinduff has joined #ruby
conta has joined #ruby
schne1der has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
clemens3 has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fuDwitc has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
fuDwitc has quit [Remote host closed the connection]
fuDwitc has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
xylophone has quit [Quit: leaving]
manjaroi3 has joined #ruby
manjaroi3 is now known as xylophone
kinduff8 has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff8 is now known as kinduff
ldepandis has joined #ruby
bga57 has quit [Ping timeout: 256 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
bga57 has joined #ruby
ur5us has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
conta has quit [Quit: conta]
reyfi9e has quit [Ping timeout: 260 seconds]
Querens has joined #ruby
reyfi9e has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
evert has quit [Remote host closed the connection]
evert has joined #ruby
evert has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 258 seconds]
evert has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
apotheon has quit [Ping timeout: 246 seconds]
apotheon has joined #ruby
alexherbo2 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
DTZUZU_ has joined #ruby
DTZUZU has quit [Ping timeout: 240 seconds]
lesha has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
BH23 has quit [Ping timeout: 265 seconds]
TCZ has joined #ruby
TCZ is now known as DoomSlayer2020
BH23 has joined #ruby
akem_ has quit [Quit: Leaving]
akem has joined #ruby
akem_ has joined #ruby
akem_ has quit [Remote host closed the connection]
AndreYuhai has joined #ruby
xylophone has quit [Ping timeout: 240 seconds]
DoomSlayer2020 has quit [Quit: Leaving]
akem_ has joined #ruby
akem has quit [Ping timeout: 246 seconds]
sh7d has quit [Read error: Connection reset by peer]
sh7d has joined #ruby
conta has joined #ruby
Emmanuel_ChanelW has joined #ruby
cnsvc_ has joined #ruby
evdubs has quit [Ping timeout: 260 seconds]
evdubs has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
Emmanuel_ChanelW has quit [Quit: Leaving]
sarna has joined #ruby
dionysus69 has joined #ruby
alexherbo2 has joined #ruby
<sarna>
is IRC the most popular chat platform used by rubyists? I'd expect a lot more people here
drincruz has joined #ruby
Emmanuel_ChanelW has joined #ruby
burningserenity has joined #ruby
vqrs has quit [Ping timeout: 246 seconds]
vqrs has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
vondruch_ has joined #ruby
<AndreYuhai>
in my rspec test file RubyMine warns me as "can not find it" but it runs fine. How can I fix that? The same applies to "to" and "describe" as well. https://dpaste.org/LE9i
burningserenity has quit [Ping timeout: 260 seconds]
vondruch has quit [Ping timeout: 260 seconds]
vondruch_ is now known as vondruch
gavlee has quit [Ping timeout: 260 seconds]
TCZ has joined #ruby
drincruz has joined #ruby
burningserenity has joined #ruby
burningserenity has quit [Client Quit]
burningserenity has joined #ruby
TCZ has quit [Quit: Leaving]
gnufied has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
troulouliou_div2 has joined #ruby
<jhass>
AndreYuhai: require "rspec" ?
<jhass>
or rather make sure require your spec_helper.rb
<jhass>
sarna: I don't know, IRC/Freenode is just in a general decline as people move to Slack, Discord, Matrix, Twitter etc unfortunately
<jhass>
this is still one of the stronger channels I'm in
troulouliou_div2 has quit [Ping timeout: 272 seconds]
<sarna>
jhass: #python still has 1800 online members :(
<AndreYuhai>
jhass, Oh yes thank you. when I did rspec before it was underlining that as well so I had deleted it. Turns out I have to wait a bit to load I guess.
gavlee has joined #ruby
<jhass>
I bet 1000 of them would prefer to be in #python2 :D
chalkmonster has joined #ruby
<sarna>
I don't like slack, it's even more ephemeral than irc, and heavy as heck :/
<sarna>
I joined a discord server but it's unfortunately pretty dead (mostly newbies asking questions, nobody responding)
<jhass>
I don't see it as an alternative to IRC, for me the usecases are entirely distinct
<jhass>
if you look for a place to get answers to questions, I'd say this one still works :)
<sarna>
well yeah, if I want irc to be alive, why don't I use irc, lol
<jhass>
maybe ruby usage is also declining a bit if we're honest as people move to things like go, rust maybe even elixir. I have the feeling Ruby people are more likely polyglots than python people
<sarna>
yeah, ruby is not so shiny anymore
<sarna>
but I'd say it's still really popular
<jennis>
If i have two Foo objects that both have an an integer attribute bar, how do I get the Foo object which has the minimum Foo.bar?
ChmEarl has joined #ruby
<sarna>
otoh at work people want to move from ruby to python.. I can't wait to move to go in three years again, eh :/
<jennis>
ah, Foo.min_by(&:bar) does the trick
mydog2 has joined #ruby
rippa has joined #ruby
<mydog2>
hey
<sarna>
hello
<AndreYuhai>
I am using mechanize as a class variable and I will create two threads using the same class variable to send requests. This might get messed up, right? :D
dretnx has joined #ruby
dretnx has quit [Client Quit]
burningserenity has quit [Ping timeout: 258 seconds]
<mydog2>
not a ruby dev.. looking to work with a ruby dev but he's new to ruby! i have a few questions
conta has quit [Quit: conta]
<mydog2>
he's got a ruby app that works on heroku
<mydog2>
i'm looking to transfer the app to run on a linux/apache platform
<jhass>
AndreYuhai: yeah, I see no statements to thread safety in its docs, so it's safer to assume it's thread unsafe. Shouldn't hurt to just give each thread its own instance
<AndreYuhai>
jhass, Alright thank you so much. I am just doing things but sometimes I don't know whether it's the correct way haha.
<havenwood>
mydog2: It's not particularly difficult, but can take a while if you've never done things like configure a firewall and setup Apache as a reverse proxy.
<jhass>
mydog2: not the most difficult one, no. Heroku certainly is 50x easier, that's what you pay for. Mostly by making many decisions for you, that you have to make on your own. If there's no prior experience it's quite a steep learning curve, but once you know how to host a ruby app, you know it.
Xiti has quit [Ping timeout: 246 seconds]
lucasb has joined #ruby
Xiti has joined #ruby
sarna has quit [Quit: Connection closed]
gpanders has quit [Ping timeout: 265 seconds]
Xiti has quit [Remote host closed the connection]
gpanders has joined #ruby
lesha has quit [Ping timeout: 246 seconds]
cnsvc_ has joined #ruby
Xiti has joined #ruby
<mydog2>
hey jhass - since you've helped me a few times on github issues.. the project i'm considering will have multiple apps, can i have a "project" github account, where i''ll place the repos for the project apps?
<jhass>
just create an organization
<mydog2>
is that free?? i know.. google it!
<mydog2>
looking now
poro has joined #ruby
Xiti has quit [Ping timeout: 260 seconds]
<mydog2>
i''ll create another account.. and go from there..
bukkitgerman8608 has quit [Ping timeout: 260 seconds]
fuDwitc has quit [Remote host closed the connection]
fuDwitc has joined #ruby
imode has joined #ruby
fuDwitc has quit [Ping timeout: 256 seconds]
fuDwitc has joined #ruby
SeepingN has joined #ruby
fuDwitc has quit [Remote host closed the connection]
<leitz>
Happy Friday everyone.
fuDwitc has joined #ruby
gitter1234 has joined #ruby
<havenwood>
jidar: Show `gem which irb` and `which irb`?
<havenwood>
jidar: Also, what's: head -n1 "$(which irb)"
lesha has joined #ruby
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
jidar: It seems either irb is getting loaded three times. I dunno why this script is doing that, but it's possible to do with #load or manually.
<havenwood>
jidar: Does just running Ruby produce a warning?: ruby -rirb -e "0"
gix has joined #ruby
<jidar>
yes to the last one: ruby -rirb -e "0" does produce the warning
<jidar>
havenwood: I do note that this is just a symlink /usr/share/ruby/irb.rb -> /usr/share/gems/gems/irb-1.2.3/lib/irb.rb
poro has quit [Ping timeout: 246 seconds]
banisterfiend has joined #ruby
conta has joined #ruby
schne1der has quit [Ping timeout: 256 seconds]
<ule>
Can someone please explain to me if it is safe to run GC.start at the end of a script execution? (In my case it is actually a Sidekiq queue process
<ule>
If I understood well from my google search here.. it doesn't run GC immediately, but instead, just tells Ruby that the code is ready to clean things up
<havenwood>
ule: It does actually start an immediate sweep by default, but that's optional. The GC will run without your intervention and when a process exits memory will be entirely reclaimed.
plutes has joined #ruby
conta has quit [Quit: conta]
fuDwitc has quit [Remote host closed the connection]
<ule>
I guess this is an issue with Sidekiq then. Because the memory here keeps growing, start using swap until collapses
<havenwood>
ule: If for some reason the GC is disabled, you can trigger a single deferred sweep for the future with: GC.start(immediate_sweep: false)
<ule>
And the process/job in the queue is gone
plutes has quit [Max SendQ exceeded]
<havenwood>
ule: Is the GC disabled?
plutes has joined #ruby
fuDwitc has joined #ruby
<ule>
havenwood: As far as I know it is not. Let me share a newrelic chart:
<ule>
As you can see, objects allocations are going down, but memory keeps increasing and never goes down
<havenwood>
ule: From a Sidekiq worker, what does `GC.enable` return? It'll return `false` if it's already enabled.
<ule>
Let me confirm that
<havenwood>
It's probably enabled, but wanted to double check.
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fuDwitc has quit [Ping timeout: 260 seconds]
<havenwood>
ule: Just checking out your screenshot, and I do see the GC runnning.
<ule>
Agree
<ule>
otherwise the objects allocation would still be up
<havenwood>
ule: It looks like the memory usage only creeps up after the initial spike (which I presume is the app loading?).
<ule>
But then what would be the reason for memory staying up?
<ule>
It goes up everey time the job runs
<ule>
I noticed that only long running jobs are generating the issue
<ule>
for simple ones thar runs < 3 seconds it does nothing on memory
<ule>
for those big ones thar runs 5 minutes < 10 minutes.. then the problem happens
<havenwood>
ule: Can you share the code of the long-running job that causes the issue?
<havenwood>
ule: Looking at the gradual climb, it seems fairly typical for malloc. Can you switch to jemalloc?
<ule>
I can't share, but basically it pulls ~20k "user" objects, creates another data structure organizing it, and fires off another worker.
<havenwood>
ule: Happy to take a look.
<havenwood>
ule: Could you switch allocators to jemalloc?
<havenwood>
ule: (Usually you just install jemalloc and add a flag when you recompile Ruby.
<havenwood>
)
<havenwood>
*install jemalloc with your package manager
<ule>
All I know about malloc is from my time with C. When you say to use jemalloc, you're saying to use JRuby for instance?
xco has joined #ruby
<ule>
I see, We're using a "regular" ruby here.. 2.6
<havenwood>
ule: Nope, nothing JRuby.
<havenwood>
ule: When you compile Ruby, it typically dynamically links to a memory allocator. The default for portability reasons is malloc, but jemalloc is widely considered superior for several reasons. While Ruby hasn't swapped the default, it does make it very easy to switch your allocator to the popular jemalloc.
<ule>
I see
<havenwood>
ule: Jemalloc is the default memory allocator in FreeBSD.
<ule>
I'll run some tests for that
<ule>
and I know FreeBSD is well known for speed/performance
<havenwood>
Fullstaq Ruby might even be a nice option, if you're looking for a package manager style Ruby with jemalloc and a nice default configuration.
<havenwood>
It's very well set up.
kashike has quit [Quit: hiss]
<havenwood>
ule: I've been really happy with it and use it in dev and production. You get speed benefits in addition to substantially less memory creep.
<havenwood>
We use it at work ubiquitously. I see it used widely.
poro has joined #ruby
<havenwood>
It pairs very nicely with Ruby.
<ule>
Do you know if there is any compiled version for Ruby with jemalloc for env managers like RVM or RBENV?
* havenwood
sulks that chruby wasn't mentioned
<ule>
lol
<ule>
Unfortunately thats my reality here :D
<havenwood>
ule: Ruby supports a --with-jemalloc flag, so it's easy to pass that on to RVM, ruby-install, ruby-build, or you can use it directly if you compile yourself.
<havenwood>
ule: For example: rvm install ruby-2.7.1 -C --with-jemalloc
<ule>
I'll try it out, but to place that in Production here I'm gonna need to test and get some approvals first
<havenwood>
ule: (First install jemalloc with your package manager.)
<havenwood>
AndreYuhai: In that ^ example, all three return the same value, but `@foo` is faster.
<jhass>
havenwood: YAGNI very much?
<jhass>
let's not confuse newbies like this
<havenwood>
jhass: They're reading code, and getting confused by deviation from what they learned.
<jhass>
what's performance to do with that?
<havenwood>
jhass: I don't think it's harmful to see the common three ways folk get readers.
<jhass>
especially YAGNI performance considerations
<havenwood>
jhass: Just suggesting one is better than the others, to head of the inevitable "why are there three ways and which should I use."
<jhass>
performance is not the only criteria
<havenwood>
jhass: I was about to say it's also easier on the reader.
<jhass>
that's opinion
<havenwood>
everything is
davispuh has joined #ruby
<jhass>
there's different styles. a comphrensive discussion on all the pros and cons from all angles might be a bit much
<AndreYuhai>
havenwood, Yeap got it, thank you. That's what I've been using so far but when I saw that code I just couldn't think it was actually calling the getter. :D
<jhass>
and picking a single fact is equally confusing
<havenwood>
I'd suggest using instance variables directly when it works. The simplest thing that works aligning with readability and performance is great.
<havenwood>
jhass: It's the single fact that isn't debatable.
<jhass>
but it's importance is
<havenwood>
It matters when it matters. I thought it was an interesting tidbit to gently guide towards best practices.
<havenwood>
YMMV
<jhass>
micro performance considerations like this is nothing we should occupy newbie heads with IMO. Heck, its a consideration I would generally avoid outside a performance optimization context, that is improving an identified bottleneck
<jhass>
outside that context, it's just YAGNI and taking up valuable headpace
<jhass>
*space
<jhass>
you can still state your opinion and it'll be respected most likely, but let's not put importance on unimportant things
<havenwood>
jhass: I've had it matter plenty of times. A default choice of the fastest, simplest way isn't just YAGNI. I didn't feel like AndreYuhai needed kid gloves, but maybe I was wrong.
<havenwood>
AndreYuhai: In any case, great to be reading code!!
ellcs1 has joined #ruby
<havenwood>
jhass: When given multiple ways to do it, I always wonder "do they differ in any substantial way?" Not trying to harp on performance, and I could have waited to see if the question was going to be asked.
<havenwood>
In this case, the three aren't aliases.
<havenwood>
But all three are fairly common.
<AndreYuhai>
Though I haven't been fiddling with Ruby long enough to learn stuff about performances, it is a nice tip and I appreciate it. I mean any kind of help gets my appreciation since you answer me and you devote your time.
<AndreYuhai>
havenwood, I am actually reading it to write another API wrapper for another website haha. Thought it's best way. :D
prestorium has quit [Ping timeout: 260 seconds]
<havenwood>
If you don't try to make it a RuboCop default, are you really grinding your style axe? :P
<havenwood>
AndreYuhai: APIs are fun. Seems much more straightforward to me when no DOM/Browser is involved.
ropeney has joined #ruby
<AndreYuhai>
havenwood, indeed, I will actually use it to scrape some stuff to use later. So I thought wrapper might serve other people as well.
<AndreYuhai>
havenwood, RuboCop on RubyMine is really annoying sometimes underlining most of the code. Probably it's because I didn't do the customization but anyway. :D
DTZUZU_ has quit [Ping timeout: 258 seconds]
<leftylink>
the purpose of this question is only because I'm curious. if I want to teach Ruby to others who know a different language, I will have an easier time with aspects of Ruby that are like many other languages. what are the aspects of Ruby that I'd have the most difficult time relating to other languages?
DTZUZU_ has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
prestorium has joined #ruby
leitz has quit [Quit: Leaving]
fuDwitc has joined #ruby
prestorium has quit [Ping timeout: 265 seconds]
mheld has joined #ruby
troulouliou_div2 has quit [Quit: Leaving]
fuDwitc_ has joined #ruby
fuDwitc has quit [Ping timeout: 256 seconds]
fuDwitc has joined #ruby
kristian_on_linu has joined #ruby
fuDwitc_ has quit [Ping timeout: 258 seconds]
Xiti` has quit [Quit: Leaving]
schne1der has joined #ruby
tau has quit [Ping timeout: 256 seconds]
bsdbandit-01 has joined #ruby
jenrzzz has quit [Read error: Connection reset by peer]
<smccarthy>
I found bundler/inline yesterday. I tried using it in AWS Lambda, but even after changing ENV['BUNDLE_PATH'], ENV['BUNDLE_USER_HOME'], and ENV['GEM_HOME'] to a directory in /tmp, I still get "You don't have write permissions for the /var/runtime directory." I even tried Dir.chdir "/tmp/" , and it still tries to write to /var/runtime (which isn't writable in AWS Lambda). Any ideas ?
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Read error: Connection reset by peer]