« Back to channel list

#ruby - 14 January 2014

« Back 1 day Forward 1 day »
[00:28:15] benzrf: whats new
[00:28:25] benzrf: new adventure time and new archer tonite!
[00:42:52] NCS_One: can someone help me with this error on Ocra: /var/lib/gems/1.8/gems/ocra-1.3.1/bin/ocra:18:in `quote': can't convert nil into String (TypeError)
[00:45:40] shevy: NCS_One seems like sloppy code in that gem
[00:45:46] shevy: you also seem to run an ancient debian ruby
[00:46:08] NCS_One: shevy: ruby 1.9.3
[00:46:39] shevy: I have 1.9.3 myself and the site dir is at /usr/lib/ruby/gems/1.9.1/gems/
[00:46:49] shevy: you run a debian-based system right?
[00:47:14] shevy: "ocra" is the ocra gem at https://rubygems.org/gems/ocra ?
[00:47:38] shevy: to have a path 1.8 in a directory while you have a version that is not 1.8.x shows that someone or something messed with the system
[00:48:21] bnagy: using gems from 1.8 ABI with 1.9 is also unlikely to be fun
[00:49:07] NCS_One: shevy: yes, ubuntu
[00:49:36] shevy: Hanmac here also uses ubuntu
[00:49:38] bnagy: NCS_One: long story short, I'd try installing 1.9 properly then reinstall the gem
[00:51:20] benzrf: i use it too B)
[00:51:49] NCS_One: I'm going to try to uninstall and install all
[00:52:16] bnagy: benzrf: wow, that's super softcore for you, dude. I would have picked you as a gentoo or slack user
[00:52:48] bnagy: or maybe awesome, so you can tile all your vim windows
[00:53:19] shevy: benzrf one day you will become a powerful user
[00:53:42] shevy: and the unity world can be left behind
[00:59:03] benzrf: bnagy: haha rly?
[00:59:16] benzrf: bnagy: i do not see the point in making things hard for yourself
[00:59:28] benzrf: using slax or w/e does not give significant advantages over ubuntu so why go to the trouble ?
[01:00:10] Hamburglr: could someone help me with using rbenv? I have a gem installed and trying to run it gets this error: https://gist.github.com/anonymous/166c0c9aca9ff31758ba as far as I can tell it's because I don't have my gem path right but I don't know where to specify it
[01:00:18] benzrf: i tried xmonad and it was p nice but my screen is not nearly big enough to really get the most out of it
[01:13:27] shevy: benzrf do you use debian ruby?
[01:14:11] benzrf: benzrf@benzrf-laptop:~$ ruby -v
[01:14:11] benzrf: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
[01:17:00] benzrf: bnagy: what do you use?
[01:17:14] shevy: Hamburglr seems as if you miss rack. I dont use rbenv myself, I compile everything from source including ruby
[01:17:41] benzrf: bnagy: *OS
[01:17:48] benzrf: also, why
[01:18:01] bnagy: osx on desktops, linux on servers
[01:18:08] benzrf: hmmmmmmm ok
[01:19:08] Hamburglr: shevy: thanks but it is installed. I found someone else having the same problem here: http://stackoverflow.com/questions/16867516/rbenv-command-line-gems-setup-with-system-install but unfortunately rbenv rehash isn't making a difference for me
[01:20:01] RubyPanther: rbenv generally does compile everything from source
[01:20:18] shevy: it falls flat on the face in this case
[01:21:22] shevy: RubyPanther what do you use to get the latest ruby running?
[01:21:46] RubyPanther: Hamburglr: it looks like your gem got installed with the system ruby or something
[01:22:38] Hamburglr: RubyPanther: I don't think it's that either, I can see the gems in /usr/local/opt/gems
[01:22:41] RubyPanther: Hamburglr: you should remove other rubies, or fix your PATH so that the rbenv bin dir is before the system bin dirs. And then install the gem
[01:22:48] benzrf: yo if anybody watches adventure time here the new episode can be dl'd @ http://www.reddit.com/r/downloadtime/comments/1v5ju9/s05e22b_apple_wedding/
[01:22:53] benzrf: </offtopic.
[01:23:05] shevy: Hamburglr that is a very unusual path
[01:23:05] RubyPanther: Right, the gems should be in with the rbenv stuff
[01:23:26] RubyPanther: but normally you install rbenv in userspace, not in some crufty local unix dir
[01:24:00] shevy: one day people will fearlessly grab the source again
[01:24:15] RubyPanther: shevy: I use ruby-build as a plugin, the releases show up within a few hours usually
[01:24:38] RubyPanther: I have at times build a custom one, you just stick it in the right dir (or symlink it) and it shows up
[01:24:48] postmodern: shevy, yeah building from source isn't hard
[01:24:54] postmodern: shevy, ./configure && make && sudo make install
[01:25:20] postmodern: shevy, only catch is you have to install all the libraries ruby needs, otherwise certain things are disabled
[01:27:01] shevy: yes but I am ready to paste the relevant links!
[01:27:13] shevy: http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
[01:27:22] shevy: http://www.zlib.net/zlib-1.2.8.tar.gz
[01:27:27] shevy: throw it at me!
[01:27:48] shevy: Hamburglr when everything else fails, try the source :>
[01:27:55] shevy: ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.bz2
[01:28:18] shevy: hmm readline possibly, can be annoying
[01:28:34] RubyPanther: yeah don't fly without readline
[01:28:40] shevy: depends a lot on the system. on slackware things are smooth and perfect, on ubuntu they are not because the users are not very knowledgable
[01:28:41] postmodern: shevy, https://github.com/postmodern/chruby/wiki/Ruby :)
[01:28:53] shevy: and so much is split up
[01:29:06] RubyPanther: on slackware people fix their problems before they admit to them, so it always looks smooth ;)
[01:29:07] postmodern: copy/paste those commands, should be good
[01:29:16] shevy: postmodern, pacman on archlinux I group together with slackware
[01:29:25] shevy: so people who use either these distributions are usually clever
[01:29:35] RubyPanther: Or, they cry a lot
[01:29:42] postmodern: shevy, im on fedora, does that make me dumb :P
[01:29:47] postmodern: shevy, or shall i say doomb
[01:30:22] shevy: I think slackware is slowly dying
[01:30:23] RubyPanther: fedora is for devs, historically
[01:30:30] shevy: #archlinux +1600 vs. #slackware ~+200
[01:30:33] postmodern: shevy, jokes on you, i ran Gentoo for years, i've paid my dues
[01:30:43] shevy: that python shit!
[01:31:13] postmodern: i believe capistrano was a gentoo project originally
[01:31:21] benzrf: come now python is pretty nice
[01:31:22] shevy: wheee... +1040 people on #gentoo
[01:31:30] RubyPanther: gentoo was cool, that was the difference with fedora. gentoo drew off the fanboys and let fedora focus on bridging the server/workstation gap
[01:31:40] postmodern: shevy, only the package manager was python, the package definitions were actually bash
[01:31:48] shevy: benzrf I want a ruby centric distribution, not portage/emerge/eselect
[01:32:01] postmodern: shevy, only used python to extract metadata and build the db
[01:32:16] shevy: debian still uses perl in dpkg
[01:32:29] shevy: I found out when I removed perl
[01:32:36] postmodern: pfff i want a Rust centric package manager
[01:32:38] shevy: stupid dpkg was no longer working :(
[01:32:47] shevy: Rust? is anyone using that?
[01:33:14] RubyPanther: yum is also python, I know this from years of making fun of the error messages.
[01:35:43] shevy: python is like the ultimate virus
[01:35:46] shevy: very successful
[01:36:06] postmodern: we should write a package manager in PHP, just because
[01:36:08] lethjakman: hey, I'm trying to run a method in my class on instantiation like this: https://gist.github.com/lethjakman/8411538
[01:36:11] lethjakman: am I thinking about this wrong?
[01:36:20] lethjakman: I just need an array of @searchable
[01:38:17] postmodern: lethjakman, you need to extend ClassMethods as well?
[01:38:37] nhhagen: I'm calling a method from a route with a querystring parameter as the method attribute, and ruby claim that the method map is not found?
[01:38:49] nhhagen: in sinatra
[01:39:12] postmodern: lethjakman, i generally avoid ActiveSupport stuff, just do def self.included(base); base.extend ClassMethods; end
[01:39:14] lethjakman: postmodern: nah, that's being pulled in with the extend, it's a rails thing.
[01:39:26] lethjakman: good to know
[01:51:44] shevy: lethjakman the gist is gone!
[01:58:07] lethjakman: shevy: I fixed it :)
[01:58:15] lethjakman: thank you for looking though!
[02:09:27] HashNuke: Hey guys ~!
[02:10:00] shevy: wattup HashNuke
[02:10:25] HashNuke: Anyone here using RestClient and trying to send files? I get IO error because the stream is closed.
[02:10:52] benzrf: sup HashNuke
[02:10:56] benzrf: hows it goin
[02:11:10] HashNuke: Not going when debugging :)
[02:11:12] wang: yeah didn't you hear the stream dried up mid last year we've been hoping for rain for months
[02:14:23] RubyPanther: I wanted to drink from a stream so bad, I dug up an empty IO object just to place it against my eyes and imagine
[02:32:06] Riking: check this out: http://cdn.discourse.org/uploads/try2_discourse/124/b2adfd7651b75d11.png
[02:44:47] shevy: so one regex to rule them all
[02:44:56] shevy: string1 = 'short-mime-1.0.0-rc1'
[02:45:05] shevy: regex = /(.+)-(\d.+)/
[02:45:32] shevy: 'short-mime-1.0.0-rc1'[/(.+)-(\d.+)/]
[02:45:38] shevy: $1 # => "short-mime"
[02:45:44] shevy: $2 # => "1.0.0-rc1"
[02:45:48] shevy: works for this input
[02:46:08] shevy: won't work for WebKit-r93670
[02:51:29] krainboltgreene: shevy: You want a SEMVER regex?
[02:51:32] krainboltgreene: The spec has it.
[02:56:13] RubyPanther: shevy: I didn't look up the spoiler, but my try is: /(.+?)-([^\d-]*\d[^0]*(-?.*))$/
[02:56:50] shevy: the .+? part
[02:56:54] shevy: that makes it optional ?
[02:57:15] RubyPanther: oops I have a typo /(.+?)-([^\d-]*\d[^-]*(-?.*))$/
[02:57:31] RubyPanther: ? makes it less greedy, more scroogey
[02:57:51] RubyPanther: Oh, the other ? makes it optional, yeah
[02:58:17] shevy: ok, need to wrap my head around it fully to grasp it
[02:59:08] RubyPanther: I didn't wrap my head around it, I just stuffed parts in until the examples came out right :o the spec probably has a better one lol
[03:01:21] krainboltgreene: I'm not sure where I got this from: https://gist.github.com/krainboltgreene/8412309
[03:01:30] krainboltgreene: But I'm fairly sure it's from before they removed it from the spec.
[03:33:27] hostess: I'm trying to refactor some ugly code. Can anyone prettify this? configs.grep(/http_username=(\S+)/i)[0].match(/http_username=(\S+)/i)[1] it's essentially reading through an array (configs) and just pulling out the value of the http_username=asdf for the single item in the array named "http_username"
[03:34:55] ddd: hrmm. say I have a @user.role string. where the string is like 'rescue_group'. How would I turn that into @user.rescue_groups ?. I mean @user.role = "rescue_group". @user has a plural collection of the same name as the role. So, I want to do something like @collection = @user.#{@user.role.pluralize}
[03:35:28] ddd: the reason for this is role can change, but role will always contain the singular form of @user's attached collection
[03:35:44] ddd: so I want to turn that into the attr name to call on @user
[03:36:18] RubyPanther: hostess: I'm trying to picture what the larger codebase would look like that has that excerpt... I'm picturing a full rewrite
[03:36:37] hostess: RubyPanther: it's a really small script actually. I'm just a ruby retard
[03:37:08] hostess: If it were C#, I could use Linq like a master, but I still can't grasp enumerables in ruby, which is almost the same thing
[03:38:26] hostess: Interesting, this kinda works: configs.grep(/http_username=(\S+)/i) { |v| $1 }
[03:39:29] bnagy: configs.map {|c| c[/http_username=(\S+)/i,1] } maybe
[03:40:23] ddd: i got it. its @user.send(@user.role.pluralize) if anyone else was interested. (many thanks to drbrain)
[03:42:44] RubyPanther: hostess: configs.find(/http_username=(\S+)/i){|s| s}
[03:43:45] hostess: bnagy: That returns an array with a nil for every item in the original array that doesn't match, and then matches on the 1 config value properly. I'd then have to remove all nil values
[03:44:16] hostess: RubyPanther: that just returns the first item in the original array
[03:45:28] centrx: Hold on, I feel an inspiration coming on
[03:45:29] RubyPanther: hostess: Without seeing the whole script, or test data, I'm not really sure what is going on
[03:45:50] hostess: RubyPanther: no worries, I think I can go with this pretty well: configs.grep(/http_username=(\S+)/i) { |v| $1 }
[03:46:08] hostess: it returns the value of the one config key that matches the regex
[03:46:26] hostess: well, technically it would return multiple if they existed
[03:46:47] bnagy: match globals are awful
[03:47:24] RubyPanther: On my test data, that is what mine did, except giving at most 1 result
[03:48:17] RubyPanther: If you really want $1 you can leave out the |v|, but yeah... I'm allergic to globals
[03:49:32] centrx: hostess, May want to use reduce/inject
[03:50:20] centrx: hostess, Also as mentioned if there is other code, there might be a better way to do the code over-all, e.g. if it splits on new line to get the config option
[03:50:42] bnagy: hostess: add .compact to the end, then
[03:51:06] RubyPanther: yeah just stick it in the compactor, that will fix it
[03:52:02] hostess: Ok, that may be a slightly better option than the global method
[04:43:41] multi_io: ruby -rdebug doesn't work here
[04:44:58] multi_io: e.g. "ruby -rdebug -e 1" prints Debug.rb\nEmacs support available, then cosumes all available CPU and is only killable via kill -9
[04:45:03] multi_io: can anyone confirm?
[04:45:07] multi_io: what is this?
[04:45:42] multi_io: what I want is to debug ruby scripts in Emacs :)
[04:46:41] multi_io: rdebug (from the debugger gem) works, but I don't know how to use that in Emacs' debugger ui
[04:47:36] centrx: eww emacs
[04:48:10] multi_io: centrx: what do you propose instead?
[04:49:10] centrx: multi_io, When I run ruby -rdebug -e 1 it works
[04:49:11] multi_io: Yeah sure :P Does that have a debugger ui?
[04:49:30] centrx: multi_io, I don't know. I let my users debug my code. Much easier
[04:49:38] multi_io: centrx: so it comes up with the (rdb:1) prompt?
[04:50:04] multi_io: centrx: what ruby do you use? I'm on 1.9.3
[04:51:09] centrx: superman@bede:~$ ruby -rdebug -e 1
[04:51:10] centrx: Emacs support available.
[04:51:10] centrx: /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:123:
[04:51:24] Oog: how do i put a non-printable ctrl+A character in a string?!
[04:51:26] multi_io: maybe a bug, then
[04:51:28] Oog: google is on crack with their auth api
[04:51:37] centrx: ruby 2.0.0p353 (2013-11-22) [x86_64-linux-gnu]
[04:51:44] Oog: base64("user=" {User} "^Aauth=Bearer " {Access Token} "^A^A")
[04:51:49] Oog: ^A represents a Control+A (\001).
[04:51:52] Oog: wtf is this
[04:51:53] centrx: Oog, \u1234
[04:51:59] centrx: Oog, So it is probably \u001
[04:52:04] Oog: i tried that it no work :(
[04:52:14] Oog: oauth="user=someuser@example.com\u0001auth=Bearer vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==\u0001\u0001"
[04:52:21] Oog: Base64.encode64 oauth
[04:52:24] Oog: and i get different than their answer
[04:52:52] Oog: beginning of base64 is correct
[04:52:53] centrx: Oog, How about \x01
[04:53:31] Oog: correct base64 is dXNlcj1zb21ldXNlckBleGFtcGxlLmNvbQFhdXRoPUJlYXJlciB2RjlkZnQ0cW1UYzJOdmIzUmxja0JoZEhSaGRtbHpkR0V1WTI5dENnPT0BAQo=
[04:53:37] Oog: hat gives "dXNlcj1zb21ldXNlckBleGFtcGxlLmNvbQFhdXRoPUJlYXJlciB2RjlkZnQ0\ncW1UYzJOdmIzUmxja0JoZEhSaGRtbHpkR0V1WTI5dENnPT0BAQ==\n"
[04:54:41] Oog: wait its so close
[04:55:41] Oog: ruby gives ==
[04:55:45] Oog: google says o= at end...
[04:58:41] Oog: any idea?
[05:04:10] centrx: Oog, Use String#unpack ?
[05:05:16] Oog: google is on crack
[05:05:20] Oog: i just tried their tool
[05:05:23] Oog: it matches ruby
[05:06:25] bnagy: \n chars aren't significant for base64
[05:06:44] Oog: their website is wrong
[05:06:53] Oog: that o should be an = ut still my code is not work authenticating...
[05:07:38] Oog: they must have been on crack when they decided ot make it so complicated
[05:08:43] bnagy: the only diff between the two base64 strings is the top one has \n in the decoded string
[05:09:27] Oog: it works...
[05:09:32] Oog: thanks for the help
[05:09:34] Oog: soemthing is messed up
[05:10:22] bnagy: fwiw you can use "\u0001" or "\x01", same same
[05:25:51] Oog: google is on crack now it worked without any of the base64 silliness.....?!
[05:25:52] Oog: whatever
[05:40:00] Fuzai: Instead of using .is_a? Something to guess what an object type is, is there a way to look it up instead?
[05:41:53] RubyPanther: Fuzai: you're supposed to use .respond_to? instead, to test for the interface you need, instead of asking the type
[05:42:33] Fuzai: A friend of mine that is new was asking and I didn't have an answer for him
[05:44:30] RubyPanther: Ruby is all about duck-typing. If it quacks, it's good.
[06:22:41] DJJeff: http://puu.sh/6kpYg.png
[07:22:12] pontiki: type those ducks
[07:23:57] ddd: woot! wife is lovin the way the new app is coming along! Actually turning out pretty sweetly!
[07:55:27] lilly19: hi. how do you get all dependencies of a gem. > gem dependency NAME -R does not give you gems that are used by gems there and there.
[08:02:26] Fractional: How would I write a method that translates a string containing hex values to decimals?
[08:29:00] Fractional: How would I write a method that translates a string containing hex values to decimals?
[08:30:28] Hanmac1: Fractional: you mean like that? "A".to_i(16) #=> 10
[08:30:29] Hanmac1: or are you looking for something like gsub?
[08:30:52] Fractional: hex = "0BFFA0"
[08:30:52] Fractional: hex.to_dec #=> [11,255,160]
[08:35:26] Hanmac1: Fractional: "0BFFA0".scan(/\h{2}/).map(&:hex) #=> [11, 255, 160]
[08:36:18] Fractional: What does the regex do?
[08:37:30] Hanmac: find each section of two hex numbers
[08:37:32] tobiasvl: Fractional: \h matches a hex digit, {2} matches two of the preciding group
[08:37:58] Fractional: tobiasvl: I assume it is recommended to learn more about regexs. I'll have to do that this weekend.
[08:38:25] tobiasvl: yes, regexes are useful
[08:38:34] tobiasvl: http://rubular.com/
[08:40:28] Fractional: I've a question for another problem;
[08:40:31] Hanmac: also read more about CharacterClasses on http://www.ruby-doc.org/core-2.0.0/Regexp.html
[08:41:02] Fractional: Bookmarked :)
[08:43:42] Fractional: Going to experience some more with regexs :D
[08:44:20] Hanmac: reg-hexes ;P
[08:47:09] Fractional: There is no \h on that website
[08:48:53] tobiasvl: sure there is
[08:48:55] tobiasvl: /\h/ - A hexdigit character ([0-9a-fA-F])
[08:49:41] Fractional: I can't see it on the Rubular website.
[09:01:43] Fly80: hello everybody
[09:03:56] Fly80: i would like to write some text (in my ERB script) and return it as a file to the client. Is it possible with Ruby? How to do that? Should I set the http response header?
[09:33:37] mechanicles: How do I convert binary file into text file?
[09:34:10] mechanicles: I have csv file which has type as binary? How can read it?
[09:36:02] Hanmac: mechanicles: show me your code in a gist and then tell me what is wrong ... (normally it should automaticlly open files in the correct mode ... )
[09:38:31] Fly80: hello, I would like to write some text (in my ERB script) and return it as a file to the client. Is it possible with Ruby? How to do that? Should I set the http response header?
[09:41:02] Hanmac: Fly80 isnt erb more used in rails? if yes you can try #rubyonrails for more help
[09:52:44] mechanicles: Hanmac: If I open bynary typed csv file like File.readlines(path)...it shows me some different output
[09:53:04] mechanicles: Hanmac: I just tried in rails console
[09:53:40] Hanmac: mechanicles: File.readlines(path,:mode=>"rb")
[09:55:24] Takumo: Hi all, I'm writing a REST client using Faraday (and the Twitter gem as a reference) but I've not seen any documentation on how to work with a dynamic endpoint
[09:55:31] Takumo: i.e. https://account.app.com
[09:57:20] Hanmac1: mechanicles: PS: DONT open a csv file with readlines ... there is a CSV module in stdlib for that
[10:00:58] mechanicles: Hanmac1: File.readlines(path,:mode=>"rb") did not work. It does not show me text format. Now testing with CSV standard library.
[10:01:46] Hanmac: mechanicles: What "textFormat" do you mean? are you sure you didnt do something wrong?
[10:02:15] Fly80: Hanmac: i'll ask there, thx
[10:02:28] workmad3: Takumo: sorry, I don't understand what you mean by 'dynamic endpoint'
[10:04:06] Takumo: workmad3: I think I've solved it, e.g. the twitter APi is always at https://api.twitter.com/api/1.1/ , some have endpoints like "https://#{account}.myapp.com"
[10:04:21] Takumo: I've just given my client an .endpoint method
[10:04:47] workmad3: Takumo: ah, you threw me because 'account.app.com' actually went to a site ;)
[10:05:14] Takumo: really? well someone paid top $$ for that domain
[10:05:17] workmad3: Takumo: but what you meant is that you need to set the account name or potentially even the entire API endpoint url
[10:06:11] workmad3: Takumo: it didn't help that you said 'i.e.' instead of 'e.g.' for an example :)
[10:06:18] Takumo: so instead of having a constant "ENDPOINT" I've defined a method to use to get the endpoint
[10:06:23] Takumo: wildroman2: i.e = informative example
[10:06:47] Takumo: i.e. giving an example which has additional information to illustrate a concept :)
[10:06:58] wildroman2: Takumo: you must have meant workmad3 :)
[10:07:14] mechanicles: Hanmac: Please refer https://gist.github.com/santoshw/2a9f97ed12764df0cffc
[10:07:34] workmad3: Takumo: right... so I read the 'i.e.' as meaning 'this is the URL with a dynamic endpoint of the type I'm meaning'
[10:08:17] workmad3: Takumo: whereas e.g. would have meant (to me at least) 'this is the style of URL I mean'
[10:12:07] workmad3: Takumo: yeah, communication is fun :)
[10:17:38] Hanmac: mechanicles: i think your data format is shitty ... i tryed : CSV.parse(s.b.encode("UTF-8",invalid: :replace,undef: :replace,replace: "",fallback: "").gsub("\x00",""), :col_sep=> "|") #=> [["id", "system_code", "assembly_code", "description", "created_at", "updated_at"]]
[10:19:28] mechanicles: Hanmac: could you share your code?
[10:19:57] Hanmac: oO i already shared my code with you if you had read my line to the end oO
[10:21:48] Hanmac: mechanicles: i found your problem ... the file is not "binary" its UTF-16LE encoded ... try something like that: s.force_encoding("UTF-16").encode("UTF-8",invalid: :replace,undef: :replace,replace: "",fallback: "")
[10:26:40] mechanicles: Hanmac: How do you know that file is UTF-16LE encoded?
[10:27:35] Hanmac: because s.force_encoding("UTF-16LE") #=> "\uFEFF\"id\"|\"system_code\"|\"assembly_code\"|\"description\"|\"created_at\"|\"updated_at\"\r\x0A" ... then i encode it back to UTF-8 and remove the unwanted stuff like "\uFEFF"
[10:29:10] mechanicles: Hanmac: cool and thanks for your help :)
[11:09:12] GeorgesLeYeti: I want to truncate a string with 2 separators
[11:09:26] shevy: example string looks like?
[11:09:48] GeorgesLeYeti: and i can't find the syntax for 2 separators
[11:09:49] workmad3: GeorgesLeYeti: example input and output strings, and work from there
[11:10:32] workmad3: GeorgesLeYeti: and what do you mean 'syntax for 2 separators'?
[11:10:33] GeorgesLeYeti: Let say : "Hello World!\nCow"
[11:10:46] GeorgesLeYeti: The 2 separators are ' ' and \n
[11:11:18] shevy: GeorgesLeYeti there are several ways
[11:11:19] GeorgesLeYeti: So the result should be: "Hello"
[11:11:37] shevy: a simple way is via .split() method
[11:11:38] workmad3: GeorgesLeYeti: ah, so you want to split the string, not truncate it
[11:12:05] workmad3: GeorgesLeYeti: yeah, just use split with a regex or
[11:12:12] shevy: or for simplicity, you can convert the \n into ' ' and then split via "Hello World!\nCow".split(' ')
[11:12:40] Hanmac: GeorgesLeYeti: "Hello World!\nCow".split(/[ \n]/) #=> ["Hello", "World!", "Cow"]
[11:12:40] shevy: "Hello World!\nCow".tr("\n", ' ').split(' ') # => ["Hello", "World!", "Cow"]
[11:13:13] workmad3: >> "Hello World!\nCow".split(" ")
[11:13:13] eval-in: workmad3 => ["Hello", "World!", "Cow"] (https://eval.in/88890)
[11:13:20] workmad3: Hanmac: explain? :)
[11:13:46] Hanmac: ACTION did hear the sentence with a darlek voice ;P
[11:13:48] yo61: Any HTTParty users around??
[11:14:01] workmad3: Hanmac: EXPLAIN!
[11:14:13] yo61: I have some proof of concept code that submits a request to a puppedb server
[11:14:15] workmad3: Hanmac: EXPLAIN NOW OR BE EXTERMINATED!
[11:14:18] yo61: https://gist.github.com/robinbowes/8416743
[11:14:40] workmad3: Hanmac: and now my internal voice has gone all dalek-ey :(
[11:14:44] Hanmac: workmad3: split(" ") is treated specially: compare it with "Hello World!\nCow".split(/ /) #=> ["Hello", "World!\nCow"]
[11:15:02] shevy: newlines are treated like ' ' ?
[11:15:04] yo61: I want to do the same thing with HTTParty
[11:15:36] yo61: (because I'm extending a puppetdb ruby library that uses HTTParty)
[11:15:44] shevy: I would have assumed " " to be like / /
[11:15:50] workmad3: shevy: same
[11:16:00] yo61: This one: https://github.com/puppetlabs/puppetdb-ruby
[11:16:22] shevy: GeorgesLeYeti well there you go, workmad3 found the simplest way :D .split(" ")
[11:16:26] Hanmac: shevy: "ruby - the language where everything is odd, even if its even too" ;P
[11:16:36] workmad3: GeorgesLeYeti: ok, so there you go... in general, you can either .tr the separators so that they're all the same, then split on the one separator, or you can use a regex with .split with a [] character class to determine what to split on
[11:16:52] workmad3: GeorgesLeYeti: but if your separators are just newlines and spaces, then .split(" ") seems to be your man ;)
[11:17:56] workmad3: GeorgesLeYeti: on top of that, if you happen to have your separators in an array, you can do something like 'str.split(Regexp.union(array_of_separators))
[11:18:36] workmad3: Hanmac: ruby is real - everything is even!
[11:18:38] Hanmac: ACTION really like Regexp.union ;P
[11:20:08] Hanmac: workmad3: ri String#split => "If pattern is a single space, str is split on whitespace, with leading whitespace and runs of contiguous whitespace characters ignored."
[11:20:17] workmad3: Hanmac: awesome :)
[11:20:35] workmad3: Hanmac: unless you want to split on single spaces...
[11:21:47] workmad3: Hanmac: now I just need to get the dalek out of my head :(
[11:22:37] Hanmac: workmad3: did you already see the DoctorWho 50th year and the last Christmas special?
[11:24:16] tobiasvl: you can just do split with no patterns
[11:24:22] tobiasvl: >> "Hello World!\nCow".split
[11:24:22] eval-in: tobiasvl => ["Hello", "World!", "Cow"] (https://eval.in/88894)
[11:25:20] Hanmac: tobiasvl: "If pattern is omitted, the value of $; is used. If $; is nil (which is the default), str is split on whitespace as if ` ' were specified."
[11:26:12] tobiasvl: interesting
[11:27:20] workmad3: Hanmac: yup
[11:27:32] workmad3: Hanmac: I get to watch Doctor Who as it happens on UK tv ;)
[11:28:37] Hanmac: workmad3: i mean the last Christmas was AWESOME ... i mean a wooden Cyberman? a WOOD-MAN? now thats what i call "low-tec" ;P
[11:30:39] workmad3: Hanmac: except, logically, it was still very hi-tec
[11:31:22] workmad3: Hanmac: it's still a highly advanced machine, it still seemed to have electricity powering it, it was carrying a flamethrower...
[11:31:23] Hanmac: workmad3: and also the darlek "meat puppets" ;P ... specially the SILENCE Darlek meat puppets ... (its like pick your two most frightening monsters and splice them together xD )
[11:31:41] workmad3: the dalek meat puppets had been seen before, iirc :)
[11:32:07] workmad3: but not the silence ones... I did like that the silence were just confessional priests :)
[11:32:57] shevy: you guys are geeks
[11:33:11] Hanmac: yeah but they are "fighting priests" ;P with the lightning powers they could nearly stop the invasion
[11:33:44] workmad3: shevy: got any more facts to state? :)
[11:37:03] shevy: workmad3 regexes are hard on the brain
[11:40:17] Hanmac: other facts for share: "Hanmacs code is creepy but mostly the best way" ;P
[11:41:13] workmad3: Hanmac: how is your code creepy? :/
[11:41:38] shevy: only hanmac understands it
[11:41:58] workmad3: that's not creepy, that's job security
[11:45:00] Hanmac: workmad3: something like that:
[11:45:01] Hanmac: >> data=["/path/to/file/file.fil", "/path/to/file/dir1/file.fil"].map {|s|s.split(/\//) }.sort_by(&:size); chunk = data[1].to_enum(:zip,data[0]).chunk{|a,b| a == b };[chunk.first.last.map(&:first).join("/"),chunk.to_a.last.last.map {|s| s.compact.join("/")}]
[11:45:01] eval-in: Hanmac => ["/path/to/file", ["dir1/file.fil", "file.fil"]] (https://eval.in/88899)
[11:45:54] workmad3: Hanmac: nice :)
[12:04:05] Takumo: Does faraday not have a JSON encoding middleware for requests?
[12:08:09] adac: I would need to connect to mysql database via tcp and not via socket, and using "host" for the active_record configuration file which should than automatically use the tcp connection. However it does not work and it still tries to use the unix socket. Does anyone know what might be wrong
[12:11:18] Takumo: adac: do you have "socket" defined?
[12:11:49] adac: Takumo, nope just using "host" and leaving socket undfined
[12:12:09] MrZYX: you might get better answers in #rubyonrails
[12:13:22] shevy: is there a simple way to have like a system where there are lots of ruby objects running in the background
[12:13:28] shevy: and you can specifically call any of these at any time
[12:13:46] shevy: like making 1000 .rb files persistent and running all the time (in idle mode)
[12:14:00] MrZYX: why would you want to?
[12:14:25] MrZYX: also making "ruby objects" == "rb file" confuses me...
[12:14:55] shevy: MrZYX certain .rb files take rather long to do their specific tasks
[12:15:28] shevy: MrZYX for instance, one is reading in data from 2500 yaml files here and processing that
[12:15:41] HansPampel: what is the recommended way to include rake tasks in a self-built gem? I want to install the gem and execute a certain raketask afterwards ?
[12:15:51] shevy: then it generates several files
[12:15:59] MrZYX: shevy: top level code? so you spawn a new ruby process for each "task"?
[12:16:29] shevy: MrZYX it is spawned right now every time that .rb file is run. there is a slight delay before it can start generating the new files
[12:16:42] shevy: that delay is rather annoying
[12:17:14] MrZYX: make it a class
[12:17:22] shevy: it already is
[12:18:15] MrZYX: then just keep a process running and build a cli to it, might as simple as starting it through irb
[12:52:38] Takumo: Anyone here familiar with WebMock?
[13:02:03] HansPampel: what is the recommended way/pattern to include rake tasks in a self-built gem? I want to install the gem and execute a certain raketask afterwards ? I could add a class that to ./bin and add the execution of a rake task to it, but i am not sure if that is what i want..
[13:55:54] Fractional: Good evening!
[13:56:02] TheLarkInn: Good morning!
[13:56:14] Fractional: One can not say good morning in the near evening!
[13:56:23] colonolGron: depends on where he lives
[13:56:33] TheLarkInn: sure does ;-)
[13:56:39] TheLarkInn: Tis 8:00AM here.
[13:56:46] TheLarkInn: But good evening to you sir!
[13:59:16] MrZYX: Fractional: TheLarkInn: http://www.total-knowledge.com/~ilya/mips/ugt.html
[14:00:00] Fractional: Good UGT evening MrZYX!
[14:00:08] Fractional: Good UGT morning*
[14:00:47] MrZYX: good morning ;P
[14:01:16] Fractional: It is almost evening here but now that I follow the UGT time I shall say good morning!
[14:06:24] Fractional: Easiest way to count how many numbers there are in an array of each number? For instance [1, 1, 2, 3, 3] # => 1:2, 2:1, 3:2
[14:08:49] Hanmac1: Fractional:
[14:08:49] Hanmac1: >> [1, 1, 2, 3, 3].group_by {|i|i}.map {|k,v|[k,v.size].join(":")}.join(",")
[14:08:50] eval-in: Hanmac1 => "1:2,2:1,3:2" (https://eval.in/88932)
[14:13:12] waxjar: >> [1,1,2,3,3].each_with_object(Hash.new 0) { |no,hash| hash[no] += 1 } # :D
[14:13:12] eval-in: waxjar => {1=>2, 2=>1, 3=>2} (https://eval.in/88933)
[14:13:42] Fractional: Do you have any good sources for learning more about algorithms with arrays?
[14:14:03] Fractional: Preferably with tasks after every read.
[14:14:58] waxjar: read the Enumerable documentation every once in a while, it's so helpful
[14:17:33] Fractional: Do you have any "tasks" for those?
[14:18:46] waxjar: i don't, but I'm sure some exist
[14:33:18] maasha: I am trying to understand why my scheme of named pipes hang: https://gist.github.com/maasha/aa39e0f65ce7dbcec58c
[14:42:16] LadyRainicorn: You know Ruby has support for pipes, right?
[14:44:26] LadyRainicorn: Omg, I was thinking of Python.
[14:44:31] LadyRainicorn: It actually doesn't.
[14:44:48] lupine: for named pipes? sure it does
[14:44:57] LadyRainicorn: maasha: require 'mkfifo'
[14:46:32] LadyRainicorn: lupine: Sure? All I can see on Google are people talming about how Ruby doesn't have a builtin for named pipes.
[14:47:35] LadyRainicorn: I was pretty shocked too.
[14:47:58] maasha: LadyRainicorn: I did note the mkfifo gem, but I simple used a system call instead.
[14:48:41] lupine: ohhh. no, you're right
[14:48:47] lupine: no mknod() wrapper
[14:49:22] LadyRainicorn: Yeah I know. ;-;
[14:49:41] LadyRainicorn: maasha: Your solution is insecure.
[14:49:47] lupine: well, could be worse
[14:49:59] LadyRainicorn: You need to call system with multiple arguments.
[14:50:11] LadyRainicorn: Using interpolation with it is vert bad.
[14:50:19] maasha: LadyRainicorn: worse, it aint working
[14:50:26] LadyRainicorn: And chmod 666 is bad too.
[14:50:38] sweeper: mark of the beast
[14:51:38] LadyRainicorn: What error do you get?
[14:52:23] maasha: No error, but it hangs - so I have missed something
[14:52:46] LadyRainicorn: Why are you opening with r+ and w+?
[14:52:55] LadyRainicorn: You want r and either w or a.
[14:53:26] LadyRainicorn: You want to send if you must instead of method(x).call
[14:53:46] Fractional: Looking for a ruby mentor or programming partner! :)
[14:54:11] maasha: LadyRainicorn: After googling examples of named pipes I saw they were using r+ and w+ (besides, without + it still hangs)
[14:54:26] LadyRainicorn: You'll get extra newlines with puts.
[14:54:47] maasha: ACTION makes a note of send
[14:56:06] maasha: LadyRainicorn: Sure, but that is not my main concern.
[14:56:09] LadyRainicorn: Ah, you're not closing the fifo.
[14:56:22] LadyRainicorn: It will hang reading until you do.
[14:56:53] LadyRainicorn: You can't just iterate over them.
[14:57:04] LadyRainicorn: You need to specifically send an EOF.
[14:59:41] maasha: LadyRainicorn: hm, yeah, I was suspecting some buffer issue. But input and output which are IO objects are invoked in block context and hence closed?
[15:00:03] maasha: Oh, but not without EOF.
[15:00:06] LadyRainicorn: No, the FIFO is still alive.
[15:00:15] maasha: So how can I do this?
[15:02:27] LadyRainicorn: system("cat blah.txt | wc -l")
[15:02:44] LadyRainicorn: (This is why you never interpolate with system.
[15:03:18] gijsje: k i'm totally confused about ruby, why is: (if hash.keys.first == "string") not true?
[15:03:25] LadyRainicorn: Or IO.pipe with your solution.
[15:03:46] LadyRainicorn: That's not valid syntax?
[15:03:47] tobiasvl: gijsje: well, what is the first key of your hash?
[15:04:02] gijsje: so my first key is "name" and i want to compare it to "name"
[15:04:11] gijsje: i tried chomp etc
[15:04:29] gijsje: key.class says String
[15:04:42] MrZYX: >> {"foo": "bar"}.keys.first == "foo"
[15:04:42] eval-in: MrZYX => /tmp/execpad-40e7b539526f/source-40e7b539526f:2: syntax error, unexpected ':', expecting => ... (https://eval.in/88945)
[15:04:56] MrZYX: >> {"foo" => "bar"}.keys.first == "foo"
[15:04:56] eval-in: MrZYX => true (https://eval.in/88946)
[15:05:18] LadyRainicorn: maasha: http://stackoverflow.com/questions/11898528/marshal-ruby-pipes-sending-serialized-object-to-child-processes/13258047#13258047
[15:05:44] gijsje: MrZYX, i'm using CSV.foreach(file.path, col_sep: ';', headers: true) do |row|
[15:05:57] gijsje: in where row.to_hash has the key
[15:06:04] gijsje: and that doesn't match
[15:06:16] MrZYX: print it using p (not puts or print)
[15:06:30] MrZYX: p row.to_hash.keys.first
[15:06:54] gijsje: lemme try it
[15:07:00] gijsje: don't see how its different tho
[15:07:13] MrZYX: copy paste the output
[15:07:23] apeiros: gijsje: possible reasons: a) your hash.keys.first is not "string", b) it is "string" but in a different encoding, c) it is something which just has the same inspect
[15:07:34] apeiros: I suspect b) without further information.
[15:07:43] maasha: LadyRainicorn: so the commands in the Pipe class here are place holders for something more advanced that needs to be coded, so I am particularly interested in a way of piping commands which is easy to fork.
[15:08:15] LadyRainicorn: What do you need to code?
[15:08:44] gijsje: row.to_hash.keys.first says name, if row.to_hash.keys.first == "name" is false
[15:08:48] LadyRainicorn: Ask the question you need answered rather than the one you think you need.
[15:09:17] gijsje: how do i drop encoding?
[15:09:31] apeiros: you don't *drop* encoding
[15:09:45] apeiros: encoding is an integral part of a string.
[15:10:06] gijsje: i mean in the compare
[15:10:14] apeiros: you can inform ruby about what encoding your string actually has, and you can transcode a string into another encoding.
[15:10:39] apeiros: again, you don't. you can't compare two strings in different encodings. so what you do is make sure they're in the same encoding before comparing.
[15:11:01] gijsje: ok, how do i check the current encoding, i know the file is utf8
[15:12:06] apeiros: str.encoding
[15:13:20] gijsje: hmm both say utf-8
[15:13:33] gijsje: the key and the string
[15:14:04] apeiros: then the remaining possibilities are a) you do something wrong (can't tell without code and data) or b) you have unprintables and did't check the inspects
[15:14:36] gijsje: i'm gonna pastebin
[15:14:51] apeiros: please use something that is not ad-ridden like pastebin.com
[15:15:01] apeiros: gist.github.com eg.
[15:15:48] gijsje: http://pastebin.com/a0T4EayU
[15:16:23] gijsje: https://gist.github.com/anonymous/fe21d529e3f38cceef87
[15:16:43] apeiros: add `logger.debug row.to_hash.keys.first.inspect`
[15:16:47] apeiros: and the output
[15:17:07] apeiros: you can publish multiple files in the same gist
[15:19:41] fbernier: I've got lots of .yml files to which I want to add a namespace node... I'd look through them all, add it, but then how do I indent the rest of the file?
[15:20:14] gijsje: https://gist.github.com/anonymous/15d4e6c9015bdf3d4e06
[15:20:15] apeiros: fbernier: that's really a $EDITOR question
[15:20:30] fbernier: yeah probably
[15:20:51] Takumo: Hi all, can anyone help me with this issue I'm having with WebMock? https://gist.github.com/LeoAdamek/8419967
[15:21:06] Takumo: my request is being made with HTTP Authentication...
[15:21:37] Takumo: and I've told WebMock to expect authentication
[15:22:03] gijsje: i really think its magical why it isnt working
[15:22:06] gijsje: such a simple thing
[15:23:06] momomomomo: gijsje: What's your issue?
[15:23:45] gijsje: that if statement never shows
[15:23:53] gijsje: the hallo never shows
[15:24:23] apeiros: gijsje: ok, something is off. if the shown output is correct, it should be ==
[15:25:57] gijsje: so it suppose to work?
[15:26:20] gijsje: i feel so stupid
[15:26:39] apeiros: but I have no further idea how to remote-debug that
[15:28:26] gijsje: logger.debug row.to_hash.keys.first <=> "name" says 1
[15:28:45] Takumo: oh I found the issue, my spec didn't expect it with the auth... but now its failing on posting JSON
[15:29:47] apeiros: gijsje: what does .length say?
[15:29:58] apeiros: (though, .inspect should show unprintables)
[15:32:04] gijsje: what the banana's
[15:32:06] gijsje: logger.debug row.to_hash.keys.first.length = 5 logger.debug "name".length = 4
[15:33:40] apeiros: sounds familiar
[15:33:54] apeiros: what's keys.first[0].ord?
[15:34:09] Fractional: Looking for mentor or programming partner in the Ruby language! :)
[15:34:54] Hanmac: ACTION thinks there is a "\n" inside the keys ... 
[15:35:03] gijsje: chomp is the same
[15:36:32] apeiros: that's a BOM
[15:36:43] ahri_: hi, is there any way to determine the call chain resulting in the current running instance of ruby? ideally i'd like to find out the names of the binaries -- this is on windows
[15:36:48] apeiros: while utf-8 doesn't need one, it can have one
[15:37:37] apeiros: gijsje: use CSV.foreach(file.path, col_sep: ';', headers: true, encoding: "bom|utf-8") do |row|
[15:37:47] apeiros: annoying that .inspect doesn't print that one
[15:38:33] gijsje: pff amazing
[15:38:40] gijsje: what is bom?
[15:40:04] apeiros: google :-p
[15:40:07] apeiros: byte order mark
[15:41:06] gijsje: apeiros let me thank you with this gif http://i1276.photobucket.com/albums/y462/staffpicks/Animated_GIFs/2qdy5o0.gif
[15:41:33] gijsje: sorry for not googling i was a bit frustrated
[15:44:16] bline79: I want to create an 8 character string. The first 3-4 characters are predefined, but then I want to have the remaining 4-5 characters be the randomized numbers
[15:46:28] apeiros: bline79: will you also ask a question?
[15:46:52] bline79: good point, just one moment. :p
[15:48:31] Fractional: Looking for mentor or programming partner in the Ruby language! :)
[15:51:04] bline79: so, I have a variable assigned to the prefix. That prefix will be 3-4 characters. What function should I use to create the remaining 4-5 characters as numberic digits randomly?
[15:52:16] workmad3: bline79: rand(10 * digits_remaining).to_s ?
[15:52:38] workmad3: bline79: oh, and some string padding
[15:53:42] apeiros: workmad3: you meant **, right?
[15:53:49] workmad3: apeiros: yes
[15:54:03] workmad3: apeiros: deliberate mistake for the reader...
[15:55:20] apeiros: bline79: btw., number and numeric, there's no numberic ;-)
[15:57:11] bline79: typo with the b
[15:57:19] bline79: still getting coffee in me here
[15:57:20] soahccc: Damn one index in the database any my import script is fast again :S
[15:58:00] Fractional: Is this a good way to calculate the median?
[15:58:01] Fractional: https://gist.github.com/Freddan962/89e4243f5214fbc5dff4
[15:58:25] workmad3: Fractional: no
[15:58:30] wald0: why is @@var so broken by default? i mean, seems like to be an improtant bug in ruby: http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
[15:58:33] Fractional: workmad3: Why not? D:
[15:58:50] workmad3: Fractional: think integer division and then tell me ;)
[15:59:18] workmad3: Fractional: also think in terms of precedence
[15:59:45] apeiros: Fractional: I assume `self` is a sorted array?
[16:00:08] Fractional: data = [6,2,4,5,7,1,9,7,9]
[16:00:09] Fractional: puts data.median #=> 7
[16:00:37] workmad3: Fractional: right... now try with an array with an even number of elements
[16:00:51] apeiros: Fractional: which would be wrong???
[16:01:06] Fractional: Oh, thanks :P
[16:01:20] Fractional: Weird, I thought I got the right answer before.
[16:01:29] workmad3: Fractional: and yeas, as apeiros says, that is not the right answer with that data set
[16:01:40] workmad3: Fractional: the median is only the middle value on *sorted* data sets
[16:02:24] workmad3: Fractional: what you have there is basically meaningless in statistical terms ;)
[16:02:39] workmad3: wald0: it's not 'broken'
[16:02:42] apeiros: workmad3: oh, no, it's a semi-random number :D
[16:02:50] workmad3: wald0: it's just not the same as a class-instance variable
[16:03:42] workmad3: wald0: the issue really is that the default behaviour is a bit surprising and not as useful as the slightly harder to use class-instance variable stuff
[16:03:51] workmad3: wald0: not that it's broken :)
[16:05:07] workmad3: apeiros: I think you'd have a bit of trouble getting a single value past a statistician as a 'sample' ;)
[16:05:31] moshef: Hi. I have a mixing module (A) that is included in B. I want to make some of the methods in module B private, how do I do that?
[16:05:42] moshef: simply adding private doesn't do much
[16:06:03] apeiros: workmad3: reminds me of a comedy show??? "we did a survey about the upcoming elections, we asked one person, who voted for party X. we extrapolated from there and predict, that the whole Bundestag will be occupied by party X."
[16:06:07] moshef: the second solution here http://stackoverflow.com/questions/318850/private-module-methods-in-ruby works, i was wondering if there is another way which isn't as ugly.
[16:06:47] bline79: https://gist.github.com/bline79/8420749 it doesn't appear to guarantee that the length is 8 digits
[16:07:01] bline79: I ran it a bunch of times and once it was 7 digits
[16:07:12] workmad3: bline79: I did say you might need to padd :P
[16:07:41] apeiros: bline79: didn't you say 4-5? :D
[16:08:01] bline79: 4-5 randoms because the prefix can vary
[16:08:06] bline79: between 3-4
[16:08:11] workmad3: bline79: e.g. with hostname.rjust(8-prefix.length, "0")
[16:08:14] apeiros: moshef: `private` marks instance methods as private
[16:08:28] apeiros: moshef: so assuming you define class methods like the poster in that SO thread, of course it won't work
[16:08:41] moshef: I'm not defining class methods, I don't have a deal
[16:08:52] moshef: i have 2 modules
[16:08:52] workmad3: bline79: btw, there's also no guarantees at all about uniqueness here
[16:09:00] apeiros: moshef: then show your code?
[16:09:23] bline79: that's okay. We won't have more then a dozen or two hostnames with any particular prefix
[16:09:29] apeiros: moshef: yeah, "I have 2 modules" is not equivalent to "I don't have class methods". modules can have class methods. they're those you define with def self.foo
[16:09:41] bline79: changes of conflict are pretty small i think
[16:09:55] bline79: yes :( sorry
[16:10:29] workmad3: bline79: 2.5% if the random generator was *truly* random
[16:10:30] Fractional: self[(self.size / 2)].to_f #=> 4 self[(self.size-1 / 2)].to_f #=> 0 when it should return 2
[16:10:31] workmad3: bline79: but it's not
[16:10:36] Fractional: On the array data = [6,2,4,6]
[16:10:38] Fractional: What looks wrong?
[16:10:49] workmad3: Fractional: precedence
[16:11:10] workmad3: Fractional: which is *not* managed with whitespace ;)
[16:11:48] Fractional: workmad3: Thanks, solved it! :D
[16:11:56] Fractional: Really appreciate you all helping me! :)
[16:12:26] workmad3: Fractional: btw, I'd probably suggest you calculate the middle with '(ary.size * 0.5).to_i
[16:12:45] workmad3: Fractional: rather than checking the array size and doing an if off it
[16:13:13] Fractional: Sorry, I do not quite think I understand what you mean
[16:13:24] moshef: apeiros: https://gist.github.com/bigimot/cbe13cf0fbf629f0e42d
[16:13:29] Fractional: https://gist.github.com/Freddan962/89e4243f5214fbc5dff4
[16:13:44] workmad3: Fractional: oh, make that '(ary.size.succ * 0.5).to_i
[16:13:53] apeiros: moshef: and your problem there is what? that you can call show_name there?
[16:14:08] moshef: i want it to be called only by other methods within that module
[16:14:10] apeiros: moshef: um, I think you haven't understood what private does
[16:14:27] apeiros: private means you can't call a method from *outside* the current object
[16:14:36] workmad3: Fractional: I'm suggesting that you could replace your entire method body with 'self[(size.succ * 0.5).to_i]'
[16:14:37] apeiros: i.e., if you do obj.show_name
[16:14:40] moshef: and here I'm inside
[16:14:41] moshef: yeah yeah
[16:14:48] moshef: what should i do then ?
[16:15:22] apeiros: separate your stuff
[16:15:28] Fractional: workmad3: Ok, is there any specific reason for it? Does it look better? =P
[16:16:04] workmad3: Fractional: it's got less complexity to it
[16:16:25] Fractional: I can't find .succ in the array class.
[16:16:36] apeiros: I don't think Array has one
[16:16:43] workmad3: Fractional: that's because size doesn't give you an array
[16:16:58] eval-in: workmad3 => 2 (https://eval.in/88966)
[16:17:01] eval-in: workmad3 => 3 (https://eval.in/88967)
[16:17:33] workmad3: Fractional: if you wanted, you could do self[((size + 1) * 0.5).to_i]
[16:17:44] workmad3: Fractional: but that introduces another layer of braces
[16:17:48] shevy: Fractional you could get .succ-like behaviour on an array by applying .each on it, then call .next. array = %w( a b c d ); _ = array.each; _.next; _.next
[16:17:51] apeiros: workmad3: bah, size>>1
[16:18:19] workmad3: apeiros: size.succ >> 1
[16:18:33] eval-in: workmad3 => 12 (https://eval.in/88968)
[16:18:37] workmad3: apeiros: because that should be 13
[16:18:54] apeiros: ah, sure, zero based counting
[16:19:10] workmad3: oh... good point...
[16:19:32] workmad3: size >> 1 is correct
[16:19:48] workmad3: Fractional: there you go - 'def median; self[size >> 1]; end' ;)
[16:20:07] apeiros: or /2 if you prefer :)
[16:20:17] apeiros: I'll just pretend that I didn't completely mess up my rationale
[16:20:30] apeiros: ACTION looks clever now
[16:21:18] workmad3: apeiros: although looking again, I now see what Fractional is doing in his median example... the definition of the median on an array with an even number of items is the middle two items divided by 2
[16:21:42] workmad3: although it does need to be sorted for that result to make sense
[16:21:52] workmad3: apeiros: only of the middle two items
[16:21:57] apeiros: I mean, average of the two median values?
[16:22:21] workmad3: item '13.5' if you will :)
[16:22:27] workmad3: of a 26 item list
[16:22:41] apeiros: size.even? ? self[size/2].quo(self[size/2+1]) : self[size/2]
[16:22:52] apeiros: or fdiv, if you want a float in every case
[16:23:02] apeiros: interpolation
[16:23:07] Fractional: Oh, why wasn't I using .even? haha
[16:23:35] workmad3: apeiros: that's not quite right
[16:24:01] workmad3: apeiros: it would be '(self[size/2] + self[size/2 + 1]).quo(2)'
[16:25:03] shevy: you two are like those two old men in the muppet show
[16:25:09] workmad3: ACTION wonders about overloading [] on an array to give a concept to ary[1.5] :)
[16:25:22] apeiros: workmad3: somebody did that and pasted it on rubyflow
[16:25:48] workmad3: apeiros: linear interpolation between the two values?
[16:25:51] apeiros: the idea is actually nice for things where you need interpolations
[16:26:00] apeiros: I'd not use Array for that, but a separate class
[16:26:00] ddd: shevy what you know about some Muppets.. Beaker!
[16:26:11] apeiros: allowing to provide an inter- and extrapolation strategy
[16:26:21] Hanmac: apeiros: did you read about W3C & DRM & HTML5 => http://lists.w3.org/Archives/Public/public-restrictedmedia/2014Jan/0060.html ?
[16:26:24] workmad3: apeiros: yeah, that would be more sensible
[16:26:26] apeiros: workmad3: I think the one I saw used linear interpolation, yes
[16:26:44] apeiros: Hanmac: only superficially
[16:27:35] workmad3: apeiros: so something like 'self[float.floor] + (float - float.floor) * self[float.ceil]' ?
[16:28:24] apeiros: I think that's incorrect
[16:29:10] apeiros: self[floor]+(index-floor)*(self[ceil]-self[floor])
[16:29:27] workmad3: apeiros: ah yes
[16:29:28] Fractional: I just finnished all my programming assignments, woho! :)
[16:29:41] workmad3: apeiros: forgot the last difference
[16:29:49] apeiros: doesn't cover extrapolations, though
[16:30:11] apeiros: PolatedGraph? :)
[16:30:46] workmad3: apeiros: how about spherical interpolation on a 3-Sphere? :)
[16:31:06] apeiros: blergh. not been to uni for a decade. I don't even remember what that is.
[16:31:08] Fractional: Anyone here who can give me some array-algorithm based problems to solve?
[16:31:14] Fractional: For a beginner.
[16:31:17] apeiros: I thought about automatic polynomial interpolation
[16:31:24] workmad3: apeiros: a 3-sphere is a sphere in 4d space
[16:31:27] apeiros: but I have not the faintest idea anymore how to do that
[16:31:37] apeiros: workmad3: ah, the equivalent of a hypercube?
[16:31:40] workmad3: apeiros: yeah
[16:32:10] workmad3: apeiros: you could call it a 4d hypersphere too, but 3-sphere works (because it's a sphere where you need 3 co-ordinates to specify a point on the surface)
[16:32:11] sweeper: yay hyperspace :v
[16:33:20] alex88: hi guys, I'm using https://github.com/gmarik/rack-try_static to serve a static website, is possible to make it respond also to POST as with GET?
[16:33:24] workmad3: apeiros: and the only reason I know much about it is because that's what you do with quaternions to do smooth interpolations for rotations :)
[16:33:25] LadyRainicorn: ACTION lives in an infinite-dimensional world.
[16:34:36] workmad3: LadyRainicorn: if you're counting 'the world' as a phase space of particle configurations and assume that the universe is infinite in extent then yes, arguably you do ;)
[16:35:58] LadyRainicorn: No silly, an infinite number of spacial dimensions!
[16:37:55] workmad3: LadyRainicorn: iirc, the dimensions in such a phase space are space-like
[16:42:54] LadyRainicorn: Yes, but they're not physical spatial dimensions.
[16:46:10] Fractional: apeiros: Mind if I ask how I "use" a regex on a string? Like you did earlier on when I needed help
[16:46:31] apeiros: Fractional: depends on what you understand as "use"
[16:46:44] apeiros: "string" =~ /regex/ # test whether a string matches a regex
[16:47:01] wald0: workmad3: so it is not going to be "fixed" (improved) in the future versions of ruby?
[16:47:07] Fractional: I want to exclude everything that doesn't match my regex and pass a command to it on one line.
[16:47:09] wald0: i want to use @@objects_created :)
[16:47:28] wald0: well, @@sides :)
[16:47:48] apeiros: Fractional: I don't understand that
[16:48:13] Fractional: string/regex/.each do |obj| end
[16:48:43] DaniG2k: ive been thinking of writing a program lately :\
[16:48:48] DaniG2k: but totally not sure what
[16:48:53] DaniG2k: actually I have no idea
[16:48:58] DaniG2k: just an itch to program
[16:49:03] DaniG2k: any suggestions?
[16:49:10] DaniG2k: something not tooooo hard
[16:49:32] apeiros: Fractional: do you have an example? with input and desired output?
[16:49:43] workmad3: wald0: the behaviour of class variables is well specified and sometimes useful
[16:49:47] workmad3: wald0: there's nothing to be 'fixed'
[16:50:39] workmad3: wald0: it sounds like you want a class instance variable but don't like that you need jump through a couple of hoops for it ;)
[16:51:13] Fractional: string/\h{2]/.each do |obj| array << obj end
[16:52:45] wald0: workmad3: well defined? not in the book that i readed about :) is was thanks to a friend which reviewed my tutorial which says "do not use @@ its b0rk3d!"
[16:53:19] wald0: workmad3: well, ruby was made for make the life of the developer easier so your statement is against ruby lol :) j/k
[16:53:46] workmad3: wald0: class instance variables work exactly the same as any other instance variable
[16:54:01] workmad3: wald0: to do otherwise would be a greater violation of the principle of least surprise
[16:54:24] workmad3: wald0: you could argue that @@ class vars (which are not class instance variables) could probably be removed
[16:54:54] workmad3: wald0: but not easily that they should act as another way to access an instance variable that happens to be on the class
[16:55:04] wald0: no, i dont mean removed, i meant the problematic of their inheritance modifications, like shown on that link
[16:55:11] wald0: bad side-effect
[16:55:29] workmad3: wald0: you mean the very thing thang makes them not just a class instance variable?
[16:55:34] apeiros: Fractional: that's not really an example, also it lacks in-/output
[16:55:42] workmad3: wald0: and the *well-known* way that they behave?
[16:55:52] apeiros: I need something concrete
[16:56:10] shevy: apeiros a HAMMER!
[16:56:11] Fractional: apeiros: Someone here helped me with it this morning but the code is on my laptop.
[16:56:13] kraljev1: Hello guys, is it possible to use PRY or other REPL engine
[16:56:22] kraljev1: to pass the typed thing as a string
[16:56:26] apeiros: Fractional: well, I'm afraid, I'm not your laptop
[16:56:27] kraljev1: to a custom function
[16:56:33] wald0: workmad3: not sure, i just discovered this "problem" told by a friend to not use @@ because this bug and im asking here :)
[16:56:35] shevy: you want another language than ruby?
[16:56:51] shevy: foo('bla') there is a string passed
[16:56:53] workmad3: wald0: your friend mis-informed you that it's a bug
[16:57:06] shevy: wald0 @@stink
[16:57:11] wald0: well, its an unwanted side-effect
[16:57:28] shevy: the use of @@ is a whole unwanted side effect
[16:57:30] kraljev1: So, if I write SELECT * FROM x
[16:57:38] workmad3: wald0: in the cases where @@cvars are suitable, it's not an unwanted side-effect
[16:57:39] kraljev1: then it gets passed to a function as a while
[16:57:42] workmad3: wald0: just those cases are limited
[16:57:47] workmad3: wald0: and your case is not one of them
[16:58:00] wald0: shevy: maybe, im just asking here about the unwanted bug behaviour asking if ruby would fix that in the future (removing inheritance access/modification) like:
[16:58:02] apeiros: workmad3: so limited that I haven't come across it in the last 10 years :)
[16:58:18] kraljev1: in other words, is it possible for pry not to eval the input?
[16:58:18] wald0: http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
[16:58:42] workmad3: wald0: if you don't want the single copy across the inheritance tree, use a class instance variable
[16:58:45] workmad3: apeiros: :)
[16:59:02] workmad3: wald0: it's *not* a bug though
[16:59:52] wald0: workmad3: where i can read / how to use an "class instance variable" ?
[17:01:05] workmad3: wald0: well, you know how to use an instance variable, right?
[17:01:07] godd2: I made my first real gem! Check it out if you like: https://github.com/nicklink483/riffy
[17:01:13] godd2: It's a RIFF file parser.
[17:01:23] workmad3: wald0: it's exactly the same, but on a class
[17:01:32] workmad3: wald0: as classes are instances of Class themselves
[17:01:56] godd2: Any feedback (positive ot negative) is welcome :)
[17:03:33] wald0: mmh, just use @var ? what is the difference with @@var then ? im a bit confused now
[17:03:50] DaniG2k: godd2: well done Dominic
[17:04:07] workmad3: wald0: @@var creates a class variable
[17:04:22] workmad3: wald0: which is shared across the entire inheritance tree below the point it is first defined
[17:04:30] workmad3: wald0: @var creates an instance variable
[17:04:52] workmad3: wald0: if you do it at the class level, it creates an instance variable on the class
[17:05:00] workmad3: wald0: which is not shared across the inheritance tree
[17:06:22] godd2: DaniG2k: Thank you :)
[17:06:34] workmad3: wald0: e.g. 'class Foo; def self.class_ivar; @class_ivar; end; def self.class_ivar=(new_value); @class_ivar = new_value; end; end'
[17:07:20] Hanmac: workmad3: or use attr_accessor inside a class << self ;P
[17:07:32] workmad3: Hanmac: yeah, I was spelling it out ;)
[17:16:01] CorySimmons: Does anyone know off the top of their head if RMagick is a fully featured port of ImageMagick?
[17:16:39] workmad3: CorySimmons: no, it's not a port at all
[17:16:47] workmad3: CorySimmons: it's an interface to imagemagick
[17:17:43] itadder: why aftter few days ruby community seems rather nice
[17:17:58] itadder: but having time to learn is hard, I came from work and ate food and fell asleep
[17:18:30] itadder: the basic are okay, but then learning about loops and other stuff getiting comple
[17:18:48] wald0: itadder: are you a procrastinator master? :)
[17:19:00] itadder: how did you know
[17:19:15] wald0: im a bit too, i recognize those words lol
[17:19:17] itadder: and if I do not get enough sleep I do nto function well the next day
[17:19:24] wald0: "no time", procrastinators NEVER found time
[17:19:27] itadder: I almost did not make to the gym this morning
[17:19:28] wald0: by any reason :)
[17:19:49] itadder: wald0: but I am liking ruby.. I wish I met a girl who liked ruby and we could work on learning it togther or she could teacah me
[17:20:00] itadder: I join a ruby nyc meetup group for nebies to ruby
[17:20:17] itadder: https://github.com/UnearthRuby
[17:20:18] DaniG2k: itadder good luck
[17:20:21] wald0: my last conclusion is that there's no any valid "technique" or tool or anything that can solve the procrastination problem, the only way is "when you ignore the tools for help you and you just do it, no-matter-what"
[17:20:32] kraljev1: Looking for something like pry, except that it would not eval
[17:20:42] kraljev1: but rather give me a raw string
[17:20:43] itadder: yea I guess so
[17:20:52] itadder: how do I sneak time at work on my windows box to do ruby
[17:20:56] itadder: with out getting in trouble
[17:21:00] wald0: so basically, forget tools, forget all, do only what you want to do IF you want to do it, otherwise, do another thing lol
[17:21:18] itadder: yea I want to acutally learn becuase I find it very usefull and fun
[17:21:20] wald0: when you really want, youll simply do it, you will found time "magically" lol
[17:21:29] itadder: but when it gets complex I feel like giving up
[17:21:36] itadder: okay will take those words
[17:22:00] wald0: ACTION reading up
[17:22:37] wald0: as a suggestion, if you want to work "out of trouble" in a windows box... well, first remove windows, its totally useless to "try" to work on it, you will just lose your time
[17:22:48] CorySimmons: workmad3: Hi again. :) So if I put RMagick in my Rails app on Heroku, I'd need to also put ImageMagick on Heroku?
[17:22:51] itadder: I see this http://www.meetup.com/unearthruby/events/16283603/?a=wm1.i_7&rv=wm1.i
[17:22:53] wald0: itadder: ^
[17:23:02] itadder: I dislike windows
[17:23:08] itadder: I love my macintosh so much more usefull
[17:23:14] itadder: it even comes with ruby preisntalled
[17:23:43] workmad3: CorySimmons: yes
[17:23:59] workmad3: CorySimmons: which, if it's not there by default, involves finding or making a heroku buildpack with it
[17:24:28] itadder: wald0: thanks
[17:24:52] kraljev1: So, anything like pry, except not evaling what user typed in???
[17:24:57] kraljev1: Noting in the whole ruby wold?
[17:25:49] Mon_Ouie: What do you mean by that?
[17:26:12] kraljev1: You know pry?
[17:26:25] kraljev1: but it evals what user types in
[17:26:35] kraljev1: i'd like to get that raw string
[17:26:40] kraljev1: so i could do:
[17:26:46] kraljev1: SELECT * FROM something
[17:26:52] kraljev1: even if that is not valid ruby code
[17:27:01] kraljev1: basically looking for an interactive console
[17:27:14] Mon_Ouie: loop { line = Readline.readline(">> "); puts run_command(line) }
[17:27:20] catphish: can anyone point me in the direction of a multithreaded websocket server?
[17:27:22] kraljev1: that's too simple
[17:27:29] kraljev1: you can't use arrows
[17:27:44] Mon_Ouie: Sure you can, using the second argument to Readline.readline
[17:27:49] kraljev1: up arrow to repeat previous command, left and right to edit typed text
[17:27:59] Mon_Ouie: And left and right work as-is
[17:28:12] Mon_Ouie: loop { line = Readline.readline(">> ", true); puts run_command(line) }
[17:28:38] CorySimmons: workmad3: As always, thanks
[17:28:54] kraljev1: hey, thanks
[17:28:58] kraljev1: this seems more like it
[17:32:09] Fractional: What do you use Ruby for?
[17:32:25] catphish: found one: https://github.com/gimite/web-socket-ruby
[17:35:31] Eiam: Fractional: I use Ruby to solve problems
[17:35:47] Eiam: last week I wanted to know how long the average keystroke was while I typed
[17:36:10] Eiam: so I used ruby. The week before I wanted to parse some 70mb file that was an organization structure for a shitton of employees... off to ruby
[17:36:17] kate_r: for a RESTful API, would it be better to opt for nginx or apache?
[17:36:33] Eiam: kate_r: I imagine most people here are going to suggest nginx
[17:36:43] kate_r: Eiam, hmm why's that though?
[17:37:22] LadyRainicorn: Apache is not so good.
[17:37:32] havenwood: kate_r: I prefer to configure Nginx.
[17:38:26] havenwood: Or write the whole API in Nginx!: http://c7.se/tiny-api-with-nginx/
[17:38:34] havenwood: j/k, but pretty neat you can...
[17:39:20] Fractional: I want to learn more Ruby but I am not sure what to do/learn =<
[17:39:37] havenwood: Fractional: Read some Ruby code for inspiration maybe?
[17:40:09] Fractional: havenwood: But what code? I'm a beginner. Perhaps I should start doing some basic 2D games? Yes.
[17:40:15] Fractional: Then I could make a clone of some classics.
[17:40:19] Fractional: That would be fun to do.
[17:40:37] workmad3: Fractional: start with zork ;)
[17:40:59] jane_doe: Fractional: Have you tried codecademy or something similar?
[17:41:12] havenwood: Fractional: Maybe try some text based games, tic-tac-toe, checkers, chess, a card game.
[17:41:29] Fractional: jane_doe: For math & physics
[17:41:35] havenwood: Fractional: If you know or want to learn a bit of math, going through Project Euler problems is good practice.
[17:41:40] jane_doe: codecademy's python curriculum teachs you how to write a battleship game.
[17:41:41] Fractional: havenwood: Already done tic-tac-toe, checkers and a card game in text.
[17:41:46] havenwood: Fractional: excellent!
[17:42:36] Fractional: Havenwood: But there are plenty of card games! What is a quite easy one to write?
[17:43:50] havenwood: Fractional: Blackjack maybe?
[17:44:06] havenwood: with an auto-dealer
[17:44:44] havenwood: and for a bit extra, expose the command line game to the web with a little Sinatra app :O
[17:44:50] itadder: wald0: are you on twitter
[17:44:59] itadder: who should I follow in the ruby community on twitter
[17:45:31] itadder: what is the IOS ruby app that you people liek to use
[17:45:40] wald0: itadder: i removed my twitter and facebook accounts because they are useless in my life and a hole of distractions, very bad for procrastinator ppl like me :)
[17:45:56] itadder: ahh same here good point
[17:46:08] wald0: in fact i lost the entire conctact with my family and friends removing facebook, but i dont give a shit, i want time -for me-
[17:46:16] itadder: maybe thier a IOS ruby app for the iphone so when I am in line wating for something I can write code
[17:46:35] itadder: wald0: oh wow, I can't leave FB my family will nto be happy
[17:46:39] itadder: and call me antisocial
[17:46:54] CorySimmons: What is a memory leak? I keep looking at using RMagick but there's a lot of mentions of it being terrible at memory leaks
[17:46:57] itadder: it would be cool to test out and learn ruby while I wait for stuff
[17:47:06] wald0: itadder: oh btw, this is the BEST article that i have found about this topic, after long researches in the past: http://blog.iqmatrix.com/overcome-procrastination
[17:47:50] wald0: itadder: for iphone, the best is to have a pdf reader and put some books on it :), i even hilighted my books on it and so i have my own summaries for future checks
[17:48:03] havenwood: itadder: here are some just looking down my twitter feed: @rubygems @rubyrogues @postmodern_mod3 @bascule @steveklabnik @avdi @tenderlove @drbrain
[17:48:45] havenwood: itadder: i tweet like twice annually, and one is probably retweet, so following me would be *super* exciting
[17:49:01] CorySimmons: Also just out of curiosity, what are your favorite image manipulation libraries in Ruby?
[17:49:11] havenwood: @rubygems will flood you, but fun to watch every newly cut gem go by
[17:50:48] ddd: i won't follow steveklabnic but the rest we match on
[17:50:56] havenwood: CorySimmons: I don't have a lot of experience in the area, but MiniMagick has treated me right: https://github.com/minimagick/minimagick#readme
[17:55:28] CorySimmons: havenwood: Yeah that's what I was looking at
[18:01:43] Eiam: kate_r: because its pretty easy to configure and has lots of tooling around it I suppose
[18:05:13] Hanmac: shevy: https://i.chzbgr.com/maxW500/7994720256/h0CB0A3D2/
[18:27:08] jonbradley: : am i wrong in thinking i can do something like @object[0]."#{i}_amount" in ruby?
[18:28:21] Hanmac: jonbradley: yes you can, look at #send method
[18:29:01] jonbradley: thanks reading on send now
[18:29:15] Sc0rp10n: a quick question
[18:29:29] Sc0rp10n: I created my first gem yesterday and pushed it to ruby gems
[18:30:02] Sc0rp10n: but today I saw it already had 33 downloads. Can anyone tell me who's downloading it? I mean how do people know about my gem?
[18:30:15] apeiros: Sc0rp10n: mirrors probably
[18:30:33] Sc0rp10n: is there a list of latest gems or something?
[18:31:11] Sc0rp10n: hey apeiros , can you tell me the mirror sites for ruby gems?
[18:33:17] shevy: Sc0rp10n bot downloads
[18:36:00] apeiros: Sc0rp10n: no, I can't
[18:42:44] zahna: is there a way to have Socket.getaddrinfo() bypass nscd?
[18:47:18] Sc0rp10n: alright, thanks guys
[18:48:14] zahna: i'm seeing that libc allows __nss_not_use_nscd_hosts to be set to allow getaddrinfo() to not use nscd and was just wondering if there's a way to access that from the ruby Socket.getaddrinfo method
[18:49:24] zahna: i'm just not seeing it in the documentation i'm reading
[18:58:40] CorySimmons: Hey guys, I suck at syntax. I'm trying `MiniMagick::Image.format('pdf', 'svg')` and here is the doc on it: http://www.rubydoc.info/github/probablycorey/mini_magick/master/MiniMagick/Image#format-instance_method
[18:58:57] CorySimmons: Any idea what I'm doing wrong? I keep getting this err: "private method `format' called for MiniMagick::Image:Class"
[18:59:18] shevy: then you are not allowed to call it directly
[18:59:42] shevy: can you show the real code you use
[19:00:27] apeiros: CorySimmons: you're probably calling `format` on the wrong receiver.
[19:00:46] apeiros: there's a global `format` method (Kernel#format), which is private
[19:01:02] CorySimmons: shevy: Here's the code I'm using http://pastie.org/8633341
[19:01:14] CorySimmons: apeiros: How do I access/use it?
[19:01:54] apeiros: CorySimmons: I don't use MiniMagick. Read its docs.
[19:02:21] CorySimmons: I'm trying, hence the link
[19:02:32] apeiros: but you probably need an instance of MiniMagick.
[19:02:35] CorySimmons: The docs are sparse, so I'm trying to understand that syntax
[19:02:50] apeiros: I don't see by what magic it'd know what you expect from it by doing MiniMagick::format('pdf', 'svg')
[19:12:27] shevy: CorySimmons where is the file that you want to convert?
[19:13:13] shevy: CorySimmons look at the examples there https://github.com/minimagick/minimagick they are usually like so: MiniMagick::Image.open("input.jpg")
[19:13:18] shevy: then you apply processing on it
[19:19:28] leo-the-manic: In IRB, how can I look at the type of a variable? E.g. in Python I can do a = 'b'; type(a) and it will say 'str'
[19:20:17] drPoggs: leo-the-manic: pleasure :) i wish everyone else asked straightforward, easy questions :D
[19:20:22] LastWhisper: do any of you guys use webmock?
[19:27:45] CorySimmons: shevy: Thanks
[19:41:58] cek: how do you stub authlogic stuff?
[19:42:38] cek: need this https://gist.github.com/jschoolcraft/184518 implemented -- it dosn't work now.
[19:43:05] cek: produces error about usersession being not activemodel
[19:43:24] cek: oops, wrong channel probably
[19:50:08] CorySimmons: Anyone have any idea what I'm doing wrong? http://pastie.org/private/yikhywv41ejcjsoxfdacq
[19:50:18] CorySimmons: I'm trying to use MiniMagick to convert a .pdf to an .svg
[19:51:10] shevy: does 'identify -quiet -ping fooooo.svg' even work
[19:51:34] shevy: identify belongs to ImageMagick
[19:51:42] shevy: perhaps you do not have this binary
[19:56:12] shevy: I hate bugs
[20:00:03] godd2: CorySimmons: just shootin in the dark, but maybe it needs foooo.svg to exist beforehand?
[20:01:08] godd2: On line ~254 of lib/mini_magick.rb it says it runs the identify command to "Verify that we have a good image"
[20:01:29] godd2: presumably if the file doesn't exist yet, that can cause a problem?
[20:02:17] shevy: I think the whole MiniMagick project seems to be sloppy
[20:02:31] shevy: it should check before running any system-commands
[20:03:08] CorySimmons: shevy: I brew installed ImageMagick
[20:03:22] CorySimmons: godd2: I don't think so. It creates it.
[20:03:35] CorySimmons: shevy: Prefer RMagick?
[20:03:35] shevy: well it obviously did not create it :)
[20:03:44] CorySimmons: It creates it
[20:03:51] shevy: you have a .svg ?
[20:03:57] CorySimmons: It just creates a horrible version of it and it's 30MB!!!
[20:04:22] CorySimmons: 400kb.pdf to 30mb.svg horrible quality with black background
[20:04:56] shevy: that's some quality there
[20:05:15] shevy: why dont you file a bug report?
[20:06:57] Nilium: The questions I get about how to use my OpenGL bindings gem are always kind of weird..
[20:08:00] Nilium: Pretty sure everyone who's emailed me about it has never used C or C++ or OpenGL.
[20:08:13] godd2: CorySimmons: try this from the command line to see if imagemagick does the same thing: `convert illustrator_17.pdf fooooo.svg`
[20:09:06] Nilium: Which would be kind of normal for most Ruby people, I guess. I doubt a lot of them leave their cloistered Rails-holes.
[20:11:18] benlieb: Are the differences in procs and lambdas meant to solve specific common programming challenges?
[20:11:28] CorySimmons: godd2: Good idea
[20:11:53] benlieb: Because I thing of procs as "not strict" lambdas, as there is no argument enforcement.
[20:12:50] shevy: benlieb no idea, they seem artificial a separation but so is module vs. class distinction
[20:12:58] benlieb: Right now the differences are just something I've memorized, but have not really learned that one or the other is more or less useful, or more applicable to specific situations
[20:13:10] shevy: what do you mean with "learn"
[20:13:19] shevy: as far as I know the main difference is that one has mandatory arguments, the other has not
[20:13:38] benlieb: shevy: I mean I can almost always use either, I just have to make sure my implementation accounts for their behavior
[20:14:01] benlieb: which makes me feel that one or the other is kinda unnecessary
[20:14:15] godd2: benlieb: sometimes you want to "save" a return for "later", in which case, lambda is your friend. A Proc will faithfully have a return get called even if it's in the body of the block, but a lambda will keep it hidden away until you acually call it.
[20:14:51] Nilium: Consider the difference in behavior when using `return` in a proc vs. a lambda and you'll probably have an idea of what it solves (e.g., like a function vs. control structure)
[20:15:59] godd2: You can think of the binding of a lambda to be tighter than a proc. when a lambda is called, the code is more encapsulated from its environment than a proc
[20:16:28] benlieb: Nilium: godd2: right so proc is more like a block (like 'if'), and lambda is more like a function when return is concerned?
[20:16:43] benlieb: is that right?
[20:16:50] Nilium: You have those backwards
[20:17:00] Nilium: Wait.. no
[20:17:20] benlieb: don't confuse me! :)
[20:17:23] Nilium: You had it right. Nevermind, this cold is scrambling my brain.
[20:17:49] godd2: if you call a return in a proc, it will behave as if that return is at the scope of the function "outside" of it. but if you have a return in a lambda, it's walled off from it's surrounding scope
[20:18:09] godd2: so the return in the lambda won't interfere with the return in a function that it's embedded in
[20:18:10] benlieb: godd2: ok I get that
[20:18:42] benlieb: godd2: so a lambda is kind of like an anonymous function (kinda)
[20:18:56] godd2: a lambda is precisely an anonymous function
[20:19:29] godd2: and a proc is just a useful chunk of code floating around
[20:19:35] benlieb: and a proc is like a 'saved' block?
[20:20:23] benlieb: do they behave the same in terms of closure-"ness"?
[20:20:24] i_s: main diff between proc and lambda is that 'return' does different things
[20:20:50] i_s: proc will return from the outer scope, whereas return in lambda just returns from the lambda
[20:21:24] workmad3: benlieb: lambdas also throw argument errors if called with incorrect numbers of args
[20:21:49] workmad3: benlieb: but yes, they create the same kind of closure
[20:24:26] benlieb: when you pass a block to a method via 'do' is that a block, a proc, or a lambda?
[20:26:30] apeiros: benlieb: neither
[20:26:36] apeiros: benlieb: when you convert it, it's a proc
[20:27:00] godd2: "By passing a block to a method whose last parameter is pre???xed with an ampersand. That parameter will receive the block as a Proc object." - Programming Ruby
[20:27:46] benlieb: so if it's not 'converted' it's just a block that can be 'yielded' to...
[20:28:15] apeiros: benlieb: yes
[20:28:30] benlieb: is there a way to convert it to a lambda?
[20:28:43] apeiros: hm, could try lambda(&block)
[20:28:58] guilund: i have a 2 modules, with the same method_names, i require and include both, but how can i access the method in the specific module? i mean: Module1::method_name
[20:29:12] benlieb: apeiros: in the method params def?
[20:29:17] guilund: something like that
[20:29:24] apeiros: benlieb: no, in the method body
[20:29:45] workmad3: guilund: please don't cross-post after it was suggested in #rubyonrails that you do some research on OO design :P
[20:30:02] benlieb: wouldn't it just be lamda(block) at that point if you have &block in the params area?
[20:30:16] guilund: workmad: they told me to ask here, for christ sake :P
[20:30:29] apeiros: benlieb: hm, nope, seems lambda(&block) is a noop
[20:30:45] guilund: workmad3: and you are what? the polcie of ruby?
[20:30:51] guilund: ruby police
[20:31:10] workmad3: guilund: no, I leave that to apeiros who has ban-stick command and an intolerance for cross-posting ;)
[20:31:27] guilund: apeiros is ma brotha from anotha matha man
[20:31:32] guilund: he always help me
[20:31:50] benlieb: apeiros: so if at some point I want to get a lambda into a method, I would pass it as a regular param, and not rely no whatever the mechanism is that grabs the block started with "do" ?
[20:31:50] guilund: i need help
[20:32:17] guilund: apeiros: put that gun down man
[20:32:18] apeiros: guilund when you cross-post, inform the channels where you're cross-posting. that's the least.
[20:32:22] apeiros: -o apeiros
[20:32:26] apeiros: ACTION bang
[20:33:00] guilund: cross posting? i mean, you are independent entitys, different channels?
[20:33:04] guilund: i dont get it, but ok
[20:33:12] apeiros: http://www.replikultes.net/medias/uploads/films/the_mask/The_Mask19.jpg
[20:33:42] apeiros: I really really need a canned reply why cross-posting people usually are dicks.
[20:33:57] guilund: i can assure you i have a dick, but im not
[20:33:59] workmad3: guilund: there's a lot of people in both, and it's polite to let people know that you've asked in multiple places so that it isn't a slap in the face when someone cross-posting questions suddenly ups and vanishes because a different channel answered it
[20:34:01] guilund: now im offende
[20:34:19] guilund: i'll google for help
[20:35:24] guilund: workmad3: thaks for the explanation, but i didnt get an answer in one place, THEN i came here
[20:35:27] apeiros: guilund: 99% of all cross-posters abandon the question once answered. I for one don't want to waste my time on somebody doing that.
[20:35:43] guilund: apeiros: i get the logic
[20:35:53] guilund: apeiros: but it doesnt apply on my case :P
[20:36:01] apeiros: guilund: said every cross-poster ever.
[20:36:12] apeiros: yet in the last 10 years I've seen, I think, two cases
[20:36:20] Sawbones: "I'm a special snowflake"
[20:36:34] maasha: workmad3: that Pipe class ... I am trying something new in order to make it run on multiple cores.
[20:36:35] guilund: no, not because of that, the guys on rails told me to ask here
[20:37:07] maasha: workmad3: so I am using named pipes to share data between processes: https://gist.github.com/maasha/103ab16038030f6ca95d
[20:37:36] maasha: workmad3: seems flawed though. It works on small test data sets, but bigger files are hanging.
[20:37:39] guilund: you guys are stressed out today, holy mother :P
[20:39:17] apeiros: Sawbones: that quote sounds familiar, where's it from? :)
[20:39:23] guilund: where is the brogramming i'm used to over here?
[20:40:12] Sawbones: apeiros: Couldn't tell you, but my gf quotes it all the time to people who complain too much
[20:40:13] apeiros: workmad3: btw., I usually only kick for cross-posting (and that only because people proved not to listen/care if I just tell them)
[20:41:21] guilund: apeiros: sorry dude, i didnt know about this cross-posting, but now i'm aware
[20:42:04] guilund: can i ask again here? or it still will be considered cross posting
[20:42:13] shevy: you'll never know beforehand!
[20:42:48] apeiros: guilund: I told you the rule - just state that you're crossposting
[20:43:32] benlieb: guilund: you've apologized. just re-ask your question.
[20:44:00] lilly19: Do you know know a way to get all of the gem dependencies recursively, 'gem dependency [name] -R' is not what I saying, dependencies of a gem with all of it's dependences and so on..?
[20:44:30] guilund: i have two modules, they have the same method names, how can i call a method specifying the module? something like Module1.method_name Module2.method_name
[20:44:35] guilund: it makes any sense?
[20:45:06] benlieb: guilund do the modules rely on vars defined in the class?
[20:45:18] benlieb: in the class their included into?
[20:45:33] shevy: guilund several ways. a simple one is to add extend self in that module
[20:45:34] guilund: belieb: yes, i require and include both
[20:45:37] benlieb: *they're*
[20:46:07] shevy: module Foo; def hi; puts 'hi'; end; extend self; end; Foo.hi # "hi"
[20:46:22] guilund: shevy: nice
[20:46:29] guilund: shevy: thanks
[20:46:37] guilund: thanks guys, you are the best
[20:46:40] shevy: other ways would be to explicitely do def self.method_name
[20:46:59] shevy: if you won't need the "def hi"
[20:47:20] shevy: and the annoying class << self probably works, but it is so ugly, nobody likes it
[20:48:47] shevy: facebook is like the ultimate brotherhood
[20:48:50] shevy: "You must log in to continue."
[20:53:25] godd2: maasha: Jim Weirich talks about Celluloid::IO in this talk: http://www.youtube.com/watch?v=vIHdhaF2R2w
[20:54:10] godd2: Celluloid provides a framework for multi-threaded programming so you can send messages between processes easily
[20:56:19] Hanmac1: workmad3 https://i.chzbgr.com/maxW500/8002507776/hBB08BE0A/
[20:58:13] maasha: godd2: right, multi-threading is easy with ruby, but multi CPU is different
[20:58:41] godd2: If you want multi-core, you should be using Rubinius or JRuby
[21:00:12] godd2: Or just switch to Scala :P
[21:04:42] benlieb: on the block / proc / lambda theme again: is there a way for a passed block to interact with the internal environment of a method, or is it always separate? This behavior kind of surprised me: https://gist.github.com/pixelterra/8425653
[21:06:55] canton7: benlieb, I prefer to avoid the 'yield' syntax when explaining how blocks work: http://pastie.org/8633683
[21:07:20] canton7: so line 4 calls a method - why should that method be scoped to the test method?
[21:07:20] apeiros: benlieb: local variables you have to pass
[21:07:45] apeiros: benlieb: you can "rebind" a block to be executed in the context of self, using instance_eval or instance_exec
[21:07:50] canton7: *calls something like a method
[21:07:51] apeiros: that'll affect ivars and method calls
[21:09:52] Hanmac: you can use binding to get the local variables ... but it still does not work as you want
[21:09:53] godd2: benlieb: "Some people like to think of the association of a block with a method as a kind of argument passing. This works on one level, but it isn???t really the whole story. You may be better off thinking of the block and the method as coroutines, which transfer control back and forth between themselves." - Programming Ruby
[21:10:48] godd2: So in your example, you can think of the code "jumping back" to the point at which you wrote the block and looks around for the variables you wrote in it, and uses those local variables, not the ones in the method definition
[21:12:14] leo-the-manic: Can I replae File.open('foo') { | f | bar(f) } with something like File.open('foo') bar?
[21:14:28] godd2: leo-the-manic: What are you trying to do, run the method bar on every line of the file?
[21:15:50] leo-the-manic: godd2: I guess it's a poor example. One method generates a stream of bytes pre-split into chunks, and I want to write it to a Gzip file. So I have two nested do's and it just looks a little noisy
[21:16:56] IceyEC: File.open('foo').map(&:bar) might work leo-the-manic
[21:17:09] canton7: that calls f.bar, not bar(f)
[21:17:10] IceyEC: but you'd be calling the method bar on a string
[21:31:45] Fernandos: Is there a downside to using middleman?
[21:31:53] Fernandos: Talking abouthttp://middlemanapp.com/
[21:32:05] Fernandos: eh sorry http://middlemanapp.com/
[21:32:24] centrx: Fernandos, I don't know much about it, but downside compared to what?
[21:32:39] centrx: Fernandos, It says it is a static site generator, so the downside would be it does not do dynamic pages
[21:32:52] Fernandos: to using a cms be it a flatfile cms with a caching system or one with a db
[21:33:04] Fernandos: centrx: it does dynamic pages..
[21:33:29] Fernandos: see http://middlemanapp.com/basics/dynamic-pages/
[21:34:37] canton7: hmm they aren't *really* dynamic pages....
[21:35:01] centrx: It is dynamic generation, but the output is static pages
[21:35:04] canton7: either way, same as every static site generator probably: no chance for anything dynamic (comments, contact forms, etc)
[21:35:11] Fernandos: hmm, not sure... what about this http://middlemanapp.com/basics/pretty-urls/ they say you can set php files as index
[21:35:45] centrx: Fernandos, What is the use case?
[21:36:10] Fernandos: I'm just thinking about using that for coming up projects which involve a cms
[21:36:47] whomp: what's the best way these days to set a breakpoint in ruby?
[21:37:07] Fernandos: I prefer having an API first CMS, such that I have A) command-line-tools for it B) A REST API which I can use to integrate business data or to consume from mobile devices
[21:37:27] Fernandos: whomp: check the jetbrains IDE
[21:37:56] whomp: *without having to change IDEs
[21:38:03] itadder: what so good about jetbrains
[21:38:04] itadder: another ide
[21:38:13] benlieb: For those not sick of my questions about lambdas / procs, here' my last one: if a lambda is a Proc (lambda{}.class = > Proc < Object), why is it different from a proc?
[21:38:22] whomp: yeah like... how can i break a program without moving off vim?
[21:38:43] neoice: I'm trying to do something like: log.level = Logger::#{sev}... I've seen .send() for using variables as method names, but I'm not sure how to instantiate an object identified by a variable.
[21:39:10] canton7: neoice, Logger.const_get(...)
[21:39:20] MrZYX: whomp: IMO binding.pry
[21:39:40] Fernandos: itadder: it's just an editor which works out of the box, that's about it. I can tune me vim to do the same, but I'm more comfortable with an IDE sometimes than with vim. It's about coding, not luxury or coolness
[21:39:46] centrx: Fernandos, It seems like with middleman you would need to set up a system to generate pages that are saved in the CMS
[21:40:00] Fernandos: I use vim in addition to the ide, here btw.
[21:40:04] whomp: MrZYX, how do i break with pry?
[21:40:07] itadder: I like vim and textmate
[21:40:21] centrx: Fernandos, It does not seem to be designed for a CMS with unprivileged users, without adding extra scripting on top of it
[21:40:24] MrZYX: whomp: check pry-byebug (or pry-debugger for 1.9)
[21:40:44] Fernandos: centrx: oh good point! No ACL,RBAC.. big thing
[21:40:45] MrZYX: or just write binding.pry where you want to break
[21:41:06] centrx: benlieb, For one, lambda requires the exact number of argument specified
[21:42:26] benlieb: centrx: I understand that, but my question in this case is if they're different, why is a lambda a proc? Why not make it a lambda class, that is maybe a subclass of proc. The whole syntax around this makes the subtle differences a bit dicier than it needs to be, in my opinion
[21:42:38] whomp: MrZYX, thx :)
[21:43:08] benlieb: normally in programming when something is mostly like something else but a bit different, it's a subclass
[21:43:32] Fernandos: centrx: I really think about creating a binary cms that can be used as cli tool to manage other cms remotely and then generate client libraries that leverage it on the server-side
[21:43:54] Fernandos: centrx: do you think that's a good idea?
[21:43:57] centrx: benlieb, lambda is a language keyword, not a class of anything
[21:44:04] whomp: MrZYX, now it dumps all of the variables at the breakpoint. i just want it to stop there!
[21:44:09] benlieb: centrx: exactly!
[21:44:23] benlieb: I know what it IS, I'm wondering why?
[21:44:47] MrZYX: benlieb: centrx actually lambda is a method: http://rubydoc.info/stdlib/core/Kernel#lambda-instance_method
[21:45:28] Fernandos: And what could go wrong with a binary cms having client libraries in many languages?
[21:45:30] Fernandos: I know a lot about cms, workflows and that there is no single cms with a decent gui. Also tinymce and wysiwyg sucks a big time, because it takes too much time to do what you want.
[21:45:32] centrx: MrZYX, Thanks
[21:45:42] centrx: MrZYX, benlieb -> is a keyword though... ?
[21:45:50] benlieb: it seems like internally it would have to subclass Proc, or at least somehow set some internal environment to make it behave differently.
[21:45:55] MrZYX: whomp: never saw it dumping all variables, it is intended to drop you into a pry session and that prints the current context
[21:46:04] MrZYX: centrx: yep
[21:46:17] godd2: Anyone have any resources so I can learn to "professionalize" my gem? The code is kinda hacked together and messy.
[21:46:19] neoice: canton7: thanks for the tip. is there a place I can learn about things like .send() and .const_get()?
[21:46:45] centrx: Fernandos, Sounds like a great idea. If it is really an empty space with no available free software for that.
[21:46:50] MrZYX: neoice: read the docs of Object, Kernel, Class and Module
[21:46:52] Fernandos: Also permissions, roles , caching and extensions are a pain in the ass in most cms. Deploying permissions isn't even possible in any of those for example.
[21:46:54] centrx: Fernandos, I would recommend making as much use of existing libraries as possible
[21:47:14] godd2: neoice: You could check out Metaprogramming Ruby by Paolo Perrotta. It's nto as intimidating as it sounds.
[21:47:21] canton7: neoice, IRC? :) Otherwise, reading all methods on the lower-level classes can be very handy (Object, BasicObject, Kernel, IO, etc)
[21:48:20] Fernandos: centrx: hmm.. idk. if there is already such a thing. I was thinking of a single binary and didn't want to use a huge framework and am still not sure of the language to use.
[21:49:00] Fernandos: maybe I should write it in C99, or Haskell, should just have ZERO dependencies, drop a binary, run it, go
[21:49:05] centrx: benlieb, I agree though. It might be to add language syntax/behavior to be similar to lambda in other languages like LISP
[21:50:50] benlieb: interestingly lambda{}.lambda? => true, lambda{}.proc? => undefined method
[21:51:18] centrx: Fernandos, Web apps is the trend these days. Does help for compatibility across platforms
[21:51:30] benlieb: Proc.new{}.proc? => undefined method
[21:51:33] neoice: godd2: I wasn't sure if "metaprogramming" was the right term. "metaprogramming" always sounds like such a lofty concept
[21:51:45] Fernandos: centrx: no idea about the language to choose really, but would you use such a thing? Having client libraries in many languages, remote control via cli and a realtime interface connecting to the API that's just static html/js/css interface.
[21:52:18] godd2: neoice: ruby is built for it, and trust me when I say that book is pretty straightforward
[21:52:20] centrx: Fernandos, I am not sure I am the target user. I don't have any content :)
[21:52:26] Fernandos: I mean CMS's are doomed to fail, because you say it. People need webapps, not a cms.
[21:52:44] Fernandos: But webapps almost always evolve to a cms
[21:53:32] Fernandos: but a cms very rarely evolves to a webapp and when it does it's big, clunky and ugly, not even talking about security here
[21:53:49] centrx: I would think that a webapp could be a CMS. Maybe I am wrong, but the concept does not require a desktop application
[21:54:20] centrx: A CMS deployed internally on an internet with a web interface is still a "webapp" even if no one on the "World Wide Web" connects to it via the public Internet
[21:55:36] Fernandos: A webapp often times evolves to a cms, when projects grow, like facebook for example. They have a highly complex RBAC/ACL system that manages security and access and a way to add content. That's it
[21:55:51] dj21: is there a gem that'll let me take a screenshot of a webpage - preferably besides ancient selenium-webdriver?
[21:55:56] kewubenduben: Hi guys, how do you do a regex if you have a variable? trying like -> a="sfs" ; "mysfs01" =~ /a/ <- is not possible
[21:56:32] Fernandos: dj21: idk about a gem, but there are many SaaS services that do that. phantomjs could help you do that yourself, iirc
[21:56:41] dj21: i just found one actually, link_thumbnailer, thx
[21:56:47] centrx: kewubenduben, Either: /#{a}/ or Regexp.new(a)
[21:56:48] dj21: kewubenduben: what are you trying to do, match or substitute?
[21:58:15] dj21: what does ~> mean in the context of bundler?
[21:58:15] Fernandos: centrx: what would you need? I mean what project do you think would help you other than a cms then?
[21:58:44] Fernandos: just trying to fix shit, because email and cms suck so hard I wanna fix it asap
[21:59:09] centrx: Fernandos, What's wrong with e-mail?
[21:59:53] shevy: dj21 it has to do with version checks
[22:00:03] godd2: dj21: http://stackoverflow.com/questions/4292905/what-is-the-difference-between-and-when-specifying-rubygem-in-gemfile
[22:00:04] shevy: dj21 I believe it somehow checks for major or minor version (probably major)
[22:00:14] Fernandos: centrx: idk, where to start... your question sounds so legitimate, but when you look at how email works at the protocol level, you'll see how bad it is and how much it sucks.
[22:00:45] centrx: Oh SMTP, yeah I don't think you are going to be able to change that :)
[22:00:59] dj21: my app depends on nokogiri 1.6.1, but a new gem (link_thumbnailer) demands ~. 1.4.0
[22:01:09] dj21: rock and a hard place
[22:01:20] godd2: dj21: its says "look for the newest release that is in the same minor release category"
[22:01:20] Fernandos: centrx: smtp, pop3, exchange, imap etc.. there is a lot of bullshit that re-invents the wheel
[22:01:58] dj21: ahhh cutycapt :]
[22:02:28] Fernandos: centrx: and that's "low-level", on the interface side the things are even worse than that. That's why social networks sprout, because email sucks. Each and everyone tries to solve a similar problem, without knowing the actual problem.
[22:03:33] centrx: Fernandos, I am all for anything that eliminates Facebook
[22:05:05] Fernandos: centrx: what frustrates me personaly is that I cannot integrate flows in to what I used to do, the sofware is dumb and writing extension requires too much time, because the software sucks at making things "easy" to extend
[22:06:07] centrx: Fernandos, How about http://www.exist.com/blog/five-popular-ruby-rails-based-cms
[22:06:41] Fernandos: not joking, I tested many more than 100 cms, didn't count after a while..
[22:07:14] Fernandos: and I looked through the source of almost all of them, regardless of the language they were written in (excluding any commercial or SaaS cms)
[22:07:47] Fernandos: Adva CMS is the only one in that list I didn't know
[22:08:00] Fernandos: ah and BrowserCMS
[22:11:53] Fernandos: thanks for listening and your input centrx, gotta go now, see you
[22:12:04] centrx: Fare thee well
[22:13:42] Sawbones: So I'm working with rails and I see this thing that says 'yield :nav' What the heck is that doing?
[22:14:24] bnagy: yielding a symbol
[22:14:44] bnagy: :nav is a symbol
[22:15:12] banister: bnagy sup nags
[22:15:17] bnagy: symbols are special because each symbol is unique, so having many refs to it saves memory etc
[22:15:26] bnagy: morning banister
[22:15:47] banister: bnagy time for u?
[22:15:48] bnagy: whereas if you use "nav" there can be arbitrary numbers of copies of that same string
[22:15:50] banister: 11:15pm here :)
[22:16:18] bnagy: UTC+12 here at the edge of the world
[22:16:39] bnagy: although NZ is at +13 because daylight savings, which still freak me out
[22:18:39] Fractional: How do I run my ruby program in RubyMine?
[22:19:02] bnagy: sounds like a question for the rubymine docs
[22:19:20] Hanmac: shevy: https://dl.dropboxusercontent.com/s/7tjxtsbtqrawiq4/the_day_we_fight_back_fail.png
[22:20:18] Fractional: binagy: Didn't find anything it earlier on.
[22:20:49] shevy: Hanmac hehe. could be decoay
[22:21:12] shevy: Hanmac or just raise awareness
[22:22:05] Sawbones: So a symbol is a string?
[22:22:24] shevy: Sawbones of course not
[22:22:40] godd2: Sawbones: a symbol is very much like a string,but there're things you cant do to it like a string
[22:22:43] bnagy: Fractional: well it took me about as long as it took to type 'rubymine run program' into google, so maybe you weren't looking right
[22:22:49] shevy: Sawbones the first thing one should remember is that symbols are super boring, they only have a cool name
[22:23:13] Sawbones: because in the rails code it calls params[:id]
[22:23:26] Sawbones: Is :id a variable in this case?
[22:23:29] Sawbones: I'm confused.
[22:23:36] bnagy: no, it's a symbol
[22:23:41] centrx: Sawbones, A symbol is a constant that looks very much like a string to the programmer
[22:23:49] shevy: Sawbones what does a symbol have as identifier for you?
[22:24:38] centrx: Sawbones, The only difference between a symbol and a string is a) it is stored once internally, as a constant, so it is more efficient to re-use, and b) the syntax is cleaner, : vs ""
[22:24:45] godd2: Sawbones: we use symbols as keys in hashes. in the params hash, the :id symbol will get you the id in that hash. so if params = {:id => 3, :name => "Jim"} then params[:id] will spit back 3 to you
[22:25:04] Fractional: bnagy: I only found it for rails.
[22:25:11] LadyRainicorn: Also, importantly, symbols are not garbage collected.
[22:25:21] shevy: ponicorns are not garbage collected either!
[22:25:25] centrx: Sawbones, A symbol also lacks many of the methods a string has, it is less bulky
[22:25:34] Sawbones: godd2: Can I just get the id from that hash with 'id'?
[22:25:37] LadyRainicorn: That is true shevy.
[22:25:50] shevy: Sawbones of course not
[22:25:53] LadyRainicorn: ACTION flies around uncollected.
[22:26:00] bnagy: so when we say 'the only difference between a symbol and a string' we really mean 'they're pretty much different in ever significant way'
[22:26:01] shevy: because 'id' is a string Sawbones
[22:26:15] Hanmac: Sawbones: did you had other programing exp before with other language?
[22:26:38] shevy: Sawbones there exists this abomination HashWithIndifferentAccess or something
[22:26:44] bnagy: unless you use Fails "hash with indifferent access" or whatever horror they have
[22:26:48] shevy: if symbols are too DIFFICULT for you, use that hash
[22:27:01] Sawbones: but usually hashes use a string for their key
[22:27:10] Hanmac: Sawbones: ... Symbols are rubys way like a creepy hybrid between a String and the Enums in C
[22:27:17] shevy: Sawbones in which language though?
[22:27:18] Sawbones: It's not difficult I just want to understand why they chose these symbols and when I should use them
[22:27:33] godd2: Sawbones: try this. open up irb and try the code in this gist: https://gist.github.com/nicklink483/8427155
[22:27:34] shevy: Sawbones because a symbol has the same object_id all the time, always. a string object does not have
[22:27:41] bnagy: string keys are uncommon in ruby
[22:27:57] shevy: but they are garbage collected!!!
[22:27:59] LadyRainicorn: Symbols are for when you care about identity.
[22:28:11] LadyRainicorn: Strings are for when you care about value.
[22:28:14] bnagy: in idiomatic ruby you'll mostly only see them when a hash is going into or coming out of json or some other serialisation format
[22:28:20] godd2: youll see that "a" got created twice and has two different object ids because they aren't the same object, but when :a was created, it was created once and forever in that code
[22:28:27] LadyRainicorn: Also, never use to_sym.
[22:28:45] Sawbones: bnagy: I just started using the ruby json library and I acquired my values with strings
[22:28:48] Hanmac: Sawbones: for sample : 1000.times.map {"a"} creates 1000 different strings ... 1000.times.map {:a} create ONE symbol
[22:29:15] godd2: LadyRainicorn: unless you're getting a string that you want to send as a method, then object.send(some_string.to_sym) would be the way
[22:29:33] bnagy: send works with strings these days
[22:29:53] Sawbones: Hanmac: ok, see that makes sense then
[22:30:14] LadyRainicorn: If some_string is user controlled, to_sym is a DoS vuln.
[22:30:32] Sawbones: that would explain why you'd write attr_accessor :thing :another_thing, because you want the same object
[22:31:28] Hanmac: attr_accessor "thing" would work too but it is not nessary
[22:32:16] Sawbones: that's stupid
[22:32:32] centrx: *~*~**!*!~*~* YOU SAID THE WORD OF THE DAY ~*~**!*!*!**~*~*~
[22:32:35] bnagy: there's no particular reason for attr_* to use symbols apart from style
[22:32:55] bnagy: you could easily write those methods to take string params
[22:33:45] Hanmac: for sample most of the methods that takes Symbols like define_method or send does work with Strings too
[22:34:15] bnagy: used to be a pain in the ass
[22:34:16] Sawbones: bbl to discuss more
[22:34:33] LadyRainicorn: Not accepting strings is very bad.
[22:34:51] godd2: Fun fact, if you want a space in your symbol, just wrap it in quotes. :"Hello, world!"
[22:35:24] centrx: :"Hello, world!".to_s
[22:36:11] rakm: how do I get rake to invoke consecutive tasks?
[22:36:11] godd2: my_str = "Hello"; :"#{my_str}, world!"
[22:36:16] rakm: http://pastie.org/8633879
[22:36:18] LadyRainicorn: ACTION fals out of the air.
[22:36:59] Hanmac: bad that symbols does not support the creepy C string cat :P "abc""def" works but :"abc""def" works not ;P
[22:37:58] workmad3: Hanmac: should string literals and symbol literals really automatically concat? :P
[22:38:25] godd2: :"#{"Hello, " + "world!"}"
[22:38:49] workmad3: godd2: :"#{"Hello, " "world!"}"
[22:39:10] workmad3: godd2: down with redundant + signs!
[22:39:24] bnagy: this is almost awful enough to force me to work on the awful code I don't want to work on
[22:39:38] Hanmac: workmad3: did you know? "def#{"xyz"}abc" is parsed as ONE string, not two ;P
[22:40:07] workmad3: Hanmac: I didn't, but fun :)
[22:40:18] LadyRainicorn: 1000000.times{|i|i.to_s.to_sym}
[22:40:32] godd2: what about "a#{"b#{"c"}d"}e"
[22:42:26] Hanmac: godd2 does this answer your question?
[22:42:26] Hanmac: >> RubyVM::InstructionSequence.compile('"a#{"b#{"c"}d"}e"').disasm.lines[2]
[22:42:26] eval-in: Hanmac => "0002 putstring \"abcde\"\n" (https://eval.in/89290)
[22:43:34] godd2: >> RubyVM::InstructionSequence.compile('"a#{"b#{String.new("c")}d"}e"').disasm.lines[2]
[22:43:35] eval-in: godd2 => "0002 putobject \"ab\"\n" (https://eval.in/89291)
[22:43:44] bnagy: eval-in is back! yay!
[22:44:03] Hanmac: workmad3: Ruby was written by the Founder of the History Monks: "Wen the Eternally ??Surprised??" ;P
[22:44:51] godd2: does that mean that "a#{"b#{String.new("c")}d"}e" is parsed as more than one string?
[22:45:06] LastWhisper: hey! does anyone here use webmock?
[22:45:41] shevy: anyone who would use "a#{"b#{String.new("c")}d"}e" should be killed on the spot
[22:46:26] Hanmac: godd2: the difference is that they are not only string literals ... for sample "a#{1}b" is not autmaticlly cutted by the parser to "a1b"
[22:48:22] Mon_Ouie: It's just a form of constant folding: since you're preforming that operation with string literals, the result can be calculated at constant time, no need to do it everytime the string is evaluated
[22:54:37] CodeBunny: Cucumber SUCKS!
[22:57:55] shevy: why would anyone shoot you
[22:59:17] Hanmac: ACTION throws an apple
[23:00:36] CodeBunny: So sick of cucumber. It takes an hour to do in cucumber to do what I can do in minitest in 5 minutes
[23:00:56] Hanmac: cucumber are only for kappas
[23:02:46] Hanmac: CodeBunny: Japanese Water Daemons ... they like cucumber :P
[23:03:16] CodeBunny: Oh good. Now I know what it's useful for.
[23:03:39] CodeBunny: Because it's certainly not useful for what this guy wants to use it for
[23:03:49] CodeBunny: NOT a testing tool people. Not a testing tool
[23:04:26] godd2: I'm having trouble finding some good resources to learn about Unit Testing and best practices in the Ruby ocmmunity regarding testing. Anyone have any links or recommendations?
[23:04:47] CodeBunny: Oooh.... google micheal feathers
[23:05:41] CodeBunny: poodr rather
[23:05:51] bnagy: godd2: the general practice is to have hundreds of tests written in a DSL that is a sexily natural language looking as possible, while never actually writing any tests that expose actual bugs or security issues
[23:06:12] nateberkopec: bnagy: #bestpractice
[23:06:54] CodeBunny: i think that still counts as bad
[23:07:04] nateberkopec: godd2: try MiniTest! https://github.com/seattlerb/minitest minitest helped me understand testing.
[23:07:12] CodeBunny: bad programmer, no donut
[23:07:24] CodeBunny: Yes. Minitest is the bomb
[23:07:43] nateberkopec: godd2: also, try reading the tests of small libraries/gems and figuring out what's going on.
[23:08:01] CodeBunny: Minitest is the reason I currently want to claw my eyes out being forced to fuck with cucumber
[23:08:33] godd2: Thank you very much you guys :)
[23:09:08] CodeBunny: all the seattlerb projects use minitest... you can learn from those
[23:09:32] godd2: I tried to use test/unit with one project, and I was following along, but I didn't really grok what I was doing even though it worked
[23:09:52] CodeBunny: The minitest docs are much better
[23:10:08] CodeBunny: and you will suddenly grob your test unit tests
[23:10:17] nateberkopec: godd2: it took me a while to understand too. reading other project's tests helped me a lot - so did contributing to open-source and having to write unit tests for the stuff I did :)
[23:11:51] CodeBunny: Travis will make you understand
[23:12:08] CodeBunny: With a big red stick
[23:13:45] Fractional: Can you do like: "if !foo" in ruby? foo is a boolean
[23:14:01] LastWhisper: CodeBunny: How come you hate cucumber?
[23:14:42] bnagy: Fractional: normally we'd write unless foo
[23:14:48] nhhagen: good evening
[23:15:00] godd2: Fractional: fire up irb and try it out! THats what it's for :)
[23:15:08] CodeBunny: LastWhisper: Because it takes going back and forth between umteen files to get anything done, and it doesn't play nice in my build system, and.... overhead overhead overhead
[23:15:41] Fractional: godd2: It works but Rubymine gives me errors :/
[23:16:26] Fractional: bnagy: Thanks! Exactly what I was looking for! :D
[23:16:36] CodeBunny: LastWhisper: if something is really truely borked and I can't figure it out, I have to go gather up all the bits that are strewn from hell to breakfast, pull them into a single minitest file, debug, then go fix it in cucumber
[23:16:49] nhhagen: I have a tab seperated file that I want to read each line from, split it, select a column and only keep unique values of that column. This is what I though was right: File.open("NO.txt", "r:utf-8").each_line.map {|line| line.split("\t")[1]}.uniq do |place|
[23:16:58] CodeBunny: LastWhisper:It's a pain in a ankle
[23:17:04] LastWhisper: Gotcha. CodeBunny Is your test suite that large that it happens that often?
[23:17:21] nhhagen: but that does not work
[23:17:28] bnagy: nhhagen: there's a csv lib in stdlib
[23:17:41] nateberkopec: nhagen: require 'csv' #BOOM
[23:17:41] CodeBunny: LastWhisper:it's not a matter of large...
[23:17:44] bnagy: which works with tab separators as well, obviously
[23:18:30] Fractional: I recently started using Rubymine and there is something weird with the IDE. It gives me errors unless I give the optional parameters of a method arguments.
[23:18:37] Fractional: Has anyone experienced anything in the like?
[23:18:39] nhhagen: bnagy: I'm not suprised, I'll check it out, but it is the selecting unique part I need help with. I'm guessing that my method chaining does not work as I expected
[23:18:42] CodeBunny: LastWhisper:it's more a matter of 'how do I get this fiddley bit to work... Oh hell, I have to get it to work in this stupid DSL on top of getting it to work in the first place. fuck me
[23:19:02] bnagy: nhhagen: well 'doesn't work' is not a useful problem description
[23:19:23] godd2: Fractional: I think it's only a warning, not an error. While it's probably a good idea to use unless in that case, always choose the control statement which makes the most sense and don't force yourself to use one that feels uncomfortable.
[23:19:37] bnagy: if you can provide sample input that's the best way
[23:19:37] CodeBunny: LastWhisper:It's not hard. It's just very time consuming.
[23:19:40] nhhagen: bnagy: well, I get duplicates
[23:20:29] Fractional: godd2: Rubymines highlights the code with underlined red unless I fill in all the arguments for a method (even the ones that are optional). Unless feels more ruby-ish :)
[23:20:45] godd2: nhhagen: you're using #uniq when you should use #uniq!
[23:21:02] godd2: nhhagen: without the exclamation point, you aren't changing the object
[23:21:03] bnagy: no, it's not that
[23:21:16] LastWhisper: I hear ya CodeBunny
[23:21:18] bnagy: you're passing a block straight to uniq - doubt that's what you want
[23:21:23] bnagy: try uniq.each
[23:21:32] nhhagen: godd2: thx, I'm new to ruby, and haven't read enough yep
[23:21:50] LastWhisper: Are any of you guys familiar with WebMock at all? In terms of creating stub_requests and then checking pages via a web browser/driving it?
[23:22:33] Hanmac: nhhagen & godd2: but you need to beware from ! methods ... some of them might return nil, so you need to be careful when you want the return value for chaining
[23:22:49] bnagy: uniq {|blah| ... uses the block result for the uniqueness test
[23:23:10] godd2: nhhagen: a couple others like that to be aware of are .sort vs .sort! and reverse! vs reverse
[23:23:38] bnagy: basically just don't chain with ! methods
[23:23:47] Hanmac: nhhagen: also beware, use File.open() always with a block like File.open() { ... } otherwise you leave the FileDescriptor open
[23:23:50] bnagy: it makes no sense anyway
[23:24:21] godd2: bnagy: unless you want to iterate over a uniq array and have the array still be uniq afterward, surely?
[23:24:37] bnagy: well if you're chaining then the intermediate result is lost anyway
[23:24:48] bnagy: so it's pointless
[23:25:26] nhhagen: Hanmac: ok, what would I put the in the block in the case
[23:25:34] bnagy: plus the wacked return values - basically it's just safer and cleaner to never do it
[23:25:47] Fractional: http://puu.sh/6lb8i.png <- Rubymine tell me that I need to fill in 4 more optional arguments.
[23:25:51] Fractional: Anyone knows how to fix this?
[23:25:53] bnagy: nhhagen: where you have uniq do use uniq.each do
[23:26:05] nhhagen: #uniq! worked, I got the correct number of objects
[23:26:20] godd2: Fractional: that's not an error. Gosu::Image.new can take three arguments just fine
[23:26:34] nhhagen: bnagy: I'll try that to, just to learn
[23:26:42] Fractional: godd2: Yes, but the red underlining that comes from "Missing 4 arguments" is annoying.
[23:26:45] Fractional: How can one disable it?
[23:27:01] bnagy: by uninstalling rubymine
[23:27:08] Hanmac: nhhagen: for sample: File.open("NO.txt", "r:utf-8") {|f|f.each_line.map { ... } } so let the block close it ... otherwise look at File.foreach which does all you want for you
[23:27:10] bnagy: it's linting is idiotic
[23:27:35] bnagy: isn't there File.each, anyway?
[23:28:00] Hanmac: bnagy: i meaned the class method
[23:28:04] godd2: Fractional: I don't know enough about RubyMine to answer your question. My solution is to use Notepad++ :P
[23:28:20] workmad3: there's also File.readlines(filename).each
[23:28:47] nhhagen: Hanmac: thx, this script only reads the file and loads the content into elasticsearch, just didn't want to spam to much
[23:28:58] Fractional: godd2: Then back to Sublime it is! :)
[23:29:02] Hanmac: "File.foreach(filename) VS File.readlines(filename).each " know the difference
[23:29:29] nhhagen: Hanmac: thx
[23:29:32] bnagy: something obscure and horrible that you're going to tell us anyway?
[23:29:33] Hanmac: ACTION uses Eclipse for Ruby and C++, but i would not recommend it for everyone
[23:29:38] godd2: Fractional: if you ctrl+click on the error, what libraray does it open up?
[23:30:45] Hanmac: godd2: i have the feeling that the gosu interface documentation (a fake method list for the parsers) is not 100% that what it is
[23:31:26] Hanmac: Fractional: i wanted to make you a Tileset class ... i forgot it again ... maybe i have time tomorrow ... (try to remember me about that)
[23:32:03] godd2: Fractional: have you heard of Ludum Dare?
[23:32:53] Fractional: godd2: I've heard about it yes :)
[23:33:04] Fractional: Hanmac: I will if I remember as well! :D
[23:34:05] Fractional: godd2: Why do you ask? :)
[23:34:19] shevy: Fractional are you already thinking in ruby?
[23:35:05] Fractional: shevy: I'm doing my best to do so! Currently writing gamestate and gamestate manager classes.
[23:35:07] godd2: Fractional: I had jsut recently gotten into Gosu and Ludum Dare because of this talk: http://www.youtube.com/watch?v=irMfy8I2OVQ
[23:35:34] godd2: Unfortunately Hasu requires Ruby 2.0 and Gosu will only work with 1.9.3 on windows
[23:35:56] Hanmac: ACTION point an laugh about gosu because it cant be installed on my system because pango is not where gosu think it is
[23:36:50] shevy: Hanmac where is pango?
[23:36:52] Fractional: Godd2: The biggest project I've made is a improved "clone" of the Asteroids game in Chingu. You can give it a play if you want! www.github.com/freddan962
[23:38:14] godd2: Fractional: awesome! Ill check it out. I made a pseudo-remake of Combat! for the atari: https://github.com/nicklink483/combat
[23:38:44] nhhagen: Hanmac: Have I understood it correctly that File.foreach will not work in my case since I want unique values?
[23:39:15] godd2: Fractional: Also, Id really love to dig into Metro: https://github.com/burtlo/metro/ and make it so that games are independently distributable
[23:40:01] Fractional: godd2: http://puu.sh/6lbTp.jpg & http://puu.sh/6lbV7.jpg (Chinguroids) =D
[23:46:31] bnagy: nhhagen: nah it would work
[23:46:59] nhhagen: bnagy: hmm, then I'm doing something wrong
[23:47:04] godd2: nhhagen: bnagy was right, File.open("NO.txt", "r:utf-8").each_line.map {|line| line.split("\t")[1]}.uniq.each do |place|; #place logic; end will work since youre passing a block to the each iterator.
[23:47:04] bnagy: nhhagen: File.foreach("whatever.txt").map {|l| l.split("\t")[1]}.uniq.each {|e| ...
[23:47:21] nhhagen: bnagy: that is what I tried
[23:47:41] Fractional: godd2: I like that video a lot!
[23:48:03] nhhagen: godd2: that is what I am doing, do the descriptor should close right
[23:48:03] godd2: Fractional: but yea, fair warning, if you're on windows, dont get your hopes up
[23:48:29] bnagy: nhhagen: provide sample input then
[23:48:29] Fractional: godd2: I'm on Ubuntu, OS X and Windows.
[23:48:34] bnagy: cause I don't believe you :)
[23:49:19] shevy: down with your pants!
[23:49:21] shevy: show the code
[23:49:47] godd2: nhhagen: I would use File.read personally, if you pass it a block, it will iterate over each line for you and close the file in one go like this: https://gist.github.com/nicklink483/8428254
[23:52:28] bnagy: on what version does read do that?
[23:53:06] bnagy: read should read the whole thing as one string
[23:53:12] bnagy: readlines is by line
[23:54:40] bnagy: or File.read(...).lines, which I guess is quite pretty
[23:56:12] nhhagen: bnagy: here is the complete code: https://gist.github.com/nhhagen/8428317
[23:58:49] bnagy: meh, looks ok
[23:58:50] godd2: nhhagen: can you gist NO.txt?
[23:59:23] bnagy: I don't think you even need each_line there
[23:59:31] bnagy: you can map right off File.open
[23:59:54] bnagy: it's an old perlism hangover :S