Forgetful_Lion has quit [Read error: Connection reset by peer]
Forgetful_Lion has joined #ruby-lang
Forgetful_Lion has quit [Read error: Connection reset by peer]
yfeldblum has quit [Ping timeout: 245 seconds]
brahmana has joined #ruby-lang
AKASkip has joined #ruby-lang
<brahmana>
Hi, can I slice a string at a unicode grapheme boundary using the standard Ruby string or do I need to use something like the Unicode gem? http://rubygems.org/gems/unicode
apeiros has joined #ruby-lang
<r0bgleeson>
brahmana: what is a unicode grapheme boundary, on 1.9 strings are composed of characters and not bytes as in 1.8, if that makes a difference
<brahmana>
With str = "d̪" , str.length returned 2. So I am wondering if native strings can do what I want
<r0bgleeson>
ah i see, well, i believe ruby tries to represent characters (as perceived by a human) and to avoid ambiguities like that, but i dont know for sure. what is the encoding of str, and are you on 1.9+?
<brahmana>
I want to get the first 100 displayable characters from a string, aka slice at the 100th grapheme cluster
<brahmana>
str.encoding => #<Encoding:UTF-8>
<r0bgleeson>
[0..99] should do that, no?
<brahmana>
This is Ruby 2.0
<r0bgleeson>
i cant ask your question for certain except to say give it a shot
<r0bgleeson>
UTF-8 is the encoding you want, probably yeah
daikan has quit [Remote host closed the connection]
robmiller has joined #ruby-lang
<dostoyevsky>
Hi... This might be a bit off-topic... but I am executing a shell script in Ruby and then forward the output line-by-line in a [200, "text/html", OutputReader##each]. The script takes a while to run and I see #each being invoked all the time. But in the browser the page only shows when the shell script was completed... I do not see each individual line like I see them on the server side being #each'ed
daikan has joined #ruby-lang
<dostoyevsky>
Is there a way to force a browser to show each line as it's being written from the server?
<yorickpeterse>
You need a webserver that supports streaming
<yorickpeterse>
Webrick doesn't support that
<yorickpeterse>
Thin/Unicorn do I believe, not 100% sure about Unicorn though
yatish27_ has quit [Remote host closed the connection]
<dostoyevsky>
>> Thin web server (v1.3.1 codename Triple Espresso)
<dostoyevsky>
That's the one Sinatra is using here
<yorickpeterse>
hm, apparently my Rubygems was butchered
<yorickpeterse>
update fixed it
<yorickpeterse>
ruby makes total sense
r0bby_ has joined #ruby-lang
robbyoconnor has quit [Read error: Connection reset by peer]
cirenyc has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
momomomomo has quit [Quit: momomomomo]
lfox has joined #ruby-lang
h_kon has quit [Remote host closed the connection]
r0bby_ is now known as robbyoconnor
ahmedelgabri has joined #ruby-lang
michaeldeol has joined #ruby-lang
<cirenyc>
If I have 3 attributes on an object and want to remove those that are not true and convert the rest to string representations, is there a better approach than https://gist.github.com/0aa3459e0fac655522d2
senj has joined #ruby-lang
<apeiros>
cirenyc: looks fine. why do you call it "an object" when you know it's a hash?
|jemc| has joined #ruby-lang
vinhbachsy has joined #ruby-lang
<apeiros>
though, your code will return an array, not a string
<cirenyc>
apeiros: Because I am building the hash from attributes on an object. That wasn't clear from the code snippet.
<cirenyc>
apeiros: Yes, I want an array of string representations.
<apeiros>
IMO that's a fine way then.
rahul_j has joined #ruby-lang
<cirenyc>
apeiros: Great, thank you.
michaeldeol has quit [Ping timeout: 248 seconds]
perdido has quit [Read error: Connection reset by peer]
mykoweb has joined #ruby-lang
yfeldblum has quit [Read error: Connection reset by peer]
jovon has quit [Quit: Leaving]
declan has quit [Quit: Leaving.]
ahmedelgabri has quit [Read error: Connection reset by peer]
bcardarella has joined #ruby-lang
ahmedelgabri has joined #ruby-lang
patriciomacadden has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bcardarella>
with Ripper I can find the line number that corresponds to the opening of a block. Is it possible to find the line number that corresponds to the closing of that block?
momomomomo has joined #ruby-lang
AKASkip has joined #ruby-lang
slyphon has joined #ruby-lang
jtw has quit [Read error: Connection reset by peer]
vlad_starkov has quit [Remote host closed the connection]
imperator2 has quit [Ping timeout: 260 seconds]
vlad_starkov has joined #ruby-lang
Thanatermesis has joined #ruby-lang
Thanatermesis has joined #ruby-lang
kurko_ has joined #ruby-lang
kurko_ has quit [Max SendQ exceeded]
kurko_ has joined #ruby-lang
paul_k has joined #ruby-lang
<r0bgleeson>
yorickpeterse: for your API question, that depends. JSON would be expected and more comfortable without a doubt, however Content-Type is there for a reason too.
<r0bgleeson>
your clients should respect that
<r0bgleeson>
for the sake of ease, JSON always is better
<yorickpeterse>
that implies the clients know what they are doing
<r0bgleeson>
exactly
<yorickpeterse>
they are most likely not in our case
<yorickpeterse>
(I went with JSON-everything btw)
<r0bgleeson>
cool
<r0bgleeson>
a good client would use 'Accept', probably.
deens has joined #ruby-lang
<yorickpeterse>
some of these bs websites I deal with require Content-Type to be set as a request header
<yorickpeterse>
which apparently is valid too
<r0bgleeson>
it is, if it is has a body
<r0bgleeson>
if it does not, it's not
<yorickpeterse>
so `Content-Type: application/json`, Accept is completely ignored
<r0bgleeson>
Accept is for, "hey, I want X back"
<r0bgleeson>
then the server can say, "nope, not got it"
<r0bgleeson>
or here you go
<r0bgleeson>
X being application/json, text/html, etc
Lewix has joined #ruby-lang
<r0bgleeson>
brb again
<bcardarella>
yorickpeterse: question on parser. Is there a way to walk the tree? The nodes don't seem to be enumerable
hahuang65 has joined #ruby-lang
lfox has quit [Ping timeout: 245 seconds]
<yorickpeterse>
bcardarella: eh yeah, I believe it's in a sub gem, sec
yfeldblum has quit [Remote host closed the connection]
daikan has quit [Remote host closed the connection]
vlad_starkov has quit [Remote host closed the connection]
CoreData has joined #ruby-lang
Pupeno_w has quit [Ping timeout: 272 seconds]
CoreData has quit [Client Quit]
CoreData has joined #ruby-lang
robmiller has quit [Quit: robmiller]
deens has quit [Remote host closed the connection]
<yorickpeterse>
np
ahmedelg_ has joined #ruby-lang
ahmedelgabri has quit [Ping timeout: 252 seconds]
<apeiros>
r0bgleeson: well, I disagree. if I specifically query foo.json, it's IMO unreasonable to return non-JSON, even with proper content-type set.
<apeiros>
it's different with content-negotiation
deens has joined #ruby-lang
<r0bgleeson>
apeiros: sure, if you have '.json' prefix.
<r0bgleeson>
apeiros: that's kind of weird though, and a rails-ism
<r0bgleeson>
apeiros: HTTP handles this in headers
<r0bgleeson>
suffix*
<r0bgleeson>
apeiros: .json may also represent a JSON content-type that is versioned, like mycompany/json-v1 etc.
<apeiros>
r0bgleeson: it's not a railsism, no
<apeiros>
.foo in urls existed *long* before rails
<r0bgleeson>
in ruby, it is
<apeiros>
it's not even a rubyism :)
<apeiros>
seriously, exhibiting the "document type" (content-type) in the url is about as old as http
<r0bgleeson>
my point of view is that it's a railism in the sense that the rails abstraction is so strong you dont even think at the level of headers, which you do
<r0bgleeson>
you think at a vague level of file extension
<r0bgleeson>
described by a vague content-type, defined by rails
<r0bgleeson>
yea sure, that wasn't my point
<apeiros>
no, rails just properly sets the content-type for you. just as apache did over a decade ago for static files with .foo in the url
<r0bgleeson>
sure, it does, and it doesn't make you think in HTTP
<apeiros>
in other words, it just ports over behavior from the static world to the dynamic world
<r0bgleeson>
check out webmachine-ruby for a toolkit that actually works with HTTP
<r0bgleeson>
not against it, or provides silly abstractions
tbuehlmann has quit [Remote host closed the connection]
hotpancakes has quit [Remote host closed the connection]
concertm_ has quit [Remote host closed the connection]
hotpancakes has joined #ruby-lang
concertman has joined #ruby-lang
DEac-_ has quit [Quit: leaving]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
hotpancakes has quit [Ping timeout: 248 seconds]
waxjar is now known as shadesaaaa
momomomomo has joined #ruby-lang
sandroqz has joined #ruby-lang
vlad_starkov has joined #ruby-lang
solars has joined #ruby-lang
cored has joined #ruby-lang
cored has quit [Changing host]
cored has joined #ruby-lang
concertman has quit [Remote host closed the connection]
concertman has joined #ruby-lang
mikecmpbll has joined #ruby-lang
concertm_ has joined #ruby-lang
plurt has joined #ruby-lang
spooft has joined #ruby-lang
momomomomo has quit [Quit: momomomomo]
concertman has quit [Ping timeout: 276 seconds]
momomomomo has joined #ruby-lang
concertm_ has quit [Ping timeout: 260 seconds]
vlad_starkov has quit [Remote host closed the connection]
spooft has quit [Read error: Connection reset by peer]
vlad_starkov has joined #ruby-lang
<apeiros>
r0bgleeson: at a cursory glance, it looks similar to what I once had in mind. wonder why it wants resources to subclass Webmachine::Resource. IMO anti pattern.
perdido has quit [Ping timeout: 272 seconds]
daikan has joined #ruby-lang
<yorickpeterse>
first step of teaching Ruby to students:
<postmodern>
too be fair, i actually taught a training, students who used RVM had no issues
* apeiros
has had 3 years of painless versioned ruby thanks to rvm and doesn't know where the hate for rvm comes from as of late…
<postmodern>
students who tried installing rbenv always forgot to add ~/.rbenv/shims to $PATH
<apeiros>
I understand that others want a different tool for rvm. but that's not the same as hating on it.
<apeiros>
*instead of rvm
heftig has joined #ruby-lang
<postmodern>
apeiros, it has caused a lot of grief
<postmodern>
apeiros, the bugs within rvm that is
<bougyman>
which bugs have you hit?
<bougyman>
i've yet to be affected by any bug with rvm that wasn't related to zsh.
<bougyman>
in those cases, I just use bash.
<postmodern>
bougyman, i also only run bash
<bougyman>
so what bugs hit you?
<apeiros>
I haven't hit a bug either. but as a single datapoint, I'm statistically irrelevant.
<apeiros>
the two times (I think) i ran into issues I got help quickly in #rvm
<yorickpeterse>
postmodern: I'll be dealing with Rbx here
<yorickpeterse>
I don't want to run in more random issues
<bougyman>
apeiros: but I double your sample size with my 0 bugs.
dingus_khan has joined #ruby-lang
<postmodern>
bougyman, i last used rvm over a year ago
<apeiros>
bougyman: still statistically irrelevant :) also no data to compare to (how many issues with chruby/rbenv/ruby-installer/etc.?)
<bougyman>
i was kidding, yo.
<bougyman>
but it does Work for Me.
<apeiros>
^^
<postmodern>
bougyman, had issues with rubies not installing correctly, or issues with newer versions of libraries/tools that broke rvm
<apeiros>
yeah, same. works for me, therefore never felt an urge to move.
<bougyman>
I even use it for prod deployments.
<postmodern>
bougyman, what motivated me to move off was the workflow
<yorickpeterse>
I should probably make it clear that I dislike RVM itself, not the people behind it
<apeiros>
and for new students, the "change your ruby version" is irrelevant. for those it's just the 2 lines: install with ruby, upgrade ruby.
<postmodern>
protip: use the packaged ruby for production systems
<postmodern>
that way you will get the security updates from the package manager
<apeiros>
yorickpeterse: that's good for you as a human ;-)
<yorickpeterse>
postmodern: only works if packaged Ruby is actually up to date
<apeiros>
too many people can't hold such things apart :(
<bougyman>
packaged ruby is almost never up to date.
<bougyman>
unless you're runninga arch linux.
<apeiros>
"I don't like your product, therefore I don't like you!" <- stupid
<yorickpeterse>
then it's too up to date
<postmodern>
apeiros, yeah nothing wrong with having students use system Ruby, provided they are running a modern OS
<bougyman>
yorickpeterse: hehahahah
danijoo has quit [Read error: Connection reset by peer]
<apeiros>
postmodern: oh, I meant with rvm
<postmodern>
bougyman, on Fedora /usr/bin/ruby -> 2.0.0p353
<apeiros>
postmodern: the two people I taught ruby, those were the only 2 rvm related lines I told them to add to their cheatsheet.
danijoo has joined #ruby-lang
<apeiros>
osx sadly shipped with 1.8 for a looooong time :)
lfox has joined #ruby-lang
<postmodern>
apeiros, yep and that's not our problem, that's Apple's
<postmodern>
apeiros, i sort of wish OSX Rubyists would have lobbied Apple to upgrade ruby
<apeiros>
postmodern: we had no pain. there was rvm which helped quickly.
<apeiros>
and before there was macports and brew
<postmodern>
apeiros, but you shouldn't need any ruby switcher
<postmodern>
apeiros, system ruby should just work
<eam>
not just apple, everyone shipped with 1.8
<apeiros>
postmodern: I'm actually not so sure what my opinion on that is
<postmodern>
eam, ubuntu, fedora, gentoo, arch all were quick to upgrade to 1.9
<eam>
postmodern: rhel, the dist used for actual prod, is still on 1.8
<apeiros>
I think software distribution at large is still very broken. despite (or because?) of all the existing package managers.
<eam>
production platforms need stability
<postmodern>
eam, of course, rhel _never_ upgrades
<eam>
postmodern: that's not true, it's just on a reasonable cycle
<postmodern>
eam, at any rate, fedora will be merged into rhel soon
<eam>
just like apple
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<eam>
ya rhel7 will update system ruby
<postmodern>
eam, except OSX is a user OS, not an enterprise server OS ;)
rynola___ has joined #ruby-lang
<eam>
lots of enterprise corp stuff deployed on osx
<eam>
windows has the same platform migration issues
<postmodern>
except Microsoft is a-ok with EOLing XP
<eam>
xp is older than ruby 1.6
<postmodern>
every vendor appears to be realizing that the market wants quicker turn-around on upgrades
<postmodern>
and are slowly moving away from the "support legacy forever" mentality
<eam>
postmodern: I don't think that's true
<eam>
unless you define "the market" as small companies only
<eam>
demand at large shops is unchanged
<postmodern>
eam, windows 7 is ending mainstream support within one year
<yxhuvud>
eam: the bigger question is if rhel7 will update ruby to a version that isn't already obsolete.
<yorickpeterse>
"RHEL 7.0, now with Ruby 1.9.2"
<postmodern>
yxhuvud, depends on how fast ruby-core releases
<eam>
they're getting ruby 2.0
<eam>
which is extremely new as far as these things go
<r0bgleeson>
apeiros: yeah, it actually implements a cool deicison tree on top of HTTP, which is what makes it unique. indeed, 'include Webmachine::Resource' would probably be a nicer pattern there.
<r0bgleeson>
the decision tree is from 'webmachine', erlang version, developed by the basho guys
<r0bgleeson>
i believe its used somewhat in riak as well
<r0bgleeson>
you couldn't replace rails with it or even try to(totally different application) but it's still a great toolkit for developing close to HTTP and in a way which makes you think in HTTP, more so than sinatra/other-micro framework
<r0bgleeson>
thats been my experience at least
<yxhuvud>
postmodern: I see two trends. One is support legacy forever (think libc, kernel, perl etc), and the other is to support as little as possible
<postmodern>
yxhuvud, the later sounds better
<yorickpeterse>
except when you're at the other end
cnivolle has joined #ruby-lang
<eam>
it depends on the nature of what lives above, and how stable its behavior needs to be
<yxhuvud>
depends on how much time you can spend on maintenance. legacy support for infrastructure like mail servers etc can be quite justified.
RobertBirnie has joined #ruby-lang
<postmodern>
certainly, there is infrastructure that must not change
<postmodern>
but we were originally discussing the OSes that students run
<eam>
I think we were discussing why update cycles vary between distros built for different use cases
perdido has joined #ruby-lang
<r0bgleeson>
apeiros: I also wrote a debugger for webmachine-ruby, you can step through each method in the decision tree(in real time) and see the request as it happens
<eam>
if you're an individual, or a startup with 1% your code and 99% someone else's code you probably don't care about disruptive updates because the surface area your code touches is small
<apeiros>
r0bgleeson: nice
Thanatermesis has quit [Read error: Connection reset by peer]
<eam>
but if you're doing heavy engineering you're going to care a lot about stable interfaces
panpainter has quit [Quit: panpainter]
<yorickpeterse>
postmodern: where does chruby by default installs it stuff (when installing from Git) ?
<yorickpeterse>
my arch linux package moves files around so I can't really compare
<postmodern>
yorickpeterse, /usr/local
<yorickpeterse>
and the main chruby.sh file?
<postmodern>
yorickpeterse, any package should probably install into /usr
<postmodern>
yorickpeterse, oh that would be /usr/local/share/chruby/chruby.sh
<yorickpeterse>
mine slaps it in /usr/share/chruby/chruby.sh
<yorickpeterse>
ah ok
<yorickpeterse>
ty
hotpancakes has joined #ruby-lang
patriciomacadden has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
relix has joined #ruby-lang
simoz3 has joined #ruby-lang
sandroqz has quit [Quit: Leaving the channel...]
ahmedelg_ has quit []
hotpanca_ has joined #ruby-lang
bantic has joined #ruby-lang
hotpancakes has quit [Ping timeout: 245 seconds]
imperator2 has joined #ruby-lang
patriciomacadden has joined #ruby-lang
hotpanca_ has quit [Ping timeout: 245 seconds]
Thanatermesis has joined #ruby-lang
Thanatermesis has quit [Changing host]
Thanatermesis has joined #ruby-lang
[_aeris_] is now known as _aeris_
Johz has joined #ruby-lang
panpainter has joined #ruby-lang
simoz3 has quit [Read error: Connection reset by peer]
__butch__ has quit [Quit: Leaving.]
mistym_ has joined #ruby-lang
mistym_ has quit [Remote host closed the connection]
alekst has quit [Quit: Computer has gone to sleep.]
nhmood has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
concertman has joined #ruby-lang
mistym has quit [Ping timeout: 245 seconds]
tylersmith has quit [Read error: Connection reset by peer]
tylersmith has joined #ruby-lang
simoz4 has joined #ruby-lang
havenwood has joined #ruby-lang
lfox has quit [Ping timeout: 246 seconds]
mistym has joined #ruby-lang
vlad_sta_ has joined #ruby-lang
enebo has joined #ruby-lang
<|jemc|>
so I was about to try to make a tool that would allow "reverse" usage of a Regexp with named captures
vlad_starkov has quit [Ping timeout: 276 seconds]
<darix>
|jemc|: reverse usage?
<|jemc|>
that is, given a hash-like object that can be referenced by key, be able to construct a string from a Regexp in which those keys' values are substituted into the named capture groups
<|jemc|>
obviously, you can't support the full set of what is possible in a regular expression
alekst has joined #ruby-lang
rynola___ has quit [Ping timeout: 272 seconds]
<|jemc|>
but basically the idea would be to be able to create one "specification" object for parsing and for creating strings
<|jemc|>
instead of /my string with (?<element>\w+)/ and "my string with #{element}"
<|jemc|>
anyway, I was going to try to create something like this unless anyone knows of something off the top of their head that addresses this concept?
<|jemc|>
ringing any bells?
<darix>
|jemc|: how would you express /foo: (?<value>\d+)/ in your language?
<darix>
how would you epxress simple things like ^$\A\z ...
concertman has quit [Remote host closed the connection]
<|jemc|>
you'd express it with a regexp in the same way - so it wouldn't be a different language
<darix>
o.O
concertman has joined #ruby-lang
<darix>
what goal are you trying to achieve?
<|jemc|>
it would just be something like:
<|jemc|>
/foo: (?<value>\d+)/.fill({value:88})
<|jemc|>
in which hash[value].to_s is validated to match \d+
<|jemc|>
or rather hash[:value].to_s
<darix>
o.O
<darix>
so you want to use regexps as format strings?
<|jemc|>
yeah so, that regexp.fill(match_data) would yield the original string
hotpancakes has joined #ruby-lang
<|jemc|>
but like I said, you can't support non-literal characters outside of named capture groups
<|jemc|>
but you don't need to if your regexps are crafted with this in mind
shinnya has joined #ruby-lang
deens has quit [Remote host closed the connection]
concertman has quit [Ping timeout: 246 seconds]
perdido has quit [Ping timeout: 246 seconds]
concertman has joined #ruby-lang
dingus_khan has quit [Remote host closed the connection]
ledestin has quit [Quit: ledestin]
mbj has quit [Quit: leaving]
CoreData has quit [Quit: CoreData]
mykoweb has quit [Remote host closed the connection]
DouweM has joined #ruby-lang
tylersmith has quit [Read error: Connection reset by peer]
tylersmith has joined #ruby-lang
imperator2 has quit [Ping timeout: 252 seconds]
michaeldeol has quit [Remote host closed the connection]
yalue has quit [Quit: Leaving]
cnivolle has quit [Ping timeout: 252 seconds]
cnivolle has joined #ruby-lang
plurt has quit [Quit: Computer has gone to sleep.]