<bdonnahue>
curl: (60) Peer's Certificate has expired.
<bdonnahue>
anyone know what to do?
sepp2k has quit [Read error: Connection reset by peer]
Ropeney has joined #ruby
<RickHull>
upgrade curl
<Papierkorb>
1) is your system clock correct? 2) Ruby2.1 is end of life'd
<RickHull>
and why install 2.1.0?
apeiros has joined #ruby
<bdonnahue>
redmine needs it afaik. double checking that
<RickHull>
I doubt it. if anything in your infra depends on something EOL'd you should reconsider your infra
<vtx>
hi guys, does anyone here have experience testing sinatra apps with rspec? i can test a simple /status endpoint with: https://gist.github.com/anonymous/10bd887c820269458a9859ff24df3725 but i don’t know how to test more complex endpoints. for example, say i have a /user endpoint that connects to an ldap service or something similar. how can i mock out calls to those services using expect/allow?
weaksauce has joined #ruby
troulouliou_dev has quit [Quit: Leaving]
apeiros has quit [Ping timeout: 240 seconds]
hxegon has quit [Quit: leaving]
guacamole has joined #ruby
ElDoggo has joined #ruby
apeiros has joined #ruby
dviola has joined #ruby
RougeR has quit [Remote host closed the connection]
apeiros has quit [Ping timeout: 255 seconds]
weaksauce has quit [Read error: Connection reset by peer]
ruby_ has joined #ruby
ruby_ has quit [Client Quit]
csk157 has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
ruby_ has joined #ruby
ruby_ has quit [Client Quit]
John__ has quit [Read error: Connection reset by peer]
csk157 has quit [Ping timeout: 240 seconds]
apeiros has joined #ruby
AndBobsYourUncle has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<benzrf>
WHYYYYYYYYYYYYY does ruby USE GLOBAL VARIABLES TO CONFIGURE DEFAULTS
<RickHull>
because perl
alfiemax has quit [Remote host closed the connection]
<RickHull>
but let's talk about smalltalk and lisp shall we?
cdg has joined #ruby
marxarelli is now known as marxarelli|afk
gizmore has joined #ruby
jphase has quit [Ping timeout: 248 seconds]
ek926m has joined #ruby
weaksauce has quit [Read error: Connection reset by peer]
gizmore|2 has quit [Ping timeout: 258 seconds]
apeiros has joined #ruby
justwentviral has joined #ruby
jphase has joined #ruby
d^sh has quit [Ping timeout: 248 seconds]
apeiros has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
jrafanie has joined #ruby
<benzrf>
i know because perl
<benzrf>
but that's not an excuse
<benzrf>
like. just because perl does it. matz still had to look at it and think "yes. that is a good idea. i will put this into my language"
PaulCape_ has quit [Read error: Connection reset by peer]
<matthewd>
Defaults are pretty much global by default, no?
vee__ has quit [Ping timeout: 240 seconds]
<benzrf>
sorry, not precisely "defaults", i mean like "defaults" in the sense of default behavior of things like #split in the absence of specific args
<benzrf>
er, and my objection was less to the use of global variables as opposed to something else, and more the ability to do that at all
<justwentviral>
why would i use ruby/rails to make a high-traffic website when it has a reputation of being slow at large scale? i feel like one would be making a bit of a mistake. i ask because, i'm hoping i'm under some misconception or something, as making an mvp in and finding additional resources (learning tools, manpower, etc.) in ruby seems infinitely easier than with, say, haskell or another esoteric but arguably more better-suited langua
jrafanie has quit [Client Quit]
rsa3157 has joined #ruby
<benzrf>
if you _really_ want that to be possible, at _least_ don't make it dynamically changable at runtime! good god
PaulCapestany has joined #ruby
rsa3157 has quit [Client Quit]
<matthewd>
justwentviral: The obvious answer would be that you're not making a high-traffic website
ek926m has quit [Ping timeout: 240 seconds]
<matthewd>
justwentviral: The second would be that "high", "slow", and "large" are all relative
<justwentviral>
so i shouldn't use ruby then for what i INTEND to be a high-traffic website, if i want to save myself some headache in the future then
jphase has quit [Ping timeout: 260 seconds]
<matthewd>
If you prefer headache now, that's up to you ¯\_(ツ)_/¯
mtkd has quit [Ping timeout: 240 seconds]
<justwentviral>
really does seem like a pick-your-poison situation, i suppose :/
nginxxx has quit [Ping timeout: 260 seconds]
csk157 has joined #ruby
mtkd has joined #ruby
<matthewd>
Personally, I prefer to solve for problems I'm having now -- ease of development, for example -- over problems I might have in future, like unquantifiable "high-traffic"
<matthewd>
There are plenty of Very Not Small things running happily either entirely or substantially on Rails
apeiros has joined #ruby
<RickHull>
justwentviral: a website needs hardly any processing power. a webapp can be a tarpit of resources
<RickHull>
but it doesn't have to be
<RickHull>
just use node and push the inefficiency to battery-powered phones, I say
<RickHull>
but for real, it's easy to make efficient websites, and server-based webapps
<RickHull>
it's also easy to hack your way through your first rails tutorial and try to stuff everything into ActiveRecord
csk157 has quit [Ping timeout: 240 seconds]
<RickHull>
maybe it works better now, I haven't used in anger in about 5 years
<RickHull>
/rant
apeiros has quit [Ping timeout: 258 seconds]
uZiel has joined #ruby
vee__ has joined #ruby
<bdonnahue>
hey guys, im seeing the following: mkmf.rb can't find header files for ruby
<bdonnahue>
i installed ruby with rvm
<bdonnahue>
any idea what im misisng?
<RickHull>
not to knock AR -- it does what it says on the tin -- but it can be an easy but wrong place to stuff important logic
<RickHull>
bdonnahue: what linux distro? you probably need the ruby-dev package
<bdonnahue>
centos
lobloblobster has joined #ruby
naitian has left #ruby ["WeeChat 1.9.1"]
<RickHull>
try installing ruby-devel
<RickHull>
what is driving mkmf.rb ?
<bdonnahue>
RickHull, im new to ruby. I am worried that the devel will not match the version i installed with rvm
<RickHull>
a gem with a C extension?
<RickHull>
what step are you trying to accomplish that bombs out with mkmf.rb ?
<bdonnahue>
RickHull, speaking french right now haha im very new to ruby
<bdonnahue>
let me check
<bdonnahue>
An error occurred while installing json (1.8.6), and Bundler cannot continue.
<bdonnahue>
does that help?
<RickHull>
if you are following a tutorial, paste a link
<hays_>
ok with all that bookmarked im going to bed. 3am in home time zone
<hays_>
thans
<hays_>
thanks
hays_ has quit [Remote host closed the connection]
aufi has joined #ruby
Dreamer3 has joined #ruby
dangelov has quit [Ping timeout: 240 seconds]
Technodrome has joined #ruby
alex`` has quit [Ping timeout: 258 seconds]
TomyWork has joined #ruby
alex`` has joined #ruby
conta has joined #ruby
Technodrome has quit [Ping timeout: 240 seconds]
hxegon has joined #ruby
hxegon has quit [Client Quit]
hxegon has joined #ruby
TinkerTyper has joined #ruby
TinkerTyper_ has quit [Ping timeout: 260 seconds]
hutch34 has joined #ruby
Burgestrand has joined #ruby
imode has quit [Ping timeout: 240 seconds]
hutch34 has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
Dimik has quit [Ping timeout: 248 seconds]
csk157 has joined #ruby
csk157 has quit [Ping timeout: 255 seconds]
uZiel has quit [Ping timeout: 240 seconds]
mn3m has joined #ruby
uZiel has joined #ruby
claudiuinberlin has joined #ruby
FahmeF_ has joined #ruby
mark_66 has joined #ruby
nertzy has joined #ruby
FahmeF has quit [Ping timeout: 255 seconds]
mim1k has quit [Ping timeout: 264 seconds]
ams__ has joined #ruby
uZiel has quit [Ping timeout: 258 seconds]
cabotto has joined #ruby
Ltem has joined #ruby
uZiel has joined #ruby
paranoicsan has joined #ruby
vtx has quit [Quit: vtx]
vondruch has joined #ruby
Dreamer3 has quit [Read error: Connection reset by peer]
vondruch has quit [Client Quit]
Dreamer3 has joined #ruby
vondruch has joined #ruby
Dreamer3 has quit [Client Quit]
hutch34 has joined #ruby
VladGh_ has joined #ruby
VladGh has quit [Ping timeout: 248 seconds]
bigkevmcd has joined #ruby
<_ppp>
Hello,I am currently at the planning phase of my project and would like to study the different options i have to start building my website and its backend.
<_ppp>
I was thinking if there is an opensource framework i can build upon like wordpress or others that would allow me to create a IT request/response ticketing solution. Mainly customers can login, submit their requests, IT professionals can login takethe request, submit the solution and get paid. The system needs to be flexible where i can change parameters for the request screen, make the request flow from one status to another etc.
<_ppp>
Is there an existing framework i can build on instead of coding from scratch the whole engine? Your opinion is really valuable to me thank you
<dminuoso>
_ppp: Yes.
<dminuoso>
_ppp: Jira Service Desk is an example. Other alternatives exist.
<apeiros>
redmine is a rails based ticket system
<apeiros>
we use and extended it at work
<apeiros>
Since I have not worked on extending it myself, I can't give any account on how good the interfaces are
zer0python has quit [Ping timeout: 248 seconds]
vondruch has quit [Remote host closed the connection]
hutch34 has quit [Ping timeout: 252 seconds]
<dminuoso>
_ppp: ?cross
<dminuoso>
?cross _ppp
<ruby[bot]>
dminuoso: I don't know anything about cross
<ruby[bot]>
_ppp: Please do not crosspost without at least telling so and mentioning provided suggestions and their outcome in all channels. Experience shows that people don't do either, and not doing so is considered rude.
<apeiros>
oh, reminds me that I'm not in #rubyonrails anymore
<dminuoso>
I really do need to write a paginator for kaminari in pure cells. :(
anisha_ has joined #ruby
RickHull has quit [Ping timeout: 260 seconds]
Tempesta has joined #ruby
milardovich has joined #ruby
Sylvia has joined #ruby
jaruga has joined #ruby
jottr has joined #ruby
Sylvia is now known as Guest34216
<apeiros>
dminuoso: I'll not pretend to understand what you're doing there ;-)
<apeiros>
kaminari is the successor to will_paginate?
Guest34216 has quit [Client Quit]
<dminuoso>
It's an alternative, but yeah.
<apeiros>
I see
<dminuoso>
apeiros: Part of the problem is that all these rails things follow that "throw everything into helpers" conventions.
<apeiros>
well, got my holidays, so I'll finally continue on my project I had to abandon 2y ago. a syncing table widget is part of it :)
<dminuoso>
And trailblazers doesn't do that, so basically every helper is opt-in. This basically means a lot of things break.
<dminuoso>
Oh that secret project you told me about without telling me anything?
<apeiros>
yepp
<apeiros>
that one
<dminuoso>
:)
<apeiros>
I hope I'll be able to tell about parts of it after these holidays
banisterfiend has joined #ruby
mim1k has joined #ruby
<argoneus>
hello
<argoneus>
as part of a homework I wrote some code that works, but I have no clue why
<argoneus>
I have a module, inside it a function called "sum", and its only statement is 'reduce(:+)', this module is than included in a class that also includes enumerable, and for some reason calling 'sum' on this gives the desired result
<argoneus>
what exactly does it mean if I just have 'reduce(:+)'? I can't find any doc on this
<argoneus>
all I see is that reduce is a method of Enumerable, but inside this other module I'm writing, I don't include Enumerable
bruno- has quit [Quit: Lost terminal]
<argoneus>
and what does that even return
bruno- has joined #ruby
hutch34 has joined #ruby
mikecmpbll has joined #ruby
bruno- has quit [Client Quit]
bruno- has joined #ruby
hutch34 has quit [Ping timeout: 264 seconds]
<banisterfiend>
anyone here famiiliar with net/http and ssl requests?
wu__ has joined #ruby
raynold has quit [Quit: Connection closed for inactivity]
cadillac_ has quit [Ping timeout: 240 seconds]
CrazyEddy has quit [Remote host closed the connection]
hutch34 has joined #ruby
cadillac_ has joined #ruby
* sneep
met Matz today \o/
<elomatreb>
argoneus: Does something you extend include Enumerable? Check with YourModule.ancestors
ldnunes has joined #ruby
<apeiros>
argoneus: since you include your module into a class which also includes Enumerable, that's sufficient
reber has quit [Remote host closed the connection]
hfp_work has quit [Quit: bye]
<apeiros>
your module's instance methods, when called on an instance of the including class, can access all instance methods of that class. that includes all methods gained from including other modules.
<dminuoso>
argoneus: reduce(:+) is just a shortcut for reduce(&:+)
<apeiros>
and as such, the docs you look for are indeed Enumerable#reduce
PaulCapestany has quit [Read error: Connection reset by peer]
Arun__ has joined #ruby
<dminuoso>
apeiros: see, if ruby had autocurrying this would be so simple. reduce((+)) :(
ElDoggo has joined #ruby
MyMind has quit [Ping timeout: 255 seconds]
CrazyEddy has joined #ruby
<banisterfiend>
apeiros sup homie you familiar with ssl and net/http ?
<banisterfiend>
apeiros i need to hit a server using https and i need to verify the identify of the server, any ideas? :D
<apeiros>
banisterfiend: not really. I have code which performs https calls using net/http, but that's about it
hfp_work has joined #ruby
_sfiguser has joined #ruby
ElDoggo_ has joined #ruby
tomphp has joined #ruby
ElDoggo has quit [Ping timeout: 240 seconds]
<apeiros>
verify the server's identity? I guess you'd have to check the cert it returns?
PaulCape_ has joined #ruby
Ropeney has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<banisterfiend>
apeiros yeah, i was told that ruby does that automatically as it bundles an up to date ca store with the common CAs in it
<banisterfiend>
but i wanted to know for sure
<apeiros>
I remember rvm doing that, but I don't remember ruby itself doing it
ElDoggo_ has quit [Ping timeout: 246 seconds]
ElDoggo has joined #ruby
<apeiros>
and I think you can tell net/http where to look for ca's, but I don't know the relevant methods by heart
<apeiros>
we usually had to disable cert checking because our infra guys couldn't be arsed to get proper certs on internal servers :(
<elomatreb>
Reading is hard
Arun__ has quit [Ping timeout: 260 seconds]
ElDoggo has quit [Ping timeout: 260 seconds]
rburton_ has joined #ruby
<rburton_>
is there a way to see the checks and choices made by eg ext/dbm when it builds? want to verify what db backend it ends up picking.
InfinityFye has joined #ruby
milardovich has quit [Remote host closed the connection]
csk157 has joined #ruby
milardovich has joined #ruby
MrSkeltal is now known as mniip
csk157 has quit [Ping timeout: 248 seconds]
milardovich has quit [Ping timeout: 248 seconds]
ElDoggo has joined #ruby
ElDoggo has quit [Remote host closed the connection]
milardovich has joined #ruby
johnDoe1122 has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apparition has joined #ruby
johnDoe1122 has quit [Remote host closed the connection]
alex`` has quit [Quit: WeeChat 1.9.1]
guardianxx has joined #ruby
sparrow_mango has joined #ruby
old1101 has joined #ruby
<old1101>
hello, the best practice is to always install the gems in vendor/ on bundler? (even when deployment for isolation)
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<old1101>
it seems to me that vendor/bundle should always be the default (ruby newbie)
<elomatreb>
Usually you don't want that, if you have multiple projects you will needlessly duplicate the gem files. The default bundler action is to store them in a shared directory, and get the project to use the right one at runtime
<old1101>
but if project A uses gem-x-1.2 and project B uses gem-x.1.5
<old1101>
it seems nice to have it always scoped, no?
<old1101>
or `gem` handles it?
<elomatreb>
Bundler does that at runtime, if your project has a gemfile it will use the one specified in it, even if there are multiple versions installed on the system
<old1101>
so I can have two global versions of the same gem?
<old1101>
different*
<elomatreb>
Yes.
<old1101>
s2
<old1101>
thanks
csk157 has joined #ruby
leah2 has quit [Ping timeout: 248 seconds]
leah2 has joined #ruby
<argoneus>
oh I see
<argoneus>
so whether reduce() exists or not is determined in the class that incldues the module
<argoneus>
not in the module itself
sparrow_mango has quit []
<elomatreb>
Calling a method without a receiver is equivalent to calling it on self, so yes
pierrearseufrasi has joined #ruby
aclark has quit [Remote host closed the connection]
aclark has joined #ruby
guardianxx has quit []
synthroid has joined #ruby
workmad3 has quit [Ping timeout: 240 seconds]
workmad3 has joined #ruby
ElDoggo has joined #ruby
mson has joined #ruby
stan has quit [Remote host closed the connection]
ek926m has joined #ruby
ElDoggo has quit [Remote host closed the connection]
ElDoggo has joined #ruby
stan has joined #ruby
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ElDoggo has quit [Ping timeout: 248 seconds]
milardovich has quit [Read error: Connection reset by peer]
<argoneus>
ah, I see
sagax has quit [Quit: Konversation terminated!]
milardovich has joined #ruby
ledestin has joined #ruby
alex`` has joined #ruby
n13z has joined #ruby
claudiuinberlin has joined #ruby
Burgestrand has quit [Quit: Good bye and have a nice day!]
mark_66 has quit [Remote host closed the connection]
bronson_ has joined #ruby
bronson has quit [Read error: Connection reset by peer]
solocshaw has joined #ruby
nikhgupta1 has quit [Quit: WeeChat 1.9.1]
nikhgupta has joined #ruby
RougeR has joined #ruby
lacour has joined #ruby
charliesome has joined #ruby
charliesome_ has quit [Ping timeout: 240 seconds]
cdg has joined #ruby
troys is now known as troys_
cdg_ has quit [Ping timeout: 240 seconds]
nikhgupta has quit [Quit: WeeChat 1.9.1]
nikhgupta has joined #ruby
solocshaw1 has joined #ruby
cdg_ has joined #ruby
solocshaw has quit [Ping timeout: 246 seconds]
solocshaw1 is now known as solocshaw
troys_ is now known as troys
cdg has quit [Ping timeout: 240 seconds]
ldnunes has quit [Ping timeout: 264 seconds]
aswen has quit [Quit: WeeChat 1.6]
dionysus69 has joined #ruby
dionysus69 has quit [Client Quit]
raynold has joined #ruby
aufi has quit [Ping timeout: 240 seconds]
conta has quit [Ping timeout: 248 seconds]
vipaca has joined #ruby
charliesome_ has joined #ruby
orbyt_ has joined #ruby
charliesome has quit [Ping timeout: 240 seconds]
Dreamer3 has joined #ruby
ldnunes has joined #ruby
code_zombie has joined #ruby
Guest77 has joined #ruby
Guest77 is now known as dragon14
<dragon14>
anyone have time to help me debug a ruby-install issue? I'm trying to install ruby v2.3.4 but getting the following error: /usr/include/sys/syslog.h:227:124: error: expected ',' or ';' before '__asm' on Mac OS 10.13.1
Burgestrand has quit [Quit: Closing time!]
<raynold>
ahh it's a wonderful day
<dragon14>
mostly cloudy here with a high chance of ruby install errors lol
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
dragon14: does it work if you set CC=clang but you want to use gcc?
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has joined #ruby
rippa has joined #ruby
<dragon14>
hmm I haven't tried that.. I've simply been using ruby-install program to handle the installation..
steph__ has joined #ruby
ek926m has joined #ruby
<havenwood>
dragon14: It seems you've installed gcc and are running into an issue with High Sierra and GCC.
kies has quit [Ping timeout: 240 seconds]
TomyWork has quit [Ping timeout: 240 seconds]
<dragon14>
havenwood: yes that's correct. This all started with the High Sierra upgrade (I previously had 2.3.4 installed.. but it stopped working with a readline error after the high sierra update
<havenwood>
dragon14: I'd recommend going back to the default clang, unless you really want to debug the gcc/high sierra issues.
<dragon14>
I'm using ruby-install application (always have)
charliesome_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<dragon14>
so I removed 2.3.4 ruby.. and tried a reinstall with ruby-install but now getting this syslog gcc error
<havenwood>
dragon14: So you've installed gcc, and ruby-install is using it. That's not the default setup on macOS.
<havenwood>
dragon14: Check: gcc --version
<havenwood>
dragon14: With the macOS command line tools, it'd be expected to be: Apple LLVM version 9.0.0 (clang-900.0.38)
<dragon14>
Apple LLVM version 9.0.0 (clang-900.0.38)
rkoller has joined #ruby
DTZUZO has quit [Ping timeout: 260 seconds]
<havenwood>
dragon14: Could you confirm that setting CC doesn't work, just to rule it out?: ruby-install ruby 2.3.4 -- CC=clang
claudiuinberlin has joined #ruby
<dragon14>
interesting.. my first attempt to run ruby-install errored saying it could't find gcc6 so I brew installed it.. which allowed it to get started.. but then the error I relayed..
<dragon14>
ok trying that now havenwood
<havenwood>
dragon14: The issue is that it's using gcc, and running into this gcc/macOS bug.
<havenwood>
It looks like some folk resolve that linking bug by reinstalling macOS >.>
<havenwood>
So I'd probably use clang until they get that resolved. ;-P
<dragon14>
yeah I read that.. uh.. this is my work computer.. I'm not completely reinstalling the OS lol
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
<havenwood>
dragon14: But the issue is likely going to be the same whether you use RVM or ruby-install or build Ruby yourself, as long as you're using gcc on that install of macOS.
stamina has quit [Quit: WeeChat 1.9.1]
jamesaxl has quit [Ping timeout: 240 seconds]
<dragon14>
havenwood yeah that makes sense.. hopefully forcing CC to clang does the trick
<matthewd>
> errored saying it could't find gcc6
<matthewd>
Do you happen to still have that message in scrollback?
<matthewd>
It sounds.. unexpected
<dragon14>
matthewd I don't sadly.. I went back and looked when I mentioned it.. but it's outside my buffer :(
<havenwood>
I suspect a badly linked gcc from an old install.
mjolnird has quit [Quit: Leaving]
<havenwood>
Default clang never got involved.
<havenwood>
It is curious.
<dragon14>
havenwood so that appears to have worked!
<havenwood>
dragon14: congrats!
dviola has joined #ruby
<dragon14>
ah you know what.. I was forcing it to use gcc6 in my old alias *sigh*
<dragon14>
now I'm not sure why (I set up that alias like 4 years ago)
<havenwood>
dragon14: I was confused why that was happening, that explains it. The fact that `gcc` wasn't aliased was hurting my brain.
troulouliou_div2 has joined #ruby
<dragon14>
havenwood you and me both honestly lol..
<matthewd>
I think you used to need gcc for 1.8 or something, maybe?
<dragon14>
yeah most likely ruby-1.9.3-p392
<havenwood>
anything older than older than 1.9.3-p429
<havenwood>
that was the patch with the fix
<dragon14>
I'll just go ahead and update that alias right now
<dragon14>
lol
mgorbach has quit [Remote host closed the connection]
<dragon14>
havenwood: I truly appreciate your help.. I've been scratching my head for hours on this..
bitemyapp has left #ruby [#ruby]
<havenwood>
dragon14: you're welcome
dn`_ has joined #ruby
dn` has quit [Read error: Connection reset by peer]
dn`_ is now known as dn`
ek926m has quit [Ping timeout: 260 seconds]
mgorbach has joined #ruby
csk157_1 has joined #ruby
mgorbach has quit [Client Quit]
ujjain has quit [Ping timeout: 248 seconds]
mgorbach has joined #ruby
<dragon14>
now to try and track down why all these gem ignores are happening and requesting I pristine them all after the high sierra update.. *sigh*
<dragon14>
I haven't coded in over a year now (been playing scrum master).. but my company just fired everyone else and left only me.. good news is I get to code again.. bad news is NONE of my dev environments are up to date oh the joy
<dragon14>
(well not fired.. layed off)
mgorbach has quit [Remote host closed the connection]
csk157_1 has quit [Ping timeout: 252 seconds]
vee__ has quit [Ping timeout: 248 seconds]
mgorbach has joined #ruby
ujjain has joined #ruby
ujjain has quit [Changing host]
ujjain has joined #ruby
charliesome has joined #ruby
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has joined #ruby
MrBusiness has joined #ruby
vipaca has joined #ruby
FahmeF_ has quit [Ping timeout: 248 seconds]
dextrey has quit [Ping timeout: 248 seconds]
profP has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<impermanence>
I've installed this: https://github.com/postmodern/combinatorics and when I call Set['ab', 'cd', 'ef'].powerset I am returned #<Enumerator: #<Set: {"ab", "cd", "ef"}>:powerset> as opposed to what the documentation says powerset should return. Am I missing something here? I expected an array of objects...
hackeron has joined #ruby
MrPunkin has joined #ruby
<lupine>
looks like it quacks fine
<MrPunkin>
I’m calling a bash script via %x(/bin/bash /path/to/script) and within that script I have a command that is supposed to run in the background (ends with &). It seems that if I run the shell script directly from the command line it does, however it seems that Ruby is waiting for the background subprocess to finish too. How can I program around this?
<impermanence>
lupine: oh, yep. I see now. calling each on the enumerator return has straightened me out.
<impermanence>
if you were talking to me.
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Antiarc has quit [Ping timeout: 252 seconds]
eckhardt has joined #ruby
claudiuinberlin has joined #ruby
<lupine>
yup
Antiarc has joined #ruby
<lupine>
MrPunkin: don't use `^x`. Use `Process::spawn` instead
Freshnuts has quit [Quit: Leaving]
<MrPunkin>
lupine: thanks for the direction, much appreciated
Devalo has quit [Remote host closed the connection]
Devalo has joined #ruby
dragon14 has quit [Remote host closed the connection]
quobo has quit [Quit: Connection closed for inactivity]
<impermanence>
How do I access elements in a data structure such as: #<Set: {3, 5, 7}>
<elomatreb>
Depends on what you mean by "access elements"
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Devalo has quit [Ping timeout: 246 seconds]
<impermanence>
elomatreb: touch them to be used. they don't need to be mutated, deleted, nothing else.
jrafanie has joined #ruby
<impermanence>
I guess I should just use the Set methods it seems...
<elomatreb>
"touch them"? I'm not sure I get what you mean
<havenwood>
impermanence: Are you trying to find a particular item in the set or iterate over all items or what?
chouhoulis has quit [Remote host closed the connection]
<impermanence>
havenwood: iterate over all items
<impermanence>
havenwood: looks like each is fine...
<havenwood>
impermanence: Yes, set mixes in Enumerable as well - which works off of #each.
alfiemax has quit [Remote host closed the connection]
<impermanence>
I suppose this ...each { |i| i.each { |j| p j } } is disgusting? :)
eckhardt has joined #ruby
<impermanence>
This at least prints out what I'm looking to do, essentially
<impermanence>
which is iterate of every element in something like this: [[1,2,3], [1,2], [1,3], [2,3], [1], [2], [3]]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
vipaca has joined #ruby
lxsameer has joined #ruby
<impermanence>
Is a nested each like that terrible? I would guess that if I have to do that then probably there is a better way to do what I want.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
workmad3 has quit [Ping timeout: 240 seconds]
vee__ has quit [Ping timeout: 248 seconds]
adlerdias has quit [Quit: adlerdias]
vipaca has quit [Client Quit]
vipaca has joined #ruby
<elomatreb>
Try #flatten?
mson has quit [Quit: Connection closed for inactivity]
ozcanesen has quit [Quit: ozcanesen]
<impermanence>
elomatreb: yep
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr>
or inject(:+) :P
InfinityFye has joined #ruby
<al2o3-cr>
yeah, flatten your array :)
<elomatreb>
flatten(1) if you don't want it to recurse, btw
jdawgaz has joined #ruby
synthroid has quit [Remote host closed the connection]
alfiemax has joined #ruby
charliesome has joined #ruby
<impermanence>
elomatreb: this is specifically what I am trying to do: ...
<elomatreb>
Recursing into nested arrays?
<impermanence>
elomatreb: one sec
cabotto has quit []
synthroid has joined #ruby
mtkd has quit [Ping timeout: 248 seconds]
alfiemax has quit [Remote host closed the connection]
<impermanence>
if any of [1, 2, 3] are factors of some number, then begin to check if the subsets of such an array are also factors: [1, 2], [1, 3], [2, 3] ... etc.
vee__ has joined #ruby
<impermanence>
that's it
<nixfreak>
sweet the directions for ruby-install worked great
<impermanence>
I started thinking I would use Combinatorics#powerset
mtkd has joined #ruby
<nixfreak>
now i have ruby as 2.4.2 thanks alot appreaciate
<impermanence>
which I suppose I could...
<impermanence>
but now, algorithmically I realize that if any of [1, 2, 3] are not factors then I don't even need to produce or check their corresponding subsets...
<impermanence>
meh
<elomatreb>
I'm too tired to think about something like that, sorry :)
jrafanie_ has joined #ruby
<impermanence>
elomatreb: that makes [1,2].size of us :)
<dminuoso>
watzon: you can also have a trailing !, but the meaning of that is muddy (sometimes it means "dangerous", or it means "mutates", or it means "exception-throwing-variant", or it means "this is some imperative stuff")
synthroid has joined #ruby
<watzon>
Ahh I gotcha. That's good to know
tomphp has quit [Read error: Connection reset by peer]
tomphp has joined #ruby
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
imode has joined #ruby
steph__ has quit [Remote host closed the connection]
<elomatreb>
The api looks a bit different now though (does set_trace_func even still work, or is it all in TracePoint now?)
<devn>
baweaver: of course a post like that would come from aphyr :D
<dminuoso>
elomatreb: It still works, but its deprecated.
<baweaver>
Ah, TracePoint finally took over?
<baweaver>
Shows how often I use that part
ozcanesen has joined #ruby
vee__ has quit [Ping timeout: 248 seconds]
postmodern has quit [Quit: Leaving]
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vipaca has joined #ruby
polishdub has quit [Quit: leaving]
RougeR has quit [Read error: Connection reset by peer]
Devalo has joined #ruby
ldnunes has quit [Quit: Leaving]
snickers has joined #ruby
marr has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
postmodern has joined #ruby
Devalo has quit [Ping timeout: 248 seconds]
jrafanie_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csk157_2 has joined #ruby
oleo is now known as oleo2
vee__ has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jdawgaz has joined #ruby
oleo2 is now known as oleo
dionysus69 has quit [Ping timeout: 248 seconds]
cagomez has joined #ruby
csk157_1 has quit [Ping timeout: 260 seconds]
RickHull has joined #ruby
troys is now known as troys_
Nexer has quit [Quit: Connection closed for inactivity]
vee__ has quit [Ping timeout: 248 seconds]
DoubleMalt has joined #ruby
claudiuinberlin has joined #ruby
cdg has joined #ruby
DoubleMalt has quit [Client Quit]
jottr has joined #ruby
AndBobsYourUncle has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cdg_ has quit [Ping timeout: 240 seconds]
RougeR has joined #ruby
<dalitom>
question... how do I iterate inside heredoc ?
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<elomatreb>
A heredoc is a string. #{...} works, if that's what you mean
<matthewd>
You don't; a heredoc is a string, not a template language.
<argoneus>
hello, I'm wondering, is Ruby suited for a websocket server project? trying to learn the language on something I might actually use
<argoneus>
I thought it'd be similar to python but blocks are killing me inside
<Papierkorb>
..?
<elomatreb>
Ruby is suitable for websockets, recent versions of Rails ship with built-in support for them. And you'll miss blocks in nearly every language after you "get" them :P
<Papierkorb>
How are blocks "killing" you?
<matthewd>
argoneus: It can certainly be done, and the code will look idiomatic and pleasant. But it's not going to be as high-concurrency as some other languages (well, runtimes) which have that as a stronger focus.
<Papierkorb>
argoneus: Rails stuff isn't vanilla websockets. There's faye-websockets, which does what you want.
<argoneus>
I'm not planning to use rails, I plan to use something else altogether to make the client
<matthewd>
Papierkorb: I'm not sure I'd put something that uses EventMachine next to the word "vanilla", but okay ;)
<argoneus>
and I don't need high performance, I just want to actually learn the language
<argoneus>
and by killing me, I mean that I understand in my head how blocks work, but then I see some examples of code that uses blocks and I'm back to square one and don't understand how it works
<Papierkorb>
matthewd: faye implements vanilla websockets without any protocol on top.
<matthewd>
argoneus: So yes, as an educational exercise in a domain you're potentially familiar with, it's a perfectly reasonable choice
agent_white has quit [Quit: leaving]
<Papierkorb>
matthewd: And thankfully, you don't actually have to "use" EM for faye to use it.
<matthewd>
Papierkorb: Oh?!... I thought the whole reason I rewrote that stuff was to get rid of EM
<Papierkorb>
matthewd: Mh, it's been a good while since I used plain faye. I think I only needed to copy the base "loop" from somewhere and it worked for me. Mostly I use Faye with Roda on Puma et al, so I don't have to mess with any of that *yay*
<argoneus>
like, when looking at the example code for faye-websockets
<argoneus>
which part of the example block keeps track of which client it's responding to? or do I need to do that
vee__ has joined #ruby
<argoneus>
I just can't picture the flow in my head
<RickHull>
have you worked with event architecture before? reactor pattern? inversion of control?
<argoneus>
nope, that'd probably be a good place to start
<RickHull>
yeah, you're taking on a big conceptual load with this
<argoneus>
I've only done raw TCP servers before which was considerably easier
ur5us has joined #ruby
<matthewd>
argoneus: In what languages?
<argoneus>
Python
<argoneus>
using asyncio
<RickHull>
you can also look at Phoenix, a project in the Elixir language
<RickHull>
i'll stop shilling for #elixir soon I promise :)
<matthewd>
RickHull: You think that would be an effective strategy for learning Ruby?
<Papierkorb>
argoneus: EventMachine ("EM") basically does async I/O in ruby. Never done Python, so can't compare
AndBobsYourUncle has joined #ruby
<argoneus>
the syntax is way different
<RickHull>
matthewd: no, but it might help the programmer :)
dalitom has quit [Quit: Page closed]
jdawgaz has joined #ruby
<argoneus>
also it's more
<argoneus>
I can understand from the examples how to use the code, but I'd like to understand what it actually does under the hood
<argoneus>
and the more I try to do this in ruby the more I regret it every time
<Papierkorb>
I wouldn't want to learn Ruby through EM
<RickHull>
i'm not a fan of inversion of control and EM -- I find it hard to reason about
<RickHull>
there are lots of other approaches in ruby
<matthewd>
argoneus: If you want to dig in, to understand language fundamentals, you'll likely be better off with a much smaller (and yes, consequently, less interesting) problem
steph_ has quit [Remote host closed the connection]
steph_ has joined #ruby
<argoneus>
well, the websocket part is just a tiny part of the server, right
<argoneus>
I still need to actually have the server do things, so I can take the websocket lib as magic for now
<Papierkorb>
"the server"?
<RickHull>
you're buying into the EM architecture first
<argoneus>
urf
<Papierkorb>
argoneus: do you plan on having a web interface and use websocket in that?
<argoneus>
yes, and/or use electron or similar
<argoneus>
it's a server for a simple text game
<argoneus>
not too concerned about the client atm
csk157_2 has quit [Quit: WeeChat 1.9.1]
benzrf has left #ruby ["WeeChat 1.9.1"]
<Papierkorb>
Well. EM is the big hammer, handling multiple clients per thread and stuff. It's what you want if you want to build stuff, maybe not when you want to learn stuff.
<argoneus>
implementing websockets by myself is probably out of the question
<Papierkorb>
Why?
<RickHull>
i'd be tempted to look at what sinatra does for websockets
<matthewd>
It's not even what I want when I build stuff ;)
<argoneus>
ruby doesn't seem too ideal for low level bitwise work
<Papierkorb>
Websocket is actually a nice, simple protocol overall
<argoneus>
or am I wrong
<RickHull>
argoneus: ruby is a great language for io heavy problems
<matthewd>
There's also a library you can use for that
<RickHull>
string manipulation, etc
<argoneus>
yes but I mean stuff like
<Papierkorb>
you can write/read binary structures using Array#pack and String#unpack (as far the stdlib is concerned)
<matthewd>
The Rails websocket implementation does its own IO & events, but uses a gem to handle the actual protocol parsing
<argoneus>
"extract the first 15 bytes from the tcp stream and convert them to a value"
<RickHull>
bread & butter
<argoneus>
hmm
<RickHull>
this takes no wall clock time relative to IO
<Papierkorb>
argoneus: That's no problem to do
<argoneus>
then how about writing my own simple websocket implementation on top of TCPServer
<argoneus>
I can always just plug the faye-websockets lib in later, right
<Papierkorb>
Faye is more complex, but in theory, yes
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
synthroid has quit []
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
selim has quit [Ping timeout: 248 seconds]
<argoneus>
writing my own WS implementation seems like good practice, since it's a lot of io work
troulouliou_div2 has quit [Quit: Leaving]
<argoneus>
thanks a lot, just one last thing, or two
<argoneus>
1) is TCPServer the go-to for just a tcp server or are there issues with that too?
<Papierkorb>
TCPServer is the basic tcp server everyone relies on
<matthewd>
I might argue that "a lot of io work" isn't necessarily the most valuable thing to practice, but that's just opinion
workmad3 has joined #ruby
<RickHull>
it's a C-based API mostly -- so be familiar with berkeley sockets and you'll be fine
<argoneus>
ah
<argoneus>
I'm used to raw sockets so that's nice
selim has joined #ruby
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RickHull>
you can do a #select loop etc
<argoneus>
and 2) is it difficult in ruby to write unit tests for network stuff? or in general things out of my control
<matthewd>
No more or less difficult than any other language, I wouldn't think
jrafanie has joined #ruby
<RickHull>
i would write as much of your logic as functions (rather than methods) that take small binary strings
<Papierkorb>
argoneus: But as matthewd said, the WS stuff by itself may not really show Ruby. Ruby starts to get really interesting when you're juggling structures
<matthewd>
Either you arrange to mock out the actual IO, or your test has to provide something on the other end of the socket
<RickHull>
and have a thin layer that reads the socket and provides small strings to the logic layer
<argoneus>
well, like I said, it's a text game server
<argoneus>
I need to implement the whole text game logic
<matthewd>
I'd focus on that
polishdub has joined #ruby
<matthewd>
And not spend time reimplementing a protocol layer you can get for free
<Papierkorb>
.. Except if you always wanted to know how websockets work
<argoneus>
hmm, well, here's what I'll do
ek926m has joined #ruby
<RickHull>
for learning and toy projects, it's best to start small rather than ambitious
<Papierkorb>
If you couldn't care less, then ...
<argoneus>
I've never actually tried implementing WS before, so I'll try that first, if it proves to be too painful, I'll use a lib and just make the game instead
<matthewd>
Learning how to write pseudo-C in ruby isn't a good strategy for learning ruby -- but yes, is potentially a great strategy for learning those low level details
<argoneus>
does that work
guacamole has joined #ruby
<argoneus>
I'm a control freak in the sense that I want to know exactly what my program does >_>
<argoneus>
instead of relying on magic function calls
<matthewd>
Then focus on learning not to.. that.
darkmorph has quit [Ping timeout: 264 seconds]
<argoneus>
*that*?
ams__ has quit [Quit: Connection closed for inactivity]
<matthewd>
Because that philosophy does not a productive programmer make.
<argoneus>
I'm still learning, it's not my job yet
<cagomez>
is there a way to conditionally add a k,v to a hash?
<RickHull>
hsh[k] = v if cond
<Papierkorb>
cagomez: `if`
MrPunkin has quit [Quit: MrPunkin]
<argoneus>
then again... I guess there's a learning curve to using the big boy libraries too?
<cagomez>
say I have it like so: {foo:1 , bar: 2}. I want to add :baz if x
workmad3 has quit [Ping timeout: 260 seconds]
<argoneus>
like, I can't just "learn" ruby and then download rails and suddenly be familiar with it, right
<RickHull>
hsh[:baz] = 'quux' if x
ramfjord has joined #ruby
<matthewd>
argoneus: You're obviously free to do what you like -- this is all just Opinions. But yes, there are things to learn anywhere.. and learning when to build and when to "buy" is itself a useful skill.
<RickHull>
argoneus: start with smaller things like a project euler problem
Devalo has joined #ruby
<RickHull>
rather than investing into an architecture blindly
<matthewd>
argoneus: You're going to be learning an API, whose implementation you don't know, either way. Might as well go for the higher level one that gets you closer to a goal.
<Papierkorb>
argoneus: I'll provide a counter to matthewds view and say that if you really want to know how X works, you should learn how to do X. If that's websockets, then that's great! Just do know however that it may not be something you do for 2hrs and "be done" with it. But only you know yourself enough to know if you should add the websocket stuff on top of learning ruby, or not. But I'm on par with saying that the websocket stuff will probably not
<Papierkorb>
teach you what ruby is really good at.
<RickHull>
you'll want to be reasonably fluent in the language before you start thinking about project structure, architecture, how to make things usable and reusable
Psybur has quit [Ping timeout: 248 seconds]
jenrzzz_ has joined #ruby
<argoneus>
I think I see what you mean
<RickHull>
s/thinking about/investing in/
<argoneus>
the average javascript developer is probably way more productive than me
<cagomez>
iterating over hashes in ruby don't have a guaranteed order, right? like {foo: 1, bar: 2}
<argoneus>
but they probably don't know what a higher order function is
<matthewd>
Papierkorb: I'm not sure we're disagreeing :P
<argoneus>
well, they do intuitively
<argoneus>
something like that?
<Papierkorb>
argoneus: Learning is always productive!
<RickHull>
cagomez: they used to be unordered. the current implementation maintains insertion order
<Papierkorb>
argoneus: Even if you go out later on and learned that you hate something, that's an important thing to know
<RickHull>
I believe the order is insertion order
<argoneus>
fair enough
segy has joined #ruby
<argoneus>
I'll just try implementing my own WS until I start hating it
<argoneus>
then I'll look into libs
jenrzzz has quit [Ping timeout: 248 seconds]
<argoneus>
thanks for the help anyhow
mson has joined #ruby
<argoneus>
rubyists seem like a nice bunch :=)
<RickHull>
argoneus: start with that faye project -- look into its codebase and dependencies
<Papierkorb>
argoneus: As I said, Ruby is really good when you start (what I call) to "juggle structures". Kiss that `for` loop good-bye, you won't miss it! Once you get the hang of it, using `each`, `map`, `reduce`, `group_by` (and a ton of other methods like that) gets so much fun that on average, people don't know how they could live without before
<argoneus>
I just realized how the pattern actually works
<argoneus>
the websocket server example isn't the full program, I still need some "rack" to run it in
cagomez has quit [Read error: Connection reset by peer]
<argoneus>
it makes sense now
cagomez has joined #ruby
alex`` has quit [Ping timeout: 248 seconds]
<RickHull>
yeah -- rack is a bit of webserver plumbing -- a standard interface and impl to build webservers from
<Papierkorb>
Rack is *the* base middleware library for webserver things. it connects a webserver lib to the web framework lib on top
<RickHull>
chris2 bless
biberu has quit []
<argoneus>
so basically whenever this "rack" receives a request, it calls the lambda stored in App, and creates a new websocket out of the client
<argoneus>
and then it's just callbacks on events
<argoneus>
well that's simple
hgost has joined #ruby
<RickHull>
Papierkorb has a good point about blocks -- I suggest starting with `each` and seeing how it's handier and cleaner than foreach (only slightly)
<RickHull>
once you get the hang of each, then `map` starts to make sense
<RickHull>
and you see the general pattern
tcopeland has quit [Quit: tcopeland]
<Papierkorb>
argoneus: You mentioend "higher order functions" before. Did you use a FP language before?
Devalo has quit [Ping timeout: 240 seconds]
jenrzzz_ has quit [Ping timeout: 248 seconds]
<argoneus>
I've done a bit of common lisp if you want strictly FP, but python supports higher order functions
<argoneus>
but no, not really
<argoneus>
why?
<argoneus>
I just know what it is
<Papierkorb>
Ah ok. Well, we basically copied `map` and friends from FP.
<argoneus>
yeah
<RickHull>
python's list comprehensions are similar but much clunkier
<Papierkorb>
Ruby is "Good OOP with Functional Programming The Good Parts"
<RickHull>
imho
<argoneus>
I'm familiar with each and map and reduce and such
<argoneus>
kind of
<RickHull>
it's more about being familiar with block semantics
<RickHull>
knowing they are closures
<Papierkorb>
if only "kind of", that'll turn into a "not only kind of" quickly :)
<RickHull>
and how to work with yield
<argoneus>
I'm actually not 100% on block semantics yet
workmad3 has joined #ruby
<argoneus>
the way I see it, when I call "yield x", it passes 'x' into an outside block currently calling the function, then the function does <stuff> and whatever is returned from the block is returned back into the yield statement, so I can assign it or put it back into the structure or such
<argoneus>
probably wrong
<Papierkorb>
nah sounds about correct
<Papierkorb>
blocks are basically embedded anonymous functions. Nothing new in that regard, the interesting part is how it's integrated into the language
<RickHull>
the day you write your first method that takes a block and handles it correctly is the day you become a Rubyist :)
<argoneus>
what I don't understand yet and didn't find proper doc on
<argoneus>
is how to_enum works
<argoneus>
like, if I'm writing some custom each, there's often something like
<RickHull>
it's equivalent to enum.map { |val| yield val }
<RickHull>
(I think, more or less)
milardovich has quit [Remote host closed the connection]
<RickHull>
there is a way to explicitly yield to the block parameter in the method definition, or you can just call naked yield, or you can have an implicit block parameter and do: yield blah if block_given?
<RickHull>
if you yield and ruby can't find a block, it will error
quobo has joined #ruby
<RickHull>
I'm a bit fuzzy on this stuff, beware :)
<argoneus>
my head hurts, but I somewhat get it
<RickHull>
btw, Enumerable#inject and Enumerable#reduce are aliases
<RickHull>
in english, the sigma function says: enum is an array like [1,2,3]; if we have a block, apply the block to the enum; now sum the enum
charliesome_ has joined #ruby
<argoneus>
mm, right
<RickHull>
sigma is written with an explicit block parameter in this case. it could be written with an implicit block parameter
<RickHull>
TMTOWTDI
milardovich has joined #ruby
<matthewd>
argoneus: Yes, an enumerator stores the current state of the method, and can resume it
charliesome has quit [Ping timeout: 240 seconds]
<argoneus>
so enumerator#next just... goes until the next yield, and then pauses again?
<ruby[bot]>
baweaver: # => /tmp/execpad-84ad8895c392/source-84ad8895c392:3: syntax error, unexpected keyword_rescue, expecting ...check link for more (https://eval.in/890970)
<baweaver>
Ack, forgot one
AndBobsYourUncle has joined #ruby
<argoneus>
and it's not just for iterating, I suppose? I can even use blocks as callbacks, like I could have something like file.open { |buf| buf << "text" }, and this will open a file, "yield" a buffer which is filled and then returned, and the file writes it into the file and closes it
marxarelli is now known as marxarelli|afk
<argoneus>
(is that a valid use of blocks? tho I'm sure this is in the std lib already)
<matthewd>
argoneus: Yes. (And yes.)
<Papierkorb>
that's exactly like that in the stdlib
<argoneus>
w-wew
<argoneus>
that makes a ton of sense though!
<matthewd>
Also for callback-callbacks, which will be evaluated later
<RickHull>
I called the FactoryFactory and I'm waiting for a callback-callback
<matthewd>
(as distinct from the file.open example, which you called a callback, but is really more of just a wrapper... the block is only invoked before the original [open, in this case] method returns)
<RickHull>
yeah, you can delay evaluation with blocks
<argoneus>
so in this case, ws is some socket object, and on_message is... some block inside the ws object, and this block is yielded to from the internal implementation whenever there's a message?
<argoneus>
like @message_block
<argoneus>
or something
<RickHull>
Log.warn build_a_huge_expensive_string() vs. Log.warn { build_a_huge_expensive_string() }
<matthewd>
on_message is a method on the websocket, which will take its given block, and store it away for later use, yes
<argoneus>
!!
<RickHull>
in the second form, if your log level is ERROR, then you don't incur the expense
<argoneus>
I get it, then :D
<argoneus>
this is awesome
<argoneus>
seems like all blocks are are just anonymous functions that take some arguments (or don't)
<RickHull>
i could have sworn someone said that already ;)
<argoneus>
anyway, thanks a lot for the discussion! I learned a lot today
<argoneus>
I feel a lot more confident in actually writing something now
<argoneus>
have a good evening
<baweaver>
'night
<RickHull>
cheers!
nopolitica has joined #ruby
jamesaxl has joined #ruby
<c-c>
- For one I don't know if its a necessary thing to sleep while trying to create a file with system-command, or perhaps that only returns once the file exists.
vipaca has joined #ruby
<RickHull>
it seems like you'll create several and error out or leak something
<Papierkorb>
c-c: 1) underscore prefixes for local vars is weird, throw them out 2) line 2: that's just `if msg&.include? wait_on_str` 3) Aalso, don't put ( ) around conditions 4) Line 30, don't #exit, raise an error instead 5) line 13, remove it, #system only returns once the command ran to completion
<RickHull>
and sleep is almost never the right thing to do in a method
<RickHull>
almost certainly mkfifo will block until the resource is created or ready
GodFather has quit [Ping timeout: 258 seconds]
<Papierkorb>
c-c: 6) that method can do one thing: Creating and opening a named pipe (That's actually two already!). It shouldn't also wait_on_str on top of that, refactor that feature into a new method
<elomatreb>
Even if it doesn't, re-trying the same operation would not be the correct thing
<RickHull>
create it once, sleep until it exists
<RickHull>
but I wouldn't even
<Papierkorb>
c-c: 7) line 11, instead of `while !`, use `until`: `until File.exist? pipe_path`
<RickHull>
only crappy APIs make you resort to sleep polling
<c-c>
Papierkorb: wow! thanks B)
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RickHull>
c-c: you can examine behavior quickly and easily in a REPL like pry or irb
nopolitica has quit [Ping timeout: 248 seconds]
nopolitica has joined #ruby
<RickHull>
if you're ever tempted to do sleep polling, ask yourself if you're dealing with a crappy API (probably not) or if there is a better way to use it (likely)
vee__ has joined #ruby
<Papierkorb>
c-c: 8) line 12: Avoid using `system("program arg1 arg2 ...")`. Use `system(program, [ arg1, arg2, ... ])` instead. Among other things, your line there will inject the pipe_path into a SHELL. If a (remote) user could control pipe_path, they can do a "shell injection" attack on you (This attack is popular with shitty consumer routers)
<Papierkorb>
c-c: You require the first form only if you need shell features, like pipes. If you somehow end up needing that form, use Shellwords, like: `system("ls #{Shellwords.escape some_var}")`. This will escape "some_var" so it can be passed safely there without causing security issues
<Papierkorb>
Um yeah I guess that's about it from my end
<RickHull>
I always drift toward popen3 or popen2 APIs for dealing with subprocesses
charliesome has joined #ruby
guacamole has joined #ruby
<Papierkorb>
There's nothing wrong with #system if all you want to is to call a command and only check if it was successful.
mtkd has quit [Ping timeout: 240 seconds]
<Papierkorb>
Which is also missing in the showcased code snippet :P
charliesome_ has quit [Ping timeout: 248 seconds]
safetypin has quit [Ping timeout: 248 seconds]
<elomatreb>
Even if you discount the security perspective, using the multi-argument form of the subprocess methods is just easier than dealing with escaping for e.g. weird filenames
jphase has quit [Remote host closed the connection]
mtkd has joined #ruby
jphase has joined #ruby
charliesome_ has joined #ruby
jphase has quit [Ping timeout: 258 seconds]
charliesome has quit [Ping timeout: 248 seconds]
Ltem has quit [Quit: Leaving]
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jphase has joined #ruby
vipaca has joined #ruby
cagomez has quit [Remote host closed the connection]
<elomatreb>
chiggins: For the very basic distinctions like that you should be able to do that just by comparing the length of the string
kapil___ has quit [Quit: Connection closed for inactivity]
<chiggins>
elomatreb: Yeah that's kind of what I was just thinking. Wasn't sure if there was a more elegant way to do that
<apeiros>
/\A\h{@hashlength}\z/
<apeiros>
where @hashlength is the length of the given hash function
<apeiros>
+of the output
<elomatreb>
Normally if you need to process a Hash somewhere either the algorithm should be standardized or there should be a tag on the hash string ("SHA256:deadbeef....")
<elomatreb>
It won't be able to distinguish between e.g. SHA2 and truncated SHA3 hashes of the same length, and will not work with base64 encoded hashes (e.g. BLAKE hashes are often base64'd instead of hex, for some reason)
vipaca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<chiggins>
I hear ya. Goal here is to just check any random input, such as IP address or string or whatever. If not IP, check if hash. If not has, then disregard
cagomez has quit [Ping timeout: 248 seconds]
<RickHull>
i mean, a hash is effectively a nonce in some integer space
oleo has quit [Quit: Leaving]
<RickHull>
it would be pretty hard to distinguish any value that could map into an integer space from a nonce
<RickHull>
but uh, carry on :)
jphase has quit [Ping timeout: 258 seconds]
<chiggins>
¯\_(ツ)_/¯
<chiggins>
No worries, I know what I'm doing for the most part
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<chiggins>
It doesn't need to be 100% valid
<chiggins>
More of a sanity check
InfinityFye has quit [Quit: Leaving]
<RickHull>
it might be better to have a whitelist of accepted formats
cadillac_ has quit [Ping timeout: 246 seconds]
<RickHull>
or I guess def is_hash_looking?(some_str) # returns a score
<elomatreb>
tbh if you have any control over the data just specify The One True Algorithm, it's the only sane option in the long run
<elomatreb>
(Oh, and encoding as well)
vipaca has joined #ruby
hgost has quit [Ping timeout: 240 seconds]
cadillac_ has joined #ruby
vipaca has quit [Read error: Connection reset by peer]
<chiggins>
RickHull: I like that idea
vee__ has quit [Ping timeout: 240 seconds]
<RickHull>
it could get expensive trying to determine if it looks random enough or whatever
orbyt_ has joined #ruby
<RickHull>
also, my own fault, a predicate method ending in question mark should return a boolean. probably: def hash_looking_score(str) # returns a score; def is_hash?(str, threshold) # calls hash_looking_score
ledestin has joined #ruby
<RickHull>
what are the odds I can get lorem_ipsum out of md5?
<c-c>
al2o3-cr: looks like it would work fine here
<al2o3-cr>
it'll sure save you a lot of hassle. :)
polishdub has quit [Quit: leaving]
Devalo has quit [Ping timeout: 240 seconds]
mson has quit [Quit: Connection closed for inactivity]
<RickHull>
I like to keep the "happy path" very simple and clean. I don't write conditionals to handle edge cases if the happy path will raise an exception for me
gnufied has quit [Ping timeout: 252 seconds]
<RickHull>
I don't write a lot of rescue clauses except at very outer layers
mson has joined #ruby
<c-c>
In the engine I'm going to use a temp directory with the pid in the name, so the pipes will be in a unique location
_sfiguser has quit [Quit: Leaving]
<RickHull>
you'll have to be careful that boundaries are maintaining their contracts
<RickHull>
or just enforce your contracts and stop worrying
conta1 has joined #ruby
<c-c>
well, it now allows you to make pipes/use existing, otherwise fails
<RickHull>
if I'm not sure that the happy path will raise exceptions for me, then I will do extensive validation at the top of the method with a lot of raises
<c-c>
not sure if should retry on open or not.
<c-c>
or if should also have limit on the number of retries
cagomez has quit [Remote host closed the connection]
<RickHull>
retries almost always backfire
<RickHull>
about 1% of my rescues have retries, and half of those backfired on me
cagomez has joined #ruby
<RickHull>
just fail fast and let some outer layer deal with it
<RickHull>
don't bother with a retry to start with. it can be helpful to have it available for some later patch
chiggins has left #ruby ["WeeChat 1.7.1"]
jgt_ has joined #ruby
jgt has quit [Read error: Connection reset by peer]
cagomez has quit [Remote host closed the connection]
<RickHull>
keep your scope small: do the one thing, and only if you get good data passed in. validate the data, do the thing. if the underlying system fails, then you probably don't have the context to know the remedy
conta1 has quit [Ping timeout: 258 seconds]
cagomez_ has joined #ruby
charliesome_ has joined #ruby
charliesome has quit [Ping timeout: 255 seconds]
AndBobsYourUncle has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jdawgaz has joined #ruby
sepp2k has quit [Quit: Leaving.]
<RickHull>
put another way: use retries only if you're sure you need to. a lot of overly complicated code has bugs resulting from premature anticipation
<c-c>
hehe not sure what else to put in the rescue clause
<c-c>
*block
<RickHull>
what's the latest?
<RickHull>
same url?
<RickHull>
yeah, don't rescue there
<RickHull>
if mkfifo fails, then bomb out
<RickHull>
er File#open, or whatever
apeiros has joined #ruby
<RickHull>
probably you want to have 0 rescues and 0 up to 5 or 10 raises in that method definition