graphene has quit [Remote host closed the connection]
armyriad has quit [Read error: Connection reset by peer]
armyriad has joined #ruby
RougeR has quit [Ping timeout: 244 seconds]
bmurt has joined #ruby
bmurt has quit [Client Quit]
lytol_ has quit [Remote host closed the connection]
cschneid_ has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
lunarkittychan has quit [Ping timeout: 252 seconds]
xfbs has quit [Quit: afk]
bmurt has joined #ruby
lunarkittychan has joined #ruby
AJA4350 has quit [Quit: AJA4350]
xfbs has joined #ruby
samort7 has joined #ruby
gix has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
cschneid_ has quit [Ping timeout: 252 seconds]
gix has quit [Ping timeout: 244 seconds]
gix has joined #ruby
apparition has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
s2013 has joined #ruby
ZzZombo has quit [Read error: Connection reset by peer]
esrse has joined #ruby
vasilakisfil has joined #ruby
<vasilakisfil>
I am a bit confused: is there an as_json method in Ruby or is it only Rails ?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tdy has joined #ruby
patr0clus has quit [Ping timeout: 252 seconds]
<vasilakisfil>
I guess it's railsy
regedit has quit [Quit: Connection closed for inactivity]
xfbs has quit [Quit: afk]
regedit has joined #ruby
vasilakisfil has quit [Ping timeout: 245 seconds]
darkhanb has joined #ruby
ZzZombo has joined #ruby
cschneid_ has joined #ruby
ivanskie has joined #ruby
braincrash has quit [Quit: bye bye]
tdy has quit [Ping timeout: 244 seconds]
baweaver_away is now known as baweaver
braincrash has joined #ruby
tdy has joined #ruby
cschneid_ has quit [Ping timeout: 244 seconds]
tristanp has joined #ruby
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darkhanb has joined #ruby
tristanp has quit [Ping timeout: 244 seconds]
darkhanb has quit [Client Quit]
gix has quit [Disconnected by services]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
white_lilies has quit [Ping timeout: 272 seconds]
ivanskie has joined #ruby
apparition has quit [Quit: Bye]
wildermind has quit [Quit: Connection closed for inactivity]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
cschneid_ has joined #ruby
thy0 has quit [Quit: TTFN]
donofrio has quit [Remote host closed the connection]
darkhanb has joined #ruby
tdy has quit [Ping timeout: 252 seconds]
cschneid_ has quit [Read error: Connection timed out]
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ivanskie has joined #ruby
ivanskie has quit [Client Quit]
cschneid_ has joined #ruby
ur5us has quit [Remote host closed the connection]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lytol_ has joined #ruby
lunarkittychan has quit [Ping timeout: 252 seconds]
lunarkittychan has joined #ruby
cschneid_ has quit [Ping timeout: 240 seconds]
BTRE has quit [Remote host closed the connection]
<ZzZombo>
`Gem::LoadError: can't activate pg (~> 0.11), already activated pg-1.1.3-x86-mingw32. Make sure all dependencies are added to Gemfile.`
<ZzZombo>
What to do to get rid of this error?
BTRE has joined #ruby
scrptktty has quit [Quit: Connection closed for inactivity]
cschneid_ has joined #ruby
<ZzZombo>
I do have `gem 'pg', '~> 1.1.3'` in my `Gemfile`, and no single trace of `~> 0.11` even if either `Gemfile` or `Gemfile.lock`.
cschneid_ has quit [Ping timeout: 240 seconds]
kapil___ has joined #ruby
cschneid_ has joined #ruby
reber has joined #ruby
cschneid_ has quit [Ping timeout: 246 seconds]
Inline has quit [Quit: Leaving]
T3RM1N41 has left #ruby [#ruby]
snickers has joined #ruby
<Radar>
ZzZombo: What exactly are you running to get that error?
<Radar>
ZzZombo: does that command start with "bundle exec" or no?
<ZzZombo>
a rake command
tdy has joined #ruby
Tuor has joined #ruby
<ZzZombo>
Radar: looked it up, it's `rake populate:users`.
<Radar>
ZzZombo: try: `bundle exec rake populate:users`. It's probably not running within a Bundler context, which is why it is ignoring your Gemfile.
<ZzZombo>
Radar: nothing changed.
cschneid_ has joined #ruby
cschneid_ has quit [Ping timeout: 245 seconds]
apeiros has quit [Remote host closed the connection]
s2013 has joined #ruby
tdy has quit [Quit: WeeChat 2.2]
Tuor has quit [Ping timeout: 272 seconds]
aupadhye has joined #ruby
Xiti` has joined #ruby
Xiti has quit [Ping timeout: 252 seconds]
DK2 has joined #ruby
darkhanb has joined #ruby
im0nde has quit [Ping timeout: 264 seconds]
cschneid_ has joined #ruby
aufi has joined #ruby
moei has quit [Ping timeout: 252 seconds]
MoritaShinobu has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
cschneid_ has quit [Ping timeout: 240 seconds]
im0nde has joined #ruby
aufi has quit [Ping timeout: 240 seconds]
cschneid_ has joined #ruby
mike11 has joined #ruby
MoritaShinobu has quit [Ping timeout: 252 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Emmanuel_Chanel has quit [Ping timeout: 272 seconds]
cschneid_ has quit [Ping timeout: 240 seconds]
MoritaShinobu has joined #ruby
cschneid_ has joined #ruby
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
madhatter has joined #ruby
lomex has joined #ruby
lomex has quit [Client Quit]
sysvalve has joined #ruby
cschneid_ has quit [Ping timeout: 245 seconds]
cschneid_ has joined #ruby
agent_white has quit [Quit: leaving]
aufi has joined #ruby
s2013 has joined #ruby
nowhere_man has joined #ruby
cschneid_ has quit [Read error: Connection timed out]
clemens3 has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cschneid_ has joined #ruby
roshanavand has joined #ruby
cschneid_ has quit [Ping timeout: 252 seconds]
vondruch has joined #ruby
Mortomes|Work has joined #ruby
cschneid_ has joined #ruby
cschneid_ has quit [Ping timeout: 245 seconds]
TheBloke- has joined #ruby
TheBloke has quit [Read error: Connection reset by peer]
TheBloke- is now known as TheBloke
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alem0lars has joined #ruby
Emmanuel_Chanel has joined #ruby
RougeR has joined #ruby
nowhere_man has quit [Ping timeout: 245 seconds]
cschneid_ has joined #ruby
z4phod has joined #ruby
lxsameer has joined #ruby
SuperL4g_ has joined #ruby
SuperLag has quit [Ping timeout: 244 seconds]
moei has joined #ruby
regedit has quit [Quit: Connection closed for inactivity]
Emmanuel_Chanel has quit [Ping timeout: 244 seconds]
mikecmpbll has joined #ruby
cschneid_ has quit [Read error: Connection timed out]
SuperLag has joined #ruby
Emmanuel_Chanel has joined #ruby
SuperL4g_ has quit [Ping timeout: 252 seconds]
schneider1 has joined #ruby
Dark_Arc has quit [Ping timeout: 245 seconds]
Dark_Arc has joined #ruby
xfbs has joined #ruby
nowhere_man has joined #ruby
cschneid_ has joined #ruby
chichou has joined #ruby
schneider1 has quit [Quit: WeeChat 2.0.1]
cschneid_ has quit [Ping timeout: 250 seconds]
xfbs has quit [Quit: afk]
Beams has joined #ruby
cschneid_ has joined #ruby
cschneid_ has quit [Ping timeout: 245 seconds]
dalpo has joined #ruby
cschneid_ has joined #ruby
yohji has joined #ruby
cschneid_ has quit [Ping timeout: 244 seconds]
TheBloke has quit [Ping timeout: 250 seconds]
cschneid_ has joined #ruby
TheBloke has joined #ruby
TheBloke has quit [Ping timeout: 240 seconds]
TheBloke has joined #ruby
cschneid_ has quit [Ping timeout: 252 seconds]
nowhere_man has quit [Ping timeout: 264 seconds]
cschneid_ has joined #ruby
roshanavand has quit [Quit: leaving]
ZzZombo has quit [Quit: Going offline, see ya! (www.adiirc.com)]
ua has joined #ruby
jottr has quit [Read error: Connection reset by peer]
jottr has joined #ruby
jottr has quit [Ping timeout: 252 seconds]
tristanp has joined #ruby
jottr has joined #ruby
cschneid_ has quit [Ping timeout: 272 seconds]
tristanp has quit [Ping timeout: 272 seconds]
lunarkittychan is now known as lunarkitty7
lunarkitty7 is now known as lunarkittychan
emers3n has joined #ruby
<emers3n>
I am using gsub to find and replace a string "{{ example-function }}". I want to allow fuzzyness between the brackets and 'example-function', so strings like "{{ example-function | extra-function-options }}" still match... Is this possibly w/o additional gem?
apeiros has joined #ruby
mikecmpb_ has joined #ruby
mikecmpbll has quit [Ping timeout: 244 seconds]
im0nde has quit [Ping timeout: 240 seconds]
cschneid_ has joined #ruby
apparition has joined #ruby
apeiros has quit []
cschneid_ has quit [Ping timeout: 244 seconds]
alem0lars has quit [Ping timeout: 244 seconds]
cschneid_ has joined #ruby
donofrio has joined #ruby
rgr has joined #ruby
apeiros_ has joined #ruby
cschneid_ has quit [Ping timeout: 252 seconds]
<mnemon>
emers3n: yes, you can use regexp with gsub
cschneid_ has joined #ruby
esrse has quit [Ping timeout: 246 seconds]
ZzZombo has joined #ruby
Mortomes|Work_ has joined #ruby
cd has quit [Quit: cd]
mikecmpb_ has quit [Quit: inabit. zz.]
mikecmpbll has joined #ruby
Mortomes|Work has quit [Ping timeout: 252 seconds]
ua has quit [Ping timeout: 240 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
cschneid_ has quit [Ping timeout: 245 seconds]
cschneid_ has joined #ruby
Nicmavr has joined #ruby
ldnunes has joined #ruby
venmx has joined #ruby
<venmx>
hi, has anyone ever used a secrets app called arcanus? i'm getting error when trying to install on alpine docker image... says ERROR: Failed to build gem native extension. any ideas?
aupadhye has quit [Remote host closed the connection]
aupadhye has joined #ruby
<pyrmont>
emers3n: http://rubular.com is a good site for practising different regex combinations to see which works for your situation.
DK2 has quit [Quit: WeeChat 1.6]
Xeago_ has joined #ruby
FirstLoveLife has joined #ruby
Xeago has quit [Ping timeout: 240 seconds]
Xeago_ is now known as Xeago
cschneid_ has quit [Read error: Connection timed out]
Mortomes|Work_ has quit [Ping timeout: 252 seconds]
roshanavand has joined #ruby
tristanp has joined #ruby
sheepman has joined #ruby
<sheepman>
hi all, whats the simplest way of finding if an Array contains both true and false booleans?
<emers3n>
thanks pyrmont, mnemon
AJA4350 has joined #ruby
vondruch has quit [Ping timeout: 244 seconds]
<pyrmont>
sheepman: Simplest is probably #include?
tristanp has quit [Ping timeout: 252 seconds]
<sheepman>
but for two elements?
DarthGandalf has quit [Remote host closed the connection]
DarthGandalf has joined #ruby
InfinityFye has joined #ruby
<pyrmont>
Just run it twice?
<pyrmont>
You can do more complicated things: do #select with a block and check the length of the result but that seems more obtuse to me.
Xiti` has quit [Quit: Xiti`]
emers3n has quit [Quit: Page closed]
sauvin is now known as Sauvin
cschneid_ has joined #ruby
Xiti has joined #ruby
im0nde has joined #ruby
<sheepman>
ok thanks pyrmont
cschneid_ has quit [Ping timeout: 264 seconds]
<RougeR>
yeah sheepman literally foo.include(true) would work
<RougeR>
sorry oo.include(true && false)
<apeiros_>
RougeR: that won't work.
apeiros_ is now known as apeiros
<RougeR>
Apocalypse: why not?
<pyrmont>
I don't think that'll work the way you expect. true && false will resolve to false and you'll just be checking for false.
<RougeR>
i just tried it in pry
<RougeR>
leme double check
<apeiros>
a) it's include?, not include, b) oo.include(true && false) will evaluate `true && false` first, which becomes `false` and hence is just oo.include?(false)
thy0 has joined #ruby
<RougeR>
hmm true
<apeiros>
possible solutions:
<apeiros>
a) ary.include?(true) && ary.include?(false)
<apeiros>
b) [true, false].all? { |value| ary.include?(value) }
<apeiros>
c) ([true, false] - ary).empty?
FirstLoveLife has quit [Ping timeout: 252 seconds]
<RougeR>
3rd one seems best
<RougeR>
still 2 loops isnt it though
Mortomes|Train has joined #ruby
<apeiros>
no, c is one loop
<RougeR>
wait yes
<apeiros>
but for small left sides, it might easily be slower than a)
<RougeR>
could also use sets id think
<apeiros>
Array#- is a set operation.
jottr has quit [Ping timeout: 252 seconds]
<apeiros>
and unless you start out with Set instances, it's faster than converting to Set + performing the operation
<RougeR>
mmm kk
IanMalcolm has joined #ruby
InfinityFye has quit [Quit: Leaving]
jcalla has joined #ruby
InfinityFye has joined #ruby
xfbs has joined #ruby
snickers has quit [Ping timeout: 250 seconds]
toiletpaper5 has joined #ruby
FirstLoveLife has joined #ruby
Sauvin has quit [Ping timeout: 240 seconds]
jottr has joined #ruby
Sauvin has joined #ruby
mike11 has quit [Quit: Leaving.]
jottr has quit [Ping timeout: 240 seconds]
xfbs has quit [Quit: afk]
jottr has joined #ruby
xfbs has joined #ruby
Sauvin has quit [Ping timeout: 245 seconds]
bmurt has joined #ruby
za1b1tsu has joined #ruby
RougeR has quit [Ping timeout: 246 seconds]
Mortomes|Train has quit [Ping timeout: 252 seconds]
kapil___ has joined #ruby
fluxAeon has joined #ruby
Sauvin has joined #ruby
RougeR has joined #ruby
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
arup_r has joined #ruby
vondruch has joined #ruby
Rapture has joined #ruby
gnufied has joined #ruby
arup_r has quit []
alem0lars has joined #ruby
Inline has joined #ruby
Inline has quit [Read error: Connection reset by peer]
Inline has joined #ruby
FirstLoveLife has quit [Ping timeout: 252 seconds]
snickers has joined #ruby
IanMalcolm has joined #ruby
aesthetikx has quit [Ping timeout: 245 seconds]
IanMalcolm has quit [Client Quit]
m27frogy has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 240 seconds]
jottr has joined #ruby
xfbs has quit [Quit: afk]
m27frogy has joined #ruby
aufi has quit [Ping timeout: 245 seconds]
xfbs has joined #ruby
cschneid_ has joined #ruby
nfk has joined #ruby
cschneid_ has quit [Ping timeout: 252 seconds]
apparition has quit [Quit: Bye]
<nfk>
hello, sorry for my google skills failing me on this silly question but how do i get and process output of a block? i'm iterating over a Dir.glob with a block and the final value of each iteration is already what I want but I can't figure out how to collect them in an array or even just a string without using something ugly like passing a variable into the block, which I could to but i'm certain there's a more beautiful ruby way to do it
aupadhye has quit [Quit: Leaving]
MoritaShinobu has quit [Ping timeout: 252 seconds]
<apeiros>
nfk: your question is a bit ambiguous, I think you want `mapped = Dir.glob(glob_expr).map { |path| …process(path)… }`
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nfk>
apeiros, yeah, i literally just wrote that into my code
<nfk>
testing it now
<nfk>
i feel a bit silly now but it proves that it's all about asking the right question. btw just out of curiosity can i collect the final value of each iteration in ruby?
<apeiros>
map does that. if you truly mean "of each iteration"
<nfk>
yeah, i just printed what i wanted: ["usr", "boot", "bin", "dev", "etc", "home", "lib", "lib64", "media", "mnt", "newroot", "opt", "proc", "root", "run", "sbin", "srv", "sys", "tmp", "var", "fio"]
<nfk>
needs more work, naturally but at least i'm getting there
<nfk>
now.. if only ruby had a decent gui and i didn't have to write on in capistrano :D
<nfk>
*one
snickers has joined #ruby
bmurt has quit [Ping timeout: 252 seconds]
c0ncealed2 has quit [Remote host closed the connection]
c0ncealed2 has joined #ruby
<nfk>
apeiros, btw, is it better on humane grounds to assign a Dir.glob array to a variable and then map { ... }.sort! that or to just go Dir.glob ... .sort in one swell swoop?
<apeiros>
depends. assigning to local variables gives you an opportunity to name intermediate results, making it easier to read the code
<nfk>
i'm inclined towards the later but i can't recall anyone ever having done that so i'm a bit worried about the sanity of anyone who might read my code
snickers has quit [Client Quit]
<apeiros>
on another note: *never* use bang methods from core when you want the return value.
aufi has joined #ruby
<apeiros>
many of them will return nil if nothing changed
<nfk>
apeiros, come again on that, please? I'm not sure i groked that
<apeiros>
so: `Dir.glob(x).map { … }.select { … }.sort`, not `Dir.glob(x).map! { … }.select { … }.sort!`
<nfk>
huh, would that be like [1, 2, 3].map! {|n| n*n } => [nil, 4, 9]?
<nfk>
why would 1 be returned when 1 and the return value of 1*1 should be the same object just like "HI" and "HI".upcase! ?
IanMalcolm has joined #ruby
<apeiros>
no, if map! worked like upcase!, the whole return value would be nil, not just a single element.
<apeiros>
but map! actually is one of the bang methods which will return self.
bmurt has joined #ruby
<nfk>
so map! is safe but sort!, upcase! and most others are not?
duderonomy has joined #ruby
<apeiros>
I don't bother to remember which ones are and which ones aren't. I find it easier to just use the rule "return value -> no bang, in-place -> bang"
<apeiros>
(though, bang actually only means "be careful", but it's almost always used for in-place variants)
<nfk>
yeah, thanks both for your initial answer and this explanation. i have a weird feeling that i might have hit that landmine before but never figured out what was going on and just not used map altogether
<nfk>
oh wait, not map but..
<nfk>
hmm.. i can remember the Rails project which gave me the most headaches but can't recall which method i got to work around as it was just giving me missing values
mike11 has joined #ruby
cagomez has joined #ruby
cagomez_ has joined #ruby
phaul has joined #ruby
<phaul>
hi, can someone point me some freely available material on Ruby lexical scopes? I've read some contradictory info and now I'm more confused than before I started my research ..
cagomez__ has joined #ruby
cagomez has quit [Read error: Connection reset by peer]
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<phaul>
I must be misunderstanding something.. What is it?
IanMalcolm has joined #ruby
beowuff has joined #ruby
<havenwood>
phaul: I don't understand the premise of the question. Places like top level actually have a different context for setting and getting methods and method lookup than they do for defining of methods and constants. Do you count top level as then not a scope, but using that of an Object instance and also the Object class?
<havenwood>
phaul: Scope of what?
<havenwood>
phaul: There are lexically scoped things, like refinements. I don't think any of the answers are right. :P
<phaul>
:)
<phaul>
I would like to have a thorough understanding of this. What should I read?
<nfk>
i think the first question here should be what is a scope
<nfk>
e.g. would a piece of code such as this: foo = "bar" introduce a variable that does not exist beyond certain bounds be considered a scope?
<nfk>
errr.
<nfk>
let me regrammarise that
<havenwood>
so we should limit the scope of the question to what is a scope?
<havenwood>
how many scopes does this question have?
<nfk>
e.g. would a piece of code such as this: foo = "bar" introducing a variable that does not exist beyond certain bounds be considered to define those bounds as a scope?
<nfk>
havenwood, no, that's the first question because i suspect that ruby has at least two answers to his original question depending on how one defines a scope
<phaul>
nfk: what are your scope definitions?
<nfk>
that having been said, i personally do not care about such things so it's just a hunch i have after years of rubying sometimes
snickers has joined #ruby
snickers has quit [Client Quit]
<nfk>
phaul, i'm just a noob, sorry. but my first one would be what i just asked. the second one is probably along the lines of either language design intent and lexical/syntactical distinctions but i do not know how to define it more clearly
<phaul>
Ok let's say we take the first one as the definition of a 'scope'. How many different things qualify as a scope then?
<havenwood>
phaul: scope of what?
<havenwood>
phaul: context for setting and getting methods and method lookup?
<nfk>
phaul, but if you want an answer from a noob, then i'd say that stackoverflow guy with 5 is closer to a practical definition of a scope even if the linguistically correct answer is a smaller number. Also I suspect the "expert" intentionally avoided the top level (script?) scope as it's not an intentional scope but a requirement to make the language work (i think)
<havenwood>
phaul: context for defining of methods and constants?
<phaul>
havenwood: let's say scope of nfk's first definition
<nfk>
havenwood, how about instead of answering a question with a question you gave us your honest opinion to the question of "how many scopes does ruby have?"
<havenwood>
phaul: so getting local variables?
<phaul>
right
<havenwood>
nfk: That's a nonsensical question. I already answered in my first comment. I do not accept the premise of there being a number of "scopes" that Ruby has.
<havenwood>
nfk: If you want a number, I say 42.
<havenwood>
nfk: It's like saying how many wins does Ruby have. I just don't get it.
mikecmpbll has quit [Quit: inabit. zz.]
<havenwood>
phaul: I guess there's two, the scope where you can get that variable and the scope where you can't. :P
<phaul>
havenwood: not helpful.
<nfk>
havenwood, look, i might be a ruby noob but i do have a degree in software engineering. a scope is a perfectly valid if a bit practically-conceptual term that denotes contexts within programming language where defining or redefining things do not clobber things of the same name and type in another scope
<havenwood>
nfk: So many things have scopes, right. The scope for variable lookup is not the same for constant assignment. It's more complex than simple counting of a single plane of a thing.
<havenwood>
nfk: It's like saying what is the count of our body parts. Then getting mad at a physician who says there's not a straightforward count.
<havenwood>
nfk: Is an arm one part? 50?
<havenwood>
nfk: I'm not debating there ARE body parts. I'm objecting to meaning of counting them.
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<havenwood>
nfk: There are scopes in Ruby, and it's interesting to talk about.
<havenwood>
I have no clue how to meaningfully count them.
<nfk>
havenwood, which is why after years of rubying i still can't answer this basic question ;) i kinda get what you're saying and that's also exactly what i feel about the definition of bodyparts but i still prefer to have a loose yet practical definition over saying: "Reality is too dificult to describe exactly so let's either give up or use some totally abstract yet mathematically valid notation"
<havenwood>
nfk: I'd love to talk about how the arm works. I just don't know how to count its parts meaningfully.
<havenwood>
Is it the scope of an Object? A Class? Both!
justinweiss has joined #ruby
<nfk>
havenwood, i know, just like a vegetable is completely arbitrary definition for roots and fruits and whatnot, so does that mean we should forget about the the word "vegetable" or answer: "how many fingers does a human arm have?" with: "there are no arms because they're too dificult to define"
<havenwood>
I think zooming in gives more interesting detail to debate. Like, "how many scopes are there in Ruby top level?"
NL3limin4t0r has joined #ruby
<havenwood>
Counting a thing that itself has many scopes as one scope is suspect.
<nfk>
wasn't ruby supposed to not surprise people familiar with it?
<havenwood>
nfk: Nope. It's supposed to be the principle of least surprise to *Matz*.
<phaul>
nfk: I'm not even surprised any more :)
<havenwood>
nfk: What Matz has to say about it is interesting. He was surprised others liked what he liked so much.
<havenwood>
nfk: I guess the closer you think to Matz, the less surprise it will be.
<nfk>
except i want to think like myself
darkhanb has joined #ruby
<havenwood>
I don't think Ruby is a simple language. That might be why few universities seem to teach with it.
ivanskie has joined #ruby
<phaul>
havenwood: is there a meaningful count on how many different scope definitions can be? And then for each we could argue how many Ruby has... Where of course the number itself is not interesting, but what those scopes are is.
<nfk>
it has a lot more to do with it not having a connection to the academia
<havenwood>
It may be easy for an experienced C programmer to adopt, but it's not simple.
<havenwood>
nfk: Maybe so
<havenwood>
phaul: It's kinda a separate question for constants, variables, methods, etc.
<havenwood>
phaul: Each is intersting.
<havenwood>
phaul: Just constant lookup and scope is a whole thing to dig into.
<havenwood>
phaul: Or just method lookup and scope is too.
<nfk>
phaul, so in short, there's >=5 scopes in ruby; whether to go down the rabbithole or do something else is up to you
<havenwood>
phaul: Methods for example have different scopes for definition than they do for getting and setting. It's a rabbit hole.
<nfk>
also "expert" is anyone who has written a book, write one yourself
<havenwood>
Ruby Under a Microscope is a good book on the subject.
<havenwood>
haven't read that ^ but seems on-subject
MaiconVieira has joined #ruby
<phaul>
well I lied I used it when I passed it to erb :)
<nfk>
the theoretical point of them is that you have methods through which you interact with some hidden internals of a class as if it was a member variable but in reality this tends to be just a bunch of boilerplate for a variable that's essentially impossible to keep away from outside tampering
<NL3limin4t0r>
nfk: You have to see getters and setters as the api to the variable. If some developer is going to change the internals of some class, variables may change but the getters and setters might stay the same.
<nfk>
NL3limin4t0r, yeah, i avoided saying that for brevity and the fact that people who need to know this already would know it so i didn't say that ;)
<phaul>
havenwood: thanks for the links. I will read them
<nfk>
NL3limin4t0r, also observe that i never said there even was an internal variable just that if one has access to them they are next to impossible to keep away from whatever internals there are
<nfk>
them being the getter and setter
clemens3 has quit [Remote host closed the connection]
<havenwood>
nfk: I'd orphan it, garbage collect, fork it then zombie the process. You might still be able to get at it, but it'd be harder. :P
<havenwood>
Like they say, "Ruby, you'll shoot your eye out."
<havenwood>
Actually, do they still say that? Hah.
lomex has joined #ruby
yohji has quit [Remote host closed the connection]
<havenwood>
nfk: I've definitely seen SDK gems that presume unexposed instance variables can't be gotten at. >.>
patr0clus has joined #ruby
[Butch] has joined #ruby
<rgr>
whats the standard approach to making the ruby thats been installed in my home directory accessible to www-data for apache/passenger? install all again as user www-data? I know nothing about ruby/rails etc. I have a passenger load module and rugby env set to my local dirs in my vhost but it seems somehow wrong.
DTZUZO has quit [Ping timeout: 244 seconds]
patr0clus has quit [Ping timeout: 246 seconds]
apeiros has quit []
<NL3limin4t0r>
rgr: I guess that question is better asked in the apache or pessenger irc channel (#httpd). Since it's the job of those programs to route the initial incomming requests.
patr0clus has joined #ruby
<nfk>
havenwood, first, i doubt it will be very effective. You would need actual anti-tampering code and even then i'm not sure how effective that would be considering that people, i imagine, produce cracks for even obfuscated proprietary software without any source code publicly available. And this is not a ruby specific issue, getters and setters being misunderstood (along the entire OOP visibility fluff) as a security feature is a common part of OOP (mis)
<nfk>
understanding and teaching
lxsameer has quit [Ping timeout: 240 seconds]
clemens3 has joined #ruby
clemens3 has quit [Client Quit]
lxsameer has joined #ruby
clemens3 has joined #ruby
<NL3limin4t0r>
nfk: Ruby is pretty hackable, it's not the intention of Ruby to make anything inaccessible. It's more like the waranty on your computer. You can screw it open if you want, change parts, whatever. But if you want the "simple" and intended experiance you just use the IO given to you by the developers.
patr0clus has quit [Ping timeout: 252 seconds]
MaiconVieira has quit [Quit: Page closed]
<NL3limin4t0r>
That's why Ruby has methods like `send` and `instance_variable_{set,get}` which allows anyone access to almost anything.
<nfk>
rgr, this is actually more about systems administration. I think it boils down to the way you interact with your ruby app. What I'd do in your place was to either try installing ruby elsewhere that would be system-wide (/usr/local comes to mind) or use the system provided ruby OR I would run a ruby application server that was only accessible locally (or from a (V)LAN, which is neat for scaling) and then have the forward facing http server send requests it does
<nfk>
not know to the application server over either local socket or loopback interface
<nfk>
NL3limin4t0r, again, my criticism is true for every single OOP implementation that I have ever learned
s2013 has joined #ruby
patr0clus has joined #ruby
<nfk>
furthermore i criticized the way people misunderstand due to misinformation and bad instructors what is a language abstraction feature as a security feature; finally at most i implicitly criticized languages for allowing to bypass this level of abstraction, essentially defeating it's purpose
lxsameer has quit [Ping timeout: 240 seconds]
lxsameer has joined #ruby
toiletpaper5 has quit [Ping timeout: 250 seconds]
eckhardt_ has joined #ruby
lxsameer has quit [Ping timeout: 252 seconds]
<nfk>
s/as/for/
duderonomy has quit [Ping timeout: 244 seconds]
<nfk>
s/it\'s/its/
patr0clus has quit [Ping timeout: 252 seconds]
lxsameer has joined #ruby
<NL3limin4t0r>
So should car manufacturers also solder the hood of an car, just you can't tinker with the insides?
<NL3limin4t0r>
just so* you
<havenwood>
I like Ruby's anarchistic principle of trusting the programmer to behave or not at their own discretion.
Beams has quit [Quit: .]
<rgr>
I is ruby specific in that I cant see how to install gems in anywhere other than my own home directory sub directories. Ah, its a locked down server. Sod it. It'll be fine pointing to my home dir. It#s not life and death.
patr0clus has joined #ruby
sparr has joined #ruby
<sparr>
With ruby 2.3.3, I just did `gem install rubocop` and got almost enough packages to run it. It seems to also want `rubocop-rspec` installed. Is this a dependency problem?
<nfk>
NL3limin4t0r, solder? i can chisel that easily. Maybe you meant weld? That would make it harder for themselves, also at least in EU that would be illegal if one couldn't replace bulbs or air filters easily
<havenwood>
sparr: What the error you're running into?
nowhere_man has joined #ruby
patr0clus has quit [Client Quit]
<nfk>
havenwood, NL3limin4t0r, again, i'm not singling out ruby for this, so chillax; all OOP implementations that I know are the same in this regard. And I never said they should disallow it for security reasons as those would be relatively easy to circumvent anyway but rather they should enforce it for the sake of staying true to OOP, if the programmer has apparently explicitly decided to embrace the use of getters and setters
<havenwood>
nfk: I'm so chillaxed I'll go comatose if I chillax further.
<nfk>
havenwood, i think you still have ways to go, bob (marley)
<nfk>
;)
<havenwood>
nfk: Ruby has one layer that respects object boundaries then another metaprogramming layer that doesn't care.
<havenwood>
nfk: It's kinda a nice way to do it.
lxsameer has quit [Ping timeout: 252 seconds]
<havenwood>
nfk: Agreed that it's also interesting to strictly enforce.
<havenwood>
I prefer to not have hard rules though, and follow them willingly. Granted, it lets you shoot your eye out.
<havenwood>
TIMTOWTDI
lxsameer has joined #ruby
<havenwood>
sparr: I don't see where rubocop-rspec is a dep of rubocop though. It's a plugin, right?
<havenwood>
sparr: Do you have this in your .rubocop.yml?: require: rubocop-rspec
wojnar has joined #ruby
jottr has quit [Ping timeout: 240 seconds]
<havenwood>
sparr: Or is this a rake task and ruboocop-rspec is added to the task requires?
<havenwood>
sparr: Say more about how you're running it?'
jgpawletko has joined #ruby
<nfk>
havenwood, then why have OOP anyway? the whole point is to force a certain external API for your code, which is then undermined by the fact that anyone can just poke at the implementation internals anyway with the only meaningful difference being that you can change them and then smugly dismiss any bugreports or complaints as well deserved grievances for abusing your code - i'm sure some *cough* Red Hat *cough* people will get off from that
jgpawletko has quit [Client Quit]
RedNifre has joined #ruby
<havenwood>
nfk: The point is to provide tools that we humans can grok. OOP isn't adding anything meaningful for the computer.
<NL3limin4t0r>
I recently encountered some anoying behaviour of Ruby. So when a module A is included in class Foo all instance method changes to A are reflected in the instances of Foo. However say I want to extend A. In my opinion the "clean" way to do this is to create a new module B and prepend that to A. However classes that already incuded A will never call the updated version in B unless they include A again, after B is
<NL3limin4t0r>
prepended to A. My example can be found here: https://gist.github.com/3limin4t0r/fa7c4f39c55c5e75269ca7050094ca85. Is there a clean way to resolve this problem? I though of the following solutions. 1) Include to Foo instead (after the inclution of A ofcourse). 2) Don't make module B and instead just open up A. (Saving the method in a variable, than calling that from my newly defined method.)
<RedNifre>
Hey, I'm doing "Quit script with ctrl+c" wrong and I don't know how to do it properly :(
<havenwood>
nfk: Whether you let programmers do anything or constrain them seems like a separate question to me.
lxsameer has quit [Ping timeout: 250 seconds]
RougeR has quit [Ping timeout: 264 seconds]
<havenwood>
RedNifre: How can you tell it's wrong?
<RedNifre>
See, I have this script that is continually processing a log file. When I quit it with ctrl+c it should write its state to a yaml file. This worked on linux, but on cygwin it seems to be killed too quickly sometimes so the file ends up empty.
<RedNifre>
What I did was begin ... ensure write_to_file end
<RedNifre>
...and the ensure part seems to get killed sometimes before the file gets written.
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
RedNifre: Are you trapping SIGINT?
<havenwood>
RedNifre: Show the code?
<RedNifre>
So I guess I'm doing "quitting the script" the wrong way... what's the proper way to quit a script and let the script save its state to a file?
<RedNifre>
I... might be I guess? Hang on...
<havenwood>
NL3limin4t0r: Hrmmm
<RedNifre>
The code is really begin (process log file by reading from STDIN) ensure (Save to yaml file) end
<nfk>
NL3limin4t0r, this won't help you in any way but if A was a class you could extend it which is the correct way to do it, imvho; alas modules should not be extendible which is what you get for using a very old cold segmentation/sharing approach from like the 60's (or thenabout)
<nfk>
*code
<RedNifre>
It often works, but often doesn't and I either end up with an empty file or the file doesn't get updated at all... let me look up SIGINT...
<nfk>
sorry about that typo, that was just my subconsciousness telling me i should do something about the low temperature in my room
<RedNifre>
I'm not sure it's even the right approach... I mean, how do you implement scripts that process a stream but can also be interrupted and save their state?
<nfk>
RedNifre, actually, if your script handles stdio, then the normal unix way would be either q or Ctrl+D
<havenwood>
It's a nice way to close the erlang/elixir/python/etc repl
<nfk>
q being for programs that do not need to directly process stdio as part of their core operation while Ctrl+D would be for true *nix programs as a sort of in-band control by design (they are supposed to process a single file on stdio and then quit)
<nfk>
RedNifre, then the next standard approach is using a signal and SIGINT seems reasonable as USRn are generally specific to the application and probably for operational rather than terminal signaling
<havenwood>
You can tell by how repls handle and mishandle these that it's not universally adopted convention >.>
<RedNifre>
Well, it sounds like SIGINT is "terminate gracefully" so I'm surprised that it gets killed so quickly that it sometimes can't even write a small yaml file.
<havenwood>
RedNifre: You can make it terminate gracefully by trapping SIGINT and making sure the grace part happens!
<nfk>
RedNifre, assuming you're correctly trapping SIGINT, then it must be either cygwin or windows specific, sorry
<nfk>
from what i have seen, on *nix the first SIGINT is left to the app and the second either has some higher up handler that's very ubiquitous or is provided by the platform itself
<RedNifre>
I'm not sure if I'm correctly trapping SIGINT, it's really just `begin ... ensure (write to file) end`
<nfk>
that having been said, true *nix programs that wait for closing of all open connections will regard any number of SIGINTs
* RedNifre
looks up how to correctly trap SIGINT int ruby...
<nfk>
RedNifre, that's just from my memory as i have never written anything like that but i think you're supposed to handle SIGINT yourself if you do not want your runtime or something handling it for you
<nfk>
probably something like it moving from your app to the runtime to language to stdlib to kernel? just a wild guess
<RedNifre>
Well, what exactly does "ensure" do in this case? does it first tell the OS "I don't care, do what you must!" and then tries to run the following code whereas `rescue Interrupt` would tell the OS "I'm hearing you, give me a sec here!"?
clemens3 has quit [Ping timeout: 252 seconds]
<havenwood>
RedNifre: Ruby also has an #on_exit
<havenwood>
RedNifre: ensure has to do with error handling, but doesn't know about signals
<nfk>
RedNifre, i think *nix signal handling conceptually is a lot like Exception handling - if you catch it, it's then up to you to handle the situation, possibly including not handling a repeated SIGINT if the user becomes impatient
<RedNifre>
Well, it feel like "ensure" kinda sees the "exception" but does not "catch" it so the OS doesn't know that the script is trying to do something... if I understand it correctly then `begin ... rescue SystemExit, Interrupt ... end` should work instead.
lxsameer has quit [Ping timeout: 245 seconds]
<havenwood>
RedNifre: Mmm, good point - you could rescue things we tend not to instead of signal trap. I guess that makes sense when you only want to trap on a particular error.
<havenwood>
RedNifre: I mean on a particular segment of code*
<havenwood>
RedNifre: Do you want to handle all exits from your program (#at_exit), all int signals from your program (#trap) or just signals in a specific segment of code (the solution you mention).
<havenwood>
RedNifre: This'd be an interesting thing to do a writeup on.
za1b1tsu has quit [Quit: WeeChat 2.1]
<RedNifre>
Well... It's just that I have the script running locally on my machine, I want to quit it easily and I want it to continue where it left off when I start it again, so it should save its state when I quit it.
<RedNifre>
I'll see if it works now...
lxsameer has joined #ruby
duderonomy has joined #ruby
<nfk>
RedNifre, in that case, you should also use a certain pattern to ensure that the file does not get corrupted even on forced termination. i'm quite certain there's a certain Linux pattern you're supposed to use, i just can't seem to find it
snickers has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
jottr has joined #ruby
za1b1tsu has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
lxsameer has joined #ruby
jottr has quit [Ping timeout: 264 seconds]
<nfk>
RedNifre, i could not find the pattern, so take this with a grain of salt but I'd do something like this: 1) periodically create a new file (rather than overwriting the old one), 2) wait for sync to finish on it, 3) mv the previous version of log to .old (i.e. foo.log.old), 4) mv the new version to be the main file and 5) rm the old version. Optionally you might do a filesystem sync after all of this. Do note that this is (probably) safe only on GNU/Linux!
phaul has quit [Quit: WeeChat 2.2]
<nfk>
for obvious reasons this is a generic pattern that is not feasible with either very large files, a system serving a lot of I/O and probably few more cases even on GNU/Linux
venmx has quit [Ping timeout: 250 seconds]
lxsameer has quit [Ping timeout: 252 seconds]
nertzy has joined #ruby
ricer2 has joined #ruby
lxsameer has joined #ruby
<nfk>
oh, and do note that it's not impossible for the mv foo.log foo.log.old; rm foo.log.old to happen before mv foo.log.new foo.log.old leaving you with the new but not the main log file!
<nfk>
also you probably need to re-open the main log if you're also reading from it as on *nix it will likely be pointing to the old file that you deleted
za1b1tsu has quit [Quit: WeeChat 2.1]
<nfk>
*happen before mv foo.log.new foo.log
cliluw has joined #ruby
conta has quit [Quit: conta]
lxsameer has quit [Ping timeout: 240 seconds]
TheBloke has quit [Ping timeout: 245 seconds]
dviola has joined #ruby
lxsameer has joined #ruby
tubbo has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lxsameer has quit [Ping timeout: 246 seconds]
SeepingN has joined #ruby
aspiers has quit [Ping timeout: 252 seconds]
rgr has quit [Quit: leaving]
jottr has joined #ruby
tubbo has quit [Quit: WeeChat 2.0.1]
tubbo has joined #ruby
<NL3limin4t0r>
If every log entry is just one line it's as simple as checking for the newline character at the end of the file. If it's there the last line was written succesfully, if it's not there the last line got currupted and should be overwritten. If a log entry may contains more than one line you can still use this, since the likelyhood of breaking after exactly a newline is not that large. However if mind the fact
<NL3limin4t0r>
that in a rare case a few lines could not be there you'll have to look for another aproach.
<NL3limin4t0r>
if you* mind
sanscoeur has joined #ruby
lxsameer has joined #ruby
MyMind has quit [Ping timeout: 244 seconds]
<NL3limin4t0r>
I've to go, it's getting late.
NL3limin4t0r has quit [Quit: WeeChat 1.9.1]
lxsameer has quit [Ping timeout: 250 seconds]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
knight33 has joined #ruby
RougeR has joined #ruby
Inside has joined #ruby
<Inside>
Heyo!
<Inside>
Q: How is it possible for Hash to have an O(1) complexity for doing look ups?
cats has quit [Ping timeout: 245 seconds]
<Inside>
I understand if you could take a key and hash it to like a ...n-bit value .. then you could store offset pointers in an n-bit sized array so you could immediately jump to the data
<Inside>
or is there a better way to check for presence of a key in a data set?
<Inside>
ah looks like Set uses hash internally as well so I've been doing it right
<apeiros>
that depends. in most generic cases, hash/set will be the fastest. but note that O(1) isn't necessarily faster than e.g. O(log(n)) for a given n.
<Inside>
ah.. huh
<Inside>
and actually looks like w/ 1M elements Set is the slowest..
lxsameer has joined #ruby
knight33 has joined #ruby
aspiers has joined #ruby
<apeiros>
that benchmark you posted doesn't test performance of key presence testing, though.
<Inside>
true true
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Inside>
Looks like it's still faster to create a hash for key lookup than it is to use a Set :(
<Inside>
er - key storage
<Inside>
with no lookup
lxsameer has quit [Ping timeout: 250 seconds]
<Inside>
Probably uses more memory though
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cd has quit [Ping timeout: 252 seconds]
ua has quit [Ping timeout: 272 seconds]
lxsameer has joined #ruby
cd has joined #ruby
knight33 has joined #ruby
Sauvin has quit [Ping timeout: 252 seconds]
lxsameer has quit [Ping timeout: 246 seconds]
sauvin_ has joined #ruby
sauvin_ is now known as Bocaneri
<Inside>
Ah, set uses hash[k] = v to insert stuff into itself
lxsameer has joined #ruby
herbmillerjr has quit [Read error: Connection reset by peer]
<Inside>
ah array.to_hash dives into C
herbmillerjr has joined #ruby
lxsameer has quit [Ping timeout: 272 seconds]
Bocaneri has quit [Ping timeout: 252 seconds]
Sauvin has joined #ruby
Sauvin has quit [Max SendQ exceeded]
lxsameer has joined #ruby
DTZUZO has joined #ruby
herbmillerjr has quit [Read error: Connection reset by peer]
herbmillerjr has joined #ruby
fluxAeon has quit [Ping timeout: 244 seconds]
lxsameer has quit [Ping timeout: 246 seconds]
LiftLeft2 has joined #ruby
LiftLeft has quit [Ping timeout: 240 seconds]
tubbo has quit [Quit: WeeChat 2.0.1]
aspiers has quit [Ping timeout: 272 seconds]
nertzy has quit [Ping timeout: 252 seconds]
code_zombie has joined #ruby
nertzy has joined #ruby
aspiers has joined #ruby
thy0 has quit [Ping timeout: 245 seconds]
TheBloke- has joined #ruby
thy0 has joined #ruby
DTZUZO has quit [Ping timeout: 272 seconds]
thy0 has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
alem0lars has joined #ruby
dellavg_ has quit [Ping timeout: 264 seconds]
desperek has quit [Quit: xoxo]
herbmillerjr has quit [Read error: Connection reset by peer]
herbmillerjr has joined #ruby
herbmillerjr has quit [Read error: Connection reset by peer]
herbmillerjr has joined #ruby
RedNifre has quit [Ping timeout: 272 seconds]
sanscoeu_ has joined #ruby
Sauvin has joined #ruby
sanscoeur has quit [Ping timeout: 250 seconds]
ams__ has quit [Quit: Connection closed for inactivity]
Sauvin has quit [Ping timeout: 272 seconds]
Sauvin has joined #ruby
Sauvin has quit [Ping timeout: 240 seconds]
sanscoeu_ has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 272 seconds]
<nfk>
Inside, in my noob experience code is either way too slow or fast enough that you don't care about actual speed ;)
nmuntz has joined #ruby
<nfk>
after all, i literally have a CPU from 2008 if not earlier yet it's currently at sub 10% on average (with immediate per-core use often 0.0%) and both graphical and video cores, and even Gen 1 PCIe at 0% utilization even though I'm currently running a modern web browser, a compositing desktop and a capistrano webapp all while chatting on irc
mike11 has quit [Ping timeout: 252 seconds]
ldnunes has quit [Quit: Leaving]
<nfk>
meanwhile a previous generation ultrabook with discrete graphis would run laps around this system
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gnufied has quit [Quit: Leaving]
IanMalcolm has joined #ruby
<nmuntz>
hi! so I inherited a ruby script that was working before and now it's giving errors. I'm not very familiar with ruby so I was hoping someone could shed some light on this code: https://pastebin.com/iPAtnJeq - at the bottom of the paste is the error i'm getting
<ruby[bot]>
nmuntz: 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
reber has quit [Remote host closed the connection]
<nfk>
ah, so that's why people don't like it
RedNifre has joined #ruby
lxsameer has joined #ruby
icarus has joined #ruby
gnufied has joined #ruby
clemens3 has joined #ruby
jottr has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lytol_ has quit [Remote host closed the connection]
RedNifre has quit [Ping timeout: 252 seconds]
lektrik has quit [Ping timeout: 240 seconds]
clemens3 has quit [Ping timeout: 272 seconds]
<nmuntz>
so inside a loop I have items[trophy.program][trophy.award] << Item.new(order, trophy) and apparently when this is encountering a nul element that's causing the exception. how can i handle this scenario?
jottr has quit [Ping timeout: 246 seconds]
Azure has joined #ruby
RedNifre has joined #ruby
<nfk>
1) check that it's not nil: nil.nil? which will return true if it is nil. 2) check that element.respond_to? :method_name or 3) just try it and handle the NoMethodError exception if it's thrown at you OR 4) there might be a bug in your code due to changes and a class member that's not supposed to be nil is not being assigned its correct value
cagomez has joined #ruby
<nfk>
there's actually more ways but they'll just be different variants of 1 and 2
<nfk>
btw, it's said that the most ruby way is to just try and handle exceptions
cagomez has quit [Remote host closed the connection]
raulp has joined #ruby
<SeepingN>
rescue next
<Inside>
nfk: Ugh I'm trying to pull in ~100k records from two different databases and Set A - Set B
<Inside>
Which is why I was trying to figure out what's faster
<Inside>
although the data loading from one database is still the bottleneck (Like.. ~10S)
DTZUZO has quit [Ping timeout: 240 seconds]
<nfk>
Inside, does that mean that you're trying to solve a non-existing issue?
<nfk>
also the number of records is pretty low as far as databases go but i'm not sure if the same goes for set operations (not my field of expertise though)
<nfk>
assuming by record you don't mean something like a whole document
mikecmpbll has joined #ruby
weaksauce has joined #ruby
<nfk>
Inside, actually have you considered just doing it in sql?
<Inside>
Well one of the queries joins about 3 tables of like 20M rows together
<Inside>
so it has a tendency to time out
<Inside>
Unfortunately that's the ERP database so I can't do anything to it
<nfk>
if synchronicity is not an issue how about just getting the data you need from the slow database into some temporary database and use that?
<Inside>
Yeaaahh
SeepingN has quit [Disconnected by services]
SeepingN_ has joined #ruby
<Inside>
This is for a rails application
<Inside>
so I am using MemoryStore to cache data for like 30 minutes or so
<nfk>
ah, is that the slow one?
<nfk>
oh wait, it's supposed to be very fast
Sauvin has joined #ruby
* nfk
feels a bit lost on what exactly Inside is trying to accomplish by optimizing an alleged non-bottleneck
RedNifre has quit [Ping timeout: 252 seconds]
wojnar has quit [Quit: Leaving]
<Radar>
maybe hes doing a speedrun ;)
<Inside>
haha
<Radar>
any% rails request
<Inside>
hahahaha
<Inside>
yes basically
<Inside>
The original question was what to do with the data once I had it out of the database -- instead of doing an O(N^2) matchup -- iterate through one list of items and then check to see if it's in the other hashmap
<Inside>
Now I'm back to the original issue of fiddling with the data coming from the database
DTZUZO has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
<Inside>
So then - this turns into more of a database question
<nfk>
we'll see
<Inside>
well
<Inside>
we're already there :D
<nfk>
i'm currently feeling scared as my irb just got 33000 entry hash
<nfk>
that was.. a sight
<nfk>
can i do 67k?
nmuntz has quit [Quit: Page closed]
<Inside>
67k what
<nfk>
to get to 100k hash
<Inside>
I see
<nfk>
so far my RAM seems to be completely in check which was the scary part
<nfk>
first one down, time for the second one
RedNifre has joined #ruby
<nfk>
actually, my keys looks pathetic
<nfk>
oops.... i feel stupid
<nfk>
ho, ho, i can hear the cpu fan spinning up
<nfk>
yeah, this time my ram is actually growing
<nfk>
+usage
RedNifre_ has joined #ruby
<nfk>
Inside, sorry, i don't think i'll be able to try what you're doing even with a simple hash as i'm nearing swapout point yet i'm less than 2/3 into the first hash generation
<Inside>
~_~
<nfk>
had to abort XD
<nfk>
have you tried it on your end?
RedNifre has quit [Ping timeout: 272 seconds]
<Inside>
I have no idea what you're talking about
<nfk>
h = {}; 100000.times.map {|n| h.merge!({Random.rand(1000000) => n})}
<nfk>
this should generate a hash with 100k elements. unfortunately i suspect your values will be more than simple integers but at least that should give you a feel for what you'll be up against
<Inside>
Err.. no
<nfk>
did i get something wrong?
<Inside>
I think it's simpler than that
<nfk>
do go on
<Inside>
I'm quering two databases - one set of data goes into a list, the second into a hash. Then I'm seeing if each record in the last has a matching record in the hash
<Inside>
I mean - it works, it's just slower than I want
* Inside
shrugs
<Inside>
it's an intranet website for internal use so it bums me out to see timeout messages on the server
raul782 has joined #ruby
<Inside>
But - that's more of a database/middleware/etcetc question than anything
<nfk>
isn't the whole point of JSON to have a data format that can be parsed without validating it?
jottr has joined #ruby
<SeepingN_>
can be
<baweaver>
Depends what they mean by validate
<baweaver>
validate the text, or the parsed content?
<baweaver>
icarus: could you clarify?
<nfk>
i'm very certain he meant field presence, data types and possibly absence
<nfk>
so basically that the client response more or less fits the bill, at which point the whole point of having a ubiquitous format that can be flexible in it's format and content is out the window, imho
<SeepingN_>
the more you assume incoming data is safe, the larger your vulnerabilities
xfbs has quit [Read error: Connection reset by peer]
<baweaver>
Short version, JSON parsers aren't exactly 100% consistent in shenanigans
DTZUZO_ has joined #ruby
<baweaver>
Though I think we're really reading too much into this one
DTZUZO has quit [Ping timeout: 240 seconds]
<nfk>
baweaver, is this the next version of: "validating e-mail addresses: how hard can that be? TM"?
<nfk>
would be funnier if 90% of university professors didn't think it was easy
s2013 has joined #ruby
<baweaver>
When doing university assignments, assume permissive
<baweaver>
It saves a ton of time, and is probably what said professor wants
<nfk>
i mean it in general: with the exception of my compsec professor (who was a literal professor and board member) no one seemed to have even a hunch that e-mail address validation is one deep rabbit hole
lxsameer has joined #ruby
<baweaver>
Some rabbits are quite simply not worth chasing down a hole
sheepman has quit [Ping timeout: 260 seconds]
Xeago_ has joined #ruby
ZzZombo_ has joined #ruby
lxsameer has quit [Ping timeout: 246 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ZzZombo has quit [Ping timeout: 252 seconds]
ZzZombo_ is now known as ZzZombo
Xeago has quit [Ping timeout: 272 seconds]
Xeago_ is now known as Xeago
sheepman has joined #ruby
im0nde has quit [Ping timeout: 244 seconds]
white_lilies has quit [Ping timeout: 240 seconds]
<nfk>
baweaver, so i ended up reading good portion of that website. thanks for the link, that was quite interesting. also nowhere near as bad as e-mail validation from what i recall
<nfk>
oh, they're fun to just write. forget parsing :D
<baweaver>
I should make a Thompson NFA implementation later, but that requires me to learn C extensions
<baweaver>
which I really really really really don't want to do.
<nfk>
nothing quite like writing in a programming language few know well and one that very different from your run of the mill languages
<nfk>
what could possibly go wrong with that, right? TM
<nfk>
*that's
thy0 has joined #ruby
<baweaver>
Consider also that most of Ruby C is macros on top of C, so you're not really writing vanilla C either
<baweaver>
Once I'm done writing this book, I may go back and force myself to write something on that too
<nfk>
i head the expert advise of leaving C to the handful of professionals that can be trusted with not making horrific mistakes and cross my fingers that linux kernel is safe enough
<baweaver>
"An Illustrated Guide to Ruby - Appendix C" seems like enough of a trollish name :D
<baweaver>
Might have to ask Pat if he'd be willing to join in on it.
<baweaver>
Ruby Under a Microscope gets close to a lot of it