tenderlove

- friends
837 link karma
316 comment karma
send messageredditor for
what's this?

TROPHY CASE


  • Two-Year Club

    Verified Email

SQL Window Functions and You by joshuadaveyin ruby

[–]tenderlove 2 points3 points ago

I know this is a nitpick, so please read this in Comic Book Guy voice:

ActiveSupport provides the group_by and sort_by methods on collections

Enumerable provides group_by and sort_by. You don't need ActiveSupport for these two methods:

>> RUBY_VERSION
=> "1.8.7"
>> [].method(:group_by)
=> #<Method: Array(Enumerable)#group_by>
>> [].method(:sort_by)
=> #<Method: Array(Enumerable)#sort_by>

Commercial support for Ruby on Windows by imperator96in ruby

[–]tenderlove 5 points6 points ago

How does this project relate to the Ruby installer? Why should I support this over the already existing (and free) project?

Doing the legwork to get gems working better on windows, and pushing changes up to ruby-core is admirable, and I would support that (and by support, I mean support with cash money). But supporting development of a commercial product that competes with an already existing (and free) project leaves me with many doubts. Especially since one of the maintainers of the free product is a ruby-core dev.

Can you explain why I should donate to this and not just send Luis a check?

Trying to wrap my head around 'require' by onsoin ruby

[–]tenderlove 8 points9 points ago

Seems like a load path problem. You need to tell ruby where to find files when you call "require". Try: ruby -I. test.rb to tell ruby to search the current directory when calls are made to require.

Rails / Ruby core committer 'tenderlove' finds his ultimate challenge. by kbedellin ruby

[–]tenderlove 23 points24 points ago

T-shirt, but no pants. Today is PANTS OFF DANCE OFF day.

Reddit, is this certification worth anything by Denommusin ruby

[–]tenderlove 26 points27 points ago

I MUST TAKE THIS.

Ruby is a LISP, so it should support lists by tenderlovein ruby

[–]tenderlove[S] 1 point2 points ago*

