<havenwood>
darix: It'd be nice to document, agreed.
raatiniemi has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 264 seconds]
apeiros has quit [Ping timeout: 260 seconds]
dstrunk has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ElDoggo has joined #ruby
RougeR has quit [Ping timeout: 252 seconds]
raatiniemi has joined #ruby
RickHull has quit [Ping timeout: 260 seconds]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nb_bez_______ has joined #ruby
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
whippythellama has quit [Ping timeout: 246 seconds]
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ElDoggo has quit [Remote host closed the connection]
workmad3 has joined #ruby
whippythellama has joined #ruby
dstrunk has joined #ruby
bmurt has joined #ruby
guacamole has joined #ruby
cagomez has joined #ruby
troys is now known as troys_
workmad3 has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
uZiel has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cagomez has quit [Ping timeout: 255 seconds]
kculpis has joined #ruby
Psybur has joined #ruby
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guille-moe has joined #ruby
jameser has joined #ruby
sepp2k has quit [Ping timeout: 258 seconds]
DTZUZO has joined #ruby
sepp2k has joined #ruby
jaegerca has joined #ruby
<jaegerca>
If I had a bunch or Articles that belonged to Categories in my Blog - would you perfer Blog::Category and Blog::Article, or Category and Article, or BlogCategory and BlogArticle?
<jaegerca>
(I am crossposting this in rails because I am curious about opinions)
<Papierkorb>
jaegerca: I don't use Rails. Though for that, I'd use a structure akin to Model::Category, Model::Article, ..
jaegerca has left #ruby [#ruby]
guacamole has joined #ruby
jaegerca has joined #ruby
<Papierkorb>
jaegerca: Basically, I always do WhatItIs::TheThingItself
<jaegerca>
Papierkorb: But you would keep article and blog on the "top level" of the Model namespace.
<Papierkorb>
Keeps the hierarchy flat, clutter to a minimum, and keeps naming-spam low
<jaegerca>
or article and category rather
<jaegerca>
Papierkorb: What if you expect this application to grow quite large - and other things end up with categories?
<jaegerca>
I ask because I always seem to regret not namespacing in every project, but I feel I end up just making more namespaces than I should be before I actually need them.
<Papierkorb>
There's nothing wrong with a Model::FooCategory
sepp2k has quit [Read error: Connection reset by peer]
dar123 has joined #ruby
<Papierkorb>
It's X::Y, rarely deeper than that (by design). I don't count a top-level module (for the lib or the application) in that
<jaegerca>
Papierkorb: I tend to agree, but it seems cluttery to me - just from a ocd sort of viewpoint.
<Papierkorb>
From my experience, it works really good for small to mid-size applications
<Papierkorb>
mid-size is <100k SLOC. Don't have much experience after that, though I guess it needs another hierarchy layer at that point
<jaegerca>
I think I would like to end up exploring microservices more with my code using docker and DevOps, then using services as "namespaces" instead.
<Papierkorb>
jaegerca: If it looks cluttery to you, then you don't have proper rules in place.
<jaegerca>
Papierkorb: That could be true
<Papierkorb>
I employ a strict naming convention
<jaegerca>
What convention is that?
alfiemax has joined #ruby
<Papierkorb>
E.g., the module is never plural. `Model`, not `Models`. Naming overlap is not a bug, but a feature: `Importer::User` and `Model::User` is great
mkroman has quit [Ping timeout: 260 seconds]
jphase has joined #ruby
<jaegerca>
Papierkorb: How many models do you think you end up with on some of your larger projects?
<Papierkorb>
And if you have something that doesn't fit anywhere, it doesn't fit anywhere. Create a new module for that. If it turns out to be bad, moving a class around is easy
mikecmpbll has quit [Quit: inabit. zz.]
mkroman has joined #ruby
guacamole has quit [Quit: My face has gone to sleep. ZZZzzz…]
<Papierkorb>
jaegerca: I don't employ strict MVC, counting in models doesn't make much sense
<jaegerca>
Papierkorb: Ok, well I appreciate your answers!
apeiros has joined #ruby
<Papierkorb>
jaegerca: Embrace the chaos if there is no possible order. Don't solve local issues globally, and don't solve global issues locally.
ElDoggo has joined #ruby
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Papierkorb>
jaegerca: And if you want a well-understood hammer, see SOLID is .. well .. more often than not .. solid
<Papierkorb>
Except when it overcomplicates things and then it's fragile. ah well.
ElDoggo_ has joined #ruby
hahuang65 has quit [Quit: WeeChat 1.9.1]
hahuang65 has joined #ruby
jphase has quit [Ping timeout: 252 seconds]
csk157 has quit [Ping timeout: 240 seconds]
<jaegerca>
Papierkorb: "Don't solve local issues globally, and don't solve global issues locally" I like that
<jaegerca>
What is SOLID?
apeiros has quit [Ping timeout: 248 seconds]
ElDogg___ has joined #ruby
Dimik has quit [Ping timeout: 246 seconds]
<Papierkorb>
google "SOLID principles", there are posts on it for ruby, though it originated in Java (coined by the GOF 'Gang of Four'). Basically, they're patterns on how to model your classes
<jaegerca>
Papierkorb: Oh, I love Gang of Four, I have the ruby version right here!
ElDoggo has quit [Ping timeout: 240 seconds]
idefine has quit [Remote host closed the connection]
idefine has joined #ruby
ElDoggo_ has quit [Ping timeout: 260 seconds]
knight33 has joined #ruby
idefine has quit [Ping timeout: 240 seconds]
enterprisey has joined #ruby
Fridtjof has quit [Ping timeout: 246 seconds]
jxv has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has joined #ruby
eckhardt has joined #ruby
orbyt_ has joined #ruby
apeiros has quit [Ping timeout: 248 seconds]
mkroman has quit [Ping timeout: 248 seconds]
cagomez has joined #ruby
arescorpio has joined #ruby
PresidentBiscuit has joined #ruby
idefine has joined #ruby
cagomez has quit [Ping timeout: 258 seconds]
jphase has joined #ruby
darkmorph has quit [Ping timeout: 264 seconds]
uZiel has quit [Ping timeout: 248 seconds]
guacamole has joined #ruby
apeiros has joined #ruby
mkroman has joined #ruby
dar123 has joined #ruby
idefine_ has joined #ruby
gizmore|2 has joined #ruby
idefine__ has joined #ruby
idefine_ has quit [Read error: Connection reset by peer]
idefine has quit [Read error: Connection reset by peer]
znz_jp has quit [Remote host closed the connection]
dar123 has quit [Client Quit]
iMadper has joined #ruby
apeiros has quit [Ping timeout: 258 seconds]
idefine_ has joined #ruby
gizmore has quit [Ping timeout: 240 seconds]
znz_jp has joined #ruby
idefine__ has quit [Ping timeout: 258 seconds]
d^sh has quit [Ping timeout: 258 seconds]
arescorpio has quit [Ping timeout: 252 seconds]
d^sh has joined #ruby
apeiros has joined #ruby
jenrzzz has joined #ruby
apeiros has quit [Ping timeout: 240 seconds]
ElDogg___ has quit [Remote host closed the connection]
idefine has joined #ruby
cdg has joined #ruby
idefine_ has quit [Read error: Connection reset by peer]
ElDoggo__ has joined #ruby
GodFather has quit [Ping timeout: 248 seconds]
idefine has quit [Ping timeout: 248 seconds]
ElDoggo has joined #ruby
ElDoggo has quit [Remote host closed the connection]
ElDoggo has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
vipaca has joined #ruby
ElDoggo has quit [Remote host closed the connection]
ElDoggo__ has quit [Ping timeout: 248 seconds]
raatiniemi has quit [Read error: Connection reset by peer]
ElDoggo has joined #ruby
guille-moe has quit [Ping timeout: 240 seconds]
raatiniemi has joined #ruby
rhyselsmore has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Synthead has joined #ruby
<Synthead>
is there a way to check if n is an index of an array without doing something like n >= 0 && n < a.count ?
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mson has quit [Quit: Connection closed for inactivity]
<Synthead>
i.e. (making this up) s.exists?(2)
RougeRR has quit [Ping timeout: 248 seconds]
ElDoggo has quit [Ping timeout: 240 seconds]
quobo has quit [Quit: Connection closed for inactivity]
cdg has quit [Remote host closed the connection]
cdg has joined #ruby
apeiros has joined #ruby
tvw has quit [Ping timeout: 255 seconds]
troys_ is now known as troys
John___ has quit [Read error: Connection reset by peer]
jphase has quit [Remote host closed the connection]
mson has joined #ruby
cdg has quit [Ping timeout: 252 seconds]
apeiros has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
dstrunk has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Fridtjof has joined #ruby
jphase has joined #ruby
PresidentBiscuit has quit [Remote host closed the connection]
dalitom has quit [Ping timeout: 260 seconds]
PresidentBiscuit has joined #ruby
chouhoulis has joined #ruby
nb_bez_______ has quit [Quit: Connection closed for inactivity]
apeiros has joined #ruby
Heph_ has joined #ruby
Heph_ has quit [Remote host closed the connection]
jphase has quit [Ping timeout: 260 seconds]
PresidentBiscuit has quit [Ping timeout: 252 seconds]
dstrunk has joined #ruby
workmad3 has joined #ruby
chouhoulis has quit [Ping timeout: 252 seconds]
apeiros has quit [Ping timeout: 260 seconds]
Psybur has quit [Ping timeout: 240 seconds]
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
workmad3 has quit [Ping timeout: 255 seconds]
sspreitz has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sspreitz has joined #ruby
tastytf has joined #ruby
jphase has joined #ruby
uZiel has joined #ruby
alex`` has joined #ruby
jphase has quit [Remote host closed the connection]
<iamarun>
can i ask one question ? do we really need rvm and rbenv
<iamarun>
is it important
<iamarun>
to have them installed
<baweaver>
We don't really keep count of questions :)
<iamarun>
;)
<baweaver>
It will make it easier on you later on if you need other versions
<baweaver>
or if you need to upgrade
<baweaver>
package managers are notoriously out of date
<iamarun>
okay
<baweaver>
It'll make it easier in the long run but slightly harder to get started
<baweaver>
For someone just playing with Ruby I don't think it's necessary, but for a developer it probably is
duderonomy has joined #ruby
rabajaj has joined #ruby
<elomatreb>
iamarun: If you're on Arch you're probably OK without them unless you actually need to switch versions, the Arch repos contain up-to-date Ruby versions
<iamarun>
@elomatreb thanks
chmurifree has quit [Ping timeout: 240 seconds]
<iamarun>
and good IDE for rails
<iamarun>
have sublime text
<elomatreb>
RubyMine (Jetbrains) is probably the only popular IDE in the classic sense, but it's perfectly reasonable to just use a normal text editor
<elomatreb>
The dynamic nature of a lot of Ruby code limits the amount of work IDEs can do for you (e.g. autocomplete)
dionysus69 has joined #ruby
chmurifree has joined #ruby
csk157 has joined #ruby
reber has joined #ruby
apeiros has quit [Remote host closed the connection]
alex`` has quit [Quit: WeeChat 1.9.1]
csk157 has quit [Ping timeout: 248 seconds]
<iamarun>
okay thanks
enterprisey has quit [Ping timeout: 240 seconds]
nephelo has joined #ruby
jphase has joined #ruby
jphase has quit [Ping timeout: 240 seconds]
enterprisey has joined #ruby
enterprisey has quit [Remote host closed the connection]
jphase has joined #ruby
workmad3 has joined #ruby
cgfbee has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
Azure has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
workmad3 has quit [Ping timeout: 248 seconds]
jphase has quit [Ping timeout: 255 seconds]
alfiemax has quit [Ping timeout: 258 seconds]
kapil___ has joined #ruby
jphase has joined #ruby
troys has quit [Quit: Bye]
harfangk has joined #ruby
apeiros has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
snickers has joined #ruby
iMadper` has joined #ruby
jameser has quit [Ping timeout: 240 seconds]
allcentury has joined #ruby
iMadper has quit [Read error: Connection reset by peer]
jameser has joined #ruby
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
claudiuinberlin has joined #ruby
alfiemax has joined #ruby
allcentury has quit [Ping timeout: 240 seconds]
enterprisey has joined #ruby
jphase has quit [Ping timeout: 258 seconds]
alfiemax has quit [Ping timeout: 240 seconds]
ta has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has joined #ruby
jameser has joined #ruby
quobo has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
conta has joined #ruby
imode has quit [Ping timeout: 255 seconds]
alfiemax has joined #ruby
irick has quit [Read error: Connection reset by peer]
irick has joined #ruby
aufi has joined #ruby
Dimik has quit [Ping timeout: 240 seconds]
mn3m has joined #ruby
Burgestrand has joined #ruby
MrBismuth has joined #ruby
MrBusiness has quit [Ping timeout: 252 seconds]
ta has joined #ruby
postmodern has quit [Quit: Leaving]
alfiemax has quit [Ping timeout: 258 seconds]
jameser has quit [Read error: Connection reset by peer]
jameser has joined #ruby
nick123 has quit [Quit: Leaving...]
morfin has joined #ruby
<morfin>
HELLO
<morfin>
oops
enterprisey has quit [Remote host closed the connection]
<morfin>
i am running rspec to test standalone code also use dotenv(and ActiveRecord). How do i set env to test when running rspec?
<morfin>
*when executing
ta has quit [Quit: Leaving...]
al2o3-cr has quit [Quit: WeeChat 1.9.1]
ur5us_ has joined #ruby
ur5us_ has quit [Read error: Connection reset by peer]
ur5us has quit [Read error: No route to host]
ur5us has joined #ruby
alfiemax_ has joined #ruby
tomphp has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
jphase has joined #ruby
mikecmpbll has joined #ruby
ur5us has joined #ruby
workmad3 has joined #ruby
jphase has quit [Ping timeout: 246 seconds]
ur5us has quit [Ping timeout: 240 seconds]
workmad3 has quit [Ping timeout: 246 seconds]
jphase has joined #ruby
reber has quit [Remote host closed the connection]
tomphp has quit [Ping timeout: 246 seconds]
jaruga has joined #ruby
jaruga has quit [Remote host closed the connection]
jaruga has joined #ruby
iamarun has quit [Quit: Leaving]
tomphp has joined #ruby
allcentury has joined #ruby
iamarun has joined #ruby
jphase has quit [Ping timeout: 255 seconds]
allcentury has quit [Ping timeout: 248 seconds]
alfiemax_ has quit [Remote host closed the connection]
alfiemax has joined #ruby
jphase has joined #ruby
houhoulis has quit [Remote host closed the connection]
doublemalt_ has joined #ruby
ta has joined #ruby
doublemalt_ has quit [Max SendQ exceeded]
doublemalt_ has joined #ruby
alex`` has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
yottanami has joined #ruby
<yottanami>
Hey all
aufi has quit [Ping timeout: 264 seconds]
<yottanami>
Whatis the different between def class_name.method_name and def method_name in Ruby?
mim1k has joined #ruby
<tobiasvl>
yottanami: one defines a class method and the other an instance method
reber has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jphase has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
<apeiros>
and to be more generic, `def obj.method_name` defines a method for obj itself, while `def meth_name` defines one for the instances of a class/module
<apeiros>
class methods being the most prominent use case
<morfin>
how i should specify APP_ENV to connect to test database instead of connecting to development one?
<apeiros>
morfin: wrong channel? or just lack of context?
<morfin>
i have config/boot.rb which perform connect to database, also it loads dotenv, my rspec require it but default env is development. should i specify env in rspec_helper.rb then(before requiring boot.rb)?
CrazyEddy has quit [Ping timeout: 248 seconds]
<apeiros>
a little bird tells me you might be using rails?
<morfin>
nope
jphase has joined #ruby
<apeiros>
then you're definitively omitting relevant context. lots.
jenrzzz has quit [Ping timeout: 260 seconds]
yCrazyEdd has joined #ruby
Freshnuts has quit [Quit: Leaving]
helpa-bot has joined #ruby
csk157 has joined #ruby
jphase has quit [Ping timeout: 240 seconds]
houhoulis has joined #ruby
helpa has quit [Remote host closed the connection]
<morfin>
this part of application is standalone. I have config/boot.rb which 1. Load bundle. 2. Require some classes(like 'mysql2', 'activerecord'). 3. Load config from database.yml(using code similar to one in Rails). 4. ActiveRecord::Base.establish_connection DATABASE_CONFIG[env] but there is one problem: database.yml i need somehow specify environment for rspec to use test instead of development from
<morfin>
database.yml
aufi has joined #ruby
helpa-bot has quit [Remote host closed the connection]
ap4y has quit [Ping timeout: 248 seconds]
helpa has joined #ruby
zautomata has quit [Ping timeout: 260 seconds]
<morfin>
rspec_helper.rb require config/boot.rb to load all required classes, establish connection etc, of course i can run like this: APP_ENV=test bundle exec rspec but i don't like this idea because i assume rspec would be used only with test environment
guille-moe has joined #ruby
Klumben has quit [Ping timeout: 258 seconds]
jameser_ has joined #ruby
kenichi has quit [Ping timeout: 258 seconds]
G has quit [Ping timeout: 258 seconds]
tris has quit [Ping timeout: 258 seconds]
<apeiros>
set it in one of the rspec exclusive files if it isn't already set
<apeiros>
I wouldn't set it unconditionally, otherwise you lose the ability to override
jameser has quit [Ping timeout: 248 seconds]
csk157 has quit [Ping timeout: 246 seconds]
G has joined #ruby
houhoulis has quit [Ping timeout: 240 seconds]
jphase has joined #ruby
cdg has joined #ruby
kenichi has joined #ruby
hs366 has joined #ruby
cdg has quit [Ping timeout: 246 seconds]
tris has joined #ruby
Serpent7776 has joined #ruby
nephelo has quit [Quit: nephelo]
jphase has quit [Ping timeout: 240 seconds]
bruno- has joined #ruby
p0p0pr37_ has joined #ruby
p0p0pr37_ has quit [Changing host]
p0p0pr37_ has joined #ruby
bruno- is now known as Guest49008
Beams has joined #ruby
p0p0pr37 has quit [Ping timeout: 248 seconds]
rabajaj has quit [Remote host closed the connection]
fullstack has quit [Ping timeout: 264 seconds]
p0p0pr37_ is now known as p0p0pr37
rabajaj has joined #ruby
tris has quit [Ping timeout: 240 seconds]
yCrazyEdd has quit [Ping timeout: 240 seconds]
jphase has joined #ruby
fullstack has joined #ruby
aclark has quit [Ping timeout: 248 seconds]
aclark has joined #ruby
kyle__ has quit [Ping timeout: 248 seconds]
kyle__ has joined #ruby
rahul_bajaj has joined #ruby
tris has joined #ruby
bruno-_ has joined #ruby
russt has quit [Ping timeout: 248 seconds]
morfin60 has joined #ruby
CrazyEddy has joined #ruby
mahlon_ has joined #ruby
helpa has quit [Read error: Connection reset by peer]
baweaver has quit [Ping timeout: 248 seconds]
helpa has joined #ruby
nikivi has quit [Ping timeout: 240 seconds]
creeg has quit [Ping timeout: 248 seconds]
SpComb^ has joined #ruby
sirecote_ has joined #ruby
Junaos has quit [Ping timeout: 248 seconds]
audy has quit [Ping timeout: 248 seconds]
TheRealMattM has quit [Ping timeout: 248 seconds]
arthurnn has quit [Ping timeout: 248 seconds]
aclark has quit [Client Quit]
morfin has quit [Read error: Connection reset by peer]
biox has quit [Read error: Connection reset by peer]
TheRealMattM has joined #ruby
cgfbee has quit [Excess Flood]
Guest49008 has quit [Ping timeout: 248 seconds]
Cyrus has quit [Ping timeout: 248 seconds]
connor_goodwolf has quit [Ping timeout: 248 seconds]
mahlon has quit [Ping timeout: 248 seconds]
SpComb has quit [Ping timeout: 248 seconds]
sirecote has quit [Ping timeout: 248 seconds]
gnarf- has quit [Ping timeout: 248 seconds]
connor_goodwolf has joined #ruby
rabajaj has quit [Ping timeout: 248 seconds]
aupadhye has quit [Ping timeout: 248 seconds]
leonthemisfit has quit [Ping timeout: 248 seconds]
Cyrus has joined #ruby
sirecote_ is now known as sirecote
jphase has quit [Ping timeout: 260 seconds]
aupadhye has joined #ruby
nikivi has joined #ruby
biox has joined #ruby
gnarf has joined #ruby
baweaver has joined #ruby
Cyrus is now known as Guest74140
creeg has joined #ruby
Junaos has joined #ruby
nikkyjr has joined #ruby
leonthemisfit has joined #ruby
leonthemisfit has quit [Changing host]
leonthemisfit has joined #ruby
arthurnn has joined #ruby
aclark has joined #ruby
baweaver is now known as Guest74876
cgfbee has joined #ruby
lxsameer has joined #ruby
hfp_work has quit [Quit: bye]
halt has quit [Ping timeout: 260 seconds]
Exagone313 has quit [Ping timeout: 260 seconds]
mgorbach has quit [Ping timeout: 260 seconds]
redondos has quit [Ping timeout: 260 seconds]
bokayio has quit [Ping timeout: 240 seconds]
bauruine has quit [Ping timeout: 260 seconds]
axsuul has quit [Ping timeout: 260 seconds]
gf3 has quit [Ping timeout: 260 seconds]
WebDawg has quit [Ping timeout: 260 seconds]
mkaito has quit [Ping timeout: 260 seconds]
infernix has quit [Ping timeout: 240 seconds]
johnny56 has quit [Ping timeout: 264 seconds]
mgorbach has joined #ruby
bokayio has joined #ruby
russt has joined #ruby
gf3 has joined #ruby
axsuul has joined #ruby
jphase has joined #ruby
halt has joined #ruby
mkaito has joined #ruby
WebDawg has joined #ruby
mim1k has quit [Disconnected by services]
mim1k_ has joined #ruby
hfp_work has joined #ruby
Exagone313 has joined #ruby
tris has quit [Ping timeout: 264 seconds]
jottr has joined #ruby
justinmcp has quit [Read error: Connection reset by peer]
bauruine has joined #ruby
iamarun has quit [Quit: Leaving]
ahuman_ has quit [Read error: Connection reset by peer]
dcluna has quit [Ping timeout: 248 seconds]
hurricanehrndz has quit [Ping timeout: 248 seconds]
audy- has joined #ruby
tris has joined #ruby
justinmcp has joined #ruby
ski4x7 has joined #ruby
ahuman has joined #ruby
ski7777 has quit [Ping timeout: 248 seconds]
ur5us has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 240 seconds]
dcluna has joined #ruby
ski4x7 has quit [Client Quit]
jottr has joined #ruby
alfiemax has joined #ruby
ski7777 has joined #ruby
mim1k_ has quit [Ping timeout: 248 seconds]
hurricanehrndz has joined #ruby
mim1k has joined #ruby
CrazyEddy has quit [Ping timeout: 258 seconds]
tris has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
Klumben has joined #ruby
CrazyEddy has joined #ruby
tris has joined #ruby
jphase has quit [Ping timeout: 252 seconds]
infernix has joined #ruby
cadillac_ has quit [Ping timeout: 240 seconds]
tcopeland has quit [Quit: tcopeland]
jameser_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Azure has joined #ruby
cadillac_ has joined #ruby
harfangk has quit [Ping timeout: 248 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
ur5us has quit [Remote host closed the connection]
johnny56 has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
alfiemax has quit [Read error: Connection reset by peer]
alfiemax_ has joined #ruby
doublemalt_ has quit [Remote host closed the connection]
aufi has quit [Ping timeout: 248 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
DoubleMalt has joined #ruby
csk157 has joined #ruby
jphase has joined #ruby
morfin60 is now known as morfin
jphase has quit [Ping timeout: 248 seconds]
csk157 has quit [Ping timeout: 240 seconds]
nikkyjr has quit [Ping timeout: 248 seconds]
nikkyjr has joined #ruby
mim1k has quit [Ping timeout: 260 seconds]
jphase has joined #ruby
mim1k has joined #ruby
aufi has joined #ruby
jphase has quit [Ping timeout: 260 seconds]
alfiemax_ has quit [Ping timeout: 260 seconds]
Puffball has quit [Remote host closed the connection]
tomphp has quit [Read error: Connection reset by peer]
<apeiros>
2 tabs? :D
<tobiasvl>
eh
<tobiasvl>
2 spaces
<tobiasvl>
lol
* apeiros
sticks to using 3 tabs for indent
<apeiros>
actually
* apeiros
sticks to using 1 tab + 1 space for indent, and tabs for alignment
<tobiasvl>
sounds awesome
michael1 has joined #ruby
jphase has joined #ruby
workmad3 has quit [Ping timeout: 240 seconds]
<apeiros>
yeah, it's proven to increase engagement by users a lot! also the emotional level skyrocks!
bruno-_ has quit [Ping timeout: 260 seconds]
<apeiros>
the effects are truly amazing :D
iamarun has joined #ruby
DaniG2k has joined #ruby
workmad3 has joined #ruby
RougeRR has joined #ruby
jphase has quit [Ping timeout: 240 seconds]
raynold has quit [Quit: Connection closed for inactivity]
jphase has joined #ruby
cabotto has joined #ruby
ldnunes has joined #ruby
jphase has quit [Ping timeout: 240 seconds]
sionronin has quit [Quit: Ex-Chat]
DaniG2k has quit [Quit: leaving]
jphase has joined #ruby
tcopeland has joined #ruby
<morfin>
i use 2 spaces for indent )
tomphp_ has quit [Read error: Connection reset by peer]
<morfin>
hmmm
<morfin>
i am not sure how would i rip off ActiveRecord migrations to standalone app
tomphp has joined #ruby
mfaeh has joined #ruby
ski7777 has quit [Ping timeout: 248 seconds]
apparition has joined #ruby
ski7777 has joined #ruby
jphase has quit [Ping timeout: 240 seconds]
rahul_bajaj has quit [Remote host closed the connection]
ski7777 has quit [Remote host closed the connection]
ski7777 has joined #ruby
harrison has joined #ruby
jottr has quit [Ping timeout: 252 seconds]
VladGh has quit [Remote host closed the connection]
charliesome has joined #ruby
VladGh has joined #ruby
iamarun has quit [Remote host closed the connection]
jottr has joined #ruby
mark_66 has joined #ruby
jphase has joined #ruby
Quentinius has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Quentinius has quit [Client Quit]
tomphp has quit [Read error: Connection reset by peer]
tomphp has joined #ruby
jphase has quit [Ping timeout: 246 seconds]
evie_hammond has quit [Ping timeout: 248 seconds]
synthroid has joined #ruby
Technodrome has joined #ruby
mensvaga has quit [Remote host closed the connection]
jphase has joined #ruby
<elomatreb>
apeiros: Use different width unicode spaces for the different levels of indentation
<dminuoso>
Oo
mensvaga has joined #ruby
anisha has quit [Quit: This computer has gone to sleep]
jphase has quit [Ping timeout: 248 seconds]
mark_66 has quit [Remote host closed the connection]
cadillac_ has quit [Ping timeout: 248 seconds]
vondruch has quit [Quit: vondruch]
cadillac_ has joined #ruby
mfaeh has quit []
jphase has joined #ruby
vondruch has joined #ruby
Burgestrand has quit [Quit: Closing time!]
jphase_ has joined #ruby
jphase__ has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
jphase has quit [Ping timeout: 252 seconds]
jphase_ has quit [Ping timeout: 252 seconds]
michael1 has quit [Ping timeout: 260 seconds]
conta has quit [Remote host closed the connection]
conta has joined #ruby
<yottanami>
Is any way to do sum two numbers without removing zeroes before each number? for example 002 + 1 = 003
jphase__ has quit [Ping timeout: 258 seconds]
b0zz0 has joined #ruby
b0zz0 has quit [Client Quit]
evie_hammond has joined #ruby
jrafanie has joined #ruby
<apeiros>
elomatreb: ooooh! great idea!
<apeiros>
elomatreb: though that requires non-monospaced fonts to take effect
<elomatreb>
I can't think of any, can you maybe do normal addition, and then pad the number with 0s again when you want to use it? (e.g. "%02d" would pad an integer with 0s to length 2)
<elomatreb>
yottanami: ^
b0zz0_ has joined #ruby
<apeiros>
yottanami: it's important to realize that the leading zeroes never are part of the number to begin with (or infinite number of leading zeroes are always part of it - depending on how you want to view it)
<apeiros>
in other words: leading zeroes in numbers are *representation*
<elomatreb>
I think php does something like that if you try to increment (++) a string of the form, btw
<apeiros>
also note: literals in ruby with a leading zero are octals :)
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csk157 has quit [Ping timeout: 248 seconds]
jphase has joined #ruby
mim1k has quit [Ping timeout: 246 seconds]
argoneus has joined #ruby
<argoneus>
helo
<argoneus>
hello*
zautomata has quit [Client Quit]
mim1k has joined #ruby
<argoneus>
I have a 'case' operator with about 15 "whens" doing a regex check on a string, basically I'm looking for substrings in the given string, and if there's a match, I want it to give a prepared response
<argoneus>
thing is, rubocop complains about too high cyclomatic complexity
zautomata has joined #ruby
<argoneus>
what's the ruby way to do this?
<elomatreb>
If there's no nice higher-level solution to your problem I
<elomatreb>
*I'd say disable that lint
<argoneus>
ex.: case string\when /keyword/i then 'response'
<argoneus>
it's part of a homework so I don't think I can just turn it off
<argoneus>
but at the same time I can't think of a better solution
<elomatreb>
Technically you can turn it off with a comment (`# rubocop:disable Lint/Whatever`, disables it for that and lower scopes)
brw has quit [Read error: Connection reset by peer]
<elomatreb>
Or did you receive instructions not to do that?
jphase has quit [Ping timeout: 252 seconds]
<argoneus>
yeah, rubocop shouldn't be touched afaik
brw has joined #ruby
cabotto has joined #ruby
<elomatreb>
Can you extract the matching into a single regex? I.e. have it match and return the keyword in a matching group?
<mtkd>
could put the case args in to an array and use each with a block
<elomatreb>
Because if you do that you could just use the match data to lookup the message in a Hash
<argoneus>
the keywords are wildly different
<argoneus>
I need to do a separate lookup for each
<apeiros>
isn't it great when externalities require a worse solution?
<elomatreb>
That would probably work, but have a word with your instructor/etc about this. These lints are very subjective, and they are designed to be turned off when they're more harm than good
<apeiros>
+1
<argoneus>
I'll send an email then, because I can't think of a cleaner solution than this
<elomatreb>
In this case, you're being forced to increase your codes complexity because of a complexity lint. See the problem?
mim1k has quit [Ping timeout: 240 seconds]
vondruch has quit [Quit: vondruch]
tsglove2 has quit [Quit: Leaving]
<apeiros>
IMO either the problem can be restructured and be solved in smaller decision trees through the restructuring, or then case/when with 15 when's is better than the array solution
mim1k has joined #ruby
<Papierkorb>
Or the instructor is looking for an entirely different solution
cdg has joined #ruby
yottanami_ has joined #ruby
yottanami has quit [Ping timeout: 255 seconds]
vondruch has joined #ruby
kobain has joined #ruby
cdg has quit [Remote host closed the connection]
cdg has joined #ruby
Psybur has joined #ruby
michael1 has quit [Ping timeout: 240 seconds]
alnewkirk has joined #ruby
cabotto has quit [Remote host closed the connection]
tomphp has quit [Read error: Connection reset by peer]
chouhoulis has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
mikecmpbll has quit [Read error: Connection reset by peer]
tomphp has joined #ruby
PaulCapestany has quit [Read error: Connection reset by peer]
mim1k has quit [Ping timeout: 248 seconds]
dinfuehr has joined #ruby
mikecmpbll has joined #ruby
jphase has joined #ruby
chouhoulis has quit [Remote host closed the connection]
PaulCape_ has joined #ruby
chouhoulis has joined #ruby
sepp2k has joined #ruby
mson has joined #ruby
tomphp has quit [Read error: Connection reset by peer]
Burgestrand has joined #ruby
tomphp has joined #ruby
yottanami__ has joined #ruby
yottanami_ has quit [Ping timeout: 248 seconds]
vtx has joined #ruby
apeiros has quit [Remote host closed the connection]
alfiemax has joined #ruby
allcentury has joined #ruby
GodFather has joined #ruby
raul782 has joined #ruby
apeiros has joined #ruby
raul782 has quit [Remote host closed the connection]
raul782 has joined #ruby
jenrzzz has joined #ruby
alfiemax_ has joined #ruby
DLSteve has joined #ruby
aupadhye has quit [Ping timeout: 248 seconds]
mim1k has joined #ruby
nowhere_man has quit [Read error: Connection reset by peer]
alfiemax has quit [Ping timeout: 240 seconds]
csk157 has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
DTZUZO has joined #ruby
ldnunes has quit [Read error: Connection reset by peer]
ldnunes has joined #ruby
jrafanie has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
csk157 has quit [Ping timeout: 248 seconds]
dinfuehr has joined #ruby
scorphus has joined #ruby
nowhere_man has joined #ruby
danielgl_ has joined #ruby
tomphp has quit [Read error: Connection reset by peer]
tomphp has joined #ruby
biberu has joined #ruby
nowhere_man has quit [Read error: Connection reset by peer]
nowhere_man has joined #ruby
xuanrui has joined #ruby
tsglove has joined #ruby
yottanami_ has joined #ruby
ams__ has joined #ruby
bruno- has quit [Ping timeout: 264 seconds]
yottanami__ has quit [Ping timeout: 240 seconds]
bruno- has joined #ruby
KtC00 has joined #ruby
KtC00 has quit [Quit: leaving]
iMadper`` has joined #ruby
iMadper` has quit [Read error: Connection reset by peer]
mim1k has quit [Ping timeout: 248 seconds]
mim1k has joined #ruby
mgorbach has quit [Ping timeout: 248 seconds]
mgorbach has joined #ruby
xuanrui has quit [Quit: Leaving]
harrison has joined #ruby
mim1k has quit [Ping timeout: 240 seconds]
uZiel has joined #ruby
uZiel has quit [Read error: Connection reset by peer]
jxv has joined #ruby
tomphp has quit [Read error: Connection reset by peer]
polishdub has joined #ruby
cabotto has joined #ruby
tomphp has joined #ruby
John___ has joined #ruby
anisha has joined #ruby
uZiel has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Axy has joined #ruby
Technodrome has joined #ruby
snickers has quit [Ping timeout: 240 seconds]
djbjd has joined #ruby
raul782 has quit []
Mia has quit [Ping timeout: 246 seconds]
vee__ has quit [Ping timeout: 255 seconds]
tomphp has quit [Read error: Connection reset by peer]
brendan- has joined #ruby
tomphp has joined #ruby
ta has quit [Read error: Connection reset by peer]
ta has joined #ruby
techn1cs has joined #ruby
apparition has quit [Quit: Bye]
jxv has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
minimalism has joined #ruby
vtx_ has joined #ruby
vtx_ has quit [Client Quit]
dionysus69 has quit [Ping timeout: 246 seconds]
chouhoulis has quit [Remote host closed the connection]
danielgl_ has quit [Quit: Bye folks. ZZZzzz...]
jxv has joined #ruby
vtx has quit [Ping timeout: 260 seconds]
Rapture has joined #ruby
houhoulis has joined #ruby
Rapture has quit [Read error: Connection reset by peer]
harrison has quit [Quit: Leaving]
vee__ has joined #ruby
connor_goodwolf has quit [Quit: leaving]
connor_goodwolf has joined #ruby
hutch34 has quit [Quit: WeeChat 1.5]
jaegerca has quit [Ping timeout: 240 seconds]
mim1k has joined #ruby
iMadper`` has quit [Remote host closed the connection]
iMadper`` has joined #ruby
Burgestrand has quit [Read error: Connection reset by peer]
pskosinski_ has joined #ruby
pskosinski has quit [Read error: Connection reset by peer]
Burgestrand has joined #ruby
Xeago_ has joined #ruby
Xeago has quit [Read error: Connection reset by peer]
Xeago_ is now known as Xeago
chmurifree has quit [Ping timeout: 252 seconds]
Gadgetoid has quit [Ping timeout: 252 seconds]
qsx has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
rgs has quit [Ping timeout: 252 seconds]
duracrisis has quit [Excess Flood]
rgs has joined #ruby
jottr has quit [Ping timeout: 260 seconds]
Gadgetoid has joined #ruby
duracrisis has joined #ruby
qsx has joined #ruby
alfiemax_ has quit [Ping timeout: 260 seconds]
jxv has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<scatterp>
hi i am using ruby 2.2.1 (and i am unable to update at this time) I am trying to download a page over https and each method i try the system freezes up
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chmurifree has joined #ruby
<elomatreb>
alfiemax: Maybe this helps: https://eval.in/890261 - You're assigning the same array object to all keys. To get a Hash that behaves like you expect use the block form, `h = Hash.new { [] }`
<apeiros>
elomatreb: I don't think that works as intended
cagomez has joined #ruby
<matthewd>
scatterp: "freezes"? "the system"?
<apeiros>
remember, the block doesn't perform any mutation on the hash on its own
<apeiros>
it's just a return value.
<elomatreb>
Yeah you're right, nevermind. You need the self-accessing form
<scatterp>
matthewd ctrl c works
<apeiros>
most likely `h = Hash.new { |h,k| h[k] = [] }` is desired
<elomatreb>
Right, I always make that mistake. Hash constructor is confusing as hell
<apeiros>
I think it's not, if you remember to think of it as a default value
<matthewd>
That actually seems like a useful core extension -- a new class method that does the assignment automatically
<apeiros>
(well, certainly confusing the first time you come across it, but IMO it makes sense the moment you think about it)
<elomatreb>
apeiros: It's confusing since it does work with integers, and that specific behavior is often shown in tutorials
<apeiros>
elomatreb: it "works" with immutables in general. for the very reason that you can't mutate them ;-)
synthroid has quit [Remote host closed the connection]
kculpis has joined #ruby
<elomatreb>
Yeah - but that requires that one understands the principle of immutables. I don't like this behavior, I'd very much enjoy a Hash constructor that Does What I Mean without me having to google for that self-accessing block
<apeiros>
they definitively should add a warning to the docs
* apeiros
just reread them
Burgestrand has quit [Quit: Closing time!]
<apeiros>
elomatreb: that's not possible, though. what you mean is very subjective.
<apeiros>
and it does a good job of doing what you tell it to do.
<matthewd>
scatterp: Is this a VM/container of some sort? Does it have network access?
<apeiros>
and blockless with mutables is difficult/impossible since there's no clear way to duplicate the object
<elomatreb>
I don
<elomatreb>
*I don't need blockless, that that wouldn't work is OK with me. But I'd like a block one where I don't have to do the assignment like that myself
<matthewd>
apeiros: I agree it's not desirable to change .new -- but I think `def Hash.foo; new {|h,k| h[k] = yield k }; end` would be a frequently-useful shortcut
bruno- has quit [Ping timeout: 248 seconds]
<elomatreb>
^ Just like that
<apeiros>
with the advent of named args, they could be more explicit and have specific arguments to new for "only return this value" and "return and assign this value"
<apeiros>
e.g. h = Hash.new default_and_assign: -> { [] }; h[:x]; h # => {x => []}
<apeiros>
(better naming welcome of course)
cats is now known as creepycats
<matthewd>
That seems a long way to go just to keep 'new' ¯\_(ツ)_/¯
<apeiros>
vs. h = Hash.new default_no_assign: -> { [] }; h[:x]; h # => {}
<apeiros>
as said, better naming welcome. or as you said, have a convenience constructor.
<elomatreb>
This feels like something activesupport would have hidden somewhere
<matthewd>
Even better: def Hash.foo(v = nil); new {|h,k| h[k] = block_given? ? yield(k) : v.dup }; end
<apeiros>
why dup and not clone?
<matthewd>
[11-01 01:32:04] <matthewd>scatterp: Is this a VM/container of some sort? Does it have network access?
uZiel has joined #ruby
vipaca has joined #ruby
<matthewd>
Mostly just because I default to dup, and didn't really think about it
<scatterp>
matthewd no standard ubuntu 16.04 remove the s in https and it works
<matthewd>
One could argue that it should be a deep clone, too, for that matter.. I'm only really anticipating the trivial {} and [] cases
<matthewd>
scatterp: Can you wget/curl that URL from that machine?
CrazyEddy has quit [Ping timeout: 240 seconds]
<matthewd>
scatterp: It's not a virtual machine? It's a physical computer named "vmi146463" with a "deploy" user?
rippa has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Ping timeout: 240 seconds]
<scatterp>
matthewd ah sorry its a vps from contabo.com
impermanence has joined #ruby
zcreative_ has joined #ruby
CrazyEddy has joined #ruby
ta has quit [Remote host closed the connection]
<scatterp>
what the hell its resolving a ipv6 address :/
<impermanence>
I'm solving a coding challenge and in it there are some strings that I know will not change. What is the best Ruby practice on storing these?
<apeiros>
impermanence: assign to a constant is a common good practice
ta has joined #ruby
<impermanence>
I have also seen the method freeze used...(?)
Immune has joined #ruby
<elomatreb>
And either explicitely freeze those by calling .freeze on them, or use the magic comment that auto-freezes all string literals
<impermanence>
magic comment?
<elomatreb>
If you just assign them to constants you can still mutate (e.g. append) them
impermanence has quit [Remote host closed the connection]
<matthewd>
Sounds like you have a network configuration/firewall issue, then
<elomatreb>
Can't you tell your wget to just use IPv4 only? (wget -4)
djbjd has quit [Quit: djbjd]
<matthewd>
If it's resolving and trying to use IPv6, that implies it thinks it will work
ta has quit [Ping timeout: 248 seconds]
<elomatreb>
It means your DNS server supports v6 records, if you can actually send traffic depends on the ISP
marr has joined #ruby
<elomatreb>
(E.g. I can't)
RougeRRR has joined #ruby
sepp2k has quit [Read error: Connection reset by peer]
ElDoggo has joined #ruby
<matthewd>
elomatreb: Your local system shouldn't try to *use* them if it doesn't believe it has a routable IPv6 address, though
RougeRR has quit [Read error: Connection reset by peer]
<elomatreb>
True.
seitensei has quit [Ping timeout: 248 seconds]
sepp2k has joined #ruby
ElDoggo_ has joined #ruby
seitensei has joined #ruby
ElDoggo has quit [Ping timeout: 260 seconds]
zcreative_ has quit [Quit: (null)]
hs366 has quit [Quit: Leaving]
<scatterp>
matthewd thanks all fixed
reber has quit [Quit: Leaving]
reber has joined #ruby
mikecmpb_ has joined #ruby
mikecmpbll has quit [Ping timeout: 248 seconds]
impermanence has joined #ruby
impermanence has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
tomphp has joined #ruby
tsglove2 has joined #ruby
John___ has quit [Ping timeout: 246 seconds]
jxv has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 246 seconds]
tsglove has quit [Ping timeout: 264 seconds]
guille-moe has quit [Quit: guille-moe]
shinnya has quit [Ping timeout: 240 seconds]
allcentury has quit [Ping timeout: 248 seconds]
tsglove3 has joined #ruby
tsglove2 has quit [Ping timeout: 240 seconds]
notemerson has quit [Quit: WeeChat 1.9.1]
cabotto has quit [Remote host closed the connection]
charliesome has joined #ruby
michael1 has quit [Ping timeout: 264 seconds]
tsglove2 has joined #ruby
DTZUZO has joined #ruby
_aeris_ has quit [Write error: Connection reset by peer]
tsglove3 has quit [Ping timeout: 258 seconds]
_aeris_ has joined #ruby
tsglove3 has joined #ruby
emerson has joined #ruby
yottanami_ has quit [Ping timeout: 264 seconds]
tsglove2 has quit [Ping timeout: 240 seconds]
tsglove2 has joined #ruby
emerson is now known as heartbleed
cabotto has joined #ruby
impi0us has joined #ruby
impi0us has left #ruby [#ruby]
tsglove3 has quit [Ping timeout: 240 seconds]
cabotto has quit [Ping timeout: 255 seconds]
swills has quit [Read error: Connection reset by peer]
swills has joined #ruby
swills has joined #ruby
swills_ has joined #ruby
hahuang65 has quit [Ping timeout: 260 seconds]
mikecmpb_ has quit [Read error: Connection reset by peer]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has joined #ruby
[Butch] has joined #ruby
swills has quit [Client Quit]
apeiros has quit [Remote host closed the connection]
tomphp has quit [Read error: Connection reset by peer]
tsglove3 has joined #ruby
synthroid has joined #ruby
tomphp has joined #ruby
conta has quit [Quit: conta]
conta has joined #ruby
Danny1 has joined #ruby
tsglove2 has quit [Ping timeout: 248 seconds]
tsglove2 has joined #ruby
KeyJoo has quit [Remote host closed the connection]
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
swills_ is now known as swills
swills has quit [Changing host]
swills has joined #ruby
conta has quit [Ping timeout: 248 seconds]
Technodrome has joined #ruby
Danny1 has quit [Remote host closed the connection]
cagomez has quit [Read error: Connection reset by peer]
darkmorph has quit [Ping timeout: 246 seconds]
cagomez has joined #ruby
Danny1 has joined #ruby
tsglove3 has quit [Ping timeout: 255 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
vtx has joined #ruby
mikecmpbll has joined #ruby
Danny1 has quit [Ping timeout: 260 seconds]
vee__ has quit [Ping timeout: 240 seconds]
<vtx>
hi guys i have just started work on a sinatra application with a few endpoints. now that i have behaviour defined for some of the endpoints, i want to write some spec tests. is there an easy way to introduce rspec to my project? i used `bundle gem <my gem>` to create the intial boilerplate, and i’m curious if a similar solution exists for rspec testing?
yottanami_ has joined #ruby
cagomez has quit [Remote host closed the connection]
tsglove2 has quit [Read error: Connection reset by peer]
<toomer>
Maybe in 2049
<eam>
most folks using RHEL in production roll their own ruby and ship it with their application
<havenwood>
toomer: Live in the now.
tsglove2 has joined #ruby
<eam>
you generally don't want to use the distro supplied runtimes as they won't ever be exactly what you want
<matthewd>
If you're only using ruby for puppet, though, and your puppet is itself presumably ancient...
<toomer>
I wish
<chrisarcand>
eam: Yeah; The project I work on currently uses SCL and we're considering that, because the backporting of things in SCL is...complicated.
tsglove3 has quit [Ping timeout: 240 seconds]
<Papierkorb>
It's just ironic how those ancient programs, which don't receive any updates, make you less secure
<eam>
chrisarcand: I say that as someone who's been running RHEL for over a decade at some of your largest customers
<eam>
:)
<chrisarcand>
The point of SCL is to fix what eam is describing though. To have more up-to-date things like Ruby, etc, which get CVEs backported and auto updated on customers' machines.
<toomer>
Guys, where do you live ??
<chrisarcand>
eam: ^_^ Yup for sure
<eam>
toomer: earth!
<Papierkorb>
In a industry that's constantly targeted by adversaries toomer
<toomer>
It took us 3 years to convince Managment to move from RHEL6 to RHEL7
<Papierkorb>
So, basically, all of IT
<toomer>
We are still in Java 7
<Papierkorb>
.. How's Java7 that bad?
<toomer>
Nobody want to spend maney on platform since it's 'Working'
charliesome has quit [Ping timeout: 248 seconds]
<toomer>
They prefer to spend money on something else
<eam>
often it's not budget so much as time and effort
<toomer>
Yes, exactly
<mnemon>
eam: time and effort are expensive
<toomer>
What is the diffrence for customer if you move from ruby 1.8 to 2.0 or RHEL6 to RHEL7
<toomer>
When all your applications that you deliver to customer is Java based
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Danny1 has quit [Remote host closed the connection]
Danny1 has joined #ruby
<toomer>
Upgrading live environments can be difficult :(
<toomer>
For example there is no in place upgrade that WORKS in RHEL
<matthewd>
IME upgrades get exponentially more painful the longer you leave them
<eam>
nor should there be - giving people in-place process instead of tear-it-down-and-rebuild allows them to calcify, operationally
<eam>
matthewd++
<eam>
this is probably the #1 "feature" of all this cloud garbage
<eam>
forcing people to deal with ephemeral systems
<toomer>
matthewd: Of course you are right
<matthewd>
eam: Ephemeral systems built out of docker containers that you can build once and never touch again... :|
<eam>
too real
<toomer>
eam: Yes, cloud garbage is much better in that perspective, you don't upgrade you just roll out new one instance
<toomer>
Untill you need to upgrade Cloud itself :)
<eam>
I threatened (and still might) rpm -e rpm new machines so they cannot be incrementally upgraded
cabotto has quit []
<eam>
then people say "but we don't know how to rebuild it" and the fun conversation starts about how you're going to be forced to do that in certain scenarios, so we might as well fix the real issue now
<mnemon>
how do you apply simple bug fixes?
<eam>
rebuild the host
<Papierkorb>
..or just the container
<eam>
yeah, or the container
<eam>
imaging a host from bare metal takes <20 minutes and spinning up a container takes <30s if done right
<eam>
there is no reason not to rebuild from scratch always, have your CI and build systems producing images
banisterfiend has joined #ruby
<eam>
there's some mess around persistent data, but that's solvable with process
<eam>
and it's a good idea to rebuild your databases periodically too, test your backups, etc
eckhardt has joined #ruby
<toomer>
Yes, this is much easier then patching and upgrading the host
<toomer>
roll out the new one :)
cagomez has quit [Remote host closed the connection]
guacamole has joined #ruby
<Papierkorb>
...backed by a one-click script using Ansible or whatever
cagomez has joined #ruby
banisterfiend has quit [Changing host]
banisterfiend has joined #ruby
hahuang65 has joined #ruby
cagomez_ has joined #ruby
ycyclist has joined #ruby
<eam>
if you ever find yourself saying "we can't rebuild that" then you absolutely must practice rebuilding it
chmurifree has joined #ruby
<mnemon>
making the rebuild automatic tends to be hard, and doing it partially manually can be time consuming(vs. incremental upgrades).
cagomez has quit [Ping timeout: 248 seconds]
<Papierkorb>
mnemon: The point is that you know what your host is actually hosting
<mnemon>
of course depends on the complexity of the system.
<mnemon>
Papierkorb: for the rebuild?
<Papierkorb>
Yes. Using Ansible or whatever you like
<Papierkorb>
And a bash script before that installs ansible and then kicks that off.
cagomez_ has quit [Ping timeout: 248 seconds]
conta has joined #ruby
tomphp has joined #ruby
<mnemon>
Papierkorb: ime, works great with relatively simple and/or stateless systems but can be pretty complex to automate nice rebuilds/upgrade of systems with more persistent data
imode has joined #ruby
<toomer>
matthewd: Thanks, your changed worked
<toomer>
Thanks to you we can stay for next decade on ruby 1.8
<toomer>
:)
<mnemon>
data or state ...
<eam>
mnemon: I find the "database" problem tends to morph into understanding whether you're prepared for device failure
mn3m has quit [Quit: mn3m]
<Papierkorb>
mnemon: we used that to start kubernetes clusters, which then spun up more complex software. At that point, it's the epheremal wild west :)
ivanskie has joined #ruby
<ivanskie>
hi all
cadillac_ has quit [Ping timeout: 240 seconds]
<ivanskie>
how's everybody doing?
Serpent7776 has quit [Quit: Leaving]
<mnemon>
eam: in some cases, I mostly work on very "HA" systems and accepting some disruptions on sudden device failure(rare) vs. working around the impact on upgrade(frequent) is different.
<ivanskie>
I have a question. I've got ruby installed on windows 10. ruby installer, and msys2 installed as well.
cadillac_ has joined #ruby
<ivanskie>
gems with executables are not getting added to path for some reason. for example i have gtm installed, but when i try to run >gtm it says command not found.
<matthewd>
ivanskie: The gem bin directory probably isn't on your path
<ivanskie>
ruby is in path, i can run >ruby -v from any command promt, cmd, powershell, cmder. same with >gem ...
<ivanskie>
k thanks
<matthewd>
`gem env` should tell you where it's putting them
<ivanskie>
weird. it has two paths for gems
<matthewd>
You're looking for the "executable directory"
<ivanskie>
ah, only shows "C:/Ruby24-x64/bin"
<ivanskie>
and that is in the path
<matthewd>
Does it contain the thing you're trying to run?
<ivanskie>
it does not
<matthewd>
Wait, what is the thing you're trying to run?
<jolamb>
the code HAS to be stable, because it's so hostile to modification
<elomatreb>
$globals
<elomatreb>
ABORT
orbyt_ has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
<Papierkorb>
I'm constantly thinking "if X was the only problem this file has", just to think next that this class has all the problems
jamesaxl has joined #ruby
conta5 has joined #ruby
darkmorph has joined #ruby
<jolamb>
I really have to pick my battles when I work on this stuff, thus why I only asked about that one particular pattern just now
vtx has quit [Quit: vtx]
<Papierkorb>
jolamb: I'd try to write tests for a single bad-method, then refactor that method into multiple smaller ones. allows you to chunk-wise improve the logic, while you can still get stuff done. Each time with a better peace of mind.
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
<Papierkorb>
Once it's bearable, maybe try splitting that thing into multiple classes - Even at the price of having those classes have funny interdependencies. That'd be the next target then. And if you get to this point, It may be overall acceptable
troys has joined #ruby
conta5 has quit [Ping timeout: 248 seconds]
cdg has quit [Remote host closed the connection]
<jolamb>
Papierkorb: yeah, that's the goal. I've started trying to add unit tests, so at least I can verify changes
<jolamb>
but there's a lot to test there...
<Papierkorb>
no small feat for sure :)
<dalitom>
noob question, but I have to ask .....if I do my_var = myfunction(data), next time I call my_var is it going to execute myfunction again ?
<eam>
dalitom: no
<eam>
the object returned by myfunction() is saved in my_var
Puffball has quit [Ping timeout: 240 seconds]
<dalitom>
awesome
<dalitom>
thanks
alfiemax has quit [Ping timeout: 248 seconds]
MagnusX has quit [Read error: Connection reset by peer]
dinfuehr has quit [Ping timeout: 264 seconds]
csk157 has quit [Ping timeout: 240 seconds]
FrostCandy has joined #ruby
dinfuehr has joined #ruby
<FrostCandy>
Do @class vars declared outside of a thread get passed to the thread ?
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<matthewd>
FrostCandy: That question suggests some fundamental misunderstanding. Add some context?
LocaMocha has quit [Ping timeout: 248 seconds]
<FrostCandy>
Well this guy creates a thread t = Thread.new do - uses @var - end where @var is defined outside the thread
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<FrostCandy>
So i'm wondering if @var's keep their contents after a thread is created and inside the thread
<matthewd>
Instance variables are stored on the instance they belong to, which has nothing to do with threads
<FrostCandy>
Ok better question then, how to pass an instance variables contents to a thread?
<matthewd>
A block doesn't [generally] change `self` when it's executed, so @var inside a block is [generally] going to use the ivar from the same object that it would outside
<FrostCandy>
guess i can look that up.
<FrostCandy>
right, but i figured threads would be differnet than normal blocks, like a whole new process
darkmorph has quit [Ping timeout: 252 seconds]
<banisterfiend>
yo why does: JSON.parse('{"hello":"\\u0627"}') give teh same result as JSON.parse('{"hello":"\u0627"}') ?
<banisterfiend>
JSON automatically converts strings with unicode trigrams into the associated character?
<FrostCandy>
just tested with a puts, instance variable is usesable inside the thread.
<banisterfiend>
anyone know?
<FrostCandy>
try \\\ , maybe json is making \u0.. creating the same character as the one you pass with \u0
<banisterfiend>
my feeling is that json automatically applies its own escaping when interpreting a string?
<banisterfiend>
it doesn't just deal with raw strings?
<baweaver>
iirc it does some odd things like that.
<baweaver>
There are some options on parse to make it stop it, I'd have to find them
<baweaver>
Nope, can't find an option for it. Unicode is not a strongsuite of mine :/
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<matthewd>
Sounds plausible, at least -- it's a JS subset, so \u can only mean what it does in JS
DTZUZO has quit [Ping timeout: 240 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
<matthewd>
Though not "actually change the internal value of the integer" interesting, which you can apparently do in Python
<eam>
do you want to ☃️.build
<impermanence>
matthewd: out of curiosity why do you say that having a constant named THREE is stupid? Because of how uninformative the name is?
<RickHull>
3 is already a constant symbol for the number 3
<matthewd>
^
<matthewd>
The point of "you should always use constants, not literals"-type teachings is that you should be *naming a concept*, and then giving its value once
<impermanence>
yeah, that's kind of what I thought you were implying. makes sense.
<matthewd>
RickHull: I'd guess it's using an already-loaded environment, then forking for each request -- so the same slot in the symbol table is "next" each time
jamesaxl has quit [Read error: Connection reset by peer]
sonOfRa has quit [Remote host closed the connection]
jamesaxl has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
sonOfRa has joined #ruby
alfiemax has joined #ruby
govg has quit [Ping timeout: 240 seconds]
anisha has quit [Quit: This computer has gone to sleep]
tomphp has joined #ruby
govg has joined #ruby
uZiel has quit [Ping timeout: 246 seconds]
workmad3 has joined #ruby
imode has quit [Ping timeout: 255 seconds]
tomphp has quit [Read error: Connection reset by peer]
govg has quit [Ping timeout: 260 seconds]
tomphp has joined #ruby
happyface has joined #ruby
workmad3 has quit [Ping timeout: 260 seconds]
Nexer has joined #ruby
rhyselsmore has joined #ruby
ur5us has joined #ruby
quobo is now known as uaithne
orbyt_ has joined #ruby
vipaca has joined #ruby
shinnya has joined #ruby
gigetoo has quit [Ping timeout: 248 seconds]
ur5us has quit [Ping timeout: 240 seconds]
mkroman has quit [Quit: Reconnecting]
mkroman has joined #ruby
mtkd has quit [Ping timeout: 246 seconds]
gigetoo has joined #ruby
mtkd has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has joined #ruby
<FrostCandy>
If I call Myclass.Mymethod(vars) will that automatically creates a new intance of Myclass right? or do I need to do a var = Myclass.new then var.Mymethod(vars) ?
<Papierkorb>
FrostCandy: ... No, that won't just create an instance
uaithne is now known as airgetlamh
RougeRRR has quit [Read error: Connection reset by peer]
airgetlamh is now known as quobo
RougeRRR has joined #ruby
<FrostCandy>
yikes ok this project is such a mess lol
goyox86 has joined #ruby
Technodrome has joined #ruby
<Caius>
FrostCandy: depends on the implementation of Mymethod really
<Caius>
if it calls new and assigns the vars passed in, then yes
<Caius>
otherwise, no :-)
<FrostCandy>
Caius: it's calling a method from a class inside a thread block
<FrostCandy>
ah no new call though. I'll fix it by creating a var = myclass.new then using that new instance to call the method. Safer i think
<Caius>
FrostCandy: Mymethod would have to explicitly create an instance (look for a call to #new or something inside it)
<Caius>
Myclass.Mymethod is different to inst = Myclass.new; inst.Mymethod though
orbyt_ has joined #ruby
dstrunk has joined #ruby
nowhere_man has quit [Ping timeout: 240 seconds]
swills has quit [Read error: Connection reset by peer]
dstrunk has quit [Client Quit]
ddffg has quit [Quit: Leaving]
guacamole has quit [Quit: My face has gone to sleep. ZZZzzz…]
swills has joined #ruby
swills has joined #ruby
guacamole has joined #ruby
dionysus69 has joined #ruby
troys is now known as troys_
eckhardt has joined #ruby
raul782 has joined #ruby
troys_ is now known as troys
workmad3 has joined #ruby
eckhardt has quit [Client Quit]
ycyclist has quit [Ping timeout: 260 seconds]
cdg has joined #ruby
<FrostCandy>
Caius: right thanks. Is there short hand for creating a new instance and calling a method like MyClass.new.Mymethod(vars) ? Just curious, can't ask the right question on google.
dionysus69 has quit [Ping timeout: 252 seconds]
<matthewd>
FrostCandy: You can do that, but it will give you the result of calling the method. Also mymethod has to be defined differently depending on whether you're going to call it on a class or an instance.
<matthewd>
FrostCandy: As a general observation, I would recommend against experiment-driven-development when working with threads -- they create a large gap between "works this time" and "works every time"
<FrostCandy>
Oh is this where the self.method comes in? I'll look in to that
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<FrostCandy>
ok i see
i831533 has joined #ruby
cdg has quit [Remote host closed the connection]
cdg has joined #ruby
ycyclist has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ycyclist>
Is there a specific discussion group or channel for these?
<matthewd>
ycyclist: There's #rubygems, and I think a Slack group maybe?
apeiros has joined #ruby
<matthewd>
Do you have a specific question?
John___ has joined #ruby
biberu has quit []
csk157 has joined #ruby
<ycyclist>
Sorry guys. I was trying to dig through my code.
<ycyclist>
I do have a specific question: What is typical for specifying a gem version like that? Can I say something in my Gemspec.lock file, or is it more typical to do something else?
beerich has quit []
cout has quit [Remote host closed the connection]
<RickHull>
this doesn't require a change to your project code, per se
csk157 has quit [Ping timeout: 248 seconds]
<RickHull>
if you are talking about a gem, you can lock down required_ruby_version in the gemspec
<RickHull>
the the project is more like a rails project, then you would want to make sure your production nodes are running a new rubygems
<RickHull>
sorry, required_rubygems_version in the gemspec (IIRC)
alfiemax has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 240 seconds]
<RickHull>
if you're just playing around in development, then update rubygems in your dev environment(s)
alfiemax has joined #ruby
<matthewd>
I don't think you can enforce a rubygems version in the Gemfile... though if you're specific enough with the ruby version, that could suffice
<RickHull>
note, Gemfile is for bundler, gemname.gemspec is for rubygems
synthroid has quit [Remote host closed the connection]
<matthewd>
ycyclist: I'd argue that this is outside your application's remit -- just as it's not responsible for checking the current OS doesn't have any known vulnerabilities
<RickHull>
yeah, upgrade the server, not your project code
<RickHull>
how do you keep your servers updated?
rhyselsmore has quit [Ping timeout: 248 seconds]
<RickHull>
e.g. if you have 3 servers and no automated infrastructure, then ssh in and e.g. apt update/upgrade or sudo gem update --system or whatever is appropriate
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ek926m has joined #ruby
<RickHull>
confirm with gem --version -- though ruby deploys can get complicated in terms of paths and `which gem` is being used
zapata has quit [Quit: WeeChat 1.9.1]
zapata has joined #ruby
<ycyclist>
We install our own version of ruby for our application.
sonOfRa has quit [Remote host closed the connection]
dalitom has quit [Quit: Page closed]
<ycyclist>
That way, we are not affected if the user specifies something different.
<RickHull>
what do you have now for `gem env` ? paste on a paste site
<RickHull>
you can omit or redact any sensitive info
<ycyclist>
Just a minute please.
sonOfRa has joined #ruby
sonOfRa has quit [Remote host closed the connection]
<ycyclist>
It appears we are using 2.5.2 instead of the 2.6.14 you see specified in this file. I wasn't sure if this file was our concoction, but fortunately it looks like it is not.
marr has quit [Ping timeout: 246 seconds]
Psybur has quit [Ping timeout: 246 seconds]
<ycyclist>
So it appears that merely upgrading this to be the one online may get us there, though I suspect it is the entire git source tree for it that we shall need.
jenrzzz has joined #ruby
<RickHull>
you should not have rubygems lib stuff inside your app
ek926m has quit [Quit: Leaving]
<RickHull>
that source code is on your filesystem somewhere, and it depends on what you have installed (i.e. to the filesystem)
<RickHull>
changing the string assigned to VERSION in the source code does nothing
<RickHull>
in a traditional web shop, this is in the realm of system administration, not development
<RickHull>
these days, it's devops or infrastructure
enterprisey has joined #ruby
<RickHull>
it's generally outside the realm of what your app has control over
<RickHull>
is there someone else in your org responsible for maintaining the servers?
<RickHull>
again, how does ruby/rubygems get installed to /usr/local ? who set that up?
eckhardt has joined #ruby
eckhardt has quit [Client Quit]
eckhardt has joined #ruby
alfiemax has joined #ruby
alnewkirk has quit [Ping timeout: 240 seconds]
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ams__ has quit [Quit: Connection closed for inactivity]
charliesome_ has joined #ruby
charliesome has quit [Ping timeout: 248 seconds]
conta2 has joined #ruby
jottr has quit [Ping timeout: 246 seconds]
charliesome has joined #ruby
imperator has joined #ruby
<imperator>
howdy folks
<imperator>
anyone here familiar with Addressable::Template?
jottr has joined #ruby
<imperator>
I'm trying to generate a url with an optional parameter, not sure how to do it
conta2 has quit [Ping timeout: 240 seconds]
<imperator>
basically, it looks like this: t = Addressable::Template.new("/subscriptions{/sub}/resourceGroup{/rg}")
<imperator>
but, "resourceGroup" should be dropped if :rg isn't specified
charliesome_ has quit [Ping timeout: 248 seconds]
<imperator>
is there a way to do that?
<baweaver>
You could always provide a different string to it
<imperator>
not sure i follow
guacamole has quit [Quit: My face has gone to sleep. ZZZzzz…]
<baweaver>
that path is a string
vtx has joined #ruby
<baweaver>
give it a different one if you don't get rg
<baweaver>
Otherwise find out if there's an optional segment somewhere in their docs (? looks promising)
DoubleMalt has joined #ruby
<imperator>
been fiddling with various combinations, but without success
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<imperator>
yeah, i was hoping for something nicer :)
cagomez has joined #ruby
<baweaver>
I'd have to read through the docs to find it and this thing looks like kind of a mess to delve :/
marxarelli is now known as marxarelli|afk
goyox86 has quit [Quit: goyox86]
alex`` has joined #ruby
michael1 has joined #ruby
ap4y has joined #ruby
GodFather has quit [Ping timeout: 248 seconds]
goyox86 has joined #ruby
Nexer has quit [Quit: Connection closed for inactivity]
GodFather has joined #ruby
<imperator>
well, i can't get it to stop encoding query params, so that's a problem, too
<vtx>
hi guys, in rspec, i am testing a class whose initialize sets up some database connections. when i run my tests, the initialization runs, and fails. this doesn’t cause my tests to fail, but i would like to somehow skip or avoid calling the methods that try to connect to databases, or, make my app think it has obtaind a valid db connection. what should i be doing to achieve this? my application uses `Mongo::Client.new` to connect t
<catphish>
is there any normal pattern for returning part way through a method, then resuming it later? i feel like for the first time in my life i need goto
cagomez_ has quit [Remote host closed the connection]
<RickHull>
continuation maybe? yield, fiber
hinbody has quit [Quit: leaving]
<RickHull>
look at yield and blocks
<catphish>
basically i have a method that parses data from a network socket, but if the socket runs out of data while i'm still parsing it, i don't want to block, i want to return to my main loop, then continue when there's more data on the socket
<RickHull>
how do you know how many bytes to read?
<catphish>
i don't, that's rather the problem, i have to work it out as i go
<catphish>
if i knew, i'd just wait until there was enough data there before i started parsing it
<matthewd>
catphish: Threads, or read_nonblock
<catphish>
but as it is, i don't know until i'm already parsing it
<matthewd>
Wait, why are you parsing the redis protocol?
<catphish>
because i'm writing a redis server
<catphish>
totally normal tuesday evening activity
<RickHull>
it seems to be line oriented, so read until you get a complete line, fail otherwise
chouhoulis has quit [Ping timeout: 252 seconds]
<matthewd>
What's your goal?
guacamole has joined #ruby
<matthewd>
There's an easy but limited performance way, and a more painful but more production-able way to do it
<catphish>
matthewd: i'll try to be brief, i have some untrusted client applications that want to use redis for caching, i don't want to run a redis instance for each one, so i'm writing a proxy that accepts client connections, authenticates them, then namespaces their keys and puts them in a real redis backend
<RickHull>
have a thread own the socket and put complete lines into a queue until failure
<RickHull>
the main thread pops the queue and parses complete lines
qsx has joined #ruby
jphase has quit [Remote host closed the connection]
<RickHull>
since the thread owns the socket, it can do blocking reads or whatever
<catphish>
RickHull: right, that's what i want to do, but here's the thing, one command can span many many lines
<catphish>
i don't want a thread for every client
<catphish>
(i have a personal dislike of lots of threads)
<RickHull>
the main thread shouldn't have a problem consuming lines while parsing
<RickHull>
catphish: i'd look at elixir personally
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
<RickHull>
this is erlang's bread and butter
<catphish>
interesting
hinbody has joined #ruby
<catphish>
right now i have an instance for each client, it receives one line at a time, that's easy
<matthewd>
Thread per client is the easy way
<apeiros>
the non-thread-way to do it would be IO.select
impermanence has quit [Ping timeout: 248 seconds]
<apeiros>
and buffer until you have a workable dataset
<catphish>
but since a command can span multiple lines, it gets trickier, because i can be half way through parsing and run out of lines
<catphish>
apeiros: knowing when i have a workable dataset require parsing the whole thing repeatedly, that's one option
<apeiros>
why repeatedly?
<catphish>
ie start parsing, if i run out of data, abaondon the parse and start over
<apeiros>
have a parser with state
<catphish>
apeiros: right, this was my original question, the best way to stop part way through and resume :)
<catphish>
i guess what i'm describing is a parser with state
roshanavand has joined #ruby
<catphish>
matthewd: is the "more painful" way a parser with lots of states?
<catphish>
so i parse one line, set the state, return, repeat
<matthewd>
Mostly it was the select loop, though yes you'll need that too
<matthewd>
I think the point is that you don't return data back -- you call forward
<catphish>
i already have a good working event loop that buffers lines and feeds them to a parser instance
michael1 has quit [Ping timeout: 252 seconds]
<RickHull>
Parser#parse_line would update some ivar that tracks the parse output. check Parser#finished? after each call to #parse_line
kspencer is now known as Bearded_Reaper
<catphish>
yeah, this is making sense, i think the parser will be unavoidably complicated
<matthewd>
Right, so now the parser needs to do something each time it sees a completed message
<RickHull>
push the queue of parser outputs :)
<catphish>
there are some other fun things, like it's not always line based, sometimes it has a fixed length binary string in there
<matthewd>
^ push parser vs pull parser is a thing
<catphish>
but i will start by writing a "parse line" and setting state and go from there
<catphish>
this protocol looks cool on paper, but parsing it in a non blocking manner is more painful than i expected :)
<RickHull>
probably there is something easy to adapt. it's a fun exercise to think about but I would abandon ship
<catphish>
well the only other option is threads
<RickHull>
if you want something useful in production
<catphish>
or a different programming language, but thats not cool
<RickHull>
for example, look at how redis itself does its parsing
<RickHull>
why not link to the redis lib?
<RickHull>
or w/e
enterprisey has quit [Remote host closed the connection]
<RickHull>
if you're doing this for cool points, I would research more about TCP messaging and parsing before getting to invested in an early design
<catphish>
i'd usually consider myself pretty experienced at this
hahuang65 has joined #ruby
<catphish>
but this multi-line semi-human-readable protocol is quite new to me
<RickHull>
where newlines are significant in a TCP stream...
<RickHull>
not HTTP -- content-length
<RickHull>
telnet ...
<RickHull>
what else? gopher?
<catphish>
http is nice and easy, only has 3 states really
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<matthewd>
RickHull: How do you get the content-length though?
<RickHull>
actually, I guess HTTP does have significant newlines between headers and body and for header parsing
<RickHull>
yeah, whups :)
cdg has quit [Remote host closed the connection]
<apeiros>
catphish: for quick & dirty parsing, strscan/StringScanner is pretty nice
nadir has quit [Quit: Connection closed for inactivity]
<apeiros>
and lends itself easily to "just consume as far as you can". depending on the protocol, one annoying part with parsing a stream is figuring whether your current "token" is actually complete (if it's at the end of the buffer)
<catphish>
i think i will just start parsing one line at a time and setting state, and see if i get stuck
BTRE has quit [Ping timeout: 240 seconds]
troys is now known as troys_
<matthewd>
Other obvious protocols that come to mind are FTP and SMTP
BTRE has joined #ruby
John___ has quit [Ping timeout: 240 seconds]
<apeiros>
bedtime for me. have fun. or try elixir as RickHull suggested. sounds fun too :)
<RickHull>
the last time I looked into FTP I resolved never again
csk157 has joined #ruby
impermanence has joined #ruby
<matthewd>
RickHull: You don't need the nasty data-connection parts to deal with the base protocol, which is actually simpler/less stateful than SMTP
marxarelli|afk is now known as marxarelli
benzrf has joined #ruby
RougeRRR is now known as RougeR_AFK
<catphish>
for general interest, this is my server class, showing how data comes in, and how i will process it https://paste.ubuntu.com/25861537/
benzrf has left #ruby ["WeeChat 1.9.1"]
<catphish>
process_r is called any time new data arrives in the receive buffer
hahuang65 has quit [Quit: WeeChat 1.9.1]
<catphish>
i'll add a bunch of state to consume_line and i should be ok
<havenwood>
matthewd: Well, that takes the cake - "y\n" * 2048, capacity 4096 I'm seeing 2GiB/s.
al2o3-cr has joined #ruby
mim1k has quit [Ping timeout: 240 seconds]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
Papierkorb: nice, another good trick
<matthewd>
havenwood: Have you considered `system("yes")`? ;)
<havenwood>
matthewd: Purely a exercise for "fun", or I'd use GNU yes, no doubt!
imperator has quit [Quit: This computer has gone to sleep]
<catphish>
i just realised, i'm somewhat overcomplicating this problem, the specification says "Clients send commands to a Redis server as a RESP Array of Bulk Strings", so actually i only need to parse 2 data types, and i know the order they will arrive
<Papierkorb>
Maybe there's a way to make it send a ringbuffer in a cycle
<Papierkorb>
zero copy yes, everything else is too slow
John__ has joined #ruby
apeiros has quit [Remote host closed the connection]
jphase has quit [Ping timeout: 258 seconds]
<Papierkorb>
or if no ringbuffer, maybe it could be instructed to send the same buffer over and over again. Even if there's a roundtrip to ruby, it could be "worthwhile"
Guest18465 has quit [Read error: Connection reset by peer]
AlexRussia has quit [Quit: WeeChat 1.9.1]
mson has joined #ruby
<RickHull>
catphish: what happens if the stream stalls out -- there are many ways for a socket to die that are nontrivial to detect. does the event loop expire stale connections?
marr has joined #ruby
davic is now known as VladimirPutin
VladimirPutin is now known as ZombiemirPutin
TinkerTyper_ has joined #ruby
<RickHull>
i haven't done much in the trenches of nonblocking io, preferring blocking reads with timeouts. gimme the data or fail the socket in a manageable way
joast has quit [Quit: Leaving.]
TinkerTyper has quit [Ping timeout: 240 seconds]
leah2 has quit [Ping timeout: 246 seconds]
vtx has quit [Quit: vtx]
eckhardt has joined #ruby
evie_hammond has joined #ruby
<RickHull>
havenwood: does ?y do anything for you?
<havenwood>
RickHull: nope
<havenwood>
RickHull: putc also slows it down
<RickHull>
I wouldn't think so. came across that syntax for the first time in a long time recently
<RickHull>
my ruby-mode doesn't like it
<havenwood>
RickHull: it used to be problematic because of different behavior in 1.8 and earlier
<havenwood>
baweaver: wow, i had to read that twice to catch it
leah2 has joined #ruby
<havenwood>
long day...
<havenwood>
hah
noobineer has joined #ruby
noobineer has quit [Max SendQ exceeded]
cdg has joined #ruby
<Papierkorb>
And it's not even friday
vee__ has quit [Ping timeout: 252 seconds]
raynold has quit [Quit: Connection closed for inactivity]
<catphish>
RickHull: there is a handle_close method it will call if it's defined to let the developer know the connection has failed, if you don't define it, it will just discard your instance
<RickHull>
i'm not sure if a nonblocking read might say nope, or if there are timeouts or expiry
enterprisey has quit [Ping timeout: 260 seconds]
Nicmavr has joined #ruby
Nicmavr is now known as Guest55964
<RickHull>
what about something slowloris like? send a character per hour? just wondering what the approach is
jottr has quit [Ping timeout: 240 seconds]
Guest55964 has quit [Read error: Connection reset by peer]
raul782 has quit []
<catphish>
there are various iterations of this library, and apps based upon it, best practice would be to define a timeout for how long a request can take from the first to the last byte, and how long a connection can be idle (between requests), also a limit on the number of unprocessed bytes in the buffer
<catphish>
myxi is quite a primative version of this pattern
<matthewd>
Does that update method not accept much larger strings? It sounds like it should.
<catphish>
i don't know enough about that to know what it's running though that method
steph_ has joined #ruby
<catphish>
but it does seem that it mostly passes the data in large blocks, like in cipher.update(data) in aes_cbc_decrypt
<benzrf>
i dont know anything about any of this - i just poked around in the code til i found where it was doing integrity checks and then went "oh huh an awful lot of this is in ruby"
<catphish>
well it's a ruby program :)
<benzrf>
usually i do not expect heavy data crunching to be in ruby.
<catphish>
but i suspect you need to actually see where it's spending time rather than guessing
<benzrf>
maybe the creator hasnt used it on anything bigger than a single 100MB file
enterprisey has quit [Ping timeout: 240 seconds]
<RickHull>
benzrf: as noted, this is mostly executed in C
<Papierkorb>
RickHull: 16B at a time
<catphish>
it is indeed mostly handed off to C, but maybe there's something big that isn't
<RickHull>
the ruby lib is a thin wrapper around a C lib
jphase has joined #ruby
<catphish>
Papierkorb: only in that one method
<RickHull>
Papierkorb: that loop is just for the MAC
<catphish>
i dont know how much data in in the "MAC" data string
<matthewd>
RickHull: Which is surely what's being used "to verify the integrity"
<catphish>
if it's large, that would suck
<benzrf>
yeah
<benzrf>
im downloading multiple seasons of a tv show in 1080p
<catphish>
i'd check that, it may be the issue if its verifying a large file
apeiros has joined #ruby
<benzrf>
so ive been doing it incrementally
<catphish>
benzrf: maybe not mention that part
<benzrf>
and it's been taking forever to finish checking and start actually downloading
<benzrf>
heh
AndBobsYourUncle has joined #ruby
PresidentBiscuit has joined #ruby
<benzrf>
i suppose i can turn off integrity check
<benzrf>
but id prefer not to realize too late that one of the files got cut off
<matthewd>
I think that loop just needs to be changed to use chunks of a sensible size
<catphish>
but i don't see why you can't just hand it the full string, correctly padded
* benzrf
shrugs
<benzrf>
i didnt write this :P
<benzrf>
be back later
<catphish>
in my experience, when a developer suddenly stops doing something simple and fast, and instead does something complicated and slow, there's a reason
steph_ has quit [Ping timeout: 248 seconds]
<catphish>
maybe that reason was purely that he didn't know how to pad it
<catphish>
but maybe something more complicated
jphase has quit [Ping timeout: 240 seconds]
<matthewd>
My guess is either that they hit "data too big to make output buffer" and fell back to a definitely-known-safe value, or yeah, it's the padding
apeiros has quit [Ping timeout: 240 seconds]
<matthewd>
Worst case is changing it affects the actual mac calculation (though I don't think it will), in which case that would be immediately obvious
<Papierkorb>
128Bit =~ 16B ;)
<matthewd>
(assuming you have one known-good file)
<Papierkorb>
considering openssl, I'm not sure if I were surprised if it didn't handle chunking itself, or if it did
<catphish>
block = data + "\x0"*(16-data.bytesize%16); mac = cipher.update(block)
<catphish>
i'd try that first
<catphish>
actually not that, it will add a whole block needlessly
<catphish>
but something like that
<matthewd>
Papierkorb: I'd be surprised if it didn't, and I'd be surprised if there weren't some obscure limitations to how it did it. Best of both worlds. :)
sandroqz has joined #ruby
sandroqz has quit [Remote host closed the connection]
<catphish>
block = data + "\x0"*((16-data.bytesize%16)%16);
apeiros has joined #ruby
<catphish>
that will pad it correctly
<catphish>
but i don't know if that's the solution :)
<matthewd>
catphish: Don't need the inner %
<catphish>
matthewd: the negative scares me, but i suspect you're correct
naprimer3 has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]