<b100s>
havenwood, thanks, what about Tempfile, can I avoid using it in my webserver?
ARCADIVS has quit [Ping timeout: 246 seconds]
<b100s>
I would like to not rely on disk and just calculate everything on fly
<havenwood>
b100s: Where does the tempfile come into it? I'm not quite following.
<b100s>
in gist : )
<havenwood>
b100s: If you need to read a file, you can use File.open to avoid the whole file in memory at once, and feed it to the digest in pieces.
<b100s>
havenwood, everything in the gist file; I do not know other way to upload files in ruby
konsolebox has quit [Ping timeout: 264 seconds]
<havenwood>
b100s: Typically if you want a file, but in memory, you'd use StringIO
dogweather has quit [Ping timeout: 250 seconds]
<b100s>
So, I need to create File and somehow get stream from sinatra?
konsolebox has joined #ruby
amar has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
bsartek has joined #ruby
ta_ has joined #ruby
bsartek has quit [Client Quit]
dogweather has joined #ruby
znz_jp has quit [Remote host closed the connection]
ARCADIVS has joined #ruby
amar has quit [Ping timeout: 256 seconds]
voxxit has quit [*.net *.split]
<havenwood>
b100s: I guess the tempfile pattern is to avoid having the thing all in memory at once anyways. Reading lines or bytes from a tempfile and shoving them onto a digest keeps it low mem.
znz_jp has joined #ruby
<b100s>
havenwood, heh, you can try on your local and be sure it is not : )
<b100s>
I mean my gist
dogweather has quit [Ping timeout: 240 seconds]
<havenwood>
try what about it?
aupadhye|food has joined #ruby
<havenwood>
b100s: someone else might spot what you mean more easily - it's been a while since i've used sinatra and i'm distracted atm
<havenwood>
shynoob: REPLs are really handy for quick feedback while learning. Ruby ships with IRB or you can install the Pry gem.
<havenwood>
?irb
<ruby[bot]>
irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
<havenwood>
?pry
<ruby[bot]>
Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<havenwood>
shynoob: Try the tryruby.org examples in irb by typing from your terminal: irb
<dminuoso>
13:34 NL3limin4t0r | Is there a cleaner way to map a certain key of an array of hashes?
<dminuoso>
wat
ta_ has quit [Remote host closed the connection]
<dminuoso>
But yes. The solution is called lenses.
<apeiros>
NL3limin4t0r: baweaver has a lib which helps with that
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
houhoulis has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
houhouli_ has quit [Ping timeout: 260 seconds]
<NL3limin4t0r>
dminuoso: ty, I'll look into it.
houhouli_ has joined #ruby
ta_ has joined #ruby
VladGh has quit [Quit: Lost terminal]
VladGh has joined #ruby
houhoulis has quit [Ping timeout: 240 seconds]
duderonomy has quit [Ping timeout: 246 seconds]
petems has quit [Quit: Connection closed for inactivity]
Liothen has quit [Remote host closed the connection]
G has quit [Remote host closed the connection]
duderonomy has joined #ruby
ta_ has quit [Remote host closed the connection]
matled has quit [Remote host closed the connection]
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
raynold has quit [Quit: Connection closed for inactivity]
Liothen has joined #ruby
anisha_ has quit [Quit: This computer has gone to sleep]
anisha_ has joined #ruby
ta_ has joined #ruby
variable has joined #ruby
ferr has joined #ruby
fyrril has joined #ruby
matled has joined #ruby
chocoelho has joined #ruby
alfiemax has quit [Remote host closed the connection]
ruby549 has joined #ruby
al2o3-cr has quit [Ping timeout: 240 seconds]
DTZUZO_ has joined #ruby
uptime has quit [Ping timeout: 240 seconds]
houhouli_ has quit [Remote host closed the connection]
Beams_ has joined #ruby
Beams has quit [Ping timeout: 256 seconds]
samosaphile has joined #ruby
<konsolebox>
NL3limin4t0r: [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].map{ |hash| hash[:a] } is already the cleanest. you make it too complicated.
ta_ has quit [Remote host closed the connection]
* apeiros
had Enumerable#map_aref in his utils for some time
<apeiros>
i.e. ary.map_aref :a
awx has joined #ruby
ellcs has joined #ruby
<konsolebox>
i'm not a fan of this, but the next "clean" solution for me would be `.map(&:[], :a)`. Someone can prepend modules to Array and Enumerable and enhance map.
<RougeR>
not_null constraints failing on timestamps
<konsolebox>
with magic, we can even a unified extension module both for Enumerable and Array. i think there's a way for the module to know its "includer".
<konsolebox>
*even have
k0mpa has joined #ruby
<apeiros>
RougeR: rails covers AR better than ruby, hence you should ask in #rubyonrails
<apeiros>
oh, cross-poster
<apeiros>
?crossposting RougeR
<ruby[bot]>
apeiros: I don't know anything about crossposting
<apeiros>
meh
<apeiros>
?crosspost RougeR
<ruby[bot]>
RougeR: 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.
<RougeR>
sorry apeiros
<RougeR>
ill bear that in mind going forward
<apeiros>
thank you
<RougeR>
sorted it
<RougeR>
im an idiot :)
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
banisterfiend has joined #ruby
duderonomy has joined #ruby
ryzokuken has joined #ruby
jottr has joined #ruby
<apeiros>
baweaver: I think your libraries can do that too already, what would be the equivalents with them? https://eval.in/1002145
<apeiros>
though for .map(&:values_at.with(:a, :c)) I actually prefer Enumerable#pluck(:a, :c)
<NL3limin4t0r>
apeiros & konsolebox thanks for your input. I like how apeiros adds the Array#to_proc method, I hadn't thought about that.
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
skweek has joined #ruby
<dminuoso>
Woah you dont need that much crazy stuff :|
<dminuoso>
All you really need is Proc#* and thats it
<dminuoso>
As a poor mans solution:
<NL3limin4t0r>
RougeR: You forgot to add the attributes to Gym object in the #create, but I guess you already figgered that out.
<RougeR>
NL3limin4t0r: yeah, i was being dumb. staring at a screen too long
<dminuoso>
Oh well I cant be arsed :|
ta_ has quit [Ping timeout: 268 seconds]
<apeiros>
dminuoso: that's not a poor man's solution, that's a broke man's solution ;-p
<dminuoso>
apeiros: the main problem is
<dminuoso>
apeiros: he's abusing map the completely wrong way
<apeiros>
btw., I have most of this stuff in my pryrc because it makes transforming csv's quite concise
aupadhye|food has quit [Ping timeout: 246 seconds]
gnufied has joined #ruby
Asher has quit [Ping timeout: 260 seconds]
duderonomy has quit [Client Quit]
stairmast0r has quit [Ping timeout: 256 seconds]
jottr has quit [Ping timeout: 248 seconds]
<samosaphile>
anyone have experience building a simple web crawler using curl? (ideally looking for spoon-feeding / hand-holding, just being honest)
Rapture has joined #ruby
stairmast0r has joined #ruby
<jforceBEE>
samosaphile Just curious, why are you asking for advice on curl in a ruby chat?
<jforceBEE>
One idea off the top of my head is that you will need to use bash or soemthing to create some kind of loop to crawl a web site
jottr has joined #ruby
orbyt_ has joined #ruby
<samosaphile>
dunno, was just wondering, maybe some knows or offer some kind of guidance, you never know without trying ... #curl chat is always pretty much dead, so i won't even try there
<samosaphile>
ok
<samosaphile>
someone*
<NL3limin4t0r>
dminuoso: That's a nice example example, but 1. You changed the structure of the array from: [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}] to [{a: [1,2]}, {a: [3,4]}, {a: [5,6]}], 2. By changing the stucture you made it more complicated, having the `at = -> i, o { o[i] }.curry` would have been enough. Good solution though.
<jforceBEE>
makes sense. Honestly writing a crawler with curl sounds like a headache. Have you tried scrapy? Python library
jottr has quit [Ping timeout: 240 seconds]
Asher has joined #ruby
solocshaw has joined #ruby
<samosaphile>
yeh, but trying to avoid using something like scrapy, it's just too big and heavy. it has all this extra baggage and functionality but for me is unecessary as what im trying to crawl is quite simple (or so i believe it to be)
<apeiros>
why do you care about the unnecessary baggage?
<samosaphile>
but maybe i'll just use it if no other option...
<apeiros>
I mean, just don't use the parts you don't need.
<jforceBEE>
Could just be too noisy
<apeiros>
and crawling nowadays is anything but simple
<jforceBEE>
You can search for "ruby web crawler" and there are some tuts that pop up for writing a simple web crawler. Maybe you can check them out and write one in ruby that is more lightweight
<apeiros>
unless you're crawling sites from the last millenium, you need an engine which can actually understand the dom and let js manipulate it
<jforceBEE>
And if you go with ruby, nokogiri is a great library for parsing DOM
<samosaphile>
cuz that is all i need one for...
Asher has quit [Ping timeout: 264 seconds]
<apeiros>
if you just want to mirror a relatively static site, wget iirc has a direct command for that
<apeiros>
either --archive or --mirror or somesuch
<apeiros>
and curl probably too
<jforceBEE>
or httrack will also clone a website really good
<apeiros>
just google for "archive website" or "mirror website"
<apeiros>
and throw curl/wget into the mix. you should find something.
<jforceBEE>
apeiros: good call with the mirroring. Gets the entire site at once
solocshaw has quit [Client Quit]
ferr has quit [Quit: WeeChat 2.1]
lucasb has joined #ruby
samosaphile has quit [Ping timeout: 260 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
samosaphile has joined #ruby
kmurphy4 has joined #ruby
mikecmpb_ has joined #ruby
dogweather has quit [Remote host closed the connection]
mikecmpbll has quit [Ping timeout: 264 seconds]
dogweather has joined #ruby
tomphp has joined #ruby
cschneid_ has quit [Remote host closed the connection]
banisterfiend has joined #ruby
tomphp has quit [Client Quit]
dcunit3d has joined #ruby
synthroid has joined #ruby
dogweather has quit [Ping timeout: 264 seconds]
kmurphy4 has quit [Quit: kmurphy4]
rippa has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ruby549 has quit [Quit: Page closed]
ferr has joined #ruby
dogweather has joined #ruby
ellcs has joined #ruby
maufart__ has quit [Ping timeout: 276 seconds]
cagomez has joined #ruby
mikecmpb_ has quit [Quit: inabit. zz.]
mikecmpbll has joined #ruby
Liothen has quit [Remote host closed the connection]
Liothen has joined #ruby
jinie has quit [Ping timeout: 255 seconds]
Liothen has quit [Changing host]
Liothen has joined #ruby
dogweather has quit [Ping timeout: 256 seconds]
chocoelho has quit [Quit: Konversation terminated!]
mostlybadfly has quit [Quit: Connection closed for inactivity]
jinie has joined #ruby
nowhere_man has quit [Ping timeout: 256 seconds]
tdy has joined #ruby
ramfjord has joined #ruby
schleppel has quit [Ping timeout: 250 seconds]
dogweather has joined #ruby
cschneid_ has joined #ruby
ramfjord has quit [Ping timeout: 250 seconds]
variable has quit [Ping timeout: 276 seconds]
ciscam has quit [Ping timeout: 256 seconds]
chouhoulis has joined #ruby
chouhoulis has quit [Read error: Connection reset by peer]
chouhoulis has joined #ruby
ciscam has joined #ruby
hgost has joined #ruby
tomphp has joined #ruby
tomphp has quit [Client Quit]
cschnei__ has joined #ruby
RedNifre has joined #ruby
cschneid_ has quit [Ping timeout: 248 seconds]
karapetyan has quit [Remote host closed the connection]
\void has joined #ruby
karapetyan has joined #ruby
banisterfiend has joined #ruby
coriander has joined #ruby
banisterfiend has quit [Client Quit]
roamingdog has joined #ruby
tomphp has joined #ruby
<coriander>
Hello! I'm trying to run rspec on Ubuntu 16.04 with ruby 2.3.1, but it gives the message "/usr/bin/env: ‘ruby2.1’: No such file or directory". Any Idea of how I fix this?
Silthias has joined #ruby
guille-moe has joined #ruby
oleo has quit [Remote host closed the connection]
banisterfiend has joined #ruby
oleo has joined #ruby
roamingdog has quit [Ping timeout: 240 seconds]
banisterfiend has quit [Client Quit]
oleo has quit [Remote host closed the connection]
oleo has joined #ruby
banisterfiend has joined #ruby
blackmesa has joined #ruby
<havenwood>
coriander: What command are you runnin gto run rspec?
KeyJoo has quit [Read error: Connection reset by peer]
<havenwood>
coriander: It sounds like you don't have that command installed, or at least in front of your path, for Ruby 2.3.
blackmesa has quit [Client Quit]
<havenwood>
coriander: Check the shebang of the command you're running, for example if it's rspec: head -n1 "$(command -v rspec)"
brodul has quit [Remote host closed the connection]
variable has quit [Ping timeout: 275 seconds]
banisterfiend has joined #ruby
mohsen_1 has joined #ruby
piixal has joined #ruby
lytol has joined #ruby
orbyt_ has joined #ruby
tomphp has joined #ruby
eckhardt has joined #ruby
raynold has joined #ruby
emilford has quit [Ping timeout: 256 seconds]
emilford has joined #ruby
ciscam has quit [Ping timeout: 256 seconds]
RougeT430 has joined #ruby
amatas has quit [Remote host closed the connection]
synthroid has quit [Remote host closed the connection]
ciscam has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
amatas has joined #ruby
RougeR has quit [Ping timeout: 240 seconds]
emilford has quit [Ping timeout: 240 seconds]
amar has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
kirun has joined #ruby
nima_m has joined #ruby
emilford has joined #ruby
conta has quit [Ping timeout: 276 seconds]
dogweather has quit [Ping timeout: 264 seconds]
piixal has quit [Quit: Leaving...]
alfiemax has joined #ruby
RougeT430 has quit [Ping timeout: 250 seconds]
Beams_ has quit [Quit: .]
dcunit3d has joined #ruby
dogweather has joined #ruby
mzo has quit [Ping timeout: 250 seconds]
dionysus69 has joined #ruby
jinie has quit [Ping timeout: 240 seconds]
anisha_ has quit [Quit: This computer has gone to sleep]
n0m4d1c has joined #ruby
govg has quit [Ping timeout: 250 seconds]
ramfjord has quit [Ping timeout: 256 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has joined #ruby
blackmesa has joined #ruby
emilford has quit [Ping timeout: 265 seconds]
Cavallari has joined #ruby
dogweather has quit [Read error: Connection timed out]
skweek has quit [Read error: Connection reset by peer]
<TomyLobo>
there's attr_accessor to save me writing accessors. is there something to save me writing a constructor that just fills all the fields from parameters?
dogweather has joined #ruby
anisha_ has joined #ruby
<dminuoso>
TomyLobo: There's Struct
<dminuoso>
>> a = Struct.new(:name, age); a.new("Isaac Newton", 21)
<ruby[bot]>
dminuoso: # => undefined local variable or method `age' for main:Object (NameError) ...check link for more (https://eval.in/1002282)
<dminuoso>
>> a = Struct.new(:name, :age); a.new("Isaac Newton", 21)
<apeiros>
anything beyond 2 arguments should be by name. and often even already with 2.
<havenwood>
^
alfiemax has quit [Ping timeout: 265 seconds]
<apeiros>
and sometimes even the first already - or would you for example know what the false means in some_obj.methods(false)? (and that's a ruby core method)
<havenwood>
apeiros: i totally agree - if it's not clear what the one-and-only argument is, a name is far preferable
<havenwood>
some_obj.methods private_only: true
<havenwood>
so much better
<havenwood>
it's easier to write code than to read it
<apeiros>
yupp
<apeiros>
but I have to admit, I have to force myself too to do it properly
anisha_ has quit [Quit: This computer has gone to sleep]
<havenwood>
aye, pre-kwarg habits are hard to break for me too
<apeiros>
but true keyword args made it a lot more bearbale to me
<havenwood>
i have to keep reminding myself
<apeiros>
*bearable
* apeiros
goes back to js without either kwargs, nor even syntax sugar for hashmap passing - and even less so block passing *sob*
<apeiros>
js syntax, sooo tedious. at least they've ... and ()=>{} now.
BTRE has joined #ruby
psychicist__ has joined #ruby
<apeiros>
biggest fuckup though is "assign without explicit scope? you've got a global now, yaaaay!"
emilford has quit [Ping timeout: 260 seconds]
pilne has joined #ruby
blackmesa has quit [Ping timeout: 256 seconds]
alex`` has quit [Quit: WeeChat 2.1]
kmurphy4 has joined #ruby
ta_ has quit [Ping timeout: 260 seconds]
facest has quit [Read error: Connection reset by peer]
facest has joined #ruby
minimalism has joined #ruby
<dminuoso>
havenwood: Ultimately the real problem is lack of a type system.
eikobear has quit [Ping timeout: 240 seconds]
amatas has quit [Quit: amatas]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kapil___ has joined #ruby
bmurt has joined #ruby
eckhardt has joined #ruby
eckhardt has quit [Client Quit]
emilford has joined #ruby
kmurphy4 has quit [Quit: kmurphy4]
Zaab1t1 is now known as Zaab1t
eikobear has joined #ruby
tomphp has joined #ruby
MzrE has joined #ruby
mostlybadfly has joined #ruby
kmurphy4 has joined #ruby
chouhoul_ has joined #ruby
<TomyLobo>
havenwood, interesting, but cant Struct just generate both?
<TomyLobo>
possibly a performance thing ^^
chouhoulis has quit [Ping timeout: 268 seconds]
RougeT430 has quit [Quit: Leaving]
RougeR has joined #ruby
<apeiros>
TomyLobo: you mean at the same time?
tomphp has quit [Read error: Connection reset by peer]
<apeiros>
that'd be a problem since how'd you distinguish between the first argument being a hash, or them being keyword args?
tomphp has joined #ruby
<TomyLobo>
uh isnt that what **kwargs is for or am i confusing that with python now?
<TomyLobo>
i probably am
<apeiros>
that does not help
<apeiros>
due to the very sad decision that foo(bar: 1, baz: 2) is a syntactical equivalent to foo({bar: 1, baz: 2})
n0m4d1c has quit [Remote host closed the connection]
<apeiros>
ruby can literally not distinguish your intention in this case.
<TomyLobo>
i think that's called cutting yourself with occams razor
<apeiros>
I think it was just a terrible choice.
<apeiros>
intended as a stop-gap, not realizing how it'd backfire (or rather limit disambiguity) in the future.
jottr has joined #ruby
<apeiros>
*limit ambiguity
n0m4d1c has joined #ruby
MzrE has quit [Remote host closed the connection]
Mike11 has joined #ruby
Mike11 has quit [Max SendQ exceeded]
synthroid has quit []
n0m4d1c has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 250 seconds]
n0m4d1c has joined #ruby
roamingdog has joined #ruby
RedNifre has quit [Ping timeout: 268 seconds]
alfiemax_ has quit [Remote host closed the connection]
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
eikobear has quit [Ping timeout: 260 seconds]
chmuri has quit [Excess Flood]
nofxx has joined #ruby
karapetyan has quit [Remote host closed the connection]
chmurifree has joined #ruby
BTRE has quit [Read error: Connection reset by peer]
alfiemax has quit [Read error: Connection reset by peer]
alfiemax has joined #ruby
n0m4d1c_ has joined #ruby
n0m4d1c has quit [Read error: Connection reset by peer]
emilford has quit [Ping timeout: 256 seconds]
<dminuoso>
asm>> foo(bar: 1, baz: 2)
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/1002362
<dminuoso>
asm>> foo({bar: 1, baz: 2})
samosaphile has quit [Quit: Page closed]
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/1002363
<apeiros>
dminuoso: does it match your expectation?
<dminuoso>
I had none to begin with
chouhoul_ has quit [Remote host closed the connection]
iceden has quit [Remote host closed the connection]
chouhoulis has joined #ruby
kmurphy4 has quit [Quit: kmurphy4]
nima_m has quit [Quit: Connection closed for inactivity]
jrafanie has joined #ruby
za1b1tsu_ has quit [Ping timeout: 240 seconds]
dviola has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has joined #ruby
tomphp has quit [Client Quit]
mohsen_1 has quit [Quit: Connection closed for inactivity]
Guest27 has joined #ruby
psychicist__ has quit [Quit: Lost terminal]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chongtxtx has joined #ruby
vee_ has quit [Ping timeout: 255 seconds]
<claw>
hello i am having encoding fun on windows
<claw>
irb(main):001:0> `echo öööööö`
<claw>
=> "\x94\x94\x94\x94\x94\x94\n"
<claw>
chcp for cmd is CP850
<claw>
Encoding.default_external is also CP850
<dminuoso>
claw: default_external is irrelevant here
<apeiros>
dminuoso: um, no, it's not
<apeiros>
``.encoding will be cp850 due to default_external
<apeiros>
anyway, I'll wait for the actual question :)
<claw>
apeiros: the actual question is how to get the "ö" back into irb
<apeiros>
claw: that depends. what encoding does your terminal application use?
<claw>
CP850 as `chcp` says
<dminuoso>
apeiros: What about __ENCODING__ ?
<apeiros>
claw: try puts
<apeiros>
as in: puts `echo ööööö`
<claw>
__ENCODING__ == CP850
Guest27 is now known as arup_r
<claw>
apeiros: well puts works somehow
<apeiros>
claw: what you're looking at is String#inspect
<apeiros>
I'm not quite sure on String#inspect's decision making on when to print bytes as hex escape sequences and when as their actual value. puts however will always print the value
arup_r has quit [Remote host closed the connection]
<claw>
nicht if i do `echo öööö > file` ; puts File.read("./file") its broken again
<apeiros>
apparently with your current setting, it decides that \x94 (ö) is not (or may not be) a printable character and hence shows its escape sequence instead.