tenderlove has quit [Remote host closed the connection]
benlieb has quit [Client Quit]
<andll>
When I download an image with open-uri -- file = open(url) -- the result is different than reading a file with say File.read(file_path, 'rb'). I suspect the encoding is different, but I'm not sure how to check. What else might be different? How do I force the result to be the same?
skweek has quit [Ping timeout: 240 seconds]
benlieb has joined #ruby
solocshaw has quit [Remote host closed the connection]
johnmilton has joined #ruby
<jazzonmym11nd>
andll: you can check encoding with String#encoding
minimalism has joined #ruby
<andll>
jazzonmym11nd: thanks, I'll try that
nertzy has joined #ruby
<jazzonmym11nd>
i think you want both to return ASCII-8BIT
benlieb has quit [Client Quit]
<al2o3-cr>
andll: binary, that is all
quazimodo has quit [Ping timeout: 244 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
<jazzonmym11nd>
the file you're downloading could be compressed or encoded some other way as well, you'd need to drop down to Net::HTTP to check.
wjimenez5271 has joined #ruby
moby has quit [Ping timeout: 264 seconds]
<andll>
jazzonmym11nd: thanks
<andll>
al2o3-cr: thanks
<jazzonmym11nd>
or just use curl -I from your shell.
RedNifre_ has joined #ruby
jphase has quit []
solocshaw has joined #ruby
ramfjord has quit [Ping timeout: 260 seconds]
karmatr0n has quit [Ping timeout: 255 seconds]
calmchaos has joined #ruby
benlieb has joined #ruby
RedNifre has quit [Ping timeout: 276 seconds]
jphase has joined #ruby
Sashimi has joined #ruby
quazimodo has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
calmchaos has quit [Ping timeout: 265 seconds]
zacstewart has quit [Ping timeout: 244 seconds]
nitric has quit [Ping timeout: 255 seconds]
dogweather has quit []
Dispatch has quit [Remote host closed the connection]
astrobun_ has quit [Remote host closed the connection]
symm- has joined #ruby
polysics has joined #ruby
greister_ has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
bkxd has joined #ruby
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
agent_white has quit [Quit: headingHome]
flashpoint9 has joined #ruby
coolboy has joined #ruby
<andll>
there must be some other difference. When I download the Google image via open-uri the type is apparently binary. When I try to then POST the image to an API via rest-client the result fails. Whereas if I read the image with File.new(file_path, 'rb') then perform the same operation with rest-client, the result succeeds.
<andll>
is it because one is a a 'stream' or something
solocshaw has quit [Remote host closed the connection]
<al2o3-cr>
>> (1670708/13).chr('utf-8').*(80) << ' be happy, don\'t worry'
<ruby[bot]>
al2o3-cr: # => "😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄 be happy, don't wo ...check link for more (https://eval.in/638270)
saneax is now known as saneax-_-|AFK
pochoa has quit [Ping timeout: 250 seconds]
CloCkWeRX has joined #ruby
mwlang has quit [Remote host closed the connection]
benlieb has quit [Remote host closed the connection]
mwlang has joined #ruby
<al2o3-cr>
andll: show us your knickers on gist
danostrowski has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
duderonomy has quit [Ping timeout: 250 seconds]
<al2o3-cr>
erm... i mean code :)
solocshaw has joined #ruby
<jazzonmym11nd>
lol
<jazzonmym11nd>
weird typo
finisherr has quit [Remote host closed the connection]
<al2o3-cr>
:p
wldcordeiro has joined #ruby
Bellthoven has joined #ruby
habitullence has quit [Ping timeout: 244 seconds]
jenrzzz has quit [Ping timeout: 255 seconds]
tdy has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
<andll>
al2o3-cr: I'd have to censor the code, as it's for work. But in short, I'm convinced the result of open(url) with open-uri is different than File.new(file_path, 'rb')
postmodern has joined #ruby
<jazzonmym11nd>
andll: did u try curl -I the url cos it could be gzip'ed.
statelesscode has quit [Ping timeout: 265 seconds]
Sashimi has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jazzonmym11nd>
bbiab
robfrawley has joined #ruby
_djbkd has quit [Remote host closed the connection]
robfrawley is now known as Guest34289
_djbkd has joined #ruby
calmchaos has quit [Ping timeout: 255 seconds]
shmuli has joined #ruby
BlkDynmt has quit [Ping timeout: 250 seconds]
Littlemyu_ has joined #ruby
JeanCarloMachado has joined #ruby
JeanCarl1Machado has joined #ruby
_djbkd has quit [Ping timeout: 264 seconds]
Mattx has joined #ruby
andll has quit [Quit: Page closed]
amclain has quit [Quit: Leaving]
ramfjord has joined #ruby
<Mattx>
Does ruby really support threads?
nankyokusei has joined #ruby
BTRE has quit [Ping timeout: 276 seconds]
<Mattx>
I'm processing two task A and B multiple times, around 15 seconds each. After the first A task I'm starting a thread to process B while at the same time I process the second A, and so on
shmuli has quit [Remote host closed the connection]
<al2o3-cr>
Mattx: knots on cotton, if thats what you mean
<Mattx>
But now those tasks finish together, but in 30 seconds
<Mattx>
it's having the same performance with or without threads
<al2o3-cr>
Mattx: are these tasks IO?
<Mattx>
al2o3-cr, I've no idea what you meant
<Mattx>
al2o3-cr, B is IO
<al2o3-cr>
Mattx: fork it
<Mattx>
kind of, it's actually saving to a pgsql database
moby has joined #ruby
CloCkWeRX has quit [Remote host closed the connection]
JeanCarl1Machado has quit [Remote host closed the connection]
JeanCarloMachado has quit [Remote host closed the connection]
charliesome has joined #ruby
BTRE has joined #ruby
shmuli has joined #ruby
<jazzonmym11nd>
Mattx: it does but there's a lock so that only one thread is running unless threads are IO bound.
nankyokusei has quit [Ping timeout: 260 seconds]
<Mattx>
how would you improve the performance in my scenario?
<jazzonmym11nd>
you could try using fork() and see if that's any better.
ruby_ has quit [Remote host closed the connection]
ruby_ has joined #ruby
mdgmt has joined #ruby
astrobun_ has quit [Ping timeout: 244 seconds]
rodfersou|afk has quit [Quit: leaving]
Ropeney has joined #ruby
ruby_ has quit [Ping timeout: 265 seconds]
capitainIsh has joined #ruby
tax has joined #ruby
hutch34_ has joined #ruby
govg has quit [Ping timeout: 260 seconds]
alfiemax has quit [Ping timeout: 252 seconds]
Guest34289 has quit [Ping timeout: 244 seconds]
hahuang61 has joined #ruby
shmuli has quit [Remote host closed the connection]
Dispatch has quit [Remote host closed the connection]
banisterfiend has quit [Ping timeout: 240 seconds]
zeroDi has quit [Quit: WeeChat 1.5]
greister__ has joined #ruby
elvis4526 has quit [Ping timeout: 250 seconds]
greister_ has quit [Ping timeout: 265 seconds]
robfrawley has joined #ruby
robfrawley is now known as Guest90323
astrobun_ has joined #ruby
ruby_ has joined #ruby
Dispatch has joined #ruby
gnufied has quit [Quit: Leaving]
binaryplease1 has joined #ruby
Sembei has quit [Read error: Connection reset by peer]
ur5us has quit [Remote host closed the connection]
Bellthoven has quit []
ur5us has joined #ruby
ruby_ has quit [Ping timeout: 265 seconds]
c355e3b has quit [Quit: Connection closed for inactivity]
dviola has quit [Quit: WeeChat 1.5]
Sembei has joined #ruby
binaryplease has quit [Ping timeout: 244 seconds]
cyphactor has quit [Ping timeout: 265 seconds]
giz|work has quit [Ping timeout: 265 seconds]
A5101 has joined #ruby
cyphase has joined #ruby
ur5us has quit [Ping timeout: 244 seconds]
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
chichou has joined #ruby
gizmore has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
gizmore has quit [Changing host]
gizmore has joined #ruby
agent_white has quit [Quit: brb]
cyphactor has joined #ruby
flashpoint9 has joined #ruby
lessless has joined #ruby
lessless has left #ruby [#ruby]
Dispatch has quit [Remote host closed the connection]
binaryplease1 is now known as binaryplease
chichou has quit [Client Quit]
shmuli has joined #ruby
flashpoint9 has quit [Ping timeout: 250 seconds]
insanedreamer_ has joined #ruby
insanedreamer has quit [Ping timeout: 255 seconds]
insanedreamer_ is now known as insanedreamer
Dispatch has joined #ruby
cyphase has quit [Ping timeout: 265 seconds]
shmuli has quit [Ping timeout: 264 seconds]
LoneHermit has quit [Remote host closed the connection]
insanedreamer has quit [Quit: insanedreamer]
sneakerhax has joined #ruby
cyphase has joined #ruby
solocshaw has quit [Remote host closed the connection]
jphase has quit [Ping timeout: 250 seconds]
solocshaw has joined #ruby
jphase has joined #ruby
Coldblackice has quit []
Wsewolod has joined #ruby
coolboy has joined #ruby
dstarh has joined #ruby
zacstewart has joined #ruby
cyphase has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
Coldblackice has joined #ruby
coolboy has quit [Ping timeout: 244 seconds]
cyphase has joined #ruby
thejamespinto has joined #ruby
NetSage has quit [Remote host closed the connection]
Coldblackice has quit [Client Quit]
giz|work has joined #ruby
nankyokusei has joined #ruby
Coldblackice has joined #ruby
braincra- has quit [Quit: bye bye]
gix has quit [Ping timeout: 260 seconds]
dasher00 has quit [Read error: Connection timed out]
nankyokusei has quit [Ping timeout: 265 seconds]
dasher00 has joined #ruby
cyphase has quit [Ping timeout: 260 seconds]
dasher00 has quit [Max SendQ exceeded]
eizua has joined #ruby
linduxed has quit [Ping timeout: 244 seconds]
gix has joined #ruby
cyphase has joined #ruby
ruby_ has joined #ruby
moparisthebest has quit [Quit: ZNC - 1.6.0 - http://znc.in]
gorp2016 has joined #ruby
giz|work has quit [Ping timeout: 244 seconds]
braincrash has joined #ruby
greister__ has quit [Ping timeout: 240 seconds]
hutch34_ has quit [Ping timeout: 255 seconds]
cyphase has quit [Ping timeout: 255 seconds]
cdg has joined #ruby
code_ has quit [Ping timeout: 244 seconds]
cyphase has joined #ruby
govg has joined #ruby
bkxd has joined #ruby
polysics has joined #ruby
shakes has joined #ruby
k3rn31 has quit [Quit: Computer has gone to sleep.]
r4z has quit [Quit: Leaving]
Cohedrin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Cohedrin has joined #ruby
Cohedrin has quit [Client Quit]
govg has quit [Ping timeout: 244 seconds]
bkxd has quit [Ping timeout: 265 seconds]
alaibe has joined #ruby
polysics has quit [Ping timeout: 276 seconds]
cyphase has quit [Ping timeout: 265 seconds]
hahuang61 has quit [Ping timeout: 250 seconds]
code_ has joined #ruby
flashpoint9 has joined #ruby
alaibe has quit [Ping timeout: 276 seconds]
zacstewart has quit [Ping timeout: 264 seconds]
yardenbar has joined #ruby
vuoto has joined #ruby
cyphase has joined #ruby
astrobu__ has joined #ruby
hutch34_ has joined #ruby
astrobun_ has quit [Ping timeout: 265 seconds]
hutch34_ has quit [Ping timeout: 265 seconds]
greister_ has joined #ruby
yardenbar has quit [Ping timeout: 255 seconds]
cyphase has quit [Ping timeout: 276 seconds]
<gizmore>
good.morning
<apeiros>
moin
flashpoint9 has quit [Remote host closed the connection]
<gizmore>
puts smileys.where("emotion LIKE %", 'fun').first
flashpoint9 has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
flashpoint9 has joined #ruby
cyphase has joined #ruby
moparisthebest has joined #ruby
solocshaw has quit [Ping timeout: 250 seconds]
vuoto has quit [Remote host closed the connection]
giz|work has joined #ruby
flashpoint9 has quit [Ping timeout: 250 seconds]
giz|work has quit [Client Quit]
shakes has quit [Quit: Leaving]
shakes has joined #ruby
zipace has joined #ruby
cyphase has quit [Ping timeout: 276 seconds]
Dispatch has quit []
yeticry has quit [Quit: leaving]
yeticry has joined #ruby
cyphase has joined #ruby
Bellthoven has joined #ruby
phoo1234567 has quit [Quit: Gotta go]
calmchaos has joined #ruby
cyphase has quit [Ping timeout: 265 seconds]
calmchaos has quit [Ping timeout: 240 seconds]
someoneelse2 has joined #ruby
Vingador has quit [Ping timeout: 265 seconds]
cdg has quit [Ping timeout: 276 seconds]
<someoneelse2>
hi all, has anyone any idea about sinatra?
_djbkd has joined #ruby
<someoneelse2>
I am trying to do something very simple: I have a folder with 8000 images in my computer and I want to show them randomly, one at a time in a <div> inside a sinatra view, then press a button and cycle them.
gorp2016 has quit [Read error: Connection reset by peer]
<dminuoso>
ftshtw: Just a quick glance, but the second sounds like a caching problem.
zacstewart has joined #ruby
<dminuoso>
ftshtw: You either need to use cache controls (which from experience have a tendency to not work as expected), or you finger print the image asset, so that each request is forced to fetch it from your remote server.
<dminuoso>
ftshtw: Ideally do some analysis with your developer tools in your browser, so you can see how it behaves.
spectrum has quit [Read error: Connection reset by peer]
claudiuinberlin has joined #ruby
mark_66 has joined #ruby
<ftshtw>
dminuoso: what do you mean finger print ?
<dminuoso>
ftshtw: This is an example asset URI from my Rails application: href="/assets/application-c64d50707afedf9503d650aaaced26b72701b854b0f4b984bcfab81c8c06ae0f.css"
<dminuoso>
ftshtw: Each time the asset changes, the fingerprint is changed - so that it looks like a new file.
<ftshtw>
dminuoso: I've been developing in Rails for the past 3-4 years and I decided to play around with Sinatra so I find the philosophy totally different
<ftshtw>
different from assets precompilation to the public folder which is predefined
<dminuoso>
ftshtw: The underlying principle of "fingerprinting resources" is an extremely common thing. Sprockets in rails handles it completely transparently for you.
olistik has joined #ruby
<ftshtw>
I mean it's been a long time since I was trying to find a solution to such a simple problem :P
<ftshtw>
dminuoso: true
<dminuoso>
ftshtw: At any rate, your question lacks details from your developer tools. If you look at the network tab, its much eaiser to see what happens.
Rodya_ has quit [Remote host closed the connection]
Madplatypus has quit [Quit: Connection closed for inactivity]
<ftshtw>
dminuoso: but send_file actually downloads an image as an attachment and the dev tools show just src='/photo' which is pretty much obvious
devbug has quit [Quit: ZZZzzz…]
mrgrieves has joined #ruby
gagrio has joined #ruby
<dminuoso>
ftshtw: Ah.
jazzonmym1nd has joined #ruby
littlemyu has quit [Ping timeout: 240 seconds]
<ftshtw>
it doesn't => <img src="/photo" alt='image' style="width: 100%;" />
<ftshtw>
I mean I find it an awful solution but I can't find anything else
<dminuoso>
ftshtw: Mm, doesnt that Dir.glob just give you a filename? Id think you would need to specify a full or relative path.
<ftshtw>
I tried to File.read and use file:/// links but everything fails
<dminuoso>
ftshtw: Alright I was not aware of that.
<ftshtw>
dminuoso: true, the full path of a filename
<ftshtw>
I set up :public_folder but it doesn't seem to understand it later in the route
DoubleMalt has quit [Remote host closed the connection]
<dminuoso>
ftshtw: Nvm, glob uses the same path ref that you pass to it.
sevenfourk has joined #ruby
olistik has quit [Ping timeout: 250 seconds]
<ftshtw>
the logical way should be to send the path to the view with something like @photo = image_url and then display it in the .erb with src="<%= @photo %>"
<ftshtw>
like Rails
<ftshtw>
but it doesn't
<dminuoso>
ftshtw: Wait a moment. What is @photo ?
<ftshtw>
I guess these are the transparent things which make Rails easy to use
<ftshtw>
so I guess I am a bad developer
<ftshtw>
dminuoso: I've tried it with @photo = Dir.glob("/Users/hyp3rkyd/Pictures/Wallpapers/*").sample
<dminuoso>
ftshtw: What happens if you do a GET /photo directly?
ctp has joined #ruby
<ftshtw>
dminuoso: this is what I am doing right now
sai_ has joined #ruby
<ftshtw>
dminuoso: well almost. GET /photo will show the image in full-size
PaulePanter has quit [Ping timeout: 276 seconds]
Madplatypus has joined #ruby
spectrum has joined #ruby
Ropeney has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
inukshuk has joined #ruby
mrgrieves has quit [Ping timeout: 276 seconds]
thejamespinto_ has joined #ruby
<dminuoso>
ftshtw: Here is what I would do. I would look at the exact HTTP response for the GET /photos
<dminuoso>
ftshtw: and compare it to what the exact response looks like when your browser fetches an image for a page.
ledestin has joined #ruby
<dminuoso>
Perhaps you need to be explicit about the content-type or some other detail.
<ftshtw>
dminuoso: it's an image so what else should it be ?
cyphase has quit [Ping timeout: 250 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
thejamespinto has quit [Ping timeout: 276 seconds]
<ftshtw>
dminuoso: but what does it have to do with my issues ?
BlkDynmt has joined #ruby
|ifei5g00d has quit [Ping timeout: 240 seconds]
alaibe has joined #ruby
vondruch has joined #ruby
<ftshtw>
dminuoso: at least I see "Content-Disposition
<ftshtw>
inline; filename=
Ishido has joined #ruby
<dminuoso>
ftshtw: Well your second issue is that it displays the image as expected, but it does not reload it right?
cyphase has joined #ruby
<ftshtw>
dminuoso: yes
sai__ has joined #ruby
sai_ has quit [Read error: Connection reset by peer]
hahuang61 has joined #ruby
zacstewart has quit [Ping timeout: 244 seconds]
alaibe has quit [Ping timeout: 276 seconds]
optikalmouse has joined #ruby
charliesome has joined #ruby
<optikalmouse>
how do I reference a class/instance method within a lambda?
<optikalmouse>
I made ruby segfault because the did_you_mean library could not find the method names within the lambda (though the lambda is declared within my class)
<dminuoso>
optikalmouse: Can you gist the segfaulting code? I would be very interested.
hahuang61 has quit [Ping timeout: 265 seconds]
Coldblackice has quit [Ping timeout: 276 seconds]
<dminuoso>
optikalmouse: As for your question, instance_eval lets you evaluate a lambda within a context of an object.
thejamespinto_ has quit [Ping timeout: 264 seconds]
<jazzonmym1nd>
Proc not a lambda no?
thejamespinto has joined #ruby
Bish has quit [Remote host closed the connection]
<dminuoso>
jazzonmym1nd: They are the same thing.
hinbody has joined #ruby
<dminuoso>
(For the purpose of this discussion)
<jazzonmym1nd>
they have different semantics.
<dminuoso>
09:45 < dminuoso> (For the purpose of this discussion)
<jazzonmym1nd>
Proc is more accurate :)
bkxd has joined #ruby
<jazzonmym1nd>
since it exhibits that behavior.
<dminuoso>
jazzonmym1nd: If we wanted to be accurate, then instance_eval only works with a block.
<dminuoso>
So it does not matter.
<dminuoso>
Happy?
<jazzonmym1nd>
block has same semantics as a Proc.
hhfemh has joined #ruby
olistik has joined #ruby
pawnbox has quit [Remote host closed the connection]
<dminuoso>
jazzonmym1nd: A block has not the same semantics as a proc.
<dminuoso>
A block is not an object.
<dminuoso>
They are not the same thing.
<dminuoso>
In fact the thing that both proc and lambda have in common, is that they both are a ruby object with a pointer to what Ruby understands as a block, and some meta data ontop of it that implements the difference between proc and lambda.
<jazzonmym1nd>
a Proc encapsulates a block, and a lambda is just a specialized Proc, how arguments are handled and behavior of 'return' is different, a block passed to instance_eval behaves same as standard Proc object
alaibe has joined #ruby
<dminuoso>
Are you trying to make a point here?
<dminuoso>
Or are you just arguing for the sake of it?
<jazzonmym1nd>
just that if anything the block passed to instance_eval is much more similar to a Proc object, arguments or lack of and 'return' are managed the same way.
<optikalmouse>
I'm trying to trace through at which point the apply_criteria lambda is called and it looks like it's after the instance is defined
<dminuoso>
optikalmouse: Works for me. Which Ruby version are you running?
astrobun_ has quit [Remote host closed the connection]
<dminuoso>
getxsick: it shows that the notion of "looping through a container" is not really some language feature, but its provided through actual methods that you can call.
<getxsick>
dminuoso: but then you have to wrap in a list the passing argument (which actually is good as it keeps API more concise
<dminuoso>
getxsick: Well you pass something to f, and it treats it like a list. Otherwise it defaults to another list.
<dminuoso>
It would feel right to pass in a list.
sevenfourk has joined #ruby
<dminuoso>
getxsick: But dont let me confuse you, this is just me toying around.
Silthias has joined #ruby
lightheaded has quit [Ping timeout: 260 seconds]
lightheaded has joined #ruby
jazzonmym1nd has joined #ruby
c355e3b has joined #ruby
giz|work has joined #ruby
Agent001 has quit [Ping timeout: 240 seconds]
jazzonmym1nd has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 240 seconds]
lightheaded has quit [Ping timeout: 276 seconds]
Pumukel has quit [Remote host closed the connection]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Agent001 has joined #ruby
Pumukel has joined #ruby
charliesome has joined #ruby
rodfersou has joined #ruby
sdothum has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
<sapphire_>
my question is still unanswered
<j416>
sapphire_: perhaps it was not clear enough
<j416>
sapphire_: or, no one knows the answer
<sapphire_>
it was clear as a glass sheet
<adaedra>
For you maybe.
aidalgol has quit [Quit: zZzZzZzZzz]
lightheaded has joined #ruby
<getxsick>
dminuoso: i ended up with this: https://eval.in/638852 and probably there is no way to set better default value for host as it rely on the user in the iteration
k3rn31 has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<[k->
do most of the people in your area not speak english?
sai_ has quit [Read error: Connection reset by peer]
<[k->
you speak it well
<sapphire_>
60%
gnufied has joined #ruby
<dminuoso>
sapphire_: Do you actually know the reason for the braces?
<sapphire_>
nr, never really dug down to it
sai_ has joined #ruby
<[k->
are you trying to solve a non problem?
giz|work has quit [Ping timeout: 265 seconds]
<[k->
did you do a survey? to gauge responses?
<dminuoso>
sapphire_: The idea is that the these expression (S-expressions) are exactly the same in the internal representation, giving you the ability to treat code as data.
<sapphire_>
well, you see the rest (40%) are just refusing or "learned deutch"
<dminuoso>
sapphire_: It's a neat thing actually. :)
tuelz1 has quit [Ping timeout: 250 seconds]
<sapphire_>
w/o proper ide you are screwed tho
<sapphire_>
+-1 brace and hello syntax error
<dminuoso>
Proper identation goes a long way to make lisp readable
anisha has quit [Quit: This computer has gone to sleep]
<dminuoso>
Well, editors have had matching parens features for decades.
<dminuoso>
sapphire_: And if you miss a semicolon or ) or } in C you can end up with pretty strange errors too.
<dminuoso>
It's not much of an argument.
<dminuoso>
Even in Ruby a missing () {} can produce super strange errors.
xoxoxoxoxoxo has quit [Remote host closed the connection]
last_staff has quit [Quit: last_staff]
<sapphire_>
well, if your editor weird enough (ey, rubymine) you'll notice that before running the app
<sapphire_>
well..."running"
<sapphire_>
'cos ruby is not compilable
<[k->
what about ide support for your proposed localised ruby?
<dminuoso>
sapphire_: Ruby quite is.
<[k->
it won't have any of the tools available
<sapphire_>
rubymine ofc
<sapphire_>
with a plugin/slight alterations
<[k->
and everyone will pay for rubymine?
<sapphire_>
and/or notepad++
<sapphire_>
srsly? Community edition all the way
<dminuoso>
sapphire_: In fact you can have Ruby just parse input to detect grammar errors.
giz|work has joined #ruby
<[k->
oh there's one alrdy?
<sapphire_>
long time actually
<sapphire_>
and some shifty unlim lic servers as well ;)
<[k->
do you have funding? company support? how are you going to convince them to switch to your ruby?
<sapphire_>
simplicity
polysics has joined #ruby
<sapphire_>
and "intuitivity"
<[k->
so you don't have funding and all?
sai_ has quit [Read error: Connection reset by peer]
sai_ has joined #ruby
<sapphire_>
why, we're not a large company
<[k->
is your company using ruby?
<sapphire_>
we don't have thousands of workstations
<sapphire_>
told you above
<[k->
sell ruby to your co-workers, see if it works
sai_ has quit [Read error: Connection reset by peer]
<[k->
then decide if you want to put in effort to localise
sai_ has joined #ruby
Rodya_ has joined #ruby
tuelz1 has joined #ruby
<[k->
show them your side projects
<[k->
show them rails
<sapphire_>
it is decided and currently the problem is - confusion,slowness,docs
sai_ has quit [Read error: Connection reset by peer]
mark_66 has quit [Remote host closed the connection]
cyphase has quit [Ping timeout: 265 seconds]
Agent001 has joined #ruby
mark_66 has joined #ruby
sai_ has joined #ruby
last_staff has joined #ruby
claudiuinberlin has joined #ruby
<sapphire_>
guess what, for some wird reason in ru_RU people only learn__rails__, not ruby itself
<sapphire_>
like, wtf
<sapphire_>
it's like learning laravel and not minding php
<[k->
implement pair programming
<[k->
get them to learn together!
banisterfiend has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<[k->
are you in a position of power?
<sapphire_>
nah, too ignorant and we have svn
<sapphire_>
i'm not, sadly
sai_ has quit [Read error: Connection reset by peer]
olistik has quit [Remote host closed the connection]
banisterfiend has joined #ruby
<[k->
(then I think the company would just shoot down your version of ruby)
pawnbox has quit [Remote host closed the connection]
sai_ has joined #ruby
olistik has joined #ruby
Rodya_ has quit [Ping timeout: 250 seconds]
claudiuinberlin has quit [Remote host closed the connection]
claudiuinberlin has joined #ruby
<sapphire_>
eh, then i'll get it on github
<[k->
and then what?
cyphase has joined #ruby
<sapphire_>
at least other people will be grateful enough
pandaant has quit [Remote host closed the connection]
hutch34_ has joined #ruby
olistik has quit [Ping timeout: 276 seconds]
banisterfiend has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<[k->
although I doubt the long term sustainability of your project, if you want to do it this way then
<dminuoso>
Im using chruby on my server (configured properly through a script in /etc/profile.d ) and capistrano is giving me "/usr/bin/env bundle: No such file or director" errors. If I log in as the deploy user that command runs just fine.
<[k->
In simple terms, monkey patching refers to the practice of extending or modifying existing code by changing classes at run-time.
Rodya_ has joined #ruby
submitnine has quit []
<a1fa>
good or a bad thing?
<Burgestrand>
Both.
<Burgestrand>
Sometimes it's convenient, sometimes it's the cleanest option without rewriting the entire implementation, and sometimes it comes back to bite you!
<[k->
however, rails is an example of the good side
xoxoxoxoxoxo has joined #ruby
<Burgestrand>
I'm a bit torn on that, but Rails has definitely added some good monkey patches without polluting too much!
<Burgestrand>
And if I'm not wrong, some of them have even been added into Ruby itself over time, because it was so nice.
<[k->
like &:method
eljimador has joined #ruby
Ipe has joined #ruby
Rodya_ has quit [Ping timeout: 250 seconds]
cyphase has joined #ruby
lidenbrock has joined #ruby
raeoks has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ngscheurich has joined #ruby
Ipe has quit [Client Quit]
maokomioko has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<adaedra>
I think you can exports apps to war files
<morfin>
war? it's like jar but war?
r4z has joined #ruby
<nowhereFast>
morfin: it does
<[k->
?patience ftshtw
<[k->
wait we don't have that?
<nowhereFast>
run a search on: openshift jruby
sai_ has joined #ruby
<morfin>
i remember some guys said i can use it if got Java apps etc
<nowhereFast>
and the book deploying with jruby
<morfin>
deploying that is possibly harder hmm
hk238 has joined #ruby
<nowhereFast>
maybe try the #jruby channel?
<morfin>
nevermind i just asked, not going to use that very soon :)
maokomioko has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<nowhereFast>
pretty sure you can do both war and jar
maokomioko has joined #ruby
<nowhereFast>
then just drop into tomcat/jboss
karmatr0n has joined #ruby
maokomioko has quit [Client Quit]
sai_ has quit [Read error: Connection reset by peer]
sai_ has joined #ruby
synruby has joined #ruby
synruby has quit [Client Quit]
synruby has joined #ruby
Burgestrand has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
synruby has quit [Client Quit]
AlexRussia has joined #ruby
hakunin has quit [Remote host closed the connection]
aegis3121 has quit [Ping timeout: 255 seconds]
[k- has quit [Quit: -a- Connection Timed Out]
jesk has joined #ruby
<jesk>
hi
Alayde has quit [Ping timeout: 240 seconds]
[k- has joined #ruby
jobewan has joined #ruby
synruby has joined #ruby
<synruby>
hi
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
synruby has quit [Client Quit]
agent_white has joined #ruby
<agent_white>
Mornin'
LastWhisper____ has joined #ruby
Rodya_ has quit [Remote host closed the connection]
jhack has quit [Quit: jhack]
sysanthrope has quit [Remote host closed the connection]
sysanthrope has joined #ruby
synruby has joined #ruby
dminuoso has quit [Remote host closed the connection]
morfin has quit [Ping timeout: 276 seconds]
nankyokusei has joined #ruby
bmurt_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rodfersou is now known as rodfersou|lunch
<synruby>
I'm not new to programming in general, but I'm new to Ruby. I installed Ruby 2.3.1-x64. What book should I follow for a fun learning experience?
7GHABZIEL has joined #ruby
cyphase has quit [Ping timeout: 255 seconds]
<synruby>
should I be concerned about this: "You will have
<synruby>
the option to download a 64-bit (x86) version. At this stage, I would recommend
<synruby>
compatible with the 64-bit version yet"
<synruby>
staying with the normal, plain (32-bit) version, as not all Ruby libraries are
<adaedra>
what are you reading?
<nowhereFast>
new to ruby or new to coding?
<synruby>
new to ruby
<synruby>
i found it in an excerpt online. its from a book i guess
<nowhereFast>
google poodr
nankyokusei has quit [Ping timeout: 244 seconds]
conta has joined #ruby
cyphase has joined #ruby
7GHABZIEL has quit [Ping timeout: 252 seconds]
<nowhereFast>
can't speak for anybody else, but this book helped me out on a few fronts re. ruby
<a1fa>
i need to combine two different Models, and sort.uniq them; (Model1.select(:name).distinct + Model2.select(:name).distinct).sort.uniq did not work
qba73 has quit [Remote host closed the connection]
hutch34_ has quit [Ping timeout: 264 seconds]
qba73 has joined #ruby
<a1fa>
i tried with pluck too, no luck
tk__ has quit [Quit: ばいばい]
<[k->
what does Model1.select(:name).distinct give you?
<[k->
an array or a Model?
qba73_ has joined #ruby
<a1fa>
Model
raMp has quit [Quit: Konversation terminated!]
weemsledeux has joined #ruby
<[k->
and what does + on Models do?
<a1fa>
two models ":)"
dminuoso has joined #ruby
<[k->
it works like that? :o
<a1fa>
it doesnt :)
<[k->
shouldn't you have one combined model or something then?
<a1fa>
[k-: may have figured it out
<[k->
you can sort an array
<[k->
not sure if you can sort a model?
mikecmpbll has quit [Read error: Connection reset by peer]
jgnagy has joined #ruby
qba73 has quit [Ping timeout: 265 seconds]
hk238 has joined #ruby
<a1fa>
well i am plucking stuff out
<a1fa>
so its an array
mikecmpbll has joined #ruby
<[k->
how does it become an array?!
<a1fa>
.pluck?
<[k->
that wasn't in the code you provided, and I don't know rails ;)
Vingador has quit [Remote host closed the connection]
qba73_ has quit [Ping timeout: 265 seconds]
<[k->
you have to explain it to me what you are doing and you will eventually figure out what's wrong as I force you to think
ftshtw has quit [Ping timeout: 264 seconds]
mark_66 has quit [Quit: Leaving.]
<[k->
I'm sorry if you felt appalled :(
jhack has joined #ruby
<a1fa>
that didnt work
<a1fa>
comparison of nilclass with string failed
qba73 has joined #ruby
jhack has quit [Client Quit]
cyphase has quit [Ping timeout: 250 seconds]
synruby has joined #ruby
qba73 has quit [Client Quit]
<a1fa>
i see why, but why.
Alayde has joined #ruby
sai_ has quit [Read error: Connection reset by peer]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<[k->
is that an error?
sai_ has joined #ruby
<a1fa>
no
sai_ has quit [Read error: Connection reset by peer]
minimalism has joined #ruby
<a1fa>
i had to do sort_by! { |a| a.to_s || 0 }.uniq
<a1fa>
gross
synruby has left #ruby ["Leaving"]
<[k->
why the || 0?
sai_ has joined #ruby
raeoks has joined #ruby
senayar has quit [Ping timeout: 265 seconds]
cyphase has joined #ruby
synruby has joined #ruby
dminuoso has quit [Ping timeout: 265 seconds]
pochoa has joined #ruby
sai_ has quit [Read error: Connection reset by peer]
synthroid has joined #ruby
synthroid has quit [Remote host closed the connection]
synthroid has joined #ruby
chouhoulis has quit [Remote host closed the connection]
eizua has quit [Remote host closed the connection]
d0nn1e has joined #ruby
nikivi has quit [Quit: irc]
einarj has quit [Ping timeout: 250 seconds]
firstdayonthejob has joined #ruby
nankyokusei has joined #ruby
Rodya_ has quit [Ping timeout: 250 seconds]
cyphase has quit [Ping timeout: 265 seconds]
blaxter has quit [Quit: foo]
jgt has quit [Ping timeout: 240 seconds]
zipace has quit [Ping timeout: 250 seconds]
Ishido has quit [Ping timeout: 255 seconds]
nankyokusei has quit [Ping timeout: 276 seconds]
cyphase has joined #ruby
vuoto has joined #ruby
_djbkd has joined #ruby
duderonomy has joined #ruby
hk238 has quit [Read error: Connection reset by peer]
tvon has joined #ruby
rippa has joined #ruby
LastWhisper____ has joined #ruby
sai__ has joined #ruby
sai_ has quit [Read error: Connection reset by peer]
jhack has quit [Quit: jhack]
Agent001 has quit [Read error: Connection reset by peer]
bigkevmcd has quit [Quit: Outta here...]
hakunin has joined #ruby
BlkDynmt has quit [Quit: BlkDynmt]
symm- has joined #ruby
ramfjord has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
Ishido has joined #ruby
SeepingN has joined #ruby
karmatr0n has quit [Ping timeout: 265 seconds]
Cohedrin has joined #ruby
spudowiar has joined #ruby
k3rn31 has quit [Quit: Computer has gone to sleep.]
hk238 has joined #ruby
Ishido has quit [Remote host closed the connection]
Ishido has joined #ruby
maokomioko has joined #ruby
devbug has joined #ruby
AustinMatherne has quit [Remote host closed the connection]
marxarelli has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AustinMatherne has joined #ruby
rcvalle has joined #ruby
TeresaP has joined #ruby
<TeresaP>
Hey there. I want to do File.directory?("/Users/username/folder_that_doesnt_exist") and have it return true but then ile.directory?("/Users/username/somefile.ext") would return false. Is there a way to do something like that? File.directory? seems to need the path to exist already but I just want to know if the syntax of the string indicates it is a directory.
Jamo has quit [Ping timeout: 244 seconds]
Jamo has joined #ruby
<[k->
you can't really tell from a string whether it indicates a directory or not unless it ends with a /
deadprez has quit [Remote host closed the connection]
<TeresaP>
Well what if it was just that after the last slash there was not a period?
<TeresaP>
and we strip off the last / first
<[k->
there could be files that have no extensions
gingray has quit [Ping timeout: 250 seconds]
<[k->
hidden folders also start with a period
<TeresaP>
OK, maybe I can check first to see if the File.file?
<[k->
You can even name directories something
<TeresaP>
If false, then proceed to chomp the slash, then check for period
<[k->
something.exe* and have it work
claudiuinberlin has joined #ruby
aegis3121 has joined #ruby
deadprez has joined #ruby
<TeresaP>
I'm writing a test tool where I want to make sure the user passes in a directory but that directory doesn't have to exist
<[k->
if it isn't, then you can stop right there already, job finished
cyphase has quit [Ping timeout: 250 seconds]
TPug has joined #ruby
<[k->
directories can be named what files can be named so there's no point really
<toretore>
(Maybe(directory?) || !file?) == !file
<TeresaP>
The user might be trying to pass in "/Some/Path/ThatDoesntExist/filename.ext"
<TeresaP>
And get confused when a directory is created
<toretore>
the actual problem probably lies elsewhere if you have logic like this
<TeresaP>
I'm just doing some simple checks before running the rest of the code
<toretore>
why?
<toretore>
?xy
<ruby[bot]>
it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
<TeresaP>
Because it's confusing if they call this method and a folder is created
<TeresaP>
Sigh.
kevin has quit [Quit: Leaving]
<TeresaP>
Usually there is a simple solution
hahuang61 has joined #ruby
<TeresaP>
Sounds like right now there isn't. And I did list my problem
<[k->
You can use File.extname to get the extension
<toretore>
there is no actual solution to what you want, so you have to change the underlying assumptions
<TeresaP>
Ooh, good point [k-
<TeresaP>
I can just check to see if that's an empty string
<TeresaP>
Thank you
cyphase has joined #ruby
heelpmeplz has quit [Quit: Leaving]
deadprez has quit [Remote host closed the connection]
deadprez has joined #ruby
sai__ has quit [Remote host closed the connection]
<TeresaP>
toretore all I need to do is check if File.file?(...) is true or File.extname(...).eql?("") is false
<TeresaP>
I don't think my users will pass in hidden directories
flashpoint9 has quit [Remote host closed the connection]
<TeresaP>
I can understand that being a use case though
flashpoint9 has joined #ruby
hahuang61 has quit [Ping timeout: 250 seconds]
<[k->
toretore is righ
tdy has quit [Ping timeout: 276 seconds]
<TeresaP>
But I believe if it's a hidden directory, it will still save to it?
<TeresaP>
It'll just be hard to find if they're not showing hidden directories
<toretore>
you won't ever have a correct solution to this problem, which means you have to rethink the underlying assumptions
<TeresaP>
In any case, my users would really just mess up and pass in a filename instead of a directory name so that's what I'm basically guarding against
<TeresaP>
This satisfies my requirements
<[k->
sounds like apple
<TeresaP>
Yes we use macs
jenrzzz has quit [Ping timeout: 240 seconds]
<[k->
Return us our freedom!
<TeresaP>
haha
AlexRussia has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
al2o3-cr has quit [Ping timeout: 250 seconds]
deadprez has quit [Ping timeout: 265 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
flashpoint9 has quit [Ping timeout: 244 seconds]
mikecmpbll has joined #ruby
Guest42974 has quit [Ping timeout: 244 seconds]
bmurt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
BlkDynmt has joined #ruby
workmad3 has quit [Ping timeout: 276 seconds]
jhack has joined #ruby
ponga has quit [Quit: Connection closed for inactivity]
firstdayonthejob has quit [Quit: WeeChat 1.5]
replay has joined #ruby
TeresaP has quit [Quit: Page closed]
flashpoint9 has joined #ruby
firstdayonthejob has joined #ruby
deadprez has joined #ruby
tdy has joined #ruby
dionysus69 has joined #ruby
cyphase has quit [Ping timeout: 240 seconds]
flashpoint9 has quit [Remote host closed the connection]
edwinvdgraaf has quit [Read error: Connection reset by peer]
flashpoint9 has joined #ruby
edwinvdgraaf has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
swills has quit [Quit: Leaving]
flashpoint9 has joined #ruby
symm- has quit [Ping timeout: 250 seconds]
Rodya_ has joined #ruby
BTRE has quit [Ping timeout: 244 seconds]
omphe has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cyphase has joined #ruby
AlexRussia has joined #ruby
sai_ has joined #ruby
BTRE has joined #ruby
Ipe_ has quit [Quit: Konversation terminated!]
ec0 has joined #ruby
LoneHerm_ has joined #ruby
Rodya_ has quit [Ping timeout: 250 seconds]
swills has joined #ruby
tyang has joined #ruby
LoneHerm_ has quit [Ping timeout: 250 seconds]
Ipe_ has joined #ruby
conta has joined #ruby
sai_ has quit [Read error: Connection reset by peer]
BlkDynmt has quit [Quit: BlkDynmt]
sai_ has joined #ruby
tyang_ has joined #ruby
robfrawley has joined #ruby
robfrawley is now known as Guest15639
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<roychri>
lalalaaa: Some servers (load balancer, firewalls, etc..) disables the ICMP port, preventing to have a pong response to our ping requests.
<catphish>
burn them
symm- has quit [Ping timeout: 244 seconds]
JackMc is now known as magic
symm- has joined #ruby
naftilos76 has quit [Quit: Αποχώρησε]
Lucky_ABA has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
n1cky has quit [Read error: Connection reset by peer]
n1cky has joined #ruby
<catphish>
i have some questions about string operations and performance, first of all what would be the fastest way to split a string into string[0..-512] and string[-511..-1]
aegis3121 has quit [Ping timeout: 240 seconds]
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Papierkorb>
catphish: if you need to split the string at all, that's probably as fast as it will get. How large is the string?
TPug has joined #ruby
futilegames has joined #ruby
aegis3121 has joined #ruby
<catphish>
Papierkorb: its 1MB, i fear that string[0..-512] would be a huge copy operation
<Papierkorb>
catphish: you're correct
<Papierkorb>
what are you building that needs to shovel a 1meg string (binary data?)
ledestin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<catphish>
maybe truncate will cut the end off efficiently
kirun has joined #ruby
ec0 has joined #ruby
tdy has quit [Ping timeout: 260 seconds]
<catphish>
perhaps if i paste my code, it will better explain what i'm doing, basically gsubbing a stream
<Papierkorb>
catphish: yes, paste on gist.github.com please
symm- has quit [Ping timeout: 244 seconds]
BlkDynmt has joined #ruby
omphe has joined #ruby
<catphish>
i'll just comment it, one moment
<Papierkorb>
catphish: String#chop! looks like it's basically just setting the new string length, but that might (?) entail an internal realloc(), not sure about ruby internas
lightheaded has quit [Remote host closed the connection]
cyphase has quit [Ping timeout: 264 seconds]
<catphish>
the aim is to efficiently gsub a stream of binary data
lightheaded has joined #ruby
<catphish>
it works well as-is, but i'm keen to really maximize performance as this code makes up a pretty substantial portion of my server load :)
stamina has joined #ruby
nankyokusei has joined #ruby
hakunin has quit [Remote host closed the connection]
spider-mario has joined #ruby
<Papierkorb>
catphish: So it's basically a stream editor aka sed?
hakunin has joined #ruby
<catphish>
Papierkorb: yes, i suppose it is
<catphish>
i hadn't thought of it that way
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Papierkorb>
catphish: I may not completely understand the ideas, but first thing coming to mind is that you could use an array of strings as buffer, instead of a huge single string
LoneHermit has joined #ruby
<Papierkorb>
if you need to do operations on those strings, if at all, it should be faster already. Make sure though to benchmark these approaches using "benchmark"
<catphish>
Papierkorb: the main problem is that it's possible something you want to replace spans between 2 input strings
Rodya_ has quit [Ping timeout: 250 seconds]
<catphish>
(since the input is in random chunks)
futilegames has quit [Quit: futilegames]
teclator has joined #ruby
cyphase has joined #ruby
ldnunes has quit [Quit: Leaving]
johnmilton has quit [Remote host closed the connection]
<Papierkorb>
Correct
last_staff has joined #ruby
lightheaded has quit [Ping timeout: 255 seconds]
zipace has joined #ruby
nankyokusei has quit [Ping timeout: 265 seconds]
<Papierkorb>
catphish: If the number of replacements is static and they're strings, you could make sure the buffer doesn't end with one of those strings
Lucky_ABA has joined #ruby
<catphish>
that sounds extensive in itself, because it could end at any point in the replacement :(:
<catphish>
* :(
sai_ has quit [Read error: Connection reset by peer]
b3atr has quit [Ping timeout: 255 seconds]
AbstractArtist has joined #ruby
foooobear has quit [Quit: (null)]
sai_ has joined #ruby
LoneHermit has quit [Ping timeout: 252 seconds]
<Papierkorb>
catphish: Mh... sorry, don't have time atm to help right now, gtg
<catphish>
i guess i should just play with benchmark
<catphish>
Papierkorb: thanks for your help anyway!
dionysus69 has quit [Remote host closed the connection]
<aegis3121>
So doing some work, and I've found that 3.fdiv(0) returns Float::INFINITY. I would have expected a ZeroDivisionError
<aegis3121>
Can anyone help me understand why?
teclator has quit [Ping timeout: 276 seconds]
hakunin has quit [Remote host closed the connection]
<roychri>
ruby-lang175: What code do you have so far?
blandflakes has joined #ruby
blandflakes has quit [Client Quit]
pawnbox has joined #ruby
pochoa has quit [Ping timeout: 252 seconds]
cyphase has quit [Ping timeout: 250 seconds]
nanoz] has quit [Read error: Connection reset by peer]
Dimik has joined #ruby
hahuang61 has joined #ruby
ivanskie has joined #ruby
ruby-lang175 has quit [Ping timeout: 264 seconds]
pochoa has joined #ruby
ivanskie has left #ruby [#ruby]
ivanskie has joined #ruby
<ivanskie>
hi
synthroid has quit []
BlkDynmt has quit [Quit: BlkDynmt]
cyphase has joined #ruby
pawnbox has quit [Ping timeout: 264 seconds]
TPug has joined #ruby
<ivanskie>
so i'm scratching my head here. I have a problem i need to solve. and im not sure which way to go about it. I have several csv files that i read. it is basically a log of a scan of every box of fruit going by a machine. so there's date, productid, and grower amongst the ones i really care about. so I read the csv files, and get them all into an array of hashes. https://gist.github.com/i5okie/04c9307774df84524cc2df8f87ca956b that has date
<ivanskie>
I need to go over the data and print out: by unique date --> by unique Grower --> and then print a list of unique product ids with count
<ivanskie>
right now i have a mini ruby app that goes over the csv files and prints counts of product ids..
blackgoat has joined #ruby
<ivanskie>
now im just not sure how i should go about doing this new thing.. do I create an array of arrays with hashes with each date...
tyang_ has quit [Quit: Leaving]
<roychri>
ivanskie: You could create a hash to keep track of every uniq type of values.
gnufied has quit [Ping timeout: 250 seconds]
<ivanskie>
this would have been easier if i had orm to work with and a database but i dont atm..
JeanCarloMachado has quit [Quit: leaving]
<ivanskie>
roychri: so right now im kind of confused about this "algorithm" thing. overall. so if you were to write this in english per steps... how would you do it?
<ivanskie>
i think I can write the ruby code to do this.. but i'm not experienced enough to come up with an elegant logic.. lol
<toretore>
ivanskie: you probably want to incrementally build a structure like this: {date1 => {grower1 => {product1 => count, product2 => count}, grower2 => {product1 => count}}, date2 => {grower1 => {product1 => count}}}
<toretore>
then, for each line, step into the structure using the values until you get to the count
<ivanskie>
that makes sense.
cyphase has quit [Ping timeout: 276 seconds]
<ivanskie>
i don't know how to get to that
<ivanskie>
my thinking at first was to go over the original data.. and have a separate array of arrays with key being date.. and say if date exists, append this row into the array under this date, if not, push the new date, and add the row under this key
<ivanskie>
so then i'd have to go in and do the same with unique grower id..
<ivanskie>
and products.. and eventually for produts..
bmurt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ramortegui has quit [Remote host closed the connection]
neanderslob has joined #ruby
pwnd_nsfw` has joined #ruby
pwnd_nsfw has quit [Ping timeout: 250 seconds]
TPug has joined #ruby
heelpmeplz has joined #ruby
<heelpmeplz>
I have a series of XML feeds named something like, "EUR_feed.xml", "USD_feed.xml", etc. Each feed contains prices for the same set of "item numbers", but corresponding to a different currency. I want to load all the data into a Hash that looks like products[itemno]["prices"][currency] . Is there a way I can loop over each feed, populating the Hash as I go? I can declare the "products" before the loop, but the keys for
<heelpmeplz>
each itemnumber are not present in the Hash after the loop runs (products is still empty). Is there a way to do this without running the loop twice (once to collect the item numbers so I can create the keys, and another to populate those keys)?
Ipe has quit [Read error: Connection reset by peer]
JoshS has quit [Quit: Leaving]
cyphase has quit [Ping timeout: 250 seconds]
gagrio has quit [Quit: Leaving...]
<heelpmeplz>
I don't know what the item numbers are (to create the itemnumber keys) until I process each feed. However, if I create those keys while I am looping through each feed, I still have an empty "products" Hash when the loop exits. This is a fairly simple question, hopefully someone can help.
nadir has quit [Quit: Connection closed for inactivity]
pochoa has quit [Ping timeout: 240 seconds]
al2o3-cr has quit [Ping timeout: 260 seconds]
<baweaver>
Step back and take a look at the problem. You know you have one hash
cyphase has joined #ruby
<heelpmeplz>
Yes, I do know that.
<baweaver>
Now, is there a way in which you can set a hash key to another hash?
stamina has quit [Ping timeout: 255 seconds]
<baweaver>
What about if you want to check whether or not it exists as a key first?
<heelpmeplz>
huh?
biberu has quit []
a1fa has left #ruby [#ruby]
<baweaver>
How do you set a value on a hash?
<heelpmeplz>
you assign a value to a key of that hash
<baweaver>
and if you want to only assign it if it does not exist yet?
<heelpmeplz>
then I use ||=
<baweaver>
good good
gnufied has quit [Ping timeout: 250 seconds]
<baweaver>
Now then, as you're looping through all the fields you have the pieces that are `item_no` and `currency`
<heelpmeplz>
I don't have trouble looping through the fields
<heelpmeplz>
I am looping through each FILE
<heelpmeplz>
as I loop through each FILE, I loop through each ITEM in the FILE
<baweaver>
I'm aware.
pokalyis has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<heelpmeplz>
I have to declare the Hash outside of these loops, but any new keys that are created in a loop are not reflected when the loop closes
<baweaver>
So you have your one hash at the top of your code. You can check whether or not it has a value for the item number
deadprez has quit [Remote host closed the connection]
<heelpmeplz>
It does not
<heelpmeplz>
It wouldn't
workmad3 has joined #ruby
<baweaver>
It does.
<heelpmeplz>
it's an empty hash before the loops run
<baweaver>
otherwise you're doing something odd.
<baweaver>
do you have your code in a gist?
<baweaver>
?gist
<ruby[bot]>
https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
nadir has joined #ruby
<heelpmeplz>
I don't know how to use gist, I'll put it in pastebin
<baweaver>
the bot will complain
<aegis3121>
there's a link. Right there.
<baweaver>
heelpmeplz: Also, please choose a better name. The current one seems really bad.
Ishido has quit [Quit: Roads? Where We're Going We Don't Need Roads.]
gnufied has joined #ruby
bmurt has joined #ruby
<heelpmeplz>
I don't know man, I can't find any obvious difference between those two pages
<baweaver>
see line 18
<heelpmeplz>
ok
<baweaver>
what happens when the loop hits again?
<baweaver>
same problem on line 48
<heelpmeplz>
It empties the Hash. Obviously a bug. Then it goes on to run products[itemno]["prices"][currency] = price . It does this a billion times, then the loop finishes, and I am left with the problem I originally described, of having an empty hash
cyphase has quit [Ping timeout: 250 seconds]
<heelpmeplz>
My question is simple. I'm not trying to "debug" a compiler error, I'm just asking why my hash is empty at the end and how I can fix it. It appears that because the empty hash is created outside the loop, it is accessible outside the loop. However, the keys and their associated data/hashes are not saved when the loop exits.
deadprez has joined #ruby
<heelpmeplz>
It's just a simple question about how to populate a hash
coolboy has quit [Ping timeout: 240 seconds]
<baweaver>
See comment
<heelpmeplz>
ok man, thanks for all the help
<baweaver>
Oh they are.
ahuman has quit [Ping timeout: 240 seconds]
SteenJobs has joined #ruby
cyphase has joined #ruby
bmurt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
[k- has quit [Ping timeout: 244 seconds]
ahuman has joined #ruby
<heelpmeplz>
guess you come here and roll the dice, today's just not my day. I'll just ugly up the code and make it work because I have no other options after wasting so much of my time. I'm pretty sure anyone could have just answered my question, but it just wasn't meant to be apparently.
griffindy has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<baweaver>
It was answered.
d0nn1e has quit [Ping timeout: 240 seconds]
d0nn1e has joined #ruby
<baweaver>
and unless you excluded code it should be working as is.
<heelpmeplz>
where
<heelpmeplz>
where did you answer it
claudiuinberlin has quit []
jhooker has quit [Quit: Leaving]
jphase_ has joined #ruby
<baweaver>
It also helps if you read the docs on YAML#dump
<aegis3121>
I think that's what you need to look at for .dump
rodfersou has quit [Quit: leaving]
* baweaver
loses track of YAML libs
_djbkd has quit [Remote host closed the connection]
jphase_ has quit [Ping timeout: 264 seconds]
<heelpmeplz>
Did I supposedly make some mistake with YAML.dump that this article would help me not to make in the future?
<baweaver>
Take a look.
cyphase has quit [Ping timeout: 265 seconds]
lightheaded has quit [Remote host closed the connection]
nando293921 has joined #ruby
lightheaded has joined #ruby
ziprar has joined #ruby
zipace has quit [Disconnected by services]
<Batholith>
I never remember what all these "fwiw" shortcuts and what not mean.
<aegis3121>
Sorry, "for what it's worth"
raMp has joined #ruby
<aegis3121>
that one is one of the few that I use a lot. Because that's a lot of words, and I'm a little lazy.
firstdayonthejob has quit [Ping timeout: 240 seconds]
SteenJobs has quit [Ping timeout: 252 seconds]
<Batholith>
Maybe I'm just too old for all them hip shortcuts. But then again, I'm not even in my mid twenties.
pochoa has joined #ruby
LoneHerm_ has joined #ruby
TreyG has joined #ruby
_djbkd has joined #ruby
raMp has quit [Client Quit]
<heelpmeplz>
ok, I looked. Not sure what the point was. I'm definitely done with all the 20 questions and trying to guess what error people think they see in my code. I asked for help, some advice was supposedly given, and the code was supposedly fine, but now I'm being asked to view the YAML help files, as though I didn't know how to use YAML.dump (pretty sure I do)? Thank you for trying to help me, I think we must be on very different
<heelpmeplz>
pages here, to the point where it's not worth trying to sort out. Thanks for trying to help.
pawnbox has joined #ruby
lightheaded has quit [Ping timeout: 255 seconds]
cyphase has joined #ruby
<baweaver>
read the docs Luke
<baweaver>
reeeeead the docs
<heelpmeplz>
bro I f***ing read it
<baweaver>
(hint: no, you don't know how to use it)
<heelpmeplz>
what is it you think I didn't read?
aidalgol has joined #ruby
<baweaver>
Line 25
aegis3121 has quit [Ping timeout: 264 seconds]
<baweaver>
What does YAML dump do?
<heelpmeplz>
It encodes a string in YAML format
<baweaver>
and returns a string
olistik has quit [Remote host closed the connection]