« Back to channel list

#ruby - 28 April 2015

« Back 1 day Forward 1 day »
[00:42:55] Ellis: i read that alias creates a method with the same name as another method??? what???s the point of alias?
[00:44:38] Radar: Ellis: https://gist.github.com/radar/0cf1a79b5f77af4b0193
[00:45:07] Ellis: radar: what does it do? change def firstname to def first_name?
[00:45:16] Radar: Ellis: It isn't changing anything.
[00:45:25] Radar: Ellis: You can still access it either as firstname or first_name.
[00:45:38] Radar: It provides an alternate name to te method
[00:46:17] Ellis: ohhh i see it is creating an alias
[00:46:29] Ellis: what is the point of that?
[00:46:37] Ellis: seems dumb
[00:47:18] Ellis: what is going on next to initialize? why is there just a random *entries?
[00:47:20] Ellis: https://github.com/Blahah/datastructures/blob/master/lib/datastructures/linked_list.rb#L20
[00:47:42] Radar: lol @ "seems dumb"
[00:47:54] Radar: could you remember without looking if the method was called firstname or first_name?
[00:47:55] sevenseacat: whats the point of alias? ohhh it creates an alias
[00:48:01] Radar: sevenseacat: ikr
[00:48:22] Radar: https://github.com/spree/spree/blob/master/core/app/models/spree/order.rb#L28
[00:48:29] Radar: Could you remember if that method was ship_total or shipment_total?
[00:48:33] Radar: Why not both?
[00:48:41] Radar: Ellis: !twgr
[00:48:41] helpa: Ellis: Learn Ruby by reading this book - http://manning.com/black3 - The Well-Grounded Rubyist by David A. Black
[00:48:48] Radar: Oh right helpa banned and all that
[00:48:53] Ellis: radar i see
[00:49:00] Radar: Let me just duplicate all my commands over to ruboto because lol
[00:49:12] Radar: Ellis: http://manning.com/black3/
[00:49:21] Radar: Ellis: *entries is not random
[00:49:31] Ellis: radar: i have that book thank you very much
[00:49:55] Radar: Ellis: Cool story.
[00:49:58] Ellis: but what???s going on in this line? why is there an astrik and no parentheses? https://github.com/Blahah/datastructures/blob/master/lib/datastructures/linked_list.rb#L20
[00:50:10] Radar: Ellis: Read the book.
[00:50:25] Nilium: Ellis: Read the book, but also, variadic arguments.
[00:50:56] Ellis: if doesn???t know answer read the book, doesn???t seem like very efficient programming :P
[00:51:23] Ellis: if doesn???t know answer ask radar sounds faster
[00:51:36] Ellis: nilium: ty
[00:52:08] sevenseacat: sounds like a decent strategy. bug an op for every simple question and ignore his advice
[00:53:01] Radar: *<variable> is hard to search for in the book, I get that
[00:53:13] Radar: but this is a pretty basic Ruby question which is probably answered within the first 5 chps of the book
[00:54:08] Ellis: wth is going on here: https://github.com/Blahah/datastructures/blob/master/lib/datastructures/linked_list.rb#L36
[00:54:26] Radar: "Please explain all this code to me
[00:54:43] sevenseacat: its a method definition.
[00:54:50] sevenseacat: just like any other.
[00:54:52] Radar: Ellis: *entries is explained in Section 7.4.2 "Array conversion with to_a and the * operator"
[00:55:49] Ellis: radar: thanks perhaps i was just confused since it wasnt inside a parentheses
[01:00:46] ponga: any document explaining what 'alias' really do in ruby? , i already tried googling
[01:02:00] Ellis: alias creates another name for referencing someothing
[01:08:15] xxneolithicxx: err that code is ugly. i hate seeing ruby code that purposely leaves out the method parens, it makes it harder to read for no reason.
[01:08:35] xxneolithicxx: readability ppl
[01:08:39] Radar: I hate seeing Ruby code that has too many parenthesis because it makes it harder to read for no reason
[01:08:43] Radar: readability ppl
[01:08:58] xxneolithicxx: i see your point
[01:09:38] Radar: I would really worry if you didn't.
[01:09:47] ponga: what's the code you guys at
[01:09:56] Radar: Ruby(Code(With(Too(Many(Parenthesis(Hurts(My(eyes()))))))
[01:10:05] ponga: that is like
[01:10:43] Radar: hey at least lisp is usually formatted neatly
[01:10:45] xxneolithicxx: not exactly what i was talking about but yes
[01:10:55] xxneolithicxx: im talking about just in the method def
[01:10:57] ponga: no offense
[01:11:23] Radar: xxneolithicxx: personally I would add them in but I am not offended if people leave them out
[01:11:33] Radar: It's clear to me that the line is defining a method and the things that follow are the arguments
[01:11:38] Radar: having parenthesis there doesn't *add* anything
[01:11:48] xxneolithicxx: it is to me but a new person reading might look at and be like wth
[01:12:17] mozzarella: I like to use ()'s in my defs
[01:39:02] ponga: what was the website that allows google search keywords with operators ( + = - )
[01:51:59] willharrison: is rsense dead? I noticed the git project taichouchou2/vim-rsense is gone and most of the posts about it online seem older
[01:53:19] willharrison: I'm trying to get auto completion in vim for ruby and it seemed like the best thing around :/
[01:57:29] sohrab: delete_if isn't working on a set im using. weird
[02:01:20] gr33n7007h: >> require 'set'; s = Set.new([*0..20]); s.delete_if {|n| n % 3 == 0 }
[02:01:22] ruboto: gr33n7007h # => #<Set: {1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20}> (https://eval.in/319651)
[02:02:25] gr33n7007h: # => syntax error 0x03242AF
[02:05:48] sohrab: wtf i changed it from a set to an array and it's workign now Oo
[02:14:45] gr33n7007h: bit of ruby ascii art: {:+@=>->{:-@}}
[02:22:35] dvlwrk: anyone know why i can only get code completion for one level deep in a gem?
[02:22:41] dvlwrk: (i'm using aws-sdk)
[02:23:08] dvlwrk: and for some reason Aws::S will show S3, but once I try to go Aws:S3::C and hit client.. crickets
[02:23:38] dvlwrk: im sorry, it's in rubymine derp
[03:39:21] i8igmac: string.scan(/test/)[0].to_s => ["test"]
[03:39:35] i8igmac: how do i get string with out []
[03:39:39] i8igmac: after scan
[03:40:13] i8igmac: "[\"test\"]"
[03:40:52] Radar: what is string?
[03:51:48] ElderFain: If I want to define a function that takes some values def func(first:1, second:2, operation: &block) and then takes a block to execute , say the block in this case checks to see if second is > some value inside the block.. is what i'm after here Procs ?
[03:53:54] i8igmac: string ="testing some testing... some more testing... and some more testing"
[03:54:53] i8igmac: wait, i guess its like a node
[03:57:45] mozzarellaaaaaaa: that's very vague, so I can't tell you it's the best way of doing what you want to do, but you can do that
[04:02:45] Hanmac: iBigmac: why not: string[/test/] #=> "test" ?
[04:11:41] ElderFain: mozzarellaaaaaaa: https://gist.github.com/anonymous/2e1f7398a38a9f281838 was what I ended up pulling together as an example
[04:12:07] ElderFain: mozzarellaaaaaaa: but I think I may want to try and use blocks intead, so you call bananas() {block me up bro!}
[04:14:34] mozzarellaaaaaaa: ElderFain: it's just a syntax, your block will also be a proc
[04:15:27] mozzarellaaaaaaa: >> def test(&block); block.class; end; test {}
[04:15:28] ruboto: mozzarellaaaaaaa # => Proc (https://eval.in/319686)
[04:33:45] ElderFain: cool, right
[04:34:23] Eiam_: hmm when i puts a rack request.cookies, its empty. upstream, i can see via Charles that cookies are definitely there
[04:34:27] Eiam_: request.env also doesn't show the cookies
[04:39:33] shevy: you and your cookies
[04:39:37] shevy: I told you they will just fatten you up
[04:40:04] Eiam_: my pants were a little tight this morning
[04:44:23] shevy: naked coding is the best anyway
[04:44:26] shevy: just as nature designed it
[04:45:23] baash05: I stepped into this conversation at the exact wrong time :)
[04:48:43] Hanmac: shevy implment "CoreWars" into the programms and let them fight each other until the strongest does survive ;P
[04:49:07] shevy: ah nature is more complicated than that!
[04:49:33] shevy: remember - all that matters is whether one can have viable offspring, no matter the strategy
[04:49:36] shevy: there is more than one way to do it!
[04:54:08] Hanmac: if someone is interested ... nobu did make a feature-branch for each_uniq and each_uniq_by !!! ;P
[05:04:22] Axighi: Is there similar method to ActiveRecord:sum that sum for customized method of a class
[05:04:46] Radar: axighi: "customized method"
[05:05:03] Eiam_: hrm.. why did I end up seeing undefined method on configure for sinatra? https://gist.github.com/anonymous/da1c0e9b6e59883c27de
[05:05:11] Eiam_: sinatra defines configure, its required there if it doesn't exist
[05:05:20] Axighi: not column
[05:05:33] Radar: axighi: Show us this customized method. Show us what it returns
[05:06:25] Eiam_: Radar: doesn't it? http://www.rubydoc.info/gems/sinatra/1.3.3/Sinatra/Base.configure
[05:06:34] Radar: Eiam_: That's Sinatra::Base.configure.
[05:06:45] Axighi: for instance: a method called "get_some_value" which returns a number
[05:06:58] Radar: axighi: Third time's a charm: SHOW US THE CODE.
[05:07:04] Radar: And the output.
[05:07:08] Radar: Pretty please with a cherry on top?
[05:08:48] Radar: Eiam: I say that as someone who doesn't have intimate knowledge of how Sinatra handles requests.
[05:09:55] Eiam_: its probalby something to do with modular applications vs classic
[05:09:56] Eiam_: im reading
[05:10:03] Radar: Er, not handles request. Brainfart.
[05:10:10] Radar: I meant how Sinatra handles its delegating.
[05:14:28] Radar: axighi: Let's continue this conversation here :)
[05:14:37] Radar: axighi: [1,2,3].sum not cutting it for you?
[05:14:51] Radar: Or whatever the stdlib method is
[05:15:37] Radar: [obj1, obj2].map(&:some_method).inject(0) { |sum, n| sum + n }
[05:15:50] sevenseacat: look ma no rails!
[05:20:27] p2-m2: hi is anyone working on a project that needs help? (I can help with a small pay in return)
[06:03:18] ngr: from inside a Gem, is there a way to get the path to the application code using the gem? the path to the Gemfile the gem was listed or so?
[06:03:48] Radar: ngr: "application code"?
[06:03:55] Radar: What kind of application?
[06:05:35] ngr: It's going to be an internal micro-framework based on Grape and I make heavy assumptions about how the 'app code' is stuctured. For example I want to automatically require all the files inside the 'models' directory without having to write any line of code in the app itself
[06:07:24] ngr: it's gonna be a Rack application, so ideally all I want in the config.ru is a "require 'my_micro_framework'" and then "run MyMicroframework::App"
[06:07:48] Radar: Grape is not so fun imo
[06:07:57] zotherstupidguy: ngr if you have a repo, it will be easier to get suggestions
[06:08:00] Radar: Have you seen rails-api? https://github.com/rails-api/rails-api
[06:08:12] zotherstupidguy: Radar try utter =)
[06:08:24] Radar: zotherstupidguy: the what now?
[06:08:52] zotherstupidguy: a micro-api framework, inspired by almost-sinatra
[06:09:04] Radar: I've not heard of it. Do you have a link to it so I can check it out?
[06:09:24] ngr: Radar: this is not a question of Grape or not, because I'm already using it in a about seven micro-services that are currently rails applications. However I feel that rails is totally overkill and since Grape is self-sufficient I wanted to remove all the overhead (i.e. rails-stuff, except ActiveRecord of course)
[06:09:56] Radar: ngr: Rails does this by defining an APP_ROOT constant in config/application.rb, which is loaded when the Rails server starts.
[06:10:13] Radar: ngr: You could define that constant in config.ru and then reference that in your framework's code.
[06:10:37] ngr: Radar: that sounds excatly like what I need, thanks a lot!
[06:10:52] zotherstupidguy: Radar https://github.com/zotherstupidguy/utter/tree/master
[06:12:19] Radar: ngr: My apologies, it's [application]/bin/rails which sets the constant
[06:12:23] zotherstupidguy: ngr i used to like grape when it first started then it started to take the approach of being rails-like
[06:12:25] Radar: http://ryanbigg.com/ddr_book/#__our_application_bin_rails
[06:12:43] Radar: That's from my new book (idea), Deep Dive Rails: https://leanpub.com/ddr
[06:13:33] ngr: Radar: thanks. I guess is doesn't matter where I create the constant?
[06:14:24] ngr: zotherstupidguy: what do you think is wrong with Grape?
[06:14:47] ngr: Radar: would like to hear the same from you. Why don't you think it's 'fun'?
[06:15:07] ngr: My experience so far is good, I like the DSL and the code is quite expressive
[06:15:17] zotherstupidguy: ngr check grape's Gemfile and see the dependencies..
[06:15:45] zotherstupidguy: ngr it is supposed to be a simple tool for api, then they got over excited imo
[06:17:06] ngr: zotherstupidguy: as far as I can tell there are 9 runtime dependencies in their gemspec which is okay imo
[06:17:46] ngr: three of them being rack related, which I use anyway
[06:18:05] zotherstupidguy: ngr activerecord is one of them!
[06:18:08] ngr: well I din't check indirect dependencies
[06:18:31] ngr: zotherstupidguy: as I mentioned I am using ActiveRecord
[06:18:52] zotherstupidguy: ngr makes sense then in your case
[06:18:57] Radar: ngr: I've had issues with rescuing exceptions nicely in Grape and other things
[06:19:16] ngr: zotherstupidguy: also, I cannot see activerecord being mentioned here https://github.com/intridea/grape/blob/master/grape.gemspec
[06:19:19] Radar: Where I worked one job ago, we were using Grape to build an API and found it too cumbersome and so we switched to straight Rails.
[06:19:55] Radar: Gemfile != actual dependencies
[06:20:27] zotherstupidguy: the bundle install log
[06:21:30] Radar: zotherstupidguy: AR is not a gem dependency of grape
[06:21:34] zotherstupidguy: ngr i might be wrong as well, its more of an impression
[06:21:38] Radar: https://rubygems.org/gems/grape
[06:22:03] zotherstupidguy: see, yeah, sorry memory failed me again
[06:22:16] ngr: Radar: okay I see why you dislike it, hopefully I'll have a more pleasing experience
[06:22:41] ngr: okay, back to work. thanks for your input Radar, zotherstupidguy :)
[06:27:57] shevy: the .read statement in sqlite3
[06:28:00] shevy: is still going today
[06:28:02] shevy: so now it's the third day
[06:28:22] shevy: 56M Apr 28 08:28 foo.sqlite3
[06:48:39] c-c: Someone ping me?
[06:49:31] c-c: must have been yesterday, past lastlog
[07:00:11] shevy: certainty will you write ruby code today?
[07:00:26] certainty: shevy: and you?
[07:06:00] certainty: shevy: are you going to write lisp code today?
[07:07:33] shevy: but some ruby code. I need to write some ruby script that manages my video collection
[07:07:57] certainty: shevy: so serious stuff xD
[07:08:06] shevy: I lost about 3 external HDDs in the last ~5 months or so. I think I even lost some videos because of that, when the last one went down without having all the backups from it...
[07:08:29] shevy: I barely make use of the old TV anymore
[07:08:34] shevy: save sometimes for news
[07:20:08] Hanmac: shevy i will write more rwx code over the current week ... there is a new widget that i want to implement into my code
[08:07:41] certainty: flughafen: o/
[08:08:34] flughafen: certainty: \o
[08:15:26] flughafen: certainty: how was your weekend? sevenseacat ?
[08:15:54] flughafen: who here was using gitlab?
[08:20:17] sevenseacat: flughafen: cant complain. i did bugger all, sat on my butt and played video games. you? :)
[08:29:02] Musashi007: sounds like a great day.. what???d you play? :P
[08:31:12] sevenseacat: elder scrolls online \o/
[08:34:49] apeiros: hearthstone, starcraft, this war of mine
[08:35:07] flughafen: sevenseacat: went climbing, put motorcycle together, went and saw avengers. i took my bike to get it's check , i can ride now but need to get a new rear tire in a month
[08:35:10] apeiros: but this war of mine is depressing
[08:35:37] Musashi007: I just started playing hearthstone
[08:35:51] Musashi007: do you play on NA, apeiros?
[08:36:00] apeiros: Musashi007: europe
[08:38:11] flughafen: sevenseacat: did yuo slay any dragons or elders?
[08:39:55] sevenseacat: flughafen: unfortunately no.
[08:40:08] flughafen: did you get to ride any dragons?
[08:40:09] sevenseacat: i have this war of mine on my steam wishlist
[08:40:26] flughafen: ACTION is unfamiliar with eso
[08:40:33] flughafen: ACTION used to play wow.
[08:41:31] sevenseacat: eso is awesome. that's all you need to know.
[08:41:49] flughafen: sevenseacat: if you play it, it must be so awesome my brains would explode
[08:43:57] flughafen: sevenseacat: what class you do prefer to play?
[08:44:32] flughafen: i'm a level 7 airport
[08:44:52] sevenseacat: i'm a vr11 dragonknight! \o/
[08:45:28] flughafen: i like big dragons and i can't deny, you other brothers can't deny, when a dragon walks in with that itty bitty waist and those big wings in your face
[08:45:37] flughafen: err. /me should learn how to rap
[08:46:50] flughafen: ACTION casts "flight delayed" against sevenseacat
[08:47:12] sevenseacat: ACTION blocks it with an 'alternate airline' defense
[08:47:38] flughafen: ACTION mwahahahahas.
[08:47:44] flughafen: ACTION casts "lost luggage"
[08:47:58] flughafen: now you've lost your sword!
[08:48:00] sevenseacat: you assume I have the 'baggage allowance' perk
[08:48:10] flughafen: ACTION cries
[08:48:40] flughafen: if you were a sorcerer you'd be lucky to not get charged to bring a wand on board
[08:48:53] sevenseacat: ACTION uses a snowstorm on flughafen 
[08:49:41] flughafen: ACTION notifies sevenseacat that my runways are heated and are immune to snowstorms
[08:50:01] sevenseacat: clever... clever
[08:51:54] flughafen: ACTION will agree to a truce if you agree to buy a 17$ cheese sandwich
[08:52:57] sevenseacat: deal. but only if i get to knock over a vending machine afterwards.
[08:53:11] flughafen: ACTION shakes your hand. "agreed"
[08:53:17] sevenseacat: last time i was an an airport, a machine ate my $10. i was annoyed.
[08:53:36] flughafen: what kind of machine takes 10$?
[08:54:29] sevenseacat: erm, all machines around here
[08:54:56] flughafen: i guess everything is for no good reason expensive in aus
[08:55:17] sevenseacat: well i put the $10 in to buy a $4.50 bottle of coke so yeah
[08:58:10] flughafen: sevenseacat: is water there cheap or free with meals? in germany water always costs money and is usually as expensive as beer(in a restaurant)
[08:58:49] sevenseacat: most places will give you chilled tap water for free. if you want filtered/bottled/anything fancy, then you pay normal prices
[10:38:17] shortCircuit__: I did this Hash[*instance_variables.map { |v| [v.to_sym, v] }.flatten] and I got {:@profiles=>:@profiles, :@sort_by=>:@sort_by, :@age_from=>:@age_from] , how to make it profiles: @profiles ?
[10:41:59] shortCircuit__: Hash[*instance_variables.map { |v| [v.to_s.delete("@").to_sym, v] }.flatten] this works but seems :(
[10:42:09] jhass: [v[1..-1], v]
[10:42:10] apeiros: shortCircuit__: you realize that :foo => bar is *the same* as foo: bar?
[10:42:29] apeiros: ah, you talk about dropping the @, not the syntax :D
[10:42:51] apeiros: jhass' solution is IMO better. also drop the flatten and splat
[10:42:52] jhass: instance_variables.map {|var| [var[1..-1], var] }.to_h
[10:43:03] apeiros: and if you're on 2.1+, what jhass just said - to_h
[10:43:27] jhass: instance_variables.each_with_object({}) {|var, vars| vars[var[1..-1]] = var }
[10:43:34] apeiros: (and if you're not on 2.1+, form the habit of informing the channel that you're using outdated software???)
[10:45:12] shortCircuit__: umm."profiles"=>:@profiles can't be "profiles"=>@profiles, I mean "profiles"=>@profiles is profiles: @profiles ?
[10:45:35] jhass: well, to_sym it
[10:45:42] jhass: but what's your goal anyway?
[10:46:11] shortCircuit__: wait let me gist it then
[10:48:54] shortCircuit__: https://gist.github.com/aghosh47/743e5db7d6bc78f8ab71#file-search_form-rb-L25-L26 previously when @search.attributes was done a has was being returned, now I am trying to compact it.. the existing code is wrong though
[10:49:55] jhass: deosn't AM define attributes already?
[10:50:37] shortCircuit__: um, I tried SearchForm.new(Profile.brides, param).attributes .. it says undefined
[10:51:04] jhass: mh, apparently not, yrah
[10:51:26] adaedra: apeiros: tbf, people are not always aware that they are using outdated software
[10:51:57] jhass: why do you unpack them into instance variables though? AR keeps an @attributes hash, a fairly sane choice IMO
[10:52:03] apeiros: adaedra: sure. I still give advice assuming they use current software. and if they run into troubles I tell them to state the version they use.
[10:52:39] shortCircuit__: I will recheck, maybe I was doing something wrong
[10:52:41] apeiros: jhass: yes, AR::Base defines #attributes /cc shortCircuit__
[10:53:06] apeiros: but no idea about AM::Model
[10:53:33] jhass: attributes seems to be to AM::Model what each is to Enumerable apparently
[10:53:42] jhass: AR::Base#attributes is just @attributes.to_hash
[10:54:04] shortCircuit__: http://pastie.org/private/ywd7pj5sndvgua7b4ugdg
[10:54:33] shevy: hanmac \o/
[10:54:48] adaedra: Bonjour shevy
[10:56:32] jhass: shortCircuit__: http://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html
[10:57:47] shevy: bageutte adaedra
[10:57:53] shevy: erm baguette
[10:58:31] adaedra: I'm gonna hit you with it
[10:58:54] shortCircuit__: but they are doing def attributes; { 'name' => @name }; end , can't it be done dynamically ? I can do that static assignment always
[11:01:37] jhass: shortCircuit__: I'd say don't unpack the params into instance variables, keep them as a hash
[11:01:42] jhass: and delegate to the hash
[11:02:22] jhass: I'm still not 100% sure whether they delegate missing calls to the hash returned by attributes, docs seem to suggest yes, examples and code not so much
[11:03:08] shevy: do you guys like the perl 6 "say" ?
[11:05:22] gregf_: shevy: "say" as in the say statement?
[11:08:02] shevy: I think so
[11:08:07] shevy: I am wondering why they changed that
[11:08:17] shevy: they could have continued with the perl5 perhaps instead?
[11:08:29] gregf_: well its available in perl 5 as well. >= 5.10.x as well i guess
[11:09:20] gregf_: Perl 6 is quite different from Perl 5. Perl6 'could be' more closer to Ruby
[11:26:28] DaniG2k: hey guys I'm trying to make my first Gem :) I am just trying to do something really basic to get it running.
[11:26:38] DaniG2k: I've run 'bundle gem mygem' and it created the files I need
[11:26:49] DaniG2k: say I add a bit of code to print out "Hello world". how would I use this gem locally?
[11:26:53] DaniG2k: just require 'mygem' ?
[11:29:08] ytti: https://github.com/planetruby/awesome-rubies oy vey
[11:29:14] ytti: elixir 'ruby to erlang'
[11:29:17] jhass: DaniG2k: iirc rake install first
[11:29:28] jhass: DaniG2k: or start with irb/ruby -Ilib
[11:29:35] ytti: pretty sure authors would not appreciate this attribution
[11:29:42] ytti: crystal 'ruby to c'
[11:30:34] jhass: eh yeah, that's pretty much BS
[11:30:36] DaniG2k: jhass: rake install mygem?
[11:31:33] DaniG2k: seems to fail :S
[11:31:57] jhass: fail how?
[11:32:34] DaniG2k: jhass: I think it's because i have the default .gemspec file and rake doesn't like it
[11:32:56] jhass: DaniG2k: you won't get any help this way
[11:33:43] DaniG2k: jhass: http://pastie.org/10118038
[11:33:44] jhass: properly describe your problem
[11:34:21] jhass: that's quite clear, you need to edit the gemspec to fix the todos/fixmes
[11:35:00] DaniG2k: yea I'll try fixing that
[11:36:15] DaniG2k: jhass: ok I think that worked now :)
[11:36:31] DaniG2k: yep, working
[11:53:06] mdw: hey guys I'm trying to get my regex to work
[11:53:07] mdw: http://rubular.com/r/pO7a5r5gCx
[11:53:15] mdw: the trouble is group 8
[11:53:32] mdw: the final group should only match until the very first \n character
[11:53:38] mdw: it seems to go all the way until the end
[11:53:49] mdw: so it should match
[11:53:51] mdw: static dispatch_queue_t http_request_operation_processing_queue() {\n
[11:54:02] apeiros: [\w\W] <-- what do you think this means?
[11:54:23] mdw: apeiros everything >.<
[11:54:50] apeiros: mdw: ok, I think you know now where to look ;-)
[11:56:18] apeiros: I think you want (?:[^\\]|\\[^n])+ instead of [\w\W]
[11:57:11] mdw: sigh, i wish i understood that
[11:57:18] mdw: it works :-)
[11:58:40] apeiros: read it step by step. it's not that complicated once you figure it ;-)
[11:59:04] mdw: going to try
[11:59:05] apeiros: in english: either a non-slash character, or a slash followed by anything but "n"
[11:59:15] apeiros: and one or more of that
[12:01:35] apeiros: oh, you actually use [\w\W] quite often??? you probably should investigate those uses too??? because as you said, that's basically . with //m flag (i.e.: any character)
[12:01:37] mdw: i understand
[12:01:57] mdw: http://rubular.com/r/s1ULOh0MlG
[12:03:27] mdw: apeiros it breaks down though if I try add multiple @@ .... @@
[12:03:28] mdw: http://rubular.com/r/6NmddndC1o
[12:03:41] toretore: if i wanted to run a very simple http file server (with uploads!), where would i look? not necessarily ruby
[12:03:42] mdw: sometimes the diff can have more than one change >.<
[12:04:19] mdw: i need to find each occurrence of (@@\s-(\d+),(\d+)\s\+(\d+),(\d+)\s@@) thereafter
[12:06:34] mdw: i think i can do this
[12:10:31] mdw: apeiros can you make sense of this?
[12:10:32] mdw: http://rubular.com/r/vNKJQw2rwM
[12:11:07] mdw: i want to match further occurrences of things like
[12:11:08] mdw: @@ -55,6 +66,8 @@ static dispatch_queue_t http_request_operation_processing_queue() {\n
[12:11:26] apeiros: mdw: sorry, busy atm
[12:11:40] mdw: np, thanks
[12:14:06] DaniG2k: hey guys I'm making a very basic gem (my first). All I am trying to do is be able to configure the object via a block. It seems to be working with the RSpec I've written but when I try to require 'zuijin' via irb, I get a LoadError
[12:14:12] DaniG2k: Here's my code (very basic): https://gist.github.com/DaniG2k/f2ae278f5fec17d977de
[12:14:27] DaniG2k: when I require 'zuijin' form irb, I get: LoadError: cannot load such file -- configuration
[12:15:09] DaniG2k: anyone know what I'm doing wrong?
[12:19:58] jhass: DaniG2k: wild guess: require "zuijin/configuration"
[12:21:31] DaniG2k: jhass: doesn't work :\
[12:21:44] DaniG2k: configuration.rb and zuijin.rb are both in the lib directory
[12:21:51] DaniG2k: so it should just be require 'configuration'
[12:22:08] jhass: mh, yes, you don't want to do that in the final version of the gem though
[12:22:27] DaniG2k: should it have a separate configuration directory?
[12:22:48] jhass: no, the module should be reflected as directory in the file path
[12:23:16] jhass: MyGem::MyConfiguration -> lib/my_gem/my_configuration.rb
[12:23:23] DaniG2k: i already have lib/zuijin/version.rb
[12:23:26] DaniG2k: ah ok I will try putting it there
[12:23:32] jhass: but that's not causing your issue
[12:24:17] jhass: another wild guess: you made that modification but don't test with irb/ruby -Ilib and didn't rerun rake install to update the installed version
[12:24:37] DaniG2k: probably ~_~ yes
[12:24:43] DaniG2k: i ran bundle
[12:24:48] DaniG2k: forgot about rake install
[12:25:12] jhass: well, ruby/irb -Ilib or bundle exec ruby/irb is the better way to test anyway
[12:25:28] DaniG2k: jhass: I raun rake install now
[12:25:35] DaniG2k: getting a similar error message: LoadError: cannot load such file -- zuijin/configuration
[12:26:07] jhass: I have to keep making wild guesses :/
[12:26:43] jhass: so number 3: the file is not included into the built gem because whatever your gemspec's spec.files looks like doesn't include it
[12:27:07] DaniG2k: jhass: I have the default
[12:27:08] DaniG2k: lib = File.expand_path('../lib', __FILE__)
[12:27:13] DaniG2k: $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
[12:27:17] DaniG2k: so it should include
[12:27:22] jhass: not what I'm referring to
[12:27:54] jhass: if I meant $LOAD_PATH I'd have wrote that
[12:27:58] jhass: I mean spec.files
[12:28:31] DaniG2k: hmm not sure about spec.files
[12:28:50] DaniG2k: its nowhere to be found in this gem
[12:28:59] DaniG2k: I basically only made two files @_@ how hard can it be to make a gem
[12:29:39] jhass: https://github.com/bundler/bundler/blob/master/lib/bundler/templates/newgem/newgem.gemspec.tt#L27
[12:30:53] DaniG2k: jhass: ah, I have that, yes
[12:30:55] DaniG2k: jhass: spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
[12:31:23] jhass: so my guess is that you didn't git add that file yet
[12:31:34] jhass: god I hate that choice made by bundler there
[12:33:12] DaniG2k: i didn't git add anything, no
[12:33:15] DaniG2k: I didn't kow I had to
[12:34:25] jhass: one reason why I hate that choice in their template
[12:34:36] DaniG2k: jhass: what do I need to add? configure?
[12:34:53] jhass: files that should be included into the built gem
[12:35:07] DaniG2k: jeez I need to manually include them?
[12:35:13] DaniG2k: I thought that's what require was for
[12:35:28] apeiros: no, that's totally unrelated to require
[12:35:42] apeiros: require is about loading code in a running ruby program
[12:35:56] apeiros: and running ruby programs have little to nothing to do with what goes into your packaged gem
[12:36:32] jhass: require is pretty dumb, it just loads the first file with a matching name that happens to be in the load path
[12:36:37] jhass: that's all it does
[12:36:49] apeiros: well, with rubygems there's also the rather complex gem activation stuff
[12:37:20] jhass: but we can pretend rubygems just magically adds stuff to the load path ;)
[12:37:22] apeiros: but the basic gist is indeed still the same - if no file in $LOAD_PATH fits, find the first gem which would have a match
[12:38:01] DaniG2k: so what do I need to change the spec.files line ot?
[12:38:32] DaniG2k: seems like a whole PhD is required just for making a gem -_-
[12:39:00] jhass: I wonder if you even attempted to understand what the existing line does
[12:39:12] apeiros: DaniG2k: um, no.
[12:39:32] apeiros: DaniG2k: all it needs is a gemspec with about 5 informations, one of them being a list of all files you want to package
[12:39:48] apeiros: and the rest is literally just gem build your.gemspec + gem push your.gem
[12:39:57] DaniG2k: jhass: its rejecting anything that's not test, spec or features?
[12:40:14] apeiros: really not difficult at all.
[12:40:28] jhass: DaniG2k: that's the second half only
[12:40:55] jhass: (and you interpreted it the wrong way around)
[12:40:57] apeiros: maybe you should write a gemspec from scratch
[12:41:04] apeiros: then you actually understand what you're doing
[12:41:22] apeiros: and can make informed decision instead of cargo culting and then go all ranty if you don't understand what happens.
[12:41:41] DaniG2k: i dont undestand because there's no clear guide that I've been able to find on how to do this
[12:42:01] apeiros: DaniG2k: no guide? like effing http://guides.rubygems.org/make-your-own-gem/ ?
[12:42:04] jhass: http://guides.rubygems.org/make-your-own-gem/
[12:42:10] jhass: bah, too slow
[12:42:58] apeiros: ok, so it's actually 9 pieces of information you need in the gemspec.
[12:43:03] apeiros: (note: date is not needed)
[12:45:35] DaniG2k: "Gotcha: For newly created folder/file, do not forget to add one entry in hola.gemspec file, as shown-"
[12:46:27] apeiros: the gemspec is ruby code. Dir.glob is your friend.
[12:46:43] apeiros: or understanding that git shellout which bundler produces.
[12:47:01] apeiros: IMO a bad pattern, though (the git shellout)
[12:48:04] DaniG2k: apeiros: it runs a git command to list files, splits it on \x0 and rejects via a regex (matches that begin with either test, spec or features get rejected)
[12:48:14] DaniG2k: i get that part
[12:48:20] DaniG2k: not sure why that's the default though
[12:48:32] DaniG2k: shoudl I just files += Dir.glob myfiles
[12:48:47] zotherstupidguy: i agree with apeiros
[12:48:50] apeiros: that's on you to decide
[12:49:28] jhass: DaniG2k: you need to figure out under what conditions git ls-files lists files
[12:52:16] DaniG2k: jhass: is it dumb to include everything in lib?
[12:52:54] apeiros: even if I'm not addressed: yes, it is.
[12:53:15] apeiros: neither tests, executables, documentation nor readme or license belong there
[12:53:16] jhass: I usually do Dir["{lib,spec}/**/*.rb"] tbh
[12:53:19] apeiros: and tons and tons of other stuff
[12:53:34] jhass: + other dirs as needed of course
[12:54:54] apeiros: mhm, I use multiple Dir instead of {} as I find it more readable. + %w[] with a list of remaining files
[12:55:50] apeiros: https://gist.github.com/apeiros/a8e2412ba36e426e86ff is my standard s.files= statement
[12:56:17] DaniG2k: thanks that worked
[12:56:19] DaniG2k: phew, finally
[12:56:20] DaniG2k: took a while
[14:03:26] apeiros: hi Sh0rtWave
[14:03:28] Sh0rtWave: I'm installing kyotocabinet-ruby, and encountering the dreaded "You have to install development tools first" error.
[14:03:59] sevenseacat: did you install the development tools? :)
[14:04:23] Sh0rtWave: That's a good question.
[14:04:27] Sh0rtWave: Because I thought I did.
[14:04:40] apeiros: ACTION assumed that more information would follow???
[14:04:49] Sh0rtWave: Hold one whilst I gather it.
[14:05:01] apeiros: well, or an actual question :-p
[14:05:20] Sh0rtWave: It claims lack of libraries or headers
[14:05:42] Sh0rtWave: And specifically, kccommon.h
[14:05:44] Sh0rtWave: What exactly is that?
[14:05:57] Sh0rtWave: (I just got to the log file after sudoing insanely)
[14:06:11] adaedra: Operating system, what command you attempted, what output did you got?
[14:06:27] Sh0rtWave: Oh I think I see
[14:06:30] Sh0rtWave: I hate that.
[14:06:38] Sh0rtWave: I hate when I start to ask a question and then answer it myself.
[14:06:53] Sh0rtWave: I think/hope
[14:07:05] apeiros: easy work around: phrase your full question first, then go to the channel ;-)
[14:07:40] Sh0rtWave: Well, guess not.
[14:08:00] adaedra: Sh0rtWave: haha, happens to me all the time. Apparrently, /join is a really good help
[14:08:12] Sh0rtWave: Ok so here's the real error: checking for kccommon.h... *** extconf.rb failed ***
[14:08:25] Sh0rtWave: I would think kccommon.h is a kyotocabinet header file.
[14:08:36] Sh0rtWave: I have kyotocabinet and kyotocabinet-devel installed, so you'd think that would solve that problem.
[14:09:31] adaedra: <adaedra> Operating system, what command you attempted, what output did you got?
[14:09:37] Sh0rtWave: It mentions a mkmf.log file, but where the hell does that go?
[14:09:38] adaedra: and by output, I mean whole trace
[14:09:48] Sh0rtWave: The OS is scientific linux.
[14:09:54] wasamasa: "checking for reading ability... *** check failed ***"
[14:10:19] Sh0rtWave: getting to a pastebin. I have to work under certain restrictions, so forgive my slowness.
[14:10:44] adaedra: No problem
[14:11:10] mdw: apeiros (thankyou for your help earlier) I understand reggex is greedy because of my use of the non-capturing group (?:.)+ is there a way I can restrict this group so I can capture the middle string '@@ -55,6 +32,8 @@'
[14:11:16] mdw: http://rubular.com/r/EdXO0167tP
[14:11:36] adaedra: wasamasa: shhh :p
[14:11:48] mdw: it's capturing the final group, but it's missing the middle one
[14:12:05] Sh0rtWave: effing RSA tokens are harshing my groove
[14:12:32] Sh0rtWave: I literally have to wait a minute between sudo commands.
[14:13:27] Sh0rtWave: http://pastie.org/10118327
[14:14:10] adaedra: did you look in /usr/local/rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/kyotocabinet-ruby-1.27.1/ ?
[14:14:48] adaedra: and. Oh, ruby 1.9.3 !
[14:15:42] Sh0rtWave: Let's presume I'm a neophyte in this area, I'm installing Ruby and such to support a larger application, and I'm not really in on which version is which. I installed what was recommended for the package.
[14:16:01] wasamasa: `pkgfile kccommon.h` tells me that the kyotocabinet package has this header
[14:16:13] Sh0rtWave: I installed kyotocabinet.devel
[14:16:14] wasamasa: on debian-like systems you may need to install -devel versions of packages to have headers
[14:16:31] wasamasa: can you `locate` the file?
[14:16:44] wasamasa: just to check whether it's merely looking in the wrong place
[14:17:01] Sh0rtWave: yup, it's there
[14:17:15] Sh0rtWave: that's why I started to lose my mind
[14:18:50] adaedra: "It's there"
[14:18:53] adaedra: Where is it?
[14:19:08] Sh0rtWave: It's in the right place. I seem to be missing a compat package for 7zip
[14:19:22] Sh0rtWave: I just don't think I needed to go down as far as I had to find that out. D:
[14:19:46] adaedra: GeorgesLeYeti est doux
[14:19:57] adaedra: Or something like that
[14:20:02] GeorgesLeYeti: Je sais je sais.
[14:20:33] GeorgesLeYeti: I try to be practical. :p
[14:20:39] adaedra: Sh0rtWave: no problem, I was just noticing. 1.9.3 becomes to be very old, by the way.
[14:23:10] Sh0rtWave: Well I think I got to the bottom of it.
[14:23:17] Sh0rtWave: missing compression libs
[14:23:28] Sh0rtWave: 7zip, xz, and zo.
[14:23:36] dudedudeman: mornnnninngggggg
[14:23:45] adaedra: bloody dependencies.
[14:24:09] adaedra: Is it planned to ditch C extensions in Ruby, like JRuby did?
[14:24:44] GeorgesLeYeti: I'd like to remove every spaces before ? or ! or : But i'm not so good with regex. I found the solution: str.gsub(/(s+)?\?/, "?").gsub(/(s+)?\!/, "!")... but is it possible to make it with only 1 gsub ?
[14:25:28] wasamasa: adaedra: lol, would you prefer downloading megabytes of jars instead?
[14:25:31] Sh0rtWave: Yes, well, more irritating is because of system restrictions that make it hard to get to the bottom of things.
[14:25:35] Sh0rtWave: chroot jails, all that jazz
[14:26:16] adaedra: >> "Hello ? Hello ! Hello : world".gsub(/\s+([?!:])/, '\\1')
[14:26:17] ruboto: adaedra # => "Hello? Hello! Hello: world" (https://eval.in/319906)
[14:26:22] adaedra: GeorgesLeYeti ^
[14:26:52] GeorgesLeYeti: adaedra, Thx a lot
[14:27:03] adaedra: wasamasa: what do you mean?
[14:29:33] wasamasa: `du -hs ~/.m2` <- 94M
[14:29:57] adaedra: Hello dudedudeman, by the way
[14:30:05] wasamasa: just for installing dependencies for a clojure project
[14:30:09] dudedudeman: adaedra: ayyyyyyyy
[14:30:17] Sh0rtWave: many thanks gentelement
[14:30:48] havenwood: `du -hs ~/.m2` <- 276M
[14:31:13] adaedra: du: /Users/adaedra/.m2: No such file or directory
[14:32:05] wasamasa: you're on osx
[14:32:26] wasamasa: there's a special place in dependency hell for you :P
[14:33:52] wasamasa: ACTION read about signing and homebrew lately
[14:34:24] wasamasa: https://github.com/Homebrew/homebrew/issues/31164
[14:35:29] adaedra: That's not a homebrew problem, actually
[14:35:47] wasamasa: no, it's an OSX problem
[14:35:51] adaedra: First to raise the issue was TrimEnable afaik
[14:36:00] wasamasa: I'm glad I jumped ship early
[14:36:28] adaedra: It's not often that you build kexts
[14:47:45] havenwood: i don't use any OS X packages with kexts afaik
[14:57:12] strcmp1: kernel extensions? sound fun to write anyway.
[15:16:13] noteugene: Hi people, I have a process with run-away memory consumption. I gdb'ed to it, and used ObjectSpace.dump_all to dump the heap. It looks like the most of memory is consumed by objects that don't have "marked":true gc flag on them, and no reference in that heap. Does anyone know how that could be possible?
[15:25:58] platzhirsch: what's again the Ruby method to iterate over an array and create a hash out of it? .inject?
[15:26:40] jhass: platzhirsch: depends heavily on usecase
[15:27:17] gregf_: >> Hash[(1..5).map{ |x| [x,x] } ]
[15:27:19] ruboto: gregf_ # => {1=>1, 2=>2, 3=>3, 4=>4, 5=>5} (https://eval.in/319918)
[15:27:25] platzhirsch: users.woop({}) { |hash, value| hash[value.id] = ... }
[15:27:38] jhass: each_with_object
[15:27:39] platzhirsch: right, Hash[ ] syntax would do I guess
[15:27:51] gregf_: platzhirsch: .to_h
[15:28:14] jhass: or maybe .group_by(&:id)
[15:28:20] jhass: it's still a bit vague
[15:53:56] shevy: I feel that the force is with us today
[15:57:18] Cat_1: Have a question on this https://gist.github.com/ccuadrado/288c5701ae566e52dfb8 on line 4, what is the purpose of doing |(text,divisor)| instead of |text,divisor| ?
[15:58:12] [k-: assign array[0] to text and array[1] to divisor
[15:58:32] [k-: |text,divisor| means it takes 2 args
[15:58:53] [k-: |(text, divisor)| means it takes 1 arg and pattern matches it
[16:00:19] toretore: for a single array argument, it will do it implicitly, but it's good to be explicit
[16:00:53] toretore: >> lambda{|one, two, three| p one }.call([1,2,3])
[16:00:54] ruboto: toretore # => wrong number of arguments (1 for 3) (ArgumentError) ...check link for more (https://eval.in/319932)
[16:01:09] toretore: >> proc{|one, two, three| p one }.call([1,2,3])
[16:01:09] [k-: i laughed
[16:01:10] ruboto: toretore # => 1 ...check link for more (https://eval.in/319933)
[16:01:31] toretore: >> proc{|(one, two, three)| p one }.call([1,2,3])
[16:01:32] ruboto: toretore # => 1 ...check link for more (https://eval.in/319934)
[16:01:57] [k-: >> [["a", "b"]].each { |(first, second)| first + second }
[16:01:58] ruboto: [k- # => [["a", "b"]] (https://eval.in/319935)
[16:02:26] toretore: and that is why you do it explicitly, then you don't have to deal with bullshit lambda/proc differences
[16:02:49] [k-: >> (first, second) = ["a", "b"]; first
[16:02:50] ruboto: [k- # => "a" (https://eval.in/319936)
[16:05:26] jhass: >> proc {|a, (b, (c, *d), e)| p [a, b, c, d, e]; }.call([1, [2, [3, 4, 5], 6]])
[16:05:27] ruboto: jhass # => [1, 2, 3, [4, 5], 6] ...check link for more (https://eval.in/319937)
[16:14:08] Senjai: jhass: eww stop itt
[16:15:01] jhass: no love for array destructing? :P
[16:15:25] Senjai: jhass: I dont mind, but you always come up with the extremes :P
[16:16:01] Senjai: also morning all
[16:16:12] toretore: i wish ruby had has destructuring too
[16:16:35] Senjai: Hash's dont need to be deconstructed
[16:17:22] adaedra: They need to be hashed
[16:17:28] adaedra: ACTION ==> []
[16:20:16] [k-: > (key, value) = { key: 1 }
[16:20:27] [k-: >> (key, value) = { key: 1 }
[16:20:28] ruboto: [k- # => {:key=>1} (https://eval.in/319939)
[16:20:40] [k-: >> (key, value) = { key: 1 }; key
[16:20:41] ruboto: [k- # => {:key=>1} (https://eval.in/319940)
[16:20:57] [k-: unfortunate then
[16:21:04] adaedra: (key, value) = { key: 1 }; key.to_a
[16:21:10] [k-: you can just do to_a tho
[16:21:22] adaedra: >> (key, value) = { key: 1 }.to_a; key
[16:21:23] ruboto: adaedra # => [:key, 1] (https://eval.in/319942)
[16:21:31] adaedra: ah, doesn't work either.
[16:21:33] [k-: to_a will return [[key, value], [key, value]]
[16:21:47] [k-: >> {key:1}.to_a
[16:21:48] ruboto: [k- # => [[:key, 1]] (https://eval.in/319945)
[16:22:00] [k-: how do you expect destructuring to work?
[16:22:05] adaedra: >> ((key, value)) = { key: 1 }.to_a; key
[16:22:06] ruboto: adaedra # => :key (https://eval.in/319946)
[16:22:14] adaedra: [k-: was just testing
[16:22:14] jhass: >> key, value = *{key: 1}; key
[16:22:15] ruboto: jhass # => [:key, 1] (https://eval.in/319947)
[16:22:16] [k-: all keys = keys? all values = values?
[16:22:20] jhass: mh, nope :P
[16:22:56] [k-: >> (key, value) = {key:1}.to_a.flatten; key
[16:22:57] ruboto: [k- # => :key (https://eval.in/319948)
[16:22:59] havenwood: >> key, value = {aim: true}.flatten; key
[16:23:00] ruboto: havenwood # => :aim (https://eval.in/319949)
[16:23:07] [k-: i win first!
[16:23:29] adaedra: I got the key above
[16:23:30] jhass: proclaiming that you win
[16:24:10] [k-: oh i missed that :(
[16:24:16] [k-: im sad now
[16:24:21] shevy: hmm... if I have string1 = "abc" and string2 = "abcdef" ... how I can qualify how identical these two strings are? should I use match-percentage? like I assume... 50% identical?
[16:24:30] adaedra: But your solution looks better, [k-, so there's that
[16:25:16] Mon_Ouie: shevy: You could use Levenshtein distance (or look up other string distance algorithms)
[16:25:34] shevy: I think gem has had that inbuilt too hmm
[16:26:12] shevy: yeah I remember it now
[16:26:15] shevy: havenwood showed me
[16:26:18] shevy: and I stored the code :-)
[16:26:32] shevy: >> require 'rubygems/text'; include Gem::Text; levenshtein_distance 'shevy', 'chevy'
[16:26:33] ruboto: shevy # => 1 (https://eval.in/319950)
[16:28:16] havenwood: shevy: Or in Crystal: require "levenshtein"; puts levenshtein "shevy", "chevy" #>> 1
[16:29:03] shevy: I guess crystal is more amenable to modifications to core
[16:29:36] shevy: there is a rubygem addon in ruby https://rubygems.org/gems/levenshtein/versions/0.2.2
[16:29:44] ebernhardson: rubocop is complaining about some cucumber code that looks like `hash["doesnotexist"].should == nil` saying i should use nil? but if i change it do `hash["doesnotexist"].should nil?` then i get `expected #<FalseClass:0> => false\n got #<NilClass:$> => nil`. Where did that false come from?
[16:30:00] havenwood: shevy: require 'damerau-levenshtein'; DamerauLevenshtein.distance 'shevy', 'chevy'
[16:30:36] shevy: what is this...
[16:30:50] havenwood: shevy: gem install damerau-levenshtein
[16:31:06] shevy: ebernhardson the comparison should be: object == nil OR object.nil?
[16:31:17] shevy: not something.should nil?
[16:31:35] shevy: in the above, while rubocop is annoying, I concur. .nil? is prettier than == nil
[16:31:51] ebernhardson: shevy: oh, so nil? is being resolved before passing into should?
[16:31:52] havenwood: shevy: https://github.com/GlobalNamesArchitecture/damerau-levenshtein/blob/master/ext/damerau_levenshtein/damerau_levenshtein.c
[16:32:36] havenwood: shevy: the RubyGems one is a nice pure Ruby implementation
[16:32:38] shevy: if I have two arrays, how can I find the one with less elements?
[16:32:45] shevy: should I use .select or .min or something
[16:33:01] [k-: nil? is called on the current main object, Object.nil? #=> false
[16:33:05] shevy: ebernhardson not entirely sure what your standalone "nil?" means there
[16:33:05] [k-: >> nil?
[16:33:07] ruboto: [k- # => false (https://eval.in/319953)
[16:33:10] ruboto: shevy # => false (https://eval.in/319954)
[16:33:17] ebernhardson: shevy: well, i only put it there because rubocop told me to
[16:33:21] shevy: guess this will evaluate to false
[16:33:21] adaedra: shevy: a.length < b.length ? a : b
[16:33:33] ebernhardson: shevy: what is the equivilent to `hash["doesnotexist"].should == nil` but using nil?
[16:33:35] shevy: adaedra :( my old nemesis, the ternary
[16:33:36] havenwood: >> [[1, 2], [1, 2, 3], [100]].min_by &:size
[16:33:37] ruboto: havenwood # => [100] (https://eval.in/319955)
[16:33:49] adaedra: shevy: ternaries are nice, sometimes
[16:33:54] shevy: ebernhardson not sure... what does `hash["doesnotexist"] return? nil?
[16:34:09] ebernhardson: i guess hash["doesnotexist"].nil?.should == true ?
[16:34:11] [k-: hash["doesnotexist"].nil? == true
[16:34:15] ebernhardson: but that seems uglier
[16:34:26] adaedra: .should == nil ?
[16:34:34] ebernhardson: adaedra: rubocop says not to do that
[16:34:43] shevy: well rubocop often is an idiot
[16:34:46] [k-: i nvr use rubocop
[16:34:48] shevy: you have to train him
[16:34:54] adaedra: and should be_nil ?
[16:34:57] shevy: you can somehow modify the behaviour it displays
[16:35:12] adaedra: `should be_nil`, learn to quote adaedra
[16:35:43] ebernhardson: ahh, be_nil looks appropriate there. thanks
[16:35:55] shevy: you could also try to file an issue request at https://github.com/bbatsov/rubocop/issues
[16:36:01] shevy: the guy is very ambitious, last comit: 2 hours ago \o/
[16:36:30] Mon_Ouie: Ruby has warnings for use of '==' when you don't use the result of it (because it assumes == is supposed to be side-effect free, so not using the result of it would make no sense)
[16:36:35] adaedra: The same way, you have be_true, be_truthy, be_false, be_falsy
[16:36:44] shevy: do_be_do_be_doo
[16:37:28] adaedra: Mon_Ouie: which is right, when you think about it
[16:37:36] adaedra: I don't want == to have side effects
[16:37:49] shevy: you want it to be a baguette
[16:37:57] shevy: c===========>
[16:38:00] shevy: now it is more a baguette
[16:38:10] shevy: ah well perhaps not
[16:38:15] shevy: the reverse of a c is not a >
[16:38:21] Mon_Ouie: Well how do you think 'foo.should == true' works?
[16:38:21] [k-: lol when == has side effects you cant be sure if the result of == can be trusted
[16:38:27] ebernhardson: i suppose being new to ruby, i was thinking == would be passed as an unresolved function that could be resolved by should. essentially a function pointer or however ruby calls it
[16:38:29] shevy: just like in PHP!
[16:38:44] [k-: ruby functions are not first class?
[16:39:18] adaedra: Mon_Ouie: I know it's the case. But saying that == is supposed to be side-effect-less still makes sense.
[16:39:26] [k-: ( foo.should ) == (true)
[16:39:30] Mon_Ouie: They are ??? or well, there are no functions and methods aren't really first class, but you can pass blocks to functions and represent them as Proc, which are first class objects)
[16:39:31] Hanmac: [k- no they are all economy class ;P
[16:39:46] [k-: you can def foo.should arg = nil
[16:40:32] Senjai: ebernhardson: Are you talking about rspec?
[16:42:03] Senjai: ebernhardson: Rspec monkey patches should into object
[16:42:20] Senjai: ebernhardson: Generally, bad practice. You probably want expect(thing).to eql(something_else)
[16:42:24] Senjai: as should is deprecated
[16:43:38] shadeslayer: how does one use Process:UID.switch?
[16:43:43] shadeslayer: anyone got a example?
[16:43:57] shadeslayer: I want to switch from the super user to a regular user and then back
[16:44:06] ebernhardson: Senjai: interesting, didn't realize that. this test suite i just inherited has over 100 uses of should, guess i have some work to do :)
[16:44:41] Senjai: ebernhardson: It's really bad :P, in older versions its fine, but if your version supports expect() you're going to want to use it
[16:45:37] kubunto: cucumber is ruby's testing suite right?
[16:45:48] Senjai: ebernhardson: If your interesting in replacing the bad syntax, you can expecitly set the syntax to expect to disable the should syntax
[16:45:58] jhass: kubunto: there are many different testing frameworks for ruby, cucumber is one
[16:45:59] Senjai: kubunto: No, minitest is the default, rspec is a variation of minitest
[16:46:19] Senjai: kubunto: Cucumber is yet another framework
[16:46:26] Senjai: kubunto: I highly recommend against cucumber
[16:46:29] kubunto: jhass: i thought so but I did not remember
[16:46:52] kubunto: Senjai: any particular reason?
[16:47:08] Senjai: kubunto: Yes, it was designed for non programmers to write tests, but practically, its only programmers that write tests.
[16:47:19] Senjai: kubunto: You have to write a bunch of regexes to support the natural language of it, its cumbersome
[16:47:38] Senjai: Its best to just use minitest, or rspec
[16:47:57] Senjai: I find rspecs DSL very explicit when written correctly in terms of understanding. But it is like learning a new language
[16:48:01] Senjai: and a lot of people hate it
[16:48:05] Senjai: but I <3 it
[16:48:07] kubunto: Senjai: i ask because it came up on a job description
[16:48:19] Senjai: kubunto: If they ask what you think about cucumber, tell them they're wrong :P
[16:48:29] [k-: hahahha
[16:48:31] Senjai: kubunto: Do your own research on the topic
[16:48:37] [k-: i heard cucumber is wrong
[16:48:43] [k-: i meant slow*
[16:48:46] [k-: you confused me
[16:48:51] Senjai: I'd be less inclined to work somewhere that forces cucumber
[16:48:59] Senjai: I'd expect more money for hardship and stress
[16:49:08] dudedudeman: double or nothing on cucubmer
[16:49:25] Senjai: A company that tests at all, is better than one that doesnt test
[16:49:57] shevy: shadeslayer hmm perhaps like so: Process.egid = 501
[16:50:03] shevy: not sure if there is a .uid= method
[16:50:13] shevy: Process.euid = 105
[16:50:45] shevy: Senjai real men don't need tests!
[16:51:33] Senjai: shevy: REAL MEN TEST WITH THEIR FACE
[16:51:50] shevy: that sounds scary
[16:51:56] shevy: poop faces
[16:52:01] [k-: they use the nose and the tongue
[16:52:02] Senjai: http://www.gifbin.com/bin/480sw822yu80.gif
[16:52:07] [k-: lick 'em bugs
[16:52:14] [k-: sniff 'em bugs
[16:52:20] shevy: now you put me into having to watch "jackass" videos on youtube Senjai ...
[16:52:30] Senjai: shevy: sorry not sorry
[16:54:37] Papipo: do you know if there is any script to spin a dummy server and obtain OAuth tokens locally?
[16:58:20] Senjai: Papipo: Yes
[16:58:22] Senjai: and its terrible
[16:58:33] Senjai: So terrible I cannot mention it
[16:58:37] Senjai: I would just write one quickly
[16:58:49] Senjai: or stub out the requests
[16:58:55] Papipo: it's for scripting
[16:59:08] Papipo: I just need a token to update all of my youtube videos
[16:59:24] Senjai: Just write a ruby script that does all of that..
[16:59:31] Papipo: that's what I am doing
[16:59:32] Senjai: Or non ruby script
[16:59:38] Papipo: but I need the damn tokens
[16:59:43] Papipo: but, I've found a way
[16:59:53] Senjai: Dont you get them from like.. youtube?
[16:59:54] Papipo: with some tool named playground on google developer site
[16:59:57] pontiki: hello rubyists
[17:00:03] Papipo: yes, but you need HTTP interactions
[17:00:05] Senjai: pontiki: Long time no see
[17:00:21] Senjai: Papipo: Right, so listen on a port to get the oauth token
[17:00:28] Senjai: or see if theres a more permenant solution
[17:00:49] Senjai: You can have a script listen on a port, that youtube can point at just for the token generation
[17:01:32] pontiki: hihi senjai
[17:01:39] pontiki: i come with a problem: https://gist.github.com/tamouse/0e75c8eb207072ac3f6c
[17:01:54] pontiki: i'm running ruby-install ruby 2.1.1 and it's throwing this compile error in readline.c
[17:02:23] pontiki: this is on ubuntu 14.04 server
[17:07:05] Senjai: pontiki: Have ypou tried 2.1.3
[17:08:11] havenn: pontiki: Use 2.1.6! But if you *must* use a Ruby before the fix you can patch a backport: ruby-install -p https://gist.github.com/mislav/a18b9d7f0dc5b9efc162.txt ruby 2.1.1
[17:08:34] Senjai: havenn: Drop the mic why dont you
[17:09:20] havenn: Senjai: good mornin'!
[17:11:22] havenn: pontiki: ruby-install ruby 2.1.6
[17:11:35] Senjai: havenn: ruby install only has 2.1.3 no?
[17:12:04] Senjai: I just reinstalled ruby install, and I only got 2.1.3 out of it
[17:12:22] pontiki: i would like to, but i don't get to control the bloddy damn .ruby-version file :(
[17:12:38] Senjai: pontiki: lol what? :( It should just be "2.1"
[17:12:48] pontiki: see previous statement
[17:12:58] Senjai: I know, I'm just ranting
[17:13:01] Senjai: Thats not a fun setup :(
[17:13:16] havenn: Senjai: ruby-install doesn't automatically update versions and checksum definitions quite yet. it will in an upcoming release. but you can install versions by just providing the version and checksum yourself, like: ruby-install ruby 2.1.6 --sha256 7b5233be35a4a7fbd64923e42efb70b7bebd455d9d6f9d4001b3b3a6e0aa6ce9
[17:13:20] pontiki: well, there's more to rant about. one is 2.1.1, another is 2.1.0, and i have use them both
[17:13:30] havenn: Senjai: how'd you install it?
[17:13:46] Senjai: havenn: via ruby build iirc
[17:14:12] Senjai: havenn: If it wasn't written in shell, I would actually contribute and add that ability to automatically add definitions
[17:14:23] Senjai: But I have no intention to learn that much shell :(
[17:14:24] pontiki: thanks for the patch, tho, havenn
[17:14:31] havenn: Senjai: are you talking ruby-build and i'm talking ruby-install?
[17:14:37] havenn: pontiki: de nada
[17:14:40] Senjai: havenn: nono, ruby install
[17:14:41] havenn: pontiki: but 2.1.6!
[17:14:50] Senjai: But i got 2.1.6 from ruby build because ruby install didnt have it
[17:15:43] havenn: Senjai: you can `make update` before `sudo make install` to fetch latest definitions including 2.1.6 from ruby-versions for now. but yeah, it'll be *soon*.
[17:16:32] Senjai: havenn: Im guessing your a contributor?
[17:16:40] Senjai: I will keep the make update trick in mind
[17:16:40] havenn: Senjai: yup
[17:17:15] Senjai: havenn: If you're willing to code review the hell out of any PR's I submit, Id probably contribute
[17:17:30] jhass: havenn: we should rewrite ruby-install in crystal :D
[17:17:38] Senjai: unless you already have a feature branch setup somewhere for it
[17:17:40] havenn: jhass: \o/
[17:21:35] havenwood: Senjai: No feature branch. Summary of latest thinking at the bottom of this thread: https://github.com/postmodern/ruby-install/issues/175
[17:22:26] Senjai: bookmarked
[17:25:27] havenwood: Senjai: And of course a --no-update option to disable automatic update. :)
[17:27:10] Papipo: anybody here using the yt gem=
[17:27:28] jhass: no, you're its only user on the world
[17:27:44] joelataylor: curious if anyone here has integrated Intercom.io ?
[17:28:17] Senjai: joelataylor: !use
[17:28:17] helpa: joelataylor: Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[17:28:22] Senjai: do we have a use entry?
[17:28:24] ruboto: I don't know anything about use
[17:28:28] ruboto: I don't know anything about help
[17:28:34] Senjai: How to add factoids?
[17:28:42] jhass: Senjai: !fact mk key value
[17:29:26] jhass: but it's restricted to ops
[17:29:35] Senjai: Oh I thought it asnt
[17:29:51] Senjai: according to apeiros, or so I thought
[17:29:54] Senjai: !fact mk use Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[17:30:03] ruboto: Just ask your question, if anyone has, they will respond.
[17:30:21] jhass: !fact mk use Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[17:30:21] ruboto: jhass, I will remember that use is Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[17:30:22] Senjai: Could I get bot access? I've kind of been around forever
[17:30:24] joelataylor: ok, thanks Senjai
[17:30:47] jhass: Senjai: sorry, currently the authentication is tied to the channel ACL
[17:31:01] joelataylor: if I add a Gem to a project, does it automatically get included and initialized?
[17:31:21] jhass: Senjai: feel free to ping me any time to add something though ;)
[17:32:13] Senjai: joelataylor: Yes, if the user hasn't set require: false
[17:32:25] Senjai: At least in rails, I believe.
[17:33:37] Papipo: jhass: fortunately I added "here" to my question
[17:34:12] Papipo: Senjai: AFAIK they changed that and now you need to explicitly require stuff
[17:34:31] Papipo: or maybe that was just for files in lib/
[17:34:36] jhass: Papipo: often people can help you with your problem regardless, it's better to ask your actual question directly ;)
[17:35:04] Papipo: my problem is that the gem is not behaving at all as expected
[17:35:23] sandstrom: Capistrano is installed via Bundler. When running `cap --help` it tries to load all gems in the Gemfile. How can I prevent that? I've tried adding `:require => false` but it doesn't work.
[17:35:27] Papipo: like account.videos.count raising a ServerError
[17:36:26] jhass: joelataylor: search your project for a call to Bundler.require, that will load all gems in the Gemfile which don't have require: false specified
[17:36:43] jhass: the argument specifies which groups to load
[17:36:43] Senjai: sandstrom: gem install capistrano
[17:36:52] jhass: joelataylor: if you can't find that call the answer is no
[17:37:11] Senjai: sandstrom: Install it globally
[17:37:25] sandstrom: Senjai thanks, will try!
[17:38:08] jhass: Papipo: 0.16 was released just yesterday, are you on the latest version?
[17:40:03] jhass: it seems well maintained, what's the specific error?
[17:42:22] sandstrom: Senjai I tried, still get 'Could not find ruby-vips-0.3.8 in any of the sources'. Totally unrelated to capistrano, but it's a gem in the gemfile.
[17:42:49] Senjai: Probably not the correct version then
[17:46:06] sandstrom: Senjai I found it :) I'd aliased `bundle exec cap` to `cap`. It was good at the time, but turned into a trip-wire now :)
[17:47:36] Senjai: Yeah, never alias bundle exec :P
[17:47:42] Senjai: I have it aliased to be
[17:47:49] Senjai: brails => bundle exec rails
[17:47:56] Senjai: but I never change rails to be bundle exec rails by default
[17:48:09] Senjai: there are ways to automatically switch aliases when your in a project dir, but I dont really advise them
[17:48:56] joelataylor: thanks jhass - looks like I needed to restart the server after I changed branches. Doh.
[17:54:31] shevy: hmm we have the >= operator
[17:54:35] shevy: but I wonder
[17:55:03] shevy: may it be easier to not use =, but instead just use "greater than" and "less than"? since the check it seems to do, would be superfluous
[17:55:20] shevy: like you could have "at least 80% identity", and check for it via >= 80 or > 79
[17:56:35] adaedra: It's valid for integers, not floats
[17:56:39] shevy: I could save one character :)
[17:56:51] shevy: not valid for floats?
[17:57:03] adaedra: 79.5 is > 79 but not >= 80
[17:58:33] adaedra: [80;+???[ is better expressed with >= 80, because of float values, and because it's more readable
[18:00:35] shevy: I need to think about this baguette situation
[18:01:10] shevy: careful with the . adaedra we may run out of them one day
[18:09:26] adaedra: ACTION run gzip
[18:20:10] Papipo: jhass: after a lot of debugging... the problem with the yt gem seems to be about a SSL certificate!
[18:32:21] Papipo: Seriously, I have tried like 4 different fixes of #<OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed>
[18:32:24] Papipo: without luck
[18:32:41] zzach: Is it possible to change /usr/bin/make in /usr/bin/gem using any option or environment variable , or is it hardcoded? (PATH change does not seem to work)
[18:50:58] al2o3-cr: >> (1..10).map{|n| 1 << n }
[18:50:59] ruboto: al2o3-cr # => [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] (https://eval.in/320005)
[19:15:11] agent_white: Afternoon folks
[19:24:43] dudedudeman: sup agent_white
[19:27:54] dudedudeman: are there any best practices worth noting about when to use, or not to use splats?
[19:28:51] GaryOak_: dudedudeman: you mean in the argument list?
[19:29:13] dudedudeman: GaryOak_: yes
[19:30:02] dudedudeman: i've seen examples of them used ina few different scenarios, but i know examples are just little bits to show what something is capable of, and not something that would be best practice
[19:30:43] GaryOak_: I think it's easy to run into problems using it
[19:31:20] GaryOak_: because you don't know whether what you passed in was an array or not
[19:32:29] dudedudeman: could you define an array to a a variable and then pass it through using interpolation?
[19:34:19] adaedra: what do you mean?
[19:34:25] adaedra: pass an array as arguments?
[19:34:34] dudedudeman: i'll gist what i have in mind
[19:34:53] adaedra: args = [ 6, 7 ]; -> (a, b) { a * b }.call(*args)
[19:34:56] adaedra: >> args = [ 6, 7 ]; -> (a, b) { a * b }.call(*args)
[19:34:57] ruboto: adaedra # => 42 (https://eval.in/320024)
[19:36:22] finisherr: When a class inherits another class and they both have initialize methods, how can one make sure that all parameters get initialized?
[19:37:04] pontiki: parameters are passed in
[19:37:44] finisherr: in the sub class, do you have to make reference to the params of the initialize method of the superclass?
[19:38:03] finisherr: in order to have access to all of them?
[19:38:27] dudedudeman: adaedra: here's what i was tinkering with
[19:38:28] dudedudeman: https://gist.github.com/anonymous/38a47d322e8bdc4ba4ba
[19:39:12] dudedudeman: GaryOak_: ^ is what i'm mulling over
[19:39:14] GaryOak_: finisherr: if you want to invoke the superclasses initialize method you have to call super
[19:39:31] finisherr: okay cool, I was wondering if ruby did something like that
[19:39:34] finisherr: or supported that
[19:40:21] pontiki: if you change the signature of the initialize method in the subclass, you have to call the superclass's initialize with explicity parameters
[19:41:01] adaedra: dudedudeman: and what's the problem?
[19:41:15] GaryOak_: I guess it's nice if you have a DSL
[19:41:23] GaryOak_: or are trying to make a DSL
[19:41:48] dudedudeman: adaedra: no problem, just me trying to see if there are best practices on when to use splat and when not to. i'm just asking based on my inexperience compared to most of you folks
[19:42:43] dudedudeman: because i look at that, and i'm like, oooo, this looks useful. but of course there are instances where you look at things and you're like, nope. don't do that. and you can say that because you've been there and done that
[19:42:46] adaedra: You use splat to dynamically pass arguments
[19:43:26] GaryOak_: dudedudeman: it depends if you want things to be really clean or really explicit
[19:44:07] finisherr: Okay, yeah. Super method is the ticket. Thank you
[19:44:17] pontiki: play around with splats, find out where and how they work, etc
[19:44:24] dudedudeman: which, if my reading of Clean Code has been of any help, I need to be thinking about writing code that others will be reading later on
[19:44:44] finisherr: Sometimes I read through books and get impatient as questions come up : )
[19:44:53] pontiki: quite so. one of those people will be you.
[19:45:11] pontiki: a year from now, you will look at code and say "what idiot wrote this?? .. oh .."
[19:45:14] dudedudeman: pontiki: i hop so!
[19:45:36] GaryOak_: I think splat doesn't show it's intentions very clearly in the method signature, but that's just me :P
[19:45:50] adaedra: dudedudeman: don't worry. With more experience, you'll be able to tell better what's good or not
[19:46:00] pontiki: avdi has a bunch of tapas on splat
[19:46:04] dudedudeman: adaedra: i do hope so.
[19:46:54] dudedudeman: pontiki: i've been mulling over subscribing to that. i've seen a few of the free ones and think they're great, but4 i know they're not entirely geared towards junior level thinking
[19:47:16] al2o3-cr: dudedudeman: Math.hypot(*[3,4]) is equiv as Math.hypot(3,4)
[19:47:43] dudedudeman: so i'm wary of spending too much time learning cool, fancy techniques when i should be grinding through things like the prag prog guide to ruby
[19:48:10] GaryOak_: get the logic and design down, and then you can mess with syntax suger
[19:49:36] shevy: how do you guys feel about using commandline ascii cheering when everything works fine
[19:49:38] shevy: like outputting:
[19:49:59] dudedudeman: ha, i would love that
[19:50:09] dudedudeman: or doing something like "... and there was much rejoicing"
[19:50:15] dudedudeman: followed by the \o/
[19:50:17] ShellFu: what about the metal head: \m/
[19:50:25] dudedudeman: someone say metal!?
[19:50:39] ShellFu: oh yeah :)
[19:50:40] shevy: how ascii can make people's mood lighten up
[19:50:43] pontiki: dudedudeman: you most definitely do not have to run through every tapas
[19:51:11] pontiki: it's easy enough to just pick and choose
[19:51:15] GaryOak_: shevy: <(^_^<)
[19:51:55] shevy: that's the japanese smiley
[19:52:00] shevy: manga style
[19:52:36] pontiki: and when it fails, you flip a table?
[19:55:15] dudedudeman: it'd be cool if you could animate a little ascii bit moving back and forth on the lines.
[19:56:36] Hanmac: shevy: ~??:3
[19:56:42] adaedra: dudedudeman: glench.com/hash/ and click 'diy'
[19:57:36] dudedudeman: ha! that's so cool
[19:57:43] dudedudeman: of course that would be something that already exisits
[19:58:02] dudedudeman: there's nothing new under the sun i guess
[19:58:18] shevy: dudedudeman
[19:58:22] shevy: you are a double dude
[19:58:32] shevy: you remind me of the dude in the big lebowski
[19:58:50] adaedra: that's like, your opinion man
[19:59:02] Hanmac: dudedudeman: that reminds me of "TimmyTurner" how did you get (that thing that should not exist)? and the answer was always "Internet" ;P
[19:59:33] dudedudeman: i am most dudes!
[19:59:45] dudedudeman: i definitely abide
[20:00:06] shevy: adaedra you watched it too?
[20:00:18] adaedra: actually not
[20:00:25] adaedra: I know some quotes
[20:00:37] shevy: adaedra one of my favourite french movies is Le fabuleux destin d'Am?lie Poulain
[20:00:54] adaedra: Never seen either
[20:01:17] pontiki: i think over here it's just titled "Amelie"
[20:01:50] shevy: le pontiki
[20:01:54] shevy: so reminds me of a french nick
[20:02:42] pontiki: i have not seen the big lebowsky either
[20:02:57] pontiki: i don't want to have to buy it, can't find it to stream
[20:02:59] dudedudeman: it's a good one just to say you've seen it
[20:03:46] adaedra: It's not on netflix?
[20:03:53] pontiki: not streaming, no
[20:03:54] adaedra: Everyone has netflix nowadays
[20:03:55] dudedudeman: http://www.reddit.com/r/fullmoviesonyoutube/comments/2z5ilg/the_big_lebowski/
[20:04:17] dudedudeman: though, the comments say the sound quality is pretty rough
[20:04:21] adaedra: "pretty bad sound quality"
[20:04:25] dudedudeman: don't know how you feel about that
[20:04:33] pontiki: follow that link
[20:04:34] adaedra: "[Comedy] [Crime] ??? The Big ..." This video is no longer available due to a copyright claim by Universal Pictures (ZEFR).
[20:04:40] dudedudeman: ah there it is
[20:04:57] adaedra: it's YouTube, a full film often stays short
[20:05:08] dudedudeman: dang, that subreddit is usually good about movies
[20:05:54] pontiki: MPAA is even better at finding shit
[20:06:16] pontiki: i'd bet they even have people reading the subr
[21:26:25] al2o3-cr: why can't you have if match = data.match /!hello/ in ruby 2.2.2
[21:29:57] apeiros: al2o3-cr: I don't know, why can't you?
[21:30:32] al2o3-cr: apeiros: ignore me i'm going mental ;P
[21:30:54] apeiros: ok. but if I ignore you, I can't help you.
[21:31:45] al2o3-cr: not literally, you need perens
[21:33:18] mwlang: I want to extract a timestamp???s values off a line with a regexp. A typical line: "Processing ContentController#index (for 207.46.13.43 at 2015-02-25 02:03:34) [GET]" ??? my regexp (which works, but is looooong): line.scan(/(\d{4})\-(\d{2})\-(\d{2})\s(\d{2})\:(\d{2})\:(\d{2})/).reject{|r| r == ''}.flatten.map(&:to_i) => [2015, 2, 25, 2, 3, 34] Can the regexp be reduced?
[21:36:26] al2o3-cr: apeiros: which is preferred "match = data.match(//); if match; ..." or "if match = data.match(//); ..."
[21:36:39] apeiros: al2o3-cr: I prefer the former
[21:36:52] adaedra: if data =~ // then use $~ ?
[21:37:19] al2o3-cr: ok thanks apeiros
[21:37:53] apeiros: mwlang: scan with capturing groups never returns a string. that reject is pointless.
[21:38:21] apeiros: and scan is the wrong tool if you only have a single match. use .match(regex).captures.map(&:to_i)
[21:38:37] mwlang: apeiros: yeah, I saw that and removed already???original regexp was returning a bunch of empty strs
[21:38:41] apeiros: regarding your question: the regex can't be reduced significantly
[21:39:02] apeiros: you can use \d\d instead of \d{2} - saves you a single digit * 5.
[21:39:14] apeiros: I don't see much else.
[21:39:43] mwlang: apeiros: a finer point worth me exploring more: match vs. scan
[21:39:56] mwlang: is match more optimized or just a better choice for the use-case?
[21:40:10] apeiros: better choice for the use-case
[21:40:25] apeiros: the only optimized regex expression is /literal/ =~ regex
[21:40:31] adaedra: you're trying to find if your string match as a whole, mwlang, not finding every substring which matches
[21:40:45] adaedra: first is match, latter is scan
[21:40:45] apeiros: well, and =~ generally being faster if all you care for "does it match" because it does not construct the MatchData object
[21:41:04] apeiros: adaedra: that one's lazy
[21:41:13] adaedra: didn't know that
[21:41:17] apeiros: adaedra: but yes, once you use $~, you give up the performance advantage
[21:41:28] adaedra: I always do like this
[21:41:44] apeiros: in fact, I think any of the $ vars related to regex will cause a construction of matchdata. not sure though.
[21:41:48] mwlang: apeiros: so here???s the final version: line.match(/(\d{4})\-(\d{2})\-(\d{2})\s(\d{2})\:(\d{2})\:(\d{2})/).captures.map(&:to_i) ??? I think I???ll keep \d{2} as that???s a little easier to read altogether.
[21:42:47] mwlang: I???m basically pulling the timestamp out of the line to feed to Time.new, so I do care about the resulting data of the match.
[21:43:26] havenwood: [/[\d-]+\s[\d\:]+/].scan /\d+/
[21:43:44] mwlang: I gotta collate several app???s log files to reconstruct the series of events across those multiple apps. (which ain???t fun, btw).
[21:44:06] apeiros: havenwood: Array#scan? what did you do to your ruby? :D
[21:44:25] mwlang: havenwood: :-o
[21:44:27] havenwood: >> "Processing ContentController#index (for 207.46.13.43 at 2015-02-25 02:03:34) [GET]"[/[\d-]+\s[\d\:]+/].scan /\d+/
[21:44:28] ruboto: havenwood # => ["2015", "02", "25", "02", "03", "34"] (https://eval.in/320055)
[21:44:41] apeiros: mwlang: you're out of luck. at work I have a basic rails log parser.
[21:44:51] apeiros: constructs even params for you :)
[21:45:10] apeiros: havenwood: ah, you mean String#[]
[21:45:18] mwlang: apeiros: haha???I just about gots a rudimentary one written now.
[21:45:51] apeiros: mwlang: older rails logs were worse. concurrent requests writing into each other's log outputs???
[21:45:59] mwlang: it???s even worse than I let on, though???the log files have not been rotated regularly???so I???m scanning 7gb logs, too. :-o
[21:46:16] mwlang: apeiros: ugh???don???t take me back to those days.
[21:46:44] apeiros: when I have to do such stuff I preprocess them
[21:46:52] mwlang: apeiros: do you by any chance know when that was fixed? I???m digging into a Rails 1.2 app.
[21:47:05] apeiros: grep -b is helpful.
[21:47:32] apeiros: I think rails 4 made the logging situation better. not sure though. I *very* rarely have to dig into rails log files.
[21:47:38] mwlang: apeiros: I???m preprocessing with grep and sed to reduce as much as possible, and then grabbing what I need with what???s left over using Ruby.
[21:47:49] apeiros: usually our other logging tools provide better and sufficient info
[21:48:17] mwlang: apeiros: sadly for me, this is a new client and project and they have a mess.
[21:48:27] apeiros: good luck :-D
[21:50:14] mwlang: apeiros: but speaking to log clobbering, I thought that was largely solved in the 2.1.x era if not sooner???.or did we ???self solve??? that with different logs per worker? (I???ve forgotten!)
[21:51:23] mwlang: if there???s one gripe about not doing giant monolythic apps, its that it???s a lot harder to trace the flow of data across the multiple apps.
[21:52:45] mwlang: and it feels weird going from ruby to .Net to Perl to .Net and back to Ruby ??? I feel like I???m translating code to ???ruby??? as much as interpreting the data exchanges.
[21:56:02] hololeap: i've got a block that relies on reading files from a temporary directory. i have it set up so that it creates the directory/files, calls yield(file), and then destroy the directory. can i move this functionality to an Enumerator?
[21:57:03] hololeap: i want it to call a method/lambda that deletes the directory as soon as the method chain returns
[21:58:00] toretore: hololeap: code
[21:58:10] toretore: here: gist.github.com
[22:01:09] mwlang: hololeap: https://gist.github.com/mwlang/d016ea8b2593704bdfe2
[22:05:18] havenwood: mwlang: you can drop the `&block`, `begin` and `end` and that still works :P
[22:06:00] mwlang: havenwood: hmmm???does that work in Ruby 1.8, too?
[22:06:43] havenwood: mwlang: yup
[22:07:05] mwlang: havenwood: cool. I guess I???ve been doing it verbosely for no good reason, then. :-p
[22:08:01] havenwood: 18>> def with_tmp_foder; yield ensure end; with_tmp_foder { puts 'do your thing' }
[22:08:02] ruboto: havenwood # => do your thing ...check link for more (https://eval.in/320066)
[22:08:42] adaedra: 10>> def with_tmp_foder; yield ensure end; with_tmp_foder { puts 'do your thing' }
[22:08:43] ruboto: adaedra # => /tmp/execpad-fb3cc805a9a8/source-fb3cc805a9a8:2: syntax error ...check link for more (https://eval.in/320067)
[22:09:22] hololeap: toretore: https://gist.github.com/hololeap/9322b7846795dddcb997
[22:10:03] mwlang: havenwood: ah, maybe I???ve gotten in the habit of being explicit so I can check if block was given, but that worked, too??? https://gist.github.com/mwlang/d016ea8b2593704bdfe2
[22:10:31] hololeap: toretore: i want to be able to use it with the progress gem like so `archive.unpack(books).with_progress('Books').each {|f| ... }` and have it delete the directory once each() returns. is this possible?
[22:10:52] mwlang: well, I now know how to write even less code today than yesterday. :-D
[22:10:59] havenwood: mwlang: yeah, `&block` with `block.call` can be nice
[22:11:27] hololeap: toretore: right now the enum is returned _after_ the directory is deleted so it can't be used (since the files that need to be used are no longer there)
[22:11:29] havenwood: mwlang: i don't think i'd mix `&block` with `yield` though
[22:11:40] adaedra: Goooood Night
[22:11:42] mwlang: havenwood: like when you want to change the binding on the block call???
[22:12:26] havenwood: mwlang: i just think the argument should be used if defined
[22:13:04] mwlang: havenwood: I removed &block from the args and changed to ???yield if block_given????
[22:13:33] mwlang: (more toying with this at this point???)
[22:13:33] havenwood: mwlang: that's nice as well :)
[23:20:22] mallu: Can you please tell me if I can do this? https://dpaste.de/fck2
[23:23:15] Radar: mallu: !try
[23:23:15] helpa: mallu: Why don't you try it and find out for yourself?
[23:23:19] Radar: mallu: Try it and find out.
[23:23:35] mallu: Radar: actually it doesn't work
[23:23:54] mallu: Radar: can you please give me another idea how I can accomplish it?
[23:24:00] Radar: No I don't know sorry.
[23:24:31] havenwood: mallu: For starters you create a `check` array then call #each on `checks` plural, whatever that is?
[23:25:08] drocsid: I tried installing the mail gem
[23:25:18] drocsid: sudo gem install mail
[23:25:18] drocsid: Successfully installed mail-2.6.3
[23:25:19] drocsid: 1 gem installed
[23:25:19] drocsid: Installing ri documentation for mail-2.6.3...
[23:25:23] drocsid: Installing RDoc documentation for mail-2.6.3...
[23:25:37] ytti: on top of what havenwood said, you probably meant
[23:25:38] ytti: command = "check-rds.rb -i #{database_name} --#{check}-warning-over #{node[monitor][check][warning]} --#{check}critial-over #{node[monitor][check][critical]} --period #{period}"
[23:25:38] drocsid: require 'mail'
[23:25:38] drocsid: LoadError: no such file to load -- mail
[23:25:58] drocsid: so why am I getting the load error when I try to use it?
[23:26:12] havenwood: drocsid: What version of Ruby?
[23:26:28] drocsid: havenwood: the version included with centos
[23:26:31] ytti: i would advice against running programs like this
[23:26:39] drocsid: I think it's 1.8.7
[23:26:46] havenwood: drocsid: Ruby 1.8 is past end-of-life and requires `require 'rubygems'` to use RubyGems.
[23:26:52] ytti: the appropriate way is to pass software and arguments as array
[23:26:54] drocsid: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
[23:27:03] ytti: instead of shell evaluation of a string
[23:27:13] havenwood: drocsid: Ruby 2.2.2!
[23:27:16] drocsid: havenwood: thanks, it's really to bad centos packages old versions like that...
[23:27:22] ytti: if you do string evaluation you need to do sanitization, and that is going to be done incorrectly anyhow
[23:27:33] drocsid: centos and puppet use them
[23:27:42] ytti: with passing binary and arguments as array, you don't have to care about sanity
[23:28:24] drocsid: on my desktop i use ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[23:28:37] drocsid: but I have no control in this other environment
[23:29:28] banister: st????????????????????????????????????ole a $160,000 diamond and traded it for $20 of
[23:29:48] banister: ????????????????????????????????????
[23:30:10] mallu: havenwood: Can you please give me an example?
[23:31:09] havenwood: >> check = %w(cpu memory disk); checks
[23:31:11] ruboto: havenwood # => undefined local variable or method `checks' for main:Object (NameError) ...check link for more (https://eval.in/320133)
[23:32:03] drocsid: require rubygems fixed that gem issue. I'm now having an issue with the module itself.
[23:32:08] drocsid: the mail module
[23:32:09] drocsid: Mail.defaults do
[23:32:10] drocsid: delivery_method :smtp, address: "localhost", port: 25
[23:32:27] drocsid: ^^^ from the mail module example
[23:32:40] drocsid: syntax error, unexpected ':', expecting kEND delivery_method :smtp, address: "localhost", port: 25
[23:33:10] drocsid: guess I should look at the source for expecting kEND delivery_method
[23:33:13] havenwood: drocsid: 1.8 doesn't support that syntax for Symbol keys.
[23:33:45] havenwood: drocsid: :address => "localhost", :port => 25
[23:33:53] havenwood: drocsid: the Hash rocket
[23:34:05] mallu: havenwood: I ma tryig to have a varible inside another variable
[23:34:17] drocsid: :delivery_method=>smtp ?
[23:35:29] havenwood: drocsid: `{aim: true}` is 1.9 syntax so with the very past-end-of-life 1.8 you have to `{:aim => true}`.
[23:35:40] havenwood: 1.9 is also past end-of-life.
[23:36:06] drocsid: so confusing...
[23:37:29] drocsid: syntax error, unexpected tASSOC, expecting kEND
[23:37:34] drocsid: :delivery_method => smtp, :address => "localhost", :port => 25
[23:38:45] havenwood: drocsid: `delivery_method` is a Method not a Symbol
[23:39:16] havenwood: drocsid: `:delivery_symbol` would be a Symbol
[23:41:05] drocsid: havenwood: thanks
[23:42:13] havenwood: drocsid: `delivery_method :smtp, address: "localhost", port: 1025` is like `delivery_method(:smtp, {:address => "localhost", :port => 1025})`.
[23:42:28] havenwood: drocsid: https://github.com/mikel/mail/blob/master/lib/mail/configuration.rb#L23
[23:43:00] havenwood: drocsid: first arg is the `method`, and second arg is the `settings` Hash
[23:43:53] mistermocha: hey still new with ruby ... is there a way to pass in a CLI flag on an rspec test?
[23:44:27] havenwood: mistermocha: what kind of flag? have an example of what you're thinking?
[23:44:38] mistermocha: I'm setting up serverspec tests, which are natively rspec tests, and would like to be able to pass in a hostname on execution
[23:44:54] mistermocha: because otherwise I'd be editing the Rakefile every time I want to test a different host
[23:45:23] mistermocha: e.g.: rspec spec/my/test_spec.rb --hostname=db001.foobar.com
[23:46:04] mistermocha: then my test would handle the value of --hostname appropriately and do tests to that host
[23:48:46] mistermocha: I have more serverspec questions if anyone is able
[23:50:07] havenwood: mistermocha: OptionParser is in the stdlib or the Slop gem is simpler.
[23:50:33] mistermocha: havenwood: doesn't rspec eat the cli flags?
[23:50:48] mistermocha: guess I should be reading rspec docs
[23:53:11] mistermocha: ah... --tag creates symbols ... probably not a supported method, but if it works
[23:56:11] Senjai: mistermocha: No, the CLI arguments are always stored in ARGV