michaeldeol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ledestin has joined #ruby-lang
michaeldeol has joined #ruby-lang
meschi has quit [Remote host closed the connection]
michaeldeol has quit [Client Quit]
michaeldeol has joined #ruby-lang
chills42 has quit [Remote host closed the connection]
tkuchiki has quit [Remote host closed the connection]
sross_work|2 has left #ruby-lang ["Once you know what it is you want to be true, instinct is a very useful device for enabling you to know that it is"]
tkuchiki has joined #ruby-lang
Musashi007 has joined #ruby-lang
sross07 has joined #ruby-lang
yfeldblu_ has joined #ruby-lang
yfeldblum has quit [Ping timeout: 245 seconds]
tkuchiki has quit [Ping timeout: 265 seconds]
brooks has joined #ruby-lang
red_menace has quit [Quit: leaving...]
michaeldeol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
michaeldeol has joined #ruby-lang
kiyote23 has joined #ruby-lang
pepperbreath has joined #ruby-lang
kiyote23 has quit [Remote host closed the connection]
stef1a has quit [Ping timeout: 264 seconds]
kalehv has joined #ruby-lang
sangwoojoo has joined #ruby-lang
Hyperfocal has joined #ruby-lang
tectonic has joined #ruby-lang
kalehv has quit [Ping timeout: 264 seconds]
gwendall has joined #ruby-lang
rand0mbits has quit [Read error: Connection reset by peer]
dellavg_ has joined #ruby-lang
gix has quit [Ping timeout: 256 seconds]
gwendall has quit [Ping timeout: 244 seconds]
<levifig>
is there a way to do a split, specifying a bunch of different delimiters in a specific order? :)
<levifig>
Like the first delimiter is a -, the second a ", the third a [, and the fourth a ]?
<|jemc|>
levifig: sounds like you should be using a Regexp and capture groups
<levifig>
hmm… |jemc|, you may be right… :X
<bnagy>
or just a token array
sangwoojoo has quit [Remote host closed the connection]
<levifig>
|jemc|, can I use regex and assign each value to a variable?
gix has joined #ruby-lang
<levifig>
preferably, creating a hash of values from the string
<levifig>
versus array[0] type locators
<|jemc|>
check out named captures
<levifig>
I'll take a look, thanks :)
<levifig>
bnagy, I'll check that too
Hyperfocal has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<bnagy>
if it's some kind of nested thing then [delim1, delim2, delim3 ...].each {|d| stuff=stuff.map {|substr| substr.split(d) or something
<bnagy>
probably needs some flatten and some error checking
<levifig>
FWIW, trying to find a way to parse an nginx access.log
Lewix has quit [Remote host closed the connection]
<levifig>
(to eventually put it into SQL)
<levifig>
it's an old, predefined access.log, not a streaming one
Lewix has joined #ruby-lang
<bnagy>
that sounds super unsafe
mistym has quit [Remote host closed the connection]
<bnagy>
a lot of that is attacker controlled
<bnagy>
especially if you're regexing on it
<bnagy>
I'd probably split on space and go from there - you can clean up the [] in the timestamp manually
<levifig>
not a publicly available script
<levifig>
and not a live access.log
<levifig>
QA needs to go through a specific timeframe of access logs to figure something out :)
fclausen has quit [Ping timeout: 272 seconds]
<levifig>
I'm in charge of getting the logs, parsing them, and dump them into a SQL DB to be analyzed by them :)
<levifig>
good point on the space delimeter
Lewix has quit [Ping timeout: 256 seconds]
<bnagy>
if the url is encoded ( like %20 ) then each line should be a fixed number of fields?
<bnagy>
or am I crazy? I have a very limited access.log from my own nginx
Musashi007 has quit [Ping timeout: 256 seconds]
<levifig>
definitely a defined number of fields
<bnagy>
then that seems easiest. You can reconstruct the timestamp by joining and cleaning those two tokens
<levifig>
interesting
<levifig>
so token array?
<bnagy>
nah just split on ' '
<levifig>
ah
<bnagy>
timestamp is toks[3][1..-1] + toks[4][0..-2] or whatever
<levifig>
ya
<bnagy>
don't use + irl use <<
<levifig>
what's the easiest way to output to SQL?
<levifig>
bnagy, FWIW, access.log in question = 11GB :X
sondr3 has quit [Quit: Ich bin ein sleep.]
<bnagy>
all the more reason to do it line by line
<bnagy>
I'm tapping out on the SQL stuff though
<bnagy>
I used Sequel but like 5 years ago
rbowlby has quit [Remote host closed the connection]
Averna has quit [Quit: Leaving.]
kyb3r_ has joined #ruby-lang
Hyperfocal has joined #ruby-lang
BadQuanta has joined #ruby-lang
brooks has quit [Quit: brooks]
<levifig>
I can probably just export it as JSON and there are ways to import JSON to SQL :)
nathanstitt has quit [Quit: I growing sleepy]
sondr3 has joined #ruby-lang
dellavg_ has quit [Ping timeout: 264 seconds]
slawrence00 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
michaeldeol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mistym has joined #ruby-lang
kiyote23 has joined #ruby-lang
charliesome has quit [Quit: zzz]
michaeldeol has joined #ruby-lang
gjaldon has joined #ruby-lang
|jemc| has quit [Quit: WeeChat 1.0.1]
|jemc| has joined #ruby-lang
gwendall has joined #ruby-lang
kiyote23 has quit [Ping timeout: 264 seconds]
ledestin has quit [Quit: ledestin]
kiyote23 has joined #ruby-lang
gjaldon has quit [Remote host closed the connection]
gwendall has quit [Ping timeout: 265 seconds]
rbowlby has joined #ruby-lang
gjaldon has joined #ruby-lang
charliesome has joined #ruby-lang
pwnz0r has joined #ruby-lang
pwnz0r has quit [Remote host closed the connection]
Musashi007 has joined #ruby-lang
sondr3 has quit [Quit: Ich bin ein sleep.]
Musashi007 has quit [Client Quit]
deol has joined #ruby-lang
michaeldeol has quit [Ping timeout: 264 seconds]
michaeldeol has joined #ruby-lang
deol has quit [Ping timeout: 245 seconds]
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby-lang
gjaldon has quit [Ping timeout: 264 seconds]
RobertBirnie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Xzanron has joined #ruby-lang
skade has joined #ruby-lang
tectonic has quit []
gwendall has joined #ruby-lang
AKASkip has joined #ruby-lang
gwendall has quit [Ping timeout: 265 seconds]
kiyote23 has quit [Remote host closed the connection]
apeiros has quit [Remote host closed the connection]
rahul_j has joined #ruby-lang
gwendall has joined #ruby-lang
Hyperfocal has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
gjaldon has joined #ruby-lang
kiyote23 has joined #ruby-lang
kiyote23 has quit [Ping timeout: 245 seconds]
mattyohe has quit [Quit: Connection closed for inactivity]
gjaldon has quit [Read error: Connection reset by peer]
Seized has joined #ruby-lang
rbowlby has quit [Remote host closed the connection]
gjaldon has joined #ruby-lang
ottlikg has joined #ruby-lang
charliesome has quit [Quit: zzz]
shubhamg_ has quit [Remote host closed the connection]
charliesome has joined #ruby-lang
ddd has quit [Quit: leaving]
apeiros has joined #ruby-lang
gjaldon has quit [Ping timeout: 256 seconds]
<levifig>
when parsing a file with each_line, how do I make it output an array (each line being an item in the array)?
iamninja has quit [Quit: ZZZzzz…]
<apeiros>
s/parsing/reading/. parsing is a different thing ;-)
<levifig>
ya… :X
<levifig>
I think I got it actually :X
shubhamgoyal has joined #ruby-lang
<apeiros>
levifig: File.readlines(path) will return an array directly
<[spoiler]>
Gah my boss brought some kinetic sand the other day and I was playing with it for a few minutes and I can find little sand thingies everywhere
<[spoiler]>
Is there that notice bot around
<apeiros>
chris2: ping: do you see any reason why Rack::Utils::HeaderHash#to_hash should not be implemented as `{}.replace(self)`. it's ~60% faster than the current implementation for a hash with 9 elements.
fclausen has quit [Ping timeout: 272 seconds]
skade has quit [Read error: Connection reset by peer]
skade has joined #ruby-lang
kiyote23 has joined #ruby-lang
amclain has quit [Quit: Leaving]
skade has quit [Remote host closed the connection]
skade has joined #ruby-lang
solars has joined #ruby-lang
kiyote23 has quit [Ping timeout: 264 seconds]
jxie has quit [Quit: leaving]
fclausen has joined #ruby-lang
Seized has quit [Quit: Page closed]
mistym has quit [Remote host closed the connection]
duderonomy has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<chris2>
apeiros: nope, propose a pr
<chris2>
i guess this one doesnt normalize?
jxie has joined #ruby-lang
|jemc| has quit [Quit: WeeChat 1.0.1]
duderonomy has joined #ruby-lang
Integralist has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
Integral2st has joined #ruby-lang
Integral1st has joined #ruby-lang
GBrawl has joined #ruby-lang
fclausen has quit [Ping timeout: 272 seconds]
arBmind has joined #ruby-lang
|jemc| has joined #ruby-lang
tmi__ has joined #ruby-lang
tmi_ has quit [Ping timeout: 252 seconds]
stardiviner has quit [Ping timeout: 244 seconds]
<apeiros>
chris2: no, but neither does the current implementation since it calls []= on the hash
futilegames has joined #ruby-lang
<apeiros>
chris2: oooh, I omitted to check #each
zucaritas has joined #ruby-lang
<apeiros>
and #each applies transformations to the value
<apeiros>
yeah, replace(self) would produce different results for values which respond to to_ary, since `v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v`
hahuang61 has joined #ruby-lang
michaeldeol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
BadQuanta has quit [Remote host closed the connection]
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
hahuang61 has quit [Ping timeout: 265 seconds]
emmesswhy has quit [Quit: Leaving]
havenwood has quit [Remote host closed the connection]
stardiviner has joined #ruby-lang
stardiviner has quit [Changing host]
stardiviner has joined #ruby-lang
rahul_j has joined #ruby-lang
JohnBat26 has joined #ruby-lang
dangerousdave has joined #ruby-lang
rocco88 has joined #ruby-lang
pwnz0r has joined #ruby-lang
rbowlby has joined #ruby-lang
rbowlby has joined #ruby-lang
vondruch has joined #ruby-lang
GBrawl has quit [Ping timeout: 265 seconds]
<ljarvis>
moin
dangerousdave has quit [Client Quit]
nux443 has quit [Quit: leaving]
nofxx has quit [Ping timeout: 256 seconds]
zucaritas has quit [Ping timeout: 244 seconds]
skade has quit [Remote host closed the connection]
rahul_j has quit [Quit: rahul_j]
gwendall has quit [Remote host closed the connection]
gwendall has joined #ruby-lang
skade has joined #ruby-lang
gwendall_ has joined #ruby-lang
gwendall has quit [Ping timeout: 265 seconds]
|jemc| has quit [Ping timeout: 264 seconds]
gwendall_ has quit [Ping timeout: 265 seconds]
qba73 has joined #ruby-lang
arBmind has quit [Quit: Leaving.]
kyb3r_ has quit [Ping timeout: 244 seconds]
ledestin has joined #ruby-lang
kapil__ has quit [Quit: Connection closed for inactivity]
gwendall has joined #ruby-lang
elia has joined #ruby-lang
Missphoenix has quit [Quit: Leaving]
Miphix has joined #ruby-lang
Miphix has quit [Client Quit]
RobertBirnie has joined #ruby-lang
<yorickpeterse>
morning
zucaritas has joined #ruby-lang
mikecmpbll has joined #ruby-lang
arBmind has joined #ruby-lang
Kryptonita has joined #ruby-lang
<Kryptonita>
Hello everydoby..
<Kryptonita>
I am creating a gem that use an extension C code. What I note is that my gems only runs with the ruby version that is build with
elia has quit [Read error: No route to host]
<Kryptonita>
How can I make my gem to be compatible with other ruby versions
<Kryptonita>
?
elia has joined #ruby-lang
Forgetful_Lion has quit [Remote host closed the connection]
<levifig>
anybody know how I can get LONGTEXT in Sequel? :X
rahul_j has joined #ruby-lang
<levifig>
never mind
<levifig>
Text works :)
zucaritas has quit [Ping timeout: 252 seconds]
shubhamgoyal has quit [Remote host closed the connection]
benlovell has joined #ruby-lang
Sadin has quit [Remote host closed the connection]
hendranata_ has quit [Quit: Leaving]
workmad3 has joined #ruby-lang
benten has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Eising>
*sigh* It's been so long since I've worked on this project that I forget how my docker image works...
ocdmw has quit [Ping timeout: 245 seconds]
pwnz0r has quit [Remote host closed the connection]
ldnunes has joined #ruby-lang
shubhamgoyal has joined #ruby-lang
qba73 has quit [Read error: Connection reset by peer]
gwendall has quit [Remote host closed the connection]
qba73 has joined #ruby-lang
francisfish has joined #ruby-lang
iamninja has joined #ruby-lang
stardiviner has quit [Ping timeout: 244 seconds]
GBrawl has joined #ruby-lang
ocdmw has joined #ruby-lang
kapil__ has joined #ruby-lang
gwendall has joined #ruby-lang
stardiviner has joined #ruby-lang
kiyote23 has joined #ruby-lang
rbowlby has quit [Remote host closed the connection]
kiyote23 has quit [Ping timeout: 255 seconds]
benlovell has quit [Ping timeout: 256 seconds]
benlovell has joined #ruby-lang
cornerma1 has joined #ruby-lang
hanjin has joined #ruby-lang
cornerman has quit [Ping timeout: 245 seconds]
cornerma1 is now known as cornerman
skade has quit [Remote host closed the connection]
skade has joined #ruby-lang
Guest81780 has joined #ruby-lang
ottlikg has quit [Ping timeout: 244 seconds]
mfaeh has joined #ruby-lang
iamninja has quit [Quit: ZZZzzz…]
francisfish has quit [Remote host closed the connection]
francisfish has joined #ruby-lang
martinbmadsen has quit [Ping timeout: 252 seconds]
solars has quit [Ping timeout: 245 seconds]
tcopeland has quit [Quit: Leaving.]
Kryptonita has quit [Ping timeout: 255 seconds]
rocco88 has quit [Read error: Connection reset by peer]
ddd has joined #ruby-lang
mfaeh has quit [Remote host closed the connection]
solars has joined #ruby-lang
yusuf has quit [Quit: Leaving.]
sideshowcoder has joined #ruby-lang
postmodern has quit [Quit: Leaving]
iamninja has joined #ruby-lang
gwendall has quit [Remote host closed the connection]
<Xzanron>
Hi. Is there a way to get rake to redirect output to logger? (I'm not using rails)
chills42 has joined #ruby-lang
skade has quit [Remote host closed the connection]
skade has joined #ruby-lang
gwendall has joined #ruby-lang
tkuchiki has joined #ruby-lang
tkuchiki has quit [Remote host closed the connection]
tkuchiki has joined #ruby-lang
joast has joined #ruby-lang
tkuchiki has quit [Ping timeout: 244 seconds]
<yorickpeterse>
Does anybody know of a tool for setting up test data (factories/fixtures/whatever you'd call them) that works with regular Ruby objects? Or basically any custom Ruby code?
<yorickpeterse>
e.g. I might have some tests that require some mocked objects
<yorickpeterse>
those mocked objects might be re-used
<ljarvis>
Xzanron: $stdout = Logger.new(...)
<yorickpeterse>
I basically just want to smack those somewhere in a file, give them a name, and load them in
<ledestin>
could anybode enlighten me how I can make warden to be authenticated for several requests. Currently, it works for first request (html), but not for AJAX (json).
<yorickpeterse>
Without having to use the fat pig that is factory_girl/factory_grill
<ljarvis>
yorickpeterse: no, sounds like a decent idea though. But probably opinionated enough to not be useful for most
<yorickpeterse>
hmpf
<yorickpeterse>
e.g. in this case I have some classes that are normally populated from an XML file
<yorickpeterse>
But that means having fixture files, which are a mess in this particular case
<yorickpeterse>
so I'd rather stub a bunch of things, but I don't want to stub the same stuff every time
<ddd>
could you marshal out the objects to a file and then pull back in?
<ljarvis>
ledestin: bit confused, but you just use warden in the scope you want. Be that html or json
<yorickpeterse>
I can abuse rspec shared examples for this, but blegh
<ledestin>
ljarvis: um, I use login_as and, well, it doesn’t work
<ljarvis>
ledestin: what framework?
<ledestin>
ljarvis: Rails + Devise
<ledestin>
Capybara
<ljarvis>
ledestin: you need to do it manually in your custom controller
<bradland>
yeah, click on the “Homepage” link on the right hand side of the page
<callumacrae>
ah thats the one I was looking at just now
<callumacrae>
I can't decide if it's abandonned or just stable
<bradland>
anyone know if coyboyd’s irc handle is cowboyd?
<DefV>
15:54 -!- ircname : Charles Lowell
<DefV>
looks like it is
<callumacrae>
nunjucks is my favourite templating language (based on jinja2), but I couldn't find a ruby port of that
rocco88 has joined #ruby-lang
Xzanron has quit [Quit: Leaving]
<bradland>
i think you should build a port :)
<callumacrae>
I don't know ruby at all :(
<bradland>
well, the up side is, you won’t need to know much
<bradland>
you can embed JS in Ruby with therubyracer, so you’ll really only need to write Ruby bindings for it
<callumacrae>
wonder how far I can get if I set {% to <%= and {{ to <% and just use erb files
<bradland>
the actual implementation can remain JS
<callumacrae>
Basically the only logic in these files are i18n stuff
<callumacrae>
Which is currently <%= t('lmn.bla.bla.bla') %>
mikecmpb_ is now known as mikecmpbll
ledestin has quit [Quit: ledestin]
_elia has joined #ruby-lang
ottlikg has quit [Ping timeout: 264 seconds]
sangwoojoo has joined #ruby-lang
elia has quit [Ping timeout: 240 seconds]
stef1a has quit [Quit: leaving]
tkuchiki has quit [Remote host closed the connection]
tkuchiki has joined #ruby-lang
hrs has joined #ruby-lang
havenwood has joined #ruby-lang
rahul_j has joined #ruby-lang
osw has joined #ruby-lang
kiyote23 has joined #ruby-lang
tkuchiki has quit [Ping timeout: 245 seconds]
j2p2 has joined #ruby-lang
leonshalimov has quit [Ping timeout: 264 seconds]
vondruch_ has joined #ruby-lang
futilegames_ has joined #ruby-lang
futilegames has quit [Ping timeout: 245 seconds]
futilegames_ is now known as futilegames
vondruch has quit [Ping timeout: 264 seconds]
kiyote23 has quit [Ping timeout: 252 seconds]
ottlikg has joined #ruby-lang
shazaum has joined #ruby-lang
loincloth has joined #ruby-lang
shazaum has quit [Changing host]
shazaum has joined #ruby-lang
nathanstitt has quit [Quit: I growing sleepy]
fijimunkii has joined #ruby-lang
Lewix has quit [Remote host closed the connection]
lcdhoffman has quit [Quit: lcdhoffman]
mcclurmc_ has joined #ruby-lang
Lewix has joined #ruby-lang
bmichelsen has joined #ruby-lang
nathanstitt has joined #ruby-lang
Bwild has quit [Ping timeout: 256 seconds]
hal_9000_ has joined #ruby-lang
btiefert has quit [Read error: Connection reset by peer]
whippythellama has joined #ruby-lang
rikkipitt has joined #ruby-lang
mcclurmc has quit [Ping timeout: 245 seconds]
leonshalimov has joined #ruby-lang
Lewix has quit [Ping timeout: 265 seconds]
Lewix has joined #ruby-lang
mistym has joined #ruby-lang
tenderlove has joined #ruby-lang
tectonic has joined #ruby-lang
mistym has quit [Remote host closed the connection]
tobiassvn has joined #ruby-lang
diegoviola has joined #ruby-lang
slawrence00 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
[H]unt3r has joined #ruby-lang
lcdhoffman has joined #ruby-lang
bmichels_ has joined #ruby-lang
skade has quit [Quit: Computer has gone to sleep.]
kiyote23 has joined #ruby-lang
skade has joined #ruby-lang
bmichels_ has quit [Quit: Bye!]
bmichelsen has quit [Quit: Bye!]
jgpawletko has joined #ruby-lang
jgpawletko is now known as jgpawletko_mtg
gwendall has joined #ruby-lang
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby-lang
mistym has joined #ruby-lang
ocdmw has quit [Remote host closed the connection]
slawrence00 has joined #ruby-lang
apeiros has quit [Ping timeout: 265 seconds]
|jemc| has joined #ruby-lang
kapil__ has quit [Quit: Connection closed for inactivity]
charliesome has quit [Quit: zzz]
kiyote23 has quit [Remote host closed the connection]
svajone has joined #ruby-lang
<svajone>
anyone here?
<svajone>
Anyone know a good way to filter hash using multiple keys and values?
<callumacrae>
dont ask to ask, just ask :)
<callumacrae>
i am slow
<svajone>
Haha. I am using irc on mac for the first time, it doesn’t show me the users. :D
<callumacrae>
theres loads of people here. im just a front-end developer who forgot to a leave, and not much use
oleo has joined #ruby-lang
nathanstitt has quit [Read error: Connection reset by peer]
<svajone>
Hehe. It’s ok. :)
lcdhoffman has quit [Quit: lcdhoffman]
kiyote23 has joined #ruby-lang
klmlfl has joined #ruby-lang
nathanstitt has joined #ruby-lang
lcdhoffman has joined #ruby-lang
charliesome has joined #ruby-lang
<bradland>
svajone: side-topic, but check out Colloquy for Mac if you need a more user-friendly IRC client.
qba73 has quit []
<svajone>
I am using colluquy :D
<svajone>
Haha.
<bradland>
haha, click the little triangle to the left of “ruby”
<svajone>
Been a linux person for so long, kinda weird transitioning.
<bradland>
that will show you the list of users
<svajone>
Haha. I see that now.
<bradland>
as far as filtering hashes, it depends on what you want to do
<svajone>
At first I thought I connected the wrong server.
<bradland>
there’s select and reject
<bradland>
which are pretty well documented
<svajone>
So hash filtering, let’s say I have a hash that contains keys and subnested keys, I want to filter those keys with values equivalent to those keys.
<bradland>
the best thing to do is to post a code snippet with the missing parts commented
intersect has quit [Ping timeout: 244 seconds]
kiyote23 has quit [Ping timeout: 264 seconds]
<bradland>
how deep is the nesting?
<svajone>
just two levels.
<svajone>
Would be like this { key: 1 { key2: value } }
<bradland>
if the depth is fixed, you can use a nested select
<bradland>
you just wrap one select call in another
<svajone>
nested select?
<ljarvis>
"I want to filter those keys with values equivalent to those keys
<ljarvis>
"
<ljarvis>
wat
<svajone>
yep.
<svajone>
I was thinking something like this.
<ljarvis>
svajone: please add input and desired output
<bradland>
it’s better to drop the code in a gist so we can easily download, run, comment, and update it
intersect has joined #ruby-lang
skade has joined #ruby-lang
charliesome has quit [Quit: zzz]
<bradland>
svajone: if you’re going to do filtering, you’ll want to use select/reject, rather than map. they’re very similar, but they alter the Hash based on whether the block evals true/false
<ljarvis>
they dont alter the hash, nor does map
skade has quit [Read error: Connection reset by peer]
<ljarvis>
</pedant>
<bradland>
sry, bad wording
<bradland>
they return a Hash based on whether the block evals true/false
<bradland>
select!/reject! alter the hash
michaeldeol has joined #ruby-lang
<ljarvis>
if only everything was immutable
<bradland>
you no like the bang methods ljarvis?
hahuang61 has joined #ruby-lang
<ljarvis>
bradland: I dont really like mutability all that much
<bradland>
so cases where you want to modify the hash, do you prefer reassignment to the variable?
<bradland>
>> foo = { bar: 'baz', qux: 'quux' };foo = foo.reject { |k, v| v == 'quux' }
rikkipitt has quit [Read error: Connection reset by peer]
<ljarvis>
bradland: generally, yeah. I use a lot of methods, though, and enjoy a functional look. So generally the outer method would be returning foo so there'd be no need to mutate. Obviously there are more cases than that, though
osw has quit [Quit: WeeChat 1.1]
intinig has joined #ruby-lang
rikkipitt has joined #ruby-lang
ocdmw has joined #ruby-lang
<ljarvis>
however, you just can't avoid it in Ruby and im ok with that
<ruby-lang608>
and I have to always use something like this @list.find { |x| x.id == precedent_id }.precedents to get property
<ruby-lang608>
and I wanna know if there is better option to do it
theta88 has quit [Quit: leaving]
<centrx>
ok so in the case of finding a max number, you can try this alternative:
wallerdev has quit [Quit: wallerdev]
<centrx>
list.map(&:number).max
<centrx>
this is equivalent to: list.map { |x| x.number }.max
<pipework>
max_by pls
wallerdev has joined #ruby-lang
<centrx>
ah right, so you have, ruby-lang608 list.max_by(&:number) even more concise
bjessbrown has joined #ruby-lang
<centrx>
ruby-lang608, You may also want to look at the bigger picture, why are you using list.find so much? Maybe you want to use a Hash (aka dictionary) instead of an array, to store these records by their id/key
blacktulip has joined #ruby-lang
<ruby-lang608>
I am writing critical path method structure
fumduq has quit [Ping timeout: 272 seconds]
yfeldblum has joined #ruby-lang
yfeldblum has quit [Remote host closed the connection]
DarkBushido has quit [Ping timeout: 272 seconds]
yfeldblum has joined #ruby-lang
theta88 has joined #ruby-lang
fumduq has joined #ruby-lang
blacktulip has quit [Ping timeout: 244 seconds]
solars has joined #ruby-lang
DarkBushido has joined #ruby-lang
solars has quit [Client Quit]
solars has joined #ruby-lang
blacktulip has joined #ruby-lang
blacktulip has quit [Client Quit]
bmichelsen has joined #ruby-lang
|jemc| has joined #ruby-lang
svajone has quit [Quit: svajone]
<ljarvis>
ruby-lang608: sounds like you want a Hash as centrx suggests
Musashi007 has quit [Quit: Musashi007]
dagda1 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hahuang61 has quit [Quit: WeeChat 1.0.1]
svajone has joined #ruby-lang
hahuang65 has joined #ruby-lang
dik_dak has quit [Read error: Connection reset by peer]
dik_dak has joined #ruby-lang
dik_dak has quit [Max SendQ exceeded]
dik_dak has joined #ruby-lang
svajone has quit [Read error: Connection reset by peer]
sideshowcoder has quit [Ping timeout: 264 seconds]
wallerdev has quit [Quit: wallerdev]
dagda1 has joined #ruby-lang
djbkd has joined #ruby-lang
sideshowcoder has joined #ruby-lang
emmesswhy has joined #ruby-lang
ldnunes has quit [Quit: Leaving]
dik_dak has quit [Client Quit]
martinbmadsen has quit [Ping timeout: 244 seconds]
lytol has quit [Remote host closed the connection]
hrs has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hrs has joined #ruby-lang
ta_ has quit [Read error: Connection reset by peer]
nifoc has quit [Remote host closed the connection]
symm- has quit [Ping timeout: 244 seconds]
rikkipitt has joined #ruby-lang
ta has joined #ruby-lang
nifoc has joined #ruby-lang
DarkBushido has quit [Ping timeout: 265 seconds]
chancancode has quit [Read error: Connection reset by peer]
spastorino has quit [Read error: Connection reset by peer]
manveru has quit [Ping timeout: 265 seconds]
lacrosse__ has quit [Ping timeout: 265 seconds]
dlackty__ has quit [Write error: Connection reset by peer]
Guest81780 has quit [Ping timeout: 265 seconds]
heftig has quit [Remote host closed the connection]
x0f has quit [Ping timeout: 265 seconds]
twe4ked has quit [Ping timeout: 265 seconds]
meizaps has quit [Ping timeout: 265 seconds]
ritek has quit [Ping timeout: 244 seconds]
akahn has quit [Ping timeout: 244 seconds]
mostlybadfly has quit [Ping timeout: 265 seconds]
hellome has quit [Remote host closed the connection]
fclausen has joined #ruby-lang
womble has quit [Ping timeout: 265 seconds]
tobiasvl has quit [Ping timeout: 265 seconds]
havenwood has quit [Remote host closed the connection]
avdi has quit [Read error: Network is unreachable]
ramblinpeck_ has quit [Write error: Connection reset by peer]
jlpeters has quit [Ping timeout: 245 seconds]
tvl has joined #ruby-lang
tvl is now known as tobiasvl
melter has quit [Ping timeout: 265 seconds]
dlackty__ has joined #ruby-lang
manveru has joined #ruby-lang
havenwood has joined #ruby-lang
benten has quit [Quit: ...]
heftig has joined #ruby-lang
workmad3 has joined #ruby-lang
lacrosse__ has joined #ruby-lang
spastorino has joined #ruby-lang
lytol has joined #ruby-lang
avdi has joined #ruby-lang
chancancode has joined #ruby-lang
ritek has joined #ruby-lang
ramblinpeck_ has joined #ruby-lang
akahn has joined #ruby-lang
jlpeters has joined #ruby-lang
sangwoojoo has joined #ruby-lang
womble has joined #ruby-lang
melter has joined #ruby-lang
mostlybadfly has joined #ruby-lang
ocdmw has joined #ruby-lang
hotpancakes has joined #ruby-lang
ocdmw has quit [Remote host closed the connection]
ocdmw has joined #ruby-lang
workmad3 has quit [Ping timeout: 244 seconds]
meizaps has joined #ruby-lang
aef has quit [Remote host closed the connection]
hrs has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
twe4ked has joined #ruby-lang
allolex___ has quit [Ping timeout: 244 seconds]
aef has joined #ruby-lang
aef has quit [Remote host closed the connection]
allolex____ has joined #ruby-lang
x0f has joined #ruby-lang
linc01n has quit [Ping timeout: 244 seconds]
hramrach has quit [Remote host closed the connection]
ishikawa has quit [Remote host closed the connection]
ishikawa has joined #ruby-lang
gnufied has quit [Ping timeout: 244 seconds]
yfeldblum has quit [Read error: Network is unreachable]
bryancp has quit [Read error: Connection reset by peer]
Raycaster has left #ruby-lang [#ruby-lang]
yfeldblum has joined #ruby-lang
hramrach has joined #ruby-lang
DarkBushido has joined #ruby-lang
DarkBushido has quit [Changing host]
DarkBushido has joined #ruby-lang
bryancp has joined #ruby-lang
hrs has joined #ruby-lang
aef has joined #ruby-lang
nomadicoder has quit [Ping timeout: 244 seconds]
linc01n has joined #ruby-lang
leonshalimov has quit [Ping timeout: 240 seconds]
gnufied has joined #ruby-lang
Kryptonita has joined #ruby-lang
odin22 has joined #ruby-lang
nomadicoder has joined #ruby-lang
odin22 has quit [Client Quit]
aef has quit [Remote host closed the connection]
yalue has quit [Quit: return 0;]
aef has joined #ruby-lang
momomomomo has joined #ruby-lang
Kryptonita has quit [Ping timeout: 244 seconds]
aef has quit [Remote host closed the connection]
aef has joined #ruby-lang
michaeldeol has joined #ruby-lang
ocdmw has quit [Remote host closed the connection]
aef has quit [Remote host closed the connection]
symm- has joined #ruby-lang
hotpancakes has quit []
diegovio1 has joined #ruby-lang
wallerdev has joined #ruby-lang
diegoviola has quit [Ping timeout: 252 seconds]
leonshalimov has joined #ruby-lang
wallerdev has quit [Client Quit]
leonshalimov has quit [Ping timeout: 245 seconds]
aef has joined #ruby-lang
bantic has quit [Quit: bantic]
djbkd has quit [Remote host closed the connection]
fusillicode has quit [Quit: Leaving.]
bantic has joined #ruby-lang
|jemc| has quit [Quit: WeeChat 1.0.1]
yfeldblu_ has joined #ruby-lang
yfeldblum has quit [Ping timeout: 245 seconds]
nifoc has quit [Remote host closed the connection]
nifoc has joined #ruby-lang
ruby-lang608 has quit [Quit: Page closed]
wallerdev has joined #ruby-lang
FastJack_ has joined #ruby-lang
setanta_ has quit [Quit: Leaving]
chills42 has quit [Remote host closed the connection]
melter has quit [Quit: Client exiting]
dellavg_ has quit [Ping timeout: 264 seconds]
martinbmadsen has joined #ruby-lang
matp has quit [Remote host closed the connection]
svajone has joined #ruby-lang
michaeldeol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
FastJack has quit [*.net *.split]
<svajone>
Anyone know a good way of indentfying if someone passes + or - on the console?
ottlikg has quit [Ping timeout: 255 seconds]
leonshalimov has joined #ruby-lang
<svajone>
say if I pay +300 then it means I am looking for values greater than 300, if I pass -300 it means I am looking for values less than 300
<eam>
what do you mean passes?
momomomomo_ has joined #ruby-lang
ruby-lang994 has joined #ruby-lang
<ruby-lang994>
ghhk
ruby-lang994 has quit [Client Quit]
michaeldeol has joined #ruby-lang
hrs has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
elia has joined #ruby-lang
melter has joined #ruby-lang
momomomomo has quit [Ping timeout: 244 seconds]
momomomomo_ is now known as momomomomo
<pipework>
svajone: Look into thor
martinbmadsen has quit [Ping timeout: 265 seconds]
Mon_Ouie has quit [Ping timeout: 245 seconds]
hrs has joined #ruby-lang
yfeldblu_ has quit [Remote host closed the connection]
elia has quit [Client Quit]
bmichelsen has quit [Read error: Connection reset by peer]
postmodern has joined #ruby-lang
rikkipitt has quit []
<svajone>
The norse god? :D
kiyote23 has joined #ruby-lang
nathanstitt has joined #ruby-lang
klmlfl_ has joined #ruby-lang
kiyote23 has quit [Ping timeout: 255 seconds]
klmlfl has quit [Ping timeout: 264 seconds]
djbkd has joined #ruby-lang
benlovell has joined #ruby-lang
arBmind has quit [Quit: Leaving.]
arBmind has joined #ruby-lang
leonshalimov has quit [Ping timeout: 245 seconds]
ItSANgo__ has quit [Quit: Leaving...]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
GBrawl has quit [Quit: (null)]
theta88 has quit [Quit: leaving]
dik_dak has joined #ruby-lang
bjessbrown has quit []
diegovio1 is now known as diegoviola
ocdmw has joined #ruby-lang
GBrawl has joined #ruby-lang
leonshalimov has joined #ruby-lang
matp has joined #ruby-lang
ascarter has joined #ruby-lang
tcopeland has quit [Ping timeout: 264 seconds]
elia has joined #ruby-lang
Nixsos has joined #ruby-lang
<svajone>
Hey guys, say the options hash a key is passed twice (the same key) how would i combine the key and the values into an OR statement?
mistym has quit [Remote host closed the connection]
<apeiros>
svajone: you can't pass the same key twice.
<svajone>
I can’t?
<svajone>
So if I have method(:key1 => value, :key1 => different_value
mistym has joined #ruby-lang
<apeiros>
you can't.
<centrx>
in a Hash, the same key overwrites the previous key
<centrx>
You might want an Array of Hashes?
yfeldblum has joined #ruby-lang
<apeiros>
or an array as value
<apeiros>
probably the saner way.
djbkd has quit [Remote host closed the connection]
<svajone>
Ah, I see.
<svajone>
Can you post me a sample gist?
<svajone>
Say, I pass in the key and have an array for the value, how would I iterate through them then?
aef has quit [Remote host closed the connection]
djbkd has joined #ruby-lang
nathanstitt has quit [Quit: I growing sleepy]
yfeldblum has quit [Ping timeout: 265 seconds]
aef has joined #ruby-lang
klmlfl_ has quit [Remote host closed the connection]
<drbrain>
options.each do |key, values| values.each do |value| # ~
klmlfl has joined #ruby-lang
djbkd has quit [Remote host closed the connection]
ocdmw has quit [Remote host closed the connection]
<svajone>
I see, thanks!
[H]unt3r has quit [Remote host closed the connection]
[H]unt3r has joined #ruby-lang
emmesswhy has quit [Quit: This computer has gone to sleep]
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mistym has quit [Remote host closed the connection]
[H]unt3r has quit [Ping timeout: 244 seconds]
[H]unt3r has joined #ruby-lang
emmesswhy has joined #ruby-lang
GBrawl has quit [Ping timeout: 265 seconds]
dagda1 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
rocco88 has joined #ruby-lang
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
rocco88 has left #ruby-lang [#ruby-lang]
ascarter has joined #ruby-lang
ascarter has quit [Max SendQ exceeded]
ItSANgo has joined #ruby-lang
ascarter has joined #ruby-lang
dagda1 has joined #ruby-lang
nathanstitt has joined #ruby-lang
Lewix has quit [Remote host closed the connection]
djbkd has joined #ruby-lang
Lewix has joined #ruby-lang
Lewix has quit [Changing host]
Lewix has joined #ruby-lang
mistym has joined #ruby-lang
Lewix has quit [Ping timeout: 252 seconds]
leonshalimov has quit [Ping timeout: 264 seconds]
djbkd has quit [Ping timeout: 252 seconds]
solars has quit [Ping timeout: 244 seconds]
pwnz0r has joined #ruby-lang
lytol has quit [Remote host closed the connection]
benlovell has quit [Ping timeout: 264 seconds]
djbkd has joined #ruby-lang
leonshalimov has joined #ruby-lang
[H]unt3r has quit []
Mon_Ouie has joined #ruby-lang
Mon_Ouie has joined #ruby-lang
Guest81780 has joined #ruby-lang
martinbmadsen has joined #ruby-lang
sondr3 has joined #ruby-lang
GBrawl has joined #ruby-lang
<svajone>
Hey guys, need a nudge on how to approach this.
<svajone>
So let’s say I can pass an option for weight, so :weight =
<svajone>
:weight => number
GBrawl has quit [Client Quit]
<svajone>
What’s the best way to hand say someone enters, +300 or -300 and if one of the operators exist it’ll do a >, < or == operation.
martinbmadsen has quit [Ping timeout: 245 seconds]
dik_dak_ has joined #ruby-lang
duderonomy has quit [Ping timeout: 256 seconds]
<centrx>
svajone, This is user input from gets? command-line argument?
dik_dak_ has quit [Client Quit]
yfeldblum has joined #ruby-lang
dik_dak_ has joined #ruby-lang
<svajone>
Yep, without using thor.
<svajone>
I want to learn how to do this right. :D
<svajone>
Or let’s start with easy, just an argument when calling the class method.
<centrx>
svajone, so either at the beginning when you get the parameter, or the end when you use it, you have a string
<centrx>
svajone, I would separate the string into an operator and a value