I should have mentioned, if you'd like turned on by default, change this line and recompile. I'm not sure what your stack traces will look like though. :(

Hope that helps!

EDIT: looks like you don't have to recompile. Just make sure to set compile_option before any code gets loaded:

code = <<-eocode
  class Tailcall
    def fact_helper(n, res)
      if n == 1
        res
      else
        fact_helper(n - 1, n * res)
      end
    end
    def fact(n)
      fact_helper(n, 1)
    end
  end
eocode

eval code.sub(/Tailcall/, 'NotTailcall')

RubyVM::InstructionSequence.compile_option = {
  :tailcall_optimization => true,
  :trace_instruction     => false
}

# Any code you want with TCO should happen after you've tweaked compile_option
eval code

FACTSIZE = 30_000

begin
  NotTailcall.new.fact(FACTSIZE)
rescue SystemStackError
  puts "DOH!"
end

begin
  Tailcall.new.fact(FACTSIZE)
rescue SystemStackError
  puts "DOH!"
end

Ruby is a LISP, so it should support lists by tenderlovein ruby

[–]tenderlove[S] 5 points6 points ago*

Actually, the VM does support TCO. It's just not enabled by default. Here is an example computing Factorials. The non TCO version will stack overflow where the other will not:

code = <<-eocode
  class Tailcall
    def fact_helper(n, res)
      if n == 1
        res
      else
        fact_helper(n - 1, n * res)
      end
    end
    def fact(n)
      fact_helper(n, 1)
    end
  end
eocode

option = {
  tailcall_optimization: true,
  trace_instruction: false,
}

iseq = RubyVM::InstructionSequence.new(code, "hello", nil, nil, option).eval

eval code.sub(/Tailcall/, 'NotTailcall')

FACTSIZE = 30_000

begin
  NotTailcall.new.fact(FACTSIZE)
rescue SystemStackError
  puts "DOH!"
end

begin
  Tailcall.new.fact(FACTSIZE)
rescue SystemStackError
  puts "DOH!"
end

EDIT: Fixed my words. Ugh.

Ruby is a LISP, so it should support lists by tenderlovein ruby

[–]tenderlove[S] 12 points13 points ago

Happy April 1st!

Company looking for Ruby programmers allows developers to apply via API by scottjsheain ruby

[–]tenderlove 12 points13 points ago

I'M A TEAPOT

Company looking for Ruby programmers allows developers to apply via API by scottjsheain ruby

[–]tenderlove 5 points6 points ago

I GET rest, I just don't POST it everywhere.

Company looking for Ruby programmers allows developers to apply via API by scottjsheain ruby

[–]tenderlove 9 points10 points ago

Does this mean Enterprise companies hire via SOAP requests?

RubyRags // Ruby and Ruby on Rails t-shirts for stylish Rubyists by sinisterffin ruby

[–]tenderlove 2 points3 points ago

Nice. I like undercover nerd shirts.

how i feel as a christian on reddit by that_one_christianin funny

[–]tenderlove 0 points1 point ago

I always assumed there was more than one person named Christian on reddit.

Be careful Ruby's OpenSSL "rulez" by jpozdenain ruby

[–]tenderlove 3 points4 points ago*

Ya. It looks like it's been deprecated since at least 2004. Probably needs better docs and for more people to run ruby with -w, otherwise the rb_warn will not show up.

Edit:

In fact, I don't think the code path shown in this article will actually touch the "Ruby rulez" part. You have to call the encrypt method with an argument in order to hit the warning. Here is the original code from the article which produces no warnings:

require 'openssl'

@cipher = OpenSSL::Cipher.new('aes-256-cbc')
@cipher.encrypt

@cipher.key = @cipher.random_key
@cipher.iv  = @cipher.random_iv # bye bye "OpenSSL for Ruby rulez!"


@cipher.update("I'm gonna be encrypted")
output = @cipher.final

My updated version that actually hits the rb_scan_args code path:

require 'openssl'

@cipher = OpenSSL::Cipher.new('aes-256-cbc')
@cipher.encrypt 'foo'

@cipher.key = @cipher.random_key
@cipher.iv  = @cipher.random_iv # bye bye "OpenSSL for Ruby rulez!"


@cipher.update("I'm gonna be encrypted")
output = @cipher.final

Is this a reasonable rate? by highway61in rails

[–]tenderlove 1 point2 points ago

I have ten degrees of awesome. ;-)

Profiling Rails startup with DTrace by tenderlovein ruby

[–]tenderlove[S] 0 points1 point ago

ya, that's why I mentioned that we should fix this in Bundler. If Bundler could better understand the checked out repository, or even generate a gemspec when it checked out (or updated) a git repo, then we wouldn't need to have the gemspec checked in. I'd prefer to not check in the gemspec, but if I want to work with bundler and edge deps, I must.

Profiling Rails startup with DTrace by tenderlovein ruby

[–]tenderlove[S] 0 points1 point ago

Look at my fork on github and figure out how to integrate systemtap! ;-)

Profiling Rails startup with DTrace by tenderlovein ruby

[–]tenderlove[S] 0 points1 point ago

I think using a dir glob would probably be slightly slower than the generated gemspec, but definitely faster than the subshell. I just prefer using a generated gemspec because file add / delete don't happen that often, and I always mess up my dir globs (editor temp files, random scripts I leave in the repo, etc). I think I might be a messy programmer! :(

Connection Management in ActiveRecord by retardoin ruby

[–]tenderlove 6 points7 points ago

sorry, this has been archived and can no longer be voted on

FFFUUUUUUUUU. I always forget to submit my own posts. ;-)

I bought something I don't need, and now I don't know what to do with it. by tenderlovein firstworldproblems

[–]tenderlove[S] 2 points3 points ago

sorry, this has been archived and can no longer be voted on

Sounds like too much work. Can I hire someone to do that for me?

view more: next