__main__ has quit [Read error: Connection reset by peer]
Synthead has quit [Remote host closed the connection]
Cohedrin_ has joined #ruby
gusrub has quit [Remote host closed the connection]
ledestin has joined #ruby
pwnd_nsfw has quit [Ping timeout: 240 seconds]
Cohedrin has quit [Ping timeout: 240 seconds]
Rodya_ has quit [Ping timeout: 260 seconds]
_main_ is now known as __main__
<Majost>
I have a simple ruby script which comprises of some methods and no classes, for I am trying to write some rspec. The script has a method which checks for the existentence of an ENV key, and if nil raises an error. I am looking on the intarwebs on how to use the `raise_error` stuff, but all the examples I find seem to assume a class instance is created, and
<Majost>
I am not sure how to test something like this script in which no class instance exists. How do I go about doing this?
mikecmpbll has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
s2013 has joined #ruby
<Radar>
Majost: Can you show us what you have already?
bkxd has joined #ruby
mwlang has quit [Quit: mwlang]
JuliusDelta has joined #ruby
Burgestrand has joined #ruby
mtkd has quit [Ping timeout: 260 seconds]
mwlang has joined #ruby
Burgestrand has quit [Client Quit]
__Yiota has joined #ruby
linduxed has joined #ruby
mogaj has joined #ruby
chouhoulis has joined #ruby
mtkd has joined #ruby
montanonic has quit [Ping timeout: 255 seconds]
<Majost>
For now, I am trying to suppress the raise at the moment.
johnzorn has quit [Read error: Connection reset by peer]
johnzorn has joined #ruby
cagomez has quit []
johnzorn has quit [Read error: Connection reset by peer]
nettoweb has joined #ruby
nettoweb1 has quit [Ping timeout: 240 seconds]
mogaj has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has quit [Ping timeout: 240 seconds]
saneax is now known as saneax-_-|AFK
mogaj has quit [Ping timeout: 240 seconds]
Slinky_Pete has quit [Remote host closed the connection]
raspado has quit [Remote host closed the connection]
mim1k has joined #ruby
SteenJobs_ has quit [Quit: SteenJobs_]
johnzorn has joined #ruby
mim1k has quit [Ping timeout: 268 seconds]
jgnagy has joined #ruby
johnzorn has left #ruby [#ruby]
millerti has joined #ruby
AndrewIsHere has joined #ruby
redhedded1 has joined #ruby
jgnagy has quit [Ping timeout: 240 seconds]
AndrewIsHere has quit [Client Quit]
TheMoonMaster has quit [Ping timeout: 276 seconds]
brent__ has quit [Ping timeout: 268 seconds]
Rodya_ has joined #ruby
bkxd has quit [Ping timeout: 240 seconds]
ruid_ has quit [Quit: Leaving]
_djbkd has quit [Quit: My people need me...]
charliesome has joined #ruby
funnel has quit [Ping timeout: 240 seconds]
ivanskie has quit [Remote host closed the connection]
Rodya_ has quit [Ping timeout: 240 seconds]
sylario has quit [Quit: Connection closed for inactivity]
xall has quit [Ping timeout: 260 seconds]
jameser has joined #ruby
barnett has quit []
cdg has quit [Remote host closed the connection]
aryaching has quit [Ping timeout: 260 seconds]
cdg has joined #ruby
duderonomy has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marr has quit [Ping timeout: 260 seconds]
enterprisey has joined #ruby
_djbkd has joined #ruby
paradisaeidae has joined #ruby
paradisaeidae_ has joined #ruby
xall has joined #ruby
axsuul has joined #ruby
SeepingN has quit [Ping timeout: 260 seconds]
jphase has quit [Read error: Connection reset by peer]
jphase has joined #ruby
blackmes1 has quit [Ping timeout: 260 seconds]
xall has quit [Ping timeout: 240 seconds]
def_jam has joined #ruby
aryaching has joined #ruby
nobitanobi has joined #ruby
eb0t has quit [Ping timeout: 260 seconds]
jackjackdripper has quit [Quit: Leaving.]
eblip has quit [Ping timeout: 268 seconds]
nobitanobi has quit [Ping timeout: 260 seconds]
Slinky_Pete has joined #ruby
agent_white has joined #ruby
_djbkd has quit [Quit: My people need me...]
bovis has joined #ruby
browndawg has joined #ruby
Slinky_Pete has quit [Ping timeout: 240 seconds]
Xentil has joined #ruby
mwlang has joined #ruby
Xentil has quit [Client Quit]
pilne has quit [Quit: Quitting!]
tau has quit [Remote host closed the connection]
mmint has left #ruby ["Leaving"]
AKPWD has quit [Quit: じゃね。]
s2013 has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bkxd has joined #ruby
mwlang has quit [Quit: mwlang]
nettoweb has joined #ruby
Rodya_ has joined #ruby
jtdoncas has quit [Ping timeout: 268 seconds]
tyang has joined #ruby
eblip has joined #ruby
tyang_ has joined #ruby
protti has joined #ruby
xpt has quit [Ping timeout: 276 seconds]
xpt has joined #ruby
ccooke has quit [Ping timeout: 260 seconds]
ccooke has joined #ruby
tyang_ has quit [Read error: Connection reset by peer]
Rodya_ has quit [Ping timeout: 240 seconds]
protti has quit [Remote host closed the connection]
tyang has quit [Ping timeout: 240 seconds]
govg has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
bmurt has joined #ruby
cyphase has quit [Ping timeout: 255 seconds]
Vile` has joined #ruby
browndawg has quit [Ping timeout: 268 seconds]
SteenJobs_ has joined #ruby
sspreitz has quit [Ping timeout: 240 seconds]
hahuang65 has quit [Ping timeout: 260 seconds]
K1WIZ has quit [Quit: Leaving]
sspreitz has joined #ruby
cyphase has joined #ruby
TheMoonMaster has joined #ruby
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
singalaut has quit [Ping timeout: 240 seconds]
JuliusDelta has quit [Quit: Leaving...]
singalaut has joined #ruby
candelabra has joined #ruby
<candelabra>
Say I've got a big text file (say 4mb), and I need execute a function once for each column of the file. I need to pass an array of of every character in the current column to the function. What's an efficient way to do this?
<Nilium>
Are the characters all ASCII?
jackjackdripper has joined #ruby
<Radar>
Is this file a CSV?
__Yiota has joined #ruby
mrgrieve1 has joined #ruby
browndawg has joined #ruby
BabyMario has joined #ruby
jenrzzz has joined #ruby
mrgrieves has quit [Ping timeout: 260 seconds]
mogaj has joined #ruby
cyphase has quit [Ping timeout: 240 seconds]
<baweaver>
candelabra: break the functions into terms where they can operate on a single item
<baweaver>
then just iterate the rows and independently transform each one with the single-item function
<baweaver>
though real code helps to adjust for context
<candelabra>
this is not a csv
mogaj has quit [Ping timeout: 240 seconds]
cyphase has joined #ruby
<candelabra>
each line resembles: Underscored_word_here ?10001010101?10001?101010... (but length is 80,000+)
<candelabra>
basically all the lines of ?100101?? together represent a matrix
TheWhip has quit [Remote host closed the connection]
<candelabra>
baweaver, that approach seems like it would end up storing a lot in memory, almost the entire file
<candelabra>
it may be the files end up being much bigger than 4mb
mim1k has joined #ruby
<baweaver>
you're going to have to be a bit more descriptive with what transformations you're trying to do here
<baweaver>
because it sounds a lot like you want Linear Algebra
<baweaver>
remember that we have no idea what you're working on so we tend to answer very generically.
skweek has joined #ruby
<candelabra>
so if you think of the file as a big matrix of 0?10010 (only ?, 0, and 1), with each row having a label, then what I need to do is, for each column in the matrix, is write a line to a new file that orders the column labels according to the 0, ?, or 1 in that specific matrix space... I'll create a gist
hahuang65 has joined #ruby
jackjackdripper has quit [Read error: Connection reset by peer]
jackjackdripper has joined #ruby
mim1k has quit [Ping timeout: 240 seconds]
EV3RYDAYPR0GRESS has quit [Read error: Connection reset by peer]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<candelabra>
I guess one specific question I have is if there is a way in ruby to get the character from a certain position (line, column) in a text file
<candelabra>
aside from file.split(/\n/)[row][col]
<nofxx>
candelabra, I would do File.open().lines.map {}
<nofxx>
a a def parse_line to receive each... just write to a file after
<candelabra>
as of now I'm incrementally writing to the file after each column
<nofxx>
candelabra, just change #map with #each and write after each line
<nofxx>
inside the loop
nowhereman has joined #ruby
<nofxx>
have a need for that? problaly faster going all to ram and flushing to disk in the end I imagine
<candelabra>
but i'm just doing array = file.split(), and then array.each{|line| #write what i want }
opt9 has quit [Ping timeout: 240 seconds]
<candelabra>
well I had originally it all in ram, but it crashed the guys pc when he tried to run it w/ a bigger file, may have been multiple gb
<baweaver>
If you're getting into multiple GB files you might consider going with something like Rust or Go
<baweaver>
If it gets into 100s of GBs, Spark.
<candelabra>
thanks
Rodya_ has joined #ruby
<candelabra>
i'll suggest that
<baweaver>
Ruby doesn't do so hot after a few hundred megs of data in memory
<nofxx>
but won't that be a matter of physical ram rather than lang? will need to work in chunks anyway
<nofxx>
you can read a file with pointer in ruby no? [from, to] limited thing?
<baweaver>
It will, but other languages tend to deal with that a bit better
<nofxx>
and that being needed (work in chunks) won't ruby be the easiest to get ir running?
<nofxx>
heheh =D
<candelabra>
this is sort of a proof of concept at the moment for a larger thing he's writing a paper on
<candelabra>
the script isn't the subject, it's the output that is the subject
<allisio>
Regular #read can do partial reads just fine.
<al2o3-cr>
yep it can
braincrash has quit [Quit: bye bye]
rakm has joined #ruby
noan has quit [Read error: Connection reset by peer]
noan has joined #ruby
<allisio>
candelabra: I think you think you want #seek and #getc, but you really don't.
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Moosashi has joined #ruby
Moosashi has quit [Client Quit]
nowhereman has quit [Ping timeout: 260 seconds]
bovis has quit [Quit: leaving]
Tech has joined #ruby
EV3RYDAYPR0GRESS has quit [Ping timeout: 240 seconds]
<candelabra>
allisio, maybeso, are you saying I don't because it will have a negative affect on performance?
tau has joined #ruby
<candelabra>
allisio, really I'm just curious to attempt different approaches
Slinky_Pete has joined #ruby
antoniobeyah has quit [Quit: Connection closed for inactivity]
<candelabra>
I'm just wondering if I know the size of the matrix, if I can just for() and then use something like IO.read(, pos) to get the space in the matrix I want
<candelabra>
and if that would be better than storing a bunch of things in memory
Tech has quit [Ping timeout: 240 seconds]
swistak35 has quit [Ping timeout: 240 seconds]
Slinky_Pete has quit [Ping timeout: 260 seconds]
jtdoncas has joined #ruby
electrostat has quit [Quit: uwotm8]
electrostat has joined #ruby
cibs has quit [Ping timeout: 260 seconds]
jtdoncas has quit [Ping timeout: 240 seconds]
hays has quit [Ping timeout: 240 seconds]
cibs has joined #ruby
<allisio>
candelabra: See above. :P
<allisio>
It sounds suspiciously like you *want* to use a flat-file database, which is a special breed of masochistic.
<allisio>
Consider finding a more efficient representation of your data, then stick them in a database for saner querying/processing.
opt9 has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<candelabra>
allisio, unfortunately that's way outside the scope
<candelabra>
the task was "here is this format of file, can you make it into this other format with a script for me?"
<candelabra>
I've got it working, I was just curious if there was a more efficient way
DTZUZO has quit [Quit: WeeChat 1.5]
bkxd has joined #ruby
Mia has quit [Ping timeout: 268 seconds]
<allisio>
candelabra: That's new information; at the outset, you indicated that you *needed* a more performant solution in order to process your actual inputs.
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
<allisio>
In any case, I'm glad you got it sorted. I suspect I'm not the only one who'd be willing to nitpick your current code if you'd be willing to post it. :)
Cogitabundus has joined #ruby
Cogitabundus has quit [Max SendQ exceeded]
<candelabra>
sorry I was unclear, what I meant by "I need to execute a function once for each column of this big text file" was that I have a file and I need to use the data in each column
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<allisio>
Are all your columns of equal width?
xall has joined #ruby
<candelabra>
I'll post a git here in a second
Cogitabundus has joined #ruby
Cogitabundus has quit [Max SendQ exceeded]
<candelabra>
yes
Cogitabundus has joined #ruby
<candelabra>
like an m*n matrix
<allisio>
#tranpose would fit the bill very nicely if you didn't have so much data.
<candelabra>
thats what I was thinking, although the matrix is offset by the column labels so that would be tricky
<candelabra>
i'll post a gist, I'm just going to add some comments
TheWhip has joined #ruby
gix has quit [Ping timeout: 260 seconds]
xall has quit [Ping timeout: 240 seconds]
gix has joined #ruby
BabyMario has left #ruby ["bbl"]
Cogitabundus has quit [Read error: Connection reset by peer]
Tharbakim has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 255 seconds]
milardovich has joined #ruby
braincrash has quit [Ping timeout: 260 seconds]
Tharbakim has joined #ruby
tildes has quit [Ping timeout: 255 seconds]
padi_ has quit []
mwlang has quit [Quit: mwlang]
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
nertzy has quit [Ping timeout: 240 seconds]
conta has joined #ruby
TheWhip has quit [Remote host closed the connection]
<kke>
i wonder if i could create a custom build option for a gem to overwrite the shebang in executables, something like the --with-mysql in mysql2 gem
<kke>
such as gem build/install foofoo --with-ruby=/usr/local/bin/ruby
<ruby[bot]>
herwin: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<herwin>
alex``: ^^
<User458764>
Hi how to display in CLI an Array or Hash with human readable display (indentation and breakline)
<kke>
User458764: there's pp. require 'pp'; pp hash
Noxid_ has quit [Quit: Oops. My brain just hit a bad sector]
gloscombe_ has quit [Quit: gloscombe_]
tomphp has joined #ruby
charliesome_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bkxd has quit [Ping timeout: 260 seconds]
tomphp has quit [Client Quit]
anonymus has joined #ruby
<anonymus>
hi
yeticry_ has joined #ruby
al2o3-cr has quit [Ping timeout: 268 seconds]
conta has joined #ruby
<anonymus>
guys please tell me some cheap way to delete several strings from some text beginning from X substring and to Y substring
<anonymus>
like delete_all_between('BEGIN', 'END')
nettoweb has joined #ruby
falconer has joined #ruby
<dminuoso>
anonymus: gsub(/BEGIN(.*)END/, "") ?
mim1k has joined #ruby
User458764 has joined #ruby
<anonymus>
maybe. I'll try. thanks
Xiti has quit [Quit: Xiti]
yeticry has quit [Ping timeout: 268 seconds]
jlebrech has joined #ruby
biberu has joined #ruby
milardov_ has quit [Remote host closed the connection]
Guest31912 has quit [Remote host closed the connection]
tomphp has joined #ruby
<Cork>
i'm trying to run a command through Net::SSH, the command doesn't respect --color=always
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
<Cork>
anyone know if there is a way to get the color to not be stripped in that case?
mtkd has quit [Ping timeout: 260 seconds]
charliesome has joined #ruby
mtkd has joined #ruby
interki has quit [Quit: Going offline, see ya! (www.adiirc.com)]
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Silthias1 has joined #ruby
<falconer>
I don't know anything about Net:SSH, but for some use-cases, I'd look at setting the color yourself. The low hanging branch there is Fazibear's Colorize gem.
troulouliou_div2 has quit [Quit: Leaving]
Silthias has quit [Ping timeout: 240 seconds]
ifctj has joined #ruby
Silthias has joined #ruby
jgnagy has quit [Remote host closed the connection]
Silthias2 has joined #ruby
troulouliou_div2 has joined #ruby
Silthias1 has quit [Ping timeout: 260 seconds]
sylario has joined #ruby
<Cork>
falconer: the command colors things based on if it is an error or things like that
<Cork>
i can't really colorize it my self in all cases as some of the state isn't in the pure text
ddffg has quit [Ping timeout: 240 seconds]
nowhereman has quit [Ping timeout: 260 seconds]
milardovich has quit [Remote host closed the connection]
Silthias has quit [Ping timeout: 240 seconds]
milardovich has joined #ruby
cibs has quit [Ping timeout: 240 seconds]
ifctj has quit [Ping timeout: 255 seconds]
cibs has joined #ruby
charliesome_ has joined #ruby
milardovich has quit [Ping timeout: 260 seconds]
charliesome has quit [Ping timeout: 260 seconds]
Puffball has quit [Quit: No Ping reply in 180 seconds.]
<kke>
Cork: maybe the TERM is not something that supports colors?
Puffball has joined #ruby
charliesome_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
TheWhip has quit [Remote host closed the connection]
Lord_of_Life has joined #ruby
Guest22659 has quit [Remote host closed the connection]
msg has joined #ruby
Rodya_ has joined #ruby
mogaj has quit [Remote host closed the connection]
flying has joined #ruby
msg is now known as Guest17266
mogaj has joined #ruby
bkxd has quit [Ping timeout: 260 seconds]
cibs has quit [Ping timeout: 240 seconds]
milardovich has joined #ruby
cibs has joined #ruby
Rodya_ has quit [Ping timeout: 255 seconds]
opt9 has quit [Quit: Bye bye]
prestorium has quit [Ping timeout: 255 seconds]
vasilakisfil has joined #ruby
milardovich has quit [Ping timeout: 260 seconds]
<vasilakisfil>
how can you have a class called like that Foobar[:something] ? I saw rails 5 migrations have something like that and I am wondering how you can build it and how you can use it
sarbs has quit [Ping timeout: 240 seconds]
arup_r has joined #ruby
<toretore>
>> class Foobar; def self.[](key); key; end; end; Foobar[:something]
<guardian>
I'm getting Numbered backref/call is not allowed. (use name).
<toretore>
where?
<guardian>
when trying to match a previous group and regexp contains both named and unnamed groups
<toretore>
code?
<vasilakisfil>
which one would you use in your code? STATES = [:intro, :connect, :download, :buy].freeze or STATES = [:intro, :connect, :download, :buy].map(&:freeze).freeze
braincrash has quit [Ping timeout: 240 seconds]
<toretore>
:intro.freeze is meaningless
<vasilakisfil>
toretore because :freeze is a symbol ?
<toretore>
yes
<vasilakisfil>
sorry I meant :intro
<vasilakisfil>
ok
<toretore>
symbols are immutable
mim1k has joined #ruby
<vasilakisfil>
but the thing is that I have more complex constants like arrays of hashes
<vasilakisfil>
should I freeze everything recursively ?
<toretore>
well then use real code in your examples
<vasilakisfil>
no I meant I also have more complex constants
<ruby[bot]>
guardian: # => /tmp/execpad-0e58f4798fdc/source-0e58f4798fdc:2: numbered backref/call is not allowed. (use name): / ...check link for more (https://eval.in/740941)
<guardian>
>> "---- x ----".scan(/(?<sep>-{4,})(.*?)(\1)/)
nowhereman has quit [Ping timeout: 260 seconds]
<guardian>
>> "---- x ----".scan(/(-{4,})(.*?)(\1)/)
<toretore>
arup_r: i don't really see anything wrong with it then; depending on what exactly the domain is, you could refactor parts of it
<dminuoso>
vasilakisfil: a class is just an object
<dminuoso>
>> foo = Class.new
<arup_r>
toretore: yes that is what I am thinking ..
<toretore>
vasilakisfil: i wouldn't bother
<arup_r>
but thanks for your reviewing my gist
<dminuoso>
12:08 < vasilakisfil> how can you have a class called like that Foobar[:something] ? I saw rails 5 migrations have something like that and I am wondering how you can build it and how you can use it
Macaveli has joined #ruby
<dminuoso>
vasilakisfil: Foremost "Foobar" is just a constant.
<vasilakisfil>
I see
jgnagy has joined #ruby
<dminuoso>
vasilakisfil: If it points at a class, then even that class can have methods
<dminuoso>
Those are commonly called class methods
<toretore>
guardian: it would be better if you explained what you're trying to achieve
charliesome has joined #ruby
<guardian>
toretore: using back references in a regexp that contains both named and unnamed groups
go|dfish has joined #ruby
<guardian>
toretore: it seems as soon as 1 of the groups is named, all back references must refer to named groups
arup_r has quit []
fusta has joined #ruby
jgnagy has quit [Ping timeout: 255 seconds]
<toretore>
guardian: is that a problem?
<guardian>
it's a discovery :)
cajone has left #ruby [#ruby]
psychicist__ has quit [Ping timeout: 255 seconds]
ldnunes has joined #ruby
anisha has quit [Quit: This computer has gone to sleep]
Mortomes|Work has quit [Ping timeout: 260 seconds]
milardovich has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
candelabra has quit [Quit: Leaving]
Mortomes|Work has joined #ruby
milardovich has quit [Ping timeout: 255 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
JeanCarloMachado has joined #ruby
JoshS has quit [Ping timeout: 260 seconds]
ifctj has joined #ruby
bkxd has joined #ruby
falconer has quit [Ping timeout: 240 seconds]
JoshS has joined #ruby
nobitanobi has quit [Remote host closed the connection]
cajone has joined #ruby
braincrash has joined #ruby
nofxxx has quit [Ping timeout: 260 seconds]
jespada has joined #ruby
jameser has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
rafadc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
psychicist__ has joined #ruby
braincrash has quit [Ping timeout: 240 seconds]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
slima has joined #ruby
funnel has joined #ruby
jameser has joined #ruby
mitt3ns has joined #ruby
bkxd_ has joined #ruby
msg has joined #ruby
bkxd has quit [Ping timeout: 268 seconds]
msg is now known as Guest45695
jameser has quit [Client Quit]
jameser has joined #ruby
aglorei has quit [Ping timeout: 240 seconds]
Kug3lis has joined #ruby
agent_white has quit [Ping timeout: 240 seconds]
aglorei has joined #ruby
ifctj has quit [Ping timeout: 240 seconds]
<slima>
Hello, I'm totaly noob in ruby, but I like to write script: call for database and puts data to std in order: username -> first: mac,serial sec: mac,serial etc.. this is my code: https://gist.github.com/slima/86725888483249e04a49f532fa3cce74 for now its working wrong (output is in end of the file) can you give me any hint? I'm totaly lost.
stamina has joined #ruby
govg has quit [Ping timeout: 260 seconds]
ta has quit [Read error: Connection reset by peer]
ta has joined #ruby
SteenJobs_ has joined #ruby
<neoncortex>
qq
<neoncortex>
err, sory =D
mogaj has quit [Remote host closed the connection]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Slinky_Pete has joined #ruby
<dminuoso>
Slinky_Pete: I can give you a hint
<dminuoso>
slima: I mean.
<dminuoso>
slima: Start with telling us *what* is wrong. What did you expect instead?
last_staff has quit [Quit: last_staff]
alibby has joined #ruby
gsilva has joined #ruby
govg has joined #ruby
skweek has quit [Ping timeout: 240 seconds]
gsilva has quit [Client Quit]
gsilva has joined #ruby
<neoncortex>
dminuoso: i think i find why my ruby was crashing yesterday, and it's my fault, as usual ..
<dminuoso>
neoncortex: Tell me, what was it?
Slinky_Pete has quit [Ping timeout: 240 seconds]
<neoncortex>
dminuoso: in a loop, i was sometimes assign a value to a variable, sometimes dont, but verifying their value in each iteration
<dminuoso>
neoncortex: Were you doing that in C code?
<dminuoso>
If not, it's definitely NOT you.
<neoncortex>
since i fixed it ( the variable have a proiper value in all iteration), the crash's seems to stopped
<dminuoso>
neoncortex: Can you unfix it please.
<dminuoso>
You just avoid a bug.
<dminuoso>
neoncortex: A ruby crash screen is without exception always an internal bug. Unless you are writing a native extensions, it's _not_ your fault.
<neoncortex>
dminuoso: do you think i just tricked the interpreter?
<dminuoso>
neoncortex: Yes.
<dminuoso>
I dont think it, Im absolutely sure in fact.
<dminuoso>
You should *never* be able to trigger that bug splat screen in Ruby.
<neoncortex>
i see
nickjj has quit [Read error: Connection reset by peer]
<dminuoso>
neoncortex: how large is your code and can it be shared?
<neoncortex>
dminuoso: you're starting to scare me haha
<dminuoso>
No actually its not the GC itself
<dminuoso>
One sec
kristofferR has joined #ruby
cschneid_ has joined #ruby
Fin7_ has joined #ruby
agent_white has joined #ruby
<herwin>
ruby 2.1.5p273
<herwin>
is that one still supported?
<dminuoso>
herwin: Already had them update.
<herwin>
"them"
<dminuoso>
Yes them.
<dminuoso>
Gender neutral pronoun. :-)
Fin7_ has left #ruby [#ruby]
<dminuoso>
Chicago Manual of Style says its fine in casual contexts.
mitt3ns has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
tonini has quit [Quit: Connection closed for inactivity]
cschneid_ has quit [Ping timeout: 255 seconds]
mogaj has quit [Remote host closed the connection]
<herwin>
got a bit confused by reading just half of the discussion, you were not the one pasting the segfault output
<herwin>
note to self: stop reading half of the discussion
* herwin
goed back to work
<neoncortex>
herwin: i pasted this yesterday, and dminuoso think i find a bug in the ruby interpreter .. anyway, go work =D
iwmrby has joined #ruby
nerfed has joined #ruby
devyn has joined #ruby
cibs has quit [Ping timeout: 255 seconds]
mitt3ns has joined #ruby
<nerfed>
hey guys, anyone know how I can temporarily disable an inherited hook on a class? if I `alias_method :__inherited_hook, :inherited` and then redefine inherited, it prevents the original from being called, but then calling __inherited_hook does not call the original hook method and aliasing it back to the original doesn't help either
tyang has joined #ruby
<nerfed>
seems like ruby handles hook methods differently and this is an edge case, I really hope there is a workaround
<dminuoso>
Ohh yes!
cibs has joined #ruby
<dminuoso>
nerfed: I have something for you.
<dminuoso>
Boy this is a perfect week.
nobitanobi has joined #ruby
rgiscard has joined #ruby
agent_white has quit [Ping timeout: 240 seconds]
<nerfed>
dminuoso: it's not often that I run into a brick wall with ruby, so I hope you do have a solution
<nerfed>
I could probably hack a solution to this with a C extension, but I'd really like to keep it pure ruby if at all possible
anisha has joined #ruby
<dminuoso>
nerfed: Absolutely I have 2 ideas. Let me just try the regular Ruby way first before we resort to Fiddle.
Rodya_ has joined #ruby
<nerfed>
the reason I need to accomplish this is that I need to do some extra initialization between creating the derived class and calling the inherited/included/extended hooks
<matthewd>
C.singleton_class.prepend Module.new { attr_accessor :inherited_disabled; def inherited *; super unless inherited_disabled; end }
Slinky_Pete has joined #ruby
<nerfed>
that seems to work, can't believe the solution was so simple
<nerfed>
now to figure out why there is a different between using #class and #singleton_class in this case, so that it can never bite me again
valkyr2e has quit [Ping timeout: 252 seconds]
chamunks has quit [Ping timeout: 252 seconds]
Kestrel-029 has quit [Ping timeout: 252 seconds]
RushPL has quit [Quit: No Ping reply in 180 seconds.]
sagax has quit [Remote host closed the connection]
valkyr2e_ is now known as valkyr2e
<nerfed>
*a difference
<dminuoso>
nerfed: class methods dont belong to the class.
valkyr2e is now known as Guest55219
<dminuoso>
nerfed: lets assume there's no difference between modules and classes (this is kind of true actually), in Ruby *only* classes can have methods.
<dminuoso>
And ruby does not distinguish between class methods and instance methods.
<dminuoso>
So the real difference is on what class they are defined on.
RushPL has joined #ruby
antgel has joined #ruby
Rodya_ has quit [Ping timeout: 255 seconds]
<nerfed>
but all other class level methods can be worked with using #class, it's only hooks which require #singleton_class
<dminuoso>
nerfed: one other thing since we have touched the subject already: within this context: class << foo; end; does nothing but open the singleton_class of foo (whatever that may be), and set it to "self" inside the block and to the default definee.
<dminuoso>
which should now explain why you can also define class methods by doing: class << self; def foo; end
GGMethos has quit [Ping timeout: 240 seconds]
<dminuoso>
because all you do is: "open the singleton class of self, and then define methods onto it"
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
timmow has quit [Ping timeout: 252 seconds]
<dminuoso>
>> a = "foo"; class << a; def length; "17.3"; end; puts a.length # nerfed
Ishido has joined #ruby
* dminuoso
kicks ruby[bot]
<dminuoso>
>> a = "foo"; class << a; def length; "17.3"; end; puts a.length # nerfed
<dminuoso>
>> a = "foo"; class << a; def length; "17.3"; end; end; puts a.length # nerfed
Mortomes|Work has quit [Ping timeout: 260 seconds]
howdoi has quit [Ping timeout: 240 seconds]
lianj has quit [Ping timeout: 252 seconds]
neuraload has joined #ruby
<nerfed>
yeah I understand all that, I just got confused about using the singleton class of a class
lianj has joined #ruby
<dminuoso>
Now do you also know what class_eval does? :p
contradictioned has quit [Quit: No Ping reply in 180 seconds.]
<nerfed>
I work on the class level a lot in ruby, but hardly ever on the singleton class of an instant of an object
<nerfed>
*instance
howdoi has joined #ruby
<dminuoso>
it does not matter whether its an object or a class, its the same story every time.
rgiscard has quit [Remote host closed the connection]
lianj has quit [Changing host]
lianj has joined #ruby
<nerfed>
yeah since everythings an object and every object has a class, including the classes class
rafadc has joined #ruby
timmow has joined #ruby
<dminuoso>
nerfed: right, and everything also has a superclass, which is different from alass
contradictioned has joined #ruby
<dminuoso>
class
<nerfed>
the super class is why I needed to mess with the inherited hook, because I'm initializing the instance of the class manually, passing the super class to the constructor
<dminuoso>
note that technically the singleton chain is infinitely deep
<nerfed>
so I need to skip the inherited hook before I do that, then initialize the actual class data after that, and only then call the inherited hook
t-recx has joined #ruby
jameser has joined #ruby
<dminuoso>
the method call lookup is basically "take the resources klass, and then check the result for its method. if you cant find it, follow the super chain"
<dminuoso>
s/resources/receivers/
<nerfed>
yup
GGMethos has joined #ruby
hightower2 has quit [Remote host closed the connection]
TheWhip has quit [Remote host closed the connection]
rwb has quit [Ping timeout: 240 seconds]
milardovich has joined #ruby
gnufied has joined #ruby
millerti has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
harfangk has joined #ruby
milardovich has quit [Ping timeout: 240 seconds]
jameser has quit [Max SendQ exceeded]
mikecmpbll has quit [Ping timeout: 240 seconds]
aspiers has joined #ruby
jameser has joined #ruby
gnufied has quit [Quit: Leaving]
_whitelogger has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ruby
aredridel has joined #ruby
Guest94512 has quit [Ping timeout: 240 seconds]
Kestrel-029 has joined #ruby
milardovich has joined #ruby
dionysus69 has joined #ruby
case__ has joined #ruby
devyn has quit [Ping timeout: 240 seconds]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kestrel-029 is now known as Guest16987
tfitts has joined #ruby
myk267 has joined #ruby
Guest45695 has quit [Remote host closed the connection]
milardovich has quit [Ping timeout: 260 seconds]
blackmesa has joined #ruby
marsjaninzmarsa has quit [Remote host closed the connection]
icedp has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marsjaninzmarsa has joined #ruby
mim1k has joined #ruby
<manveru>
hmm, wasn't there a method called #eigenclass instead of #singleton_class for a while?
<manveru>
my memory is fuzzy on that
psychicist__ has quit [Ping timeout: 240 seconds]
milardovich has joined #ruby
err_ok has joined #ruby
<manveru>
no, doens't look like it
jameser has joined #ruby
xen0fon has joined #ruby
mim1k has quit [Ping timeout: 240 seconds]
<nerfed>
I recall eigenclass being the terminology for ruby singleton classes many years ago
mim1k has joined #ruby
xen0fon has quit [Client Quit]
antgel has quit [Ping timeout: 255 seconds]
jameser has quit [Client Quit]
TheWhip has joined #ruby
nettoweb has quit [Ping timeout: 240 seconds]
milardovich has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
Slinky_Pete has quit [Remote host closed the connection]
nettoweb has joined #ruby
gnufied has joined #ruby
AKPWD has joined #ruby
terens has joined #ruby
milardovich has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
aspiers has quit [Ping timeout: 260 seconds]
jose_leeto has joined #ruby
nettoweb1 has joined #ruby
nettoweb has quit [Ping timeout: 260 seconds]
andikr has quit [Remote host closed the connection]
<dminuoso>
nerfed: because there were some inaccuracies, I have a new revised version now
Tech has joined #ruby
__Yiota has joined #ruby
<manveru>
yeah, i think _why popularized that at some point
agent_white has joined #ruby
milardovich has quit [Ping timeout: 240 seconds]
<dminuoso>
manveru: I just use the internal names because it helps me concile the terminology with the internals -> keeps your sanity up while debugging
<manveru>
don't worry, my question was totally unrelated to you :)
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<dminuoso>
That should be even better! :D
mitt3ns has quit [Ping timeout: 240 seconds]
govg has quit [Ping timeout: 260 seconds]
tuelz has joined #ruby
jhack has joined #ruby
govg has joined #ruby
<tuelz>
I've got an ivar that is initially nil, is there an idiomatic way/method to push things onto an ivar that creates an array if the ivar is nil?
falconer has joined #ruby
<dminuoso>
tuelz: ivar ||= []
milardovich has joined #ruby
<dminuoso>
tuelz: Note that it does not exactly fulfill your requirement (since it will also do the assignment if ivar is false), but it's a common idiom.
<tuelz>
dminuoso: yeah that's what I'm doing was hoping to omit that LOC
Rodya_ has joined #ruby
Alina-malina_ has joined #ruby
xen0fon has joined #ruby
<dminuoso>
tuelz: Another way is to construct in your initialize method which I prefer.
<tuelz>
thanks though, that works
<dminuoso>
tuelz: Let your constructor set up the class contract.
<dminuoso>
That way all parts can reason about what state your instance variables are in. :)
<tuelz>
makes sense
<tuelz>
dminuoso: thanks as always :)
fusta has quit [Ping timeout: 255 seconds]
jameser has joined #ruby
aspiers has joined #ruby
Alina-malina_ has joined #ruby
Alina-malina_ has quit [Changing host]
braincrash has quit [Ping timeout: 260 seconds]
Alina-malina has quit [Ping timeout: 260 seconds]
Alina-malina_ is now known as Alina-malina
Rodya_ has quit [Ping timeout: 240 seconds]
milardovich has quit [Ping timeout: 260 seconds]
<nerfed>
I wish there was a nice way for derived classes to inherit an inherited hook
tau has joined #ruby
<nerfed>
it's really common for me to require a base class to initialize class level instance variables in a derived class, which I'd use a inherited/included hook for
mikecmpbll has joined #ruby
<nerfed>
but that limits the use to one level of inheritance, any classes which are derived from a derived class will no longer have those ivars initialized
milardovich has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
malconis has joined #ruby
<dminuoso>
nerfed: Do you want me to get the water gun?
<dminuoso>
Look at all the funny stuff you can do with this.
<dminuoso>
On that note I just realized must module Prepend must work in the ruby object model.
<nerfed>
I've been looking for a good real world use case to use prepend for a while now
<nerfed>
I almost thought I was one yesterday, but turned out that would have broken other stuff that I needed
<dminuoso>
Im guessing it takes original klass object, replaces it with a new IClass object and sets that IClass'es superclas to be the original klass object. ;o
<nerfed>
*found one
tyang has quit [Ping timeout: 268 seconds]
<dminuoso>
nerfed: module Prepend is basically your go-to whenever you think you have to use alias_method :P
<dminuoso>
its great for monkey patching stuff
anisha has quit [Quit: This computer has gone to sleep]
milardovich has joined #ruby
<dminuoso>
nerfed: un-prepending and un-including is very simple too.
dionysus69 has quit [Ping timeout: 240 seconds]
<nerfed>
I must remember it for monkeypatching in the future
pandaant has quit [Remote host closed the connection]
itarato has quit [Quit: WeeChat 1.4]
bmurt has joined #ruby
govg has joined #ruby
<tuelz>
is there a method which takes two enumerables and maps each element against all elements in the other? e.g. [1,2,3].map([a,b,c]) { |x,y| [x,y] } #=> [1,a] ...
modin has quit [Ping timeout: 245 seconds]
Burgestrand has quit [Quit: Closing time!]
<rob__>
tuelz: zip
<tuelz>
rob__: thanks
bkxd has joined #ruby
nobody72 has joined #ruby
<allisio>
rob__: Be advised that it doesn't work with Enumerables in the general case.
modin has joined #ruby
<allisio>
You can't #zip Ranges, for instance. :/
<allisio>
Er... never mind? I know there's some nuance to be mindful of, though.
last_staff has joined #ruby
mtkd has quit [Ping timeout: 260 seconds]
nettoweb1 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mtkd has joined #ruby
<allisio>
I guess I must have been thinking of #product.
fusta has joined #ruby
jhack has quit [Quit: jhack]
nopacien13 is now known as nopacienc3
DLSteve has joined #ruby
rafaelaraujo has joined #ruby
cdg has joined #ruby
rafaelaraujo has left #ruby [#ruby]
fuzzyhorns has joined #ruby
iwmrby has quit [Quit: WeeChat 1.7]
itarato has joined #ruby
jenrzzz has joined #ruby
Lyubo1 has quit [Ping timeout: 268 seconds]
<noan>
I think I have my config.ru wrong but I have no idea how to fix it.
volhit has joined #ruby
<noan>
or maybe it's sinatra. Whatever the case I'm getting nothing on the console from one of the "apps" I'm trying to inf.
mogaj has quit [Remote host closed the connection]
mogaj has joined #ruby
<dionysus69>
ok that's it
Slinky_Pete has joined #ruby
<dionysus69>
please someone give me advices on, how to make a ruby gui application that will work on both linux and windows
funnel has quit [Quit: Lost terminal]
skweek has joined #ruby
funnel has joined #ruby
<dionysus69>
I understand that i would have to preinstall ruby on the windows machine manually, or if that's not necessary please let me know that too
mitt3ns has joined #ruby
t-recx has quit [Quit: t-recx]
Slinky_Pete has quit [Ping timeout: 260 seconds]
agit0 has quit [Quit: zzzZZZ….]
mim1k has quit [Ping timeout: 240 seconds]
User458764 has joined #ruby
<allisio>
noan: That's clearly not the problematic portion of the JSON: https://eval.in/741145
User458764 has joined #ruby
<mitt3ns>
Mornin' folks
agent_white has quit [Disconnected by services]
mitt3ns is now known as agent_white
<noan>
allisio, hence whut. I resolved the issue there though I think
mitt3ns has joined #ruby
<jlebrech>
annoyingly, when you do Benchmark.measure any variables in the block are undefined afterwards.
<ChrisWarrick>
I want to iterate over a string, getting two variables: current character and next character (or nil). How do I do that?
anisha has joined #ruby
choke has joined #ruby
<allisio>
ChrisWarrick: You want #each_cons.
<allisio>
jlebrech: There's really no good reason to *want* variables to leak out of their original scopes.
falconer has quit [Quit: Leaving]
swills has quit [Ping timeout: 240 seconds]
<allisio>
If you're hell-bent on having their new values accessible after the measurement, you could pre-initialize them outside the block.
<allisio>
>> x = 1; proc { x = 2 }.call; x
<jlebrech>
allisio: understandable, but sometime you're measuring a line or two and the code needs modifying
nobody72 has joined #ruby
<ChrisWarrick>
allisio: For that, I’d need to (a) .split('') into an array, and then (b) append an extra element to get [last_character, nil]
<dionysus69>
whats most up to date way to create ruby gui app? shoes seems to be forgotten, judging from the last commit.
<allisio>
ChrisWarrick: Prefer `chars` over `split('')`, but yes; still the best way to go about it.
<allisio>
Explicitly iterating over indices is usually bad form.
<allisio>
That is, `(0...s.length).map { |i| [s[i], s[i + 1]] }` is gross.
<ChrisWarrick>
allisio: What about array.zip(array[1..-1]) if I need an array anyways?
<allisio>
ChrisWarrick: Smart.
<matthewd>
ChrisWarrick: That starts to depend on what feels right, based on what you're doing inside the loop
mark_66 has quit [Remote host closed the connection]
noan has quit [Remote host closed the connection]
LambdaSix has quit [Ping timeout: 240 seconds]
noan has joined #ruby
coreutil has joined #ruby
nOwz has quit [Quit: WeeChat 1.7]
JeanCarloMachado has joined #ruby
noan has quit [Remote host closed the connection]
coreutil has quit [Remote host closed the connection]
LambdaSix has joined #ruby
noan has joined #ruby
swills has joined #ruby
bkxd has joined #ruby
Emmanuel_Chanel has joined #ruby
djbkd has joined #ruby
chouhoulis has joined #ruby
siwica has joined #ruby
nobody72 has quit [Ping timeout: 260 seconds]
nettoweb has quit [Ping timeout: 240 seconds]
nobody72 has joined #ruby
TheWhip has quit [Remote host closed the connection]
<siwica>
When comparing two symbols, is it better practice to do `:symbol1 == :symbol2` or `:symbol1.equal(:symbol2)`?
brent__ has joined #ruby
<toretore>
==
<baweaver>
== is fine.
doadet has joined #ruby
<ytti>
i would say first is more idiomatic, whle latter is more pure
<baweaver>
though symbols are literally the same object as opposed to a String or Integer
<baweaver>
s/or Integer//
* baweaver
goes to get coffee before he says something else off
Skarlso- has joined #ruby
yitsushi has joined #ruby
teclator has joined #ruby
armyriad has quit [Ping timeout: 240 seconds]
SuperLag has quit [Quit: leaving]
faces has quit [Ping timeout: 268 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Snowy has quit [Remote host closed the connection]
brent__ has quit [Ping timeout: 260 seconds]
conta has quit [Ping timeout: 268 seconds]
gregf_ has joined #ruby
jtdoncas has joined #ruby
nettoweb has joined #ruby
markholmes has joined #ruby
jenrzzz has joined #ruby
Snowy has joined #ruby
interki has joined #ruby
interki has quit [Excess Flood]
interki has joined #ruby
interki has quit [Client Quit]
jenrzzz has quit [Ping timeout: 255 seconds]
patarr has joined #ruby
Snowy has quit [Quit: ragequit]
brent__ has joined #ruby
interki has joined #ruby
skarlso has quit [Quit: Leaving...]
faces has joined #ruby
polishdub has joined #ruby
Kug3lis_ has joined #ruby
nobody72 has quit [Ping timeout: 240 seconds]
amclain has joined #ruby
reverberations has quit [Read error: Connection reset by peer]
Kug3lis has quit [Ping timeout: 240 seconds]
reverberations has joined #ruby
acovrig has joined #ruby
Burgestrand has quit [Quit: Closing time!]
<acovrig>
I have an *old* system (ruby-1.8.7-p374) that has a reference for rake abc:import; what can I do to figure out what that does? I looked in lib and vendor but don’t see anything that smells like an importer
tyang_ has joined #ruby
Rodya_ has joined #ruby
mim1k has joined #ruby
jlebrech has quit [Remote host closed the connection]
agit0 has joined #ruby
rgiscard has quit [Remote host closed the connection]
nettoweb has quit [Ping timeout: 260 seconds]
Kug3lis_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tyang__ has quit [Ping timeout: 268 seconds]
Rodya_ has quit [Ping timeout: 240 seconds]
Guest71630 has quit [Remote host closed the connection]
msg has joined #ruby
msg is now known as Guest29178
tyang__ has joined #ruby
braincrash has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Remote host closed the connection]
rakm has joined #ruby
Guest29178 has quit [Ping timeout: 240 seconds]
nobitanobi has joined #ruby
tyang_ has quit [Ping timeout: 268 seconds]
nettoweb has joined #ruby
benlieb has quit [Quit: benlieb]
benlieb has joined #ruby
nobitanobi has quit [Ping timeout: 240 seconds]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
agit0 has quit [Quit: zzzZZZ….]
mim1k has quit [Ping timeout: 260 seconds]
aspiers has quit [Ping timeout: 240 seconds]
mtkd has quit [Ping timeout: 240 seconds]
acovrig has quit [Quit: acovrig]
mtkd has joined #ruby
tildes has joined #ruby
tyang_ has joined #ruby
aufi has quit [Quit: Leaving]
t-recx has joined #ruby
tyang__ has quit [Ping timeout: 268 seconds]
nettoweb has quit [Ping timeout: 240 seconds]
tyang has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
itarato has quit [Quit: WeeChat 1.4]
tyang_ has quit [Ping timeout: 268 seconds]
ikopico has joined #ruby
montanonic has joined #ruby
tildes has quit [Remote host closed the connection]
aupadhye has quit [Ping timeout: 260 seconds]
milardovich has quit [Remote host closed the connection]
mogaj has quit [Remote host closed the connection]
<siwica>
What would be the most elegant way to modify each element in an array after a certain condition of an element is met for the first time? E.g. comment out every line in an array of lines after a certain keyword occured in a line for the first time.
montanonic has quit [Ping timeout: 268 seconds]
milardovich has joined #ruby
enterprisey has quit [Remote host closed the connection]
<siwica>
I'd like to use some sort of map that maintains a state between between elements
<toretore>
that's what reduce is
<toretore>
well, not exactly, but it can be
TheWhip has quit [Ping timeout: 240 seconds]
renchan has quit [Quit: Leaving...]
ikopico has quit [Ping timeout: 260 seconds]
antgel has joined #ruby
<siwica>
toretore: Could you provide a minimal example?
synthroi_ has joined #ruby
duderonomy has joined #ruby
anisha has quit [Quit: Leaving]
Tech has quit [Read error: Connection reset by peer]
whathappens has quit [Read error: Connection reset by peer]
whathappens has joined #ruby
synthroid has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<noan>
so if I'm accessing my headers object in sinatra/rack.. is this ALL my headers in a hash? or can some be left out
<siwica>
toretore: ok, I see!
<toretore>
but for your problem, just do `condition = false; array.map{|e| if condition; modify e; else; condition = true if something; end }`
synthroi_ has quit [Ping timeout: 260 seconds]
anisha has joined #ruby
<apeiros>
there's something off with that
<apeiros>
oh
<apeiros>
I see
<apeiros>
nvm :)
<toretore>
needs more flip flop?
<apeiros>
no code ever needs more flip flop
<allisio>
How does the flip-flop work in a #map?
<toretore>
tbh it's an ideal use case for it
<toretore>
if there ever was
montanonic has joined #ruby
<apeiros>
maybe. but you'll have to comment what your code does, and that comment will a) be longer than the alternative code and b) an anti-pattern :)
<toretore>
lol
<toretore>
30 lines of comment explaining wtf a flip flop is
Cohedrin has joined #ruby
<apeiros>
you could cheat and just link to an explanation ^^
chouhou__ has quit [Remote host closed the connection]
JeanCarloMachado has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
JeanCarloMachado has joined #ruby
OMGtechy has joined #ruby
anisha has quit [Quit: This computer has gone to sleep]
xall_ has joined #ruby
GodFather has joined #ruby
matcouto has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
renchan has joined #ruby
marxarelli is now known as marxarelli|afk
GodFather has quit [Remote host closed the connection]
mim1k has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
atmosx has quit [Quit: WeeChat 1.4]
milardovich has quit [Remote host closed the connection]
gsilva has quit [Quit: Leaving]
esObe has joined #ruby
GodFather has joined #ruby
TheWhip has joined #ruby
last_staff has joined #ruby
Anonymoose2 has joined #ruby
mim1k has quit [Ping timeout: 260 seconds]
jgnagy has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 240 seconds]
davezd has quit [Quit: Leaving]
atmosx has joined #ruby
reverberations has quit [Ping timeout: 240 seconds]
mim1k has joined #ruby
<sparr>
I've got a class with an initialize method that takes some params. I'd like to predefine most of those params somewhere, in a way that I can merge them with modifiers when I initialize the object.
<sparr>
example of what I have now: Deck.new(cards: 5, width: 1125, height: 825, layout: ['foo','bar'])
esObe has quit [Remote host closed the connection]
esObe has joined #ruby
jtdoncas has joined #ruby
<sparr>
what I'd like to do is define the width, height, and 'foo' layout in one place and give it a name, then call Deck.new(cards:5, predefinedstuff:thatname, layout:['bar']), but that would require changing the initialize method. Instead, I'd like to maybe make thatname be a hash that gets merged with a second hash of the custom params and that hash gets broken up into the params for the initialize method.
singalaut has quit [Quit: paeh]
<sparr>
what might that look like?
OMGtechy has quit [Quit: Leaving]
alibby has quit [Quit: Leaving.]
singalaut has joined #ruby
<toretore>
why don't you want to change initialize?
<sparr>
not my code to change
Rodya_ has joined #ruby
<toretore>
so what you have is a hash, and you want to merge that hash with some default values?
cdg has quit [Remote host closed the connection]
<sparr>
yes, and then use that hash as the named parameters to new()
nobody72 has quit [Ping timeout: 240 seconds]
<sparr>
in python I'd have two dicts, use update() to merge them, then pass that dict in as **keywords on the function call.
esObe has quit [Ping timeout: 260 seconds]
<toretore>
but it won't deep merge
<toretore>
you can do the same in ruby
<daed>
whoa, 2.4 is out?
<daed>
for quite a while eh..
<sparr>
the merge on the layout array is the trickiest part, I think
A124 has quit [Quit: '']
ikopico has joined #ruby
<toretore>
sparr: you know what the logic you want is, just write a method that merges them the way you want
Rodya_ has quit [Ping timeout: 268 seconds]
benlieb has quit [Quit: benlieb]
<toretore>
Deck.new(my_merge(defaults, other))
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jackjackdripper has quit [Quit: Leaving.]
oetjenj has joined #ruby
A124 has joined #ruby
synthro__ has quit [Remote host closed the connection]
<sparr>
I think I'm gonna make a gist with a better description of my overall situation. Thanks for the help so far!
<djellemah>
jgar: I'm guessing gdbm has a native library dependency, which you haven't installed.
hahuang65 has quit [Ping timeout: 260 seconds]
<allisio>
sparr: Ah, I did miss that part, but djellemah's suggestion (#merge with conflict resolution) is probably just the thing you need.
jackjackdripper has joined #ruby
lenwood has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<jgar>
djellemah - I have installed libgdbm3 and libgdbm-dev - is there something about that stack trace that gives you a clue that a dependency is not installed? I am not familiar with reading ruby traces
<jgar>
@djellemah - also, it seems I can require it OK: root@0101fd913ca1:/snip# ruby -e "require 'gdbm'" root@0101fd913ca1:/snip# echo $? 0
<fuzzyhorns>
it may give some clues where it looks for libs
<sparr>
I want to return an array with a value appended to it, without modifying the original array. can I do that without an explicit copy of the array?
mim1k has quit [Ping timeout: 260 seconds]
<fuzzyhorns>
sparr: no
tyang_ has quit [Ping timeout: 268 seconds]
<fuzzyhorns>
immutability requires copies
<fuzzyhorns>
this isn't just a ruby thing either
<jgar>
fuzzyhorns, djellemah, allisio - you have all been very helpful thank you. I'll investigate further about getting ruby and the deps (ffi and gdbm) linked/working correctly
<fuzzyhorns>
jgar: let us know how it goes and good luck, every time i've dealt with this it's been a bit of a pain!
<sparr>
ok, I'm starting with what allisio gave me earlier, template.merge(custom) { |key, old, new| key == :layout ? old + new : new }
l4v2 has joined #ruby
nettoweb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<allisio>
sparr: ^ indicates that Array#+ doesn't modify the receiver, just to clarify.
synthroid has quit [Ping timeout: 255 seconds]
<sparr>
I want to augment it to allow custom['layout'] to be a single string, instead of an array. in that case, I need my block to evaluate to old.push(new), but I don't want to change old
<sparr>
allisio: yeah, I got it. I'm trying with Array#push now :(
<sparr>
oh, oh, I could use +[new]
<allisio>
Good eye.
<sparr>
template.merge(custom) { |key, old, new| key == :layout ? (new.is_a?(Array) ? old + [new] : old + new) : new }
ifctj has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
nettoweb has joined #ruby
synthroi_ has quit [Ping timeout: 240 seconds]
nettoweb has quit [Client Quit]
<sparr>
yes, yes, rubocop, I know nested conditionals are bad :/
KCmetro_ has joined #ruby
BTRE has quit [Quit: Leaving]
<sparr>
also, my inner ?: is backwards, oops
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
<fuzzyhorns>
jgar: follow-up, i think it's likely you need to rename the lib gdbm
<sparr>
ok, here's a fun question... can a gem contain non-ruby files, and if so then how do I refer to them in my code? like if I want to directly open one for reading.
<fuzzyhorns>
sparr: you can read any file in to string or bytes
<fuzzyhorns>
so as long as your gem is packaged with the files, and your calling code knows where to find them, yep
raspado has quit [Quit: Leaving...]
ifctj has quit [Ping timeout: 240 seconds]
<sparr>
"where to find them" is the question
<djellemah>
sparr: __FILE__ and __dir__
<sparr>
djellemah: that's how a ruby file finds itself, no?
ifctj has joined #ruby
<elomatreb>
IIRC there are some RubyGems conventions on where you should put such files
quoboo has quit [Quit: Connection closed for inactivity]
<sparr>
ok, here's a better writeup of what I'm trying to do in terms of deduplicating array data and code in my current project. I'd appreciate any guidance on how to make the block-calling-a-block part work, and ruby-izing the rest of it: https://gist.github.com/sparr/f668bd7349754f9361e540160f093027
nahra has quit [Read error: Connection reset by peer]
nahra has joined #ruby
zzxc has quit [Ping timeout: 240 seconds]
<sparr>
I'm very fuzzy on the idea of having a block call a block
zzxc has joined #ruby
<fuzzyhorns>
have you worked with Proc objects before sparr>
<fuzzyhorns>
?
nobody72_ has quit [Read error: Connection reset by peer]
last_staff has quit [Quit: last_staff]
<sparr>
I have not
<fuzzyhorns>
sparr: that might help a bit
nobody72 has joined #ruby
milardovich has joined #ruby
rafadc has joined #ruby
redhedded1 has joined #ruby
<fuzzyhorns>
f = proc {|g| g.call('f called') }
<fuzzyhorns>
h = proc {|x| p "#{x} from h" }
benlieb has quit [Quit: benlieb]
<fuzzyhorns>
f.call(h)
<fuzzyhorns>
=> "f called from h"
<fuzzyhorns>
procs are a lot like blocks, but you can pass them around
<fuzzyhorns>
if you need a proc to turn into a block, you use &
<elomatreb>
Not strictly your question but if you want to do something The Ruby Way you should probably avoid nested ternaries D:
Technaton has quit [Quit: ZNC 1.6.4 - http://znc.in]
<sparr>
elomatreb: just for concise irc pasting. I'll break it apart later.
<fuzzyhorns>
not even in ruby but anywhere. nested ternaries are bad :d
skweek has quit [Ping timeout: 260 seconds]
Lyubo1 has quit [Ping timeout: 240 seconds]
<allisio>
sparr: It's a little... all over the place, but you're thinking along the right lines; in the final analysis, Hash#merge is the cleanest approach to this sort of hierarchical configuration.
<sparr>
so, I've got a method that wants a block. I want to deduplicate some code that I always put in that block. I need to be using proc objects to make that work?
blackmesa has joined #ruby
<allisio>
You could go out of your way to architect it around delegation and the like, but that'd be overkill just now.
<fuzzyhorns>
if you want to extract a block out you want a proc
<sparr>
allisio: yeah, the Hash#merge part seems straightforward. Deduplicating the code in all the blocks is where I'm really stuck.
Technaton has joined #ruby
milardovich has quit [Remote host closed the connection]
<djellemah>
>> fn = -> i {i*2}; [1,2,3].map(&fn) #sparr
<allisio>
sparr: Then you'll want to pass along `&some_proc`.
<sparr>
I can't change how Deck.new works
Burgestrand has joined #ruby
<allisio>
I mean, you can... this is Ruby.
rafadc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
millerti has joined #ruby
milardovich has joined #ruby
<sparr>
I'd like to not change how Deck.new works because the person using MY library might still want to call Deck.new on their own later and expect it to still work the same
<elomatreb>
But you don't need to, "turning a Proc into a block" how we described is probably your best option
<sparr>
I'm trying to wrap my head around all the examples everyone has just given
millerti has quit [Client Quit]
jackjackdripper has quit [Quit: Leaving.]
jackjackdripper has joined #ruby
<allisio>
sparr: Sure, and its current signature of (Hash, &block) makes a great deal of sense.
montanonic has quit [Ping timeout: 255 seconds]
<elomatreb>
toretore: "blocks are just anonymous functions as implicit parameters", the Ruby version of "monads are monoids in the category of endofunctors"
dionysus69 has joined #ruby
<allisio>
But with considerably greater informational content.
<sparr>
ok, so, in my make_deck, there's an implicit block parameter
<sparr>
in the definition of make_deck, how do I call that block?
<allisio>
Most performant is `yield`.
<toretore>
`yield` calls the implicit function
<sparr>
yield is how I guessed, and what I put in my example
hahuang65 has quit [Ping timeout: 260 seconds]
oetjenj_ has joined #ruby
<allisio>
sparr: If you don't mind putting the "stuff that always gets called" right there in #make_deck (in the call to Deck.new), then you essentially just need to consider putting the `yield` at the end instead.
Lyubo1 has joined #ruby
rafadc has joined #ruby
ElFerna has joined #ruby
sepp2k has joined #ruby
milardovich has quit [Ping timeout: 268 seconds]
<sparr>
allisio: I need the yield to come first, not last
<sparr>
the stuff that always gets called gets called after the per-deck stuff
ikopico has joined #ruby
marxarelli|afk is now known as marxarelli
<allisio>
sparr: And you're quite sure that's what you want?
xall has quit [Ping timeout: 255 seconds]
marxarelli has joined #ruby
<sparr>
yes. among the stuff that always gets called is the "save the per-deck stuff to a file" call
raspado has quit [Remote host closed the connection]
<allisio>
Sounds like what you really need is a sandwich.
<allisio>
Some prologue and epilogue, to clarify.
raspado has joined #ruby
flips has joined #ruby
oetjenj has quit [Ping timeout: 255 seconds]
Slinky_Pete has joined #ruby
bkxd has joined #ruby
rafadc has quit [Client Quit]
<sparr>
I'm gonna shelve this question for a bit and hope it makes more sense to me later
<allisio>
It's just that you probably want the block passed to #make_deck to be able to perform overrides in the same way as they're able to override values in the constructing Hash.
<sparr>
thanks for all the input, I just need to think about a different part of the problem for a bit
jhack has joined #ruby
jhack has quit [Client Quit]
ElFerna has quit [Client Quit]
workmad3 has quit [Ping timeout: 260 seconds]
matcouto has joined #ruby
raspado has quit [Client Quit]
samdvr has joined #ruby
szulak has joined #ruby
<flips>
With rvm, do I need to separate do a "rvm gemdir" after I've done "rvm [use] <some other version>"?
elifoster has quit [Quit: class]
<sparr>
now I'm thinking about how to make all of this work as a gem. Should I make a new module, like Squib_FOO, or should I augment the Squib module? Either way, should I stick with one Deck class that takes parameters on construction, or should I make one class for each size deck that all inherit from a generic deck?
jhack has joined #ruby
samdvr has left #ruby [#ruby]
jhack has quit [Client Quit]
__Yiota has joined #ruby
benlieb has joined #ruby
nowhereman has quit [Ping timeout: 260 seconds]
<sparr>
does the name of a module need to be the same (ignoring case) as its gem?
cschneid_ has quit [Remote host closed the connection]
<elomatreb>
It's just a convention though, you can break it if it makes sense for you
<sparr>
I did read that, but part of it was confusing...
<sparr>
If you’re adding functionality to another gem, use a dash. This usually corresponds to a / in the require statement (and therefore your gem’s directory structure) and a :: in the name of your main class or module.
hllywluis has joined #ruby
<sparr>
rdoc-data require 'rdoc/data' RDoc::Data
ElFerna has joined #ruby
<sparr>
say I want to publish rdoc-data, but I'm not the author of rdoc. wouldn't that mean my gem can't live in rdoc/ ?
Kug3lis has joined #ruby
<elomatreb>
It can, those are two different directories on your system
bruce_lee has quit [Remote host closed the connection]
jgnagy has quit [Ping timeout: 240 seconds]
cdg has joined #ruby
<sparr>
I still don't understand, but maybe I don't have to
nofxxx has joined #ruby
<elomatreb>
I'm bad at explaining, sorry :(
<sparr>
so, if I want bundler to automatically handle my gem that has an all-caps acronym in its name, I might name it a_b_c so that the module would be ABC?
ElFerna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Burgestrand has quit [Quit: Closing time!]
<sparr>
to make this less abstract... Squib is the gem for making game card decks
Rodya_ has joined #ruby
<elomatreb>
If your module is named ABC your gem should be named "abc" I'd say
<sparr>
I want to extend Squib to handle layouts for a particular game publishing company, The Game Crafter. thegamecrafter is way too long to keep typing, so I'm thinking I want this to be squib-tgc squib/tgc Squib::TGC
nofxx has quit [Ping timeout: 255 seconds]
<sparr>
but the naming page says that 'tgc' capitalizes to 'Tgc' while t_g_c capitalizes to 'TGC'
<elomatreb>
I *think* that's supposed to be for using a module name that consists of multiple words, e.g. StuffDoer
<sparr>
yeah, maybe I should just break the recommendations in this case?
<elomatreb>
I personally don't find TheGameCrafter too bo too long to type, your editor will autocomplete after the first time
aspiers has quit [Ping timeout: 255 seconds]
<allisio>
sparr: You probably shouldn't put your thing in Squib's namespace.
Slinky_Pete has quit []
Rodya_ has quit [Ping timeout: 255 seconds]
<sparr>
my thing is useless without Squib, and strictly extends Squib functionality
millerti has joined #ruby
ElFerna has joined #ruby
Rodya_ has joined #ruby
Rodya__ has joined #ruby
nobitanobi has joined #ruby
ldnunes has quit [Quit: Leaving]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
Xentil has quit [Ping timeout: 268 seconds]
Rodya_ has quit [Ping timeout: 260 seconds]
cdg_ has joined #ruby
_aeris_ has quit [Remote host closed the connection]
ElFerna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sparr>
I could, instead, make a top level module that replaces Squib?
<sparr>
(depends on squib, then provides augmented versions of everything Squib provides)
nobitanobi has quit [Ping timeout: 240 seconds]
ElFerna has joined #ruby
ElFerna has quit [Client Quit]
prestorium has quit [Quit: Leaving]
cdg has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mrgrieve1 has quit [Quit: leaving]
rafadc has joined #ruby
jenrzzz has joined #ruby
Burgestrand has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
esObe has joined #ruby
ElFerna has joined #ruby
rafadc has quit [Client Quit]
renchan has quit [Remote host closed the connection]
Klumben has quit [Ping timeout: 245 seconds]
alem0lars has quit [Ping timeout: 276 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
_aeris_ has joined #ruby
aspiers has joined #ruby
ElFerna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rwb has quit [Ping timeout: 240 seconds]
bdnelson has joined #ruby
whathapp_ has quit [Remote host closed the connection]
Gasher has joined #ruby
whathappens has joined #ruby
bdnelson has left #ruby [#ruby]
tyang__ has quit [Ping timeout: 268 seconds]
alem0lars has joined #ruby
cschneid_ has joined #ruby
milardovich has joined #ruby
cdg has joined #ruby
whathappens has quit [Ping timeout: 260 seconds]
bkxd has quit [Ping timeout: 260 seconds]
griffindy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cschneid_ has quit [Ping timeout: 240 seconds]
aspiers has quit [Ping timeout: 268 seconds]
biberu has quit []
cdg_ has quit [Ping timeout: 260 seconds]
postmodern has joined #ruby
griffindy has joined #ruby
griffindy has quit [Read error: Connection reset by peer]
_2easy_ has quit [Quit: Lost terminal]
synthro__ has quit []
nowhereman has joined #ruby
millerti has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
_2easy has joined #ruby
skweek has joined #ruby
t-recx has quit [Quit: t-recx]
teclator has quit [Ping timeout: 260 seconds]
hahuang61 has joined #ruby
teclator has joined #ruby
Klumben has joined #ruby
Karl____ has joined #ruby
t-recx has joined #ruby
<Karl____>
I'm having the weirdest error. I'm trying to read from a file with file.getc(). The only thing I ever do on the file is open() and getc(). Yet somehow I get the same text twice (but with an extra \" at the end)
tau has quit [Remote host closed the connection]
tomphp has joined #ruby
<Karl____>
I'm probably just being stupid somehow, but I can't for my life figure out how. The thing I described is not expected behavior, right?
antgel has quit [Ping timeout: 260 seconds]
<Karl____>
I tried printing each char with file.pos() next to it, file.pos() is monotonely rising, but when I look at the corresponding lines it looks like they have rewinded until the last eol
JeanCarloMachado has quit [Ping timeout: 260 seconds]
<toretore>
Karl____: code?
<toretore>
?gist
<ruby[bot]>
https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Tech has quit [Quit: Leaving]
KCmetro_ has quit [Remote host closed the connection]
<Karl____>
toretore: I'll try to clean out the worst unnecessary code, brb
<allisio>
Karl____: Are you reading a file with Windows line endings on a system that expects Unix ones?
<allisio>
Printing the '\r' character will return the cursor to the beginning of the line.
hanmac has joined #ruby
<Karl____>
allisio: really? printing it to anyware?
<allisio>
Karl____: Printing it to any non-Windows console, at any rate.
<Papierkorb>
Karl____: "\r" is 'carriage return'. It's job is to move the cursor back to column 0 of the current line
<Papierkorb>
*its
<allisio>
*column 1
markholmes has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
Rodya__ has quit [Remote host closed the connection]
<Karl____>
I'm running it in atom on windows, via the "script" plugin, so it's highly possible that something like that is happening
jtdoncas has quit [Ping timeout: 268 seconds]
<Karl____>
I tried removing all the debug prints in the code and now it looks wrong, but in a different way
<Karl____>
so I think you're on to something
ResidentBiscuit has joined #ruby
Rodya_ has joined #ruby
jackjackdripper has quit [Quit: Leaving.]
aspiers has joined #ruby
<allisio>
Karl____: Yeah, '\r' is almost certainly the culprit. The simplest fix would be to check each character before printing and skip over carriage returns.
<allisio>
At least, you'll get sane output that way.
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has quit [Ping timeout: 240 seconds]
<Papierkorb>
Or, considering this is a toy program, just call #inspect on the character before outputting it
hahuang61 has quit [Remote host closed the connection]
jhack has joined #ruby
hellowarz has joined #ruby
hahuang61 has joined #ruby
blackwind_123 has quit [Ping timeout: 268 seconds]
jtdoncas has joined #ruby
montanonic has quit [Ping timeout: 260 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
astrobunny has joined #ruby
blackwind_123 has joined #ruby
mikecmpbll has joined #ruby
millerti has joined #ruby
cdg has quit [Read error: Connection reset by peer]