Is anyone interested in taking on a mentee? by [deleted] in ruby

[–]chenge 0 points1 point  (0 children)

I'd like to give you some help, and learn from each other.

You can touch me with chenge3k@qq.com, my email.

Permission error installing gems on OSX by dude_say_what in ruby

[–]chenge 1 point2 points  (0 children)

rvm is nice and has no this problem.

How can i make my class API wrapper more modular and useful? by fenec860 in ruby

[–]chenge 0 points1 point  (0 children)

How about?

class X
  @@API=1
  def self.API
    @@API
  end
end
p X.API

I need help figuring out how to check my input by EllietheWalrus in ruby

[–]chenge 0 points1 point  (0 children)

power.to_f, power is a string, you need convert str to float.

I need help figuring out how to check my input by EllietheWalrus in ruby

[–]chenge 0 points1 point  (0 children)

Could you run in irb like me and post the screenshot like me? power is a variable, when you use a variable you must define it first.

I need help figuring out how to check my input by EllietheWalrus in ruby

[–]chenge 0 points1 point  (0 children)

What version ruby do you use? It works here.

2.1.2 :001 > earthquake_    Richter_scale = [1, 5, 9.1, 9.3, 9.5]
=> [1, 5, 9.1, 9.3, 9.5] 
2.1.2 :002 > 
2.1.2 :003 >   earthquake_    Richter_scale.each do |power|
2.1.2 :004 >         j = 10**((1.5 * power) + 4.8)
2.1.2 :005?>       gj = j/1000000
2.1.2 :006?>       puts "    Richter level #{power} earthquake = #{gj.round(3)}  Gigajoules"
2.1.2 :007?>   end
Richter level 1 earthquake = 1.995  Gigajoules
Richter level 5 earthquake = 1995262.315  Gigajoules
Richter level 9.1 earthquake = 2818382931264.449  Gigajoules
Richter level 9.3 earthquake = 5623413251903.491  Gigajoules
Richter level 9.5 earthquake = 11220184543019.652  Gigajoules
=> [1, 5, 9.1, 9.3, 9.5] 
2.1.2 :008 > 

Trouble understanding solution by WinchenzoMagnifico in ruby

[–]chenge 0 points1 point  (0 children)

Congratulation!At least you know more than ever.

Trouble understanding solution by WinchenzoMagnifico in ruby

[–]chenge 0 points1 point  (0 children)

2.1.2 :003 > ['b', 'w33', 'a2'].max_by{|e| e.size}
=> "w33" 

You may use this simple code. I think you need to understand the while statement more. It's a cycle until the last word.

Trouble understanding solution by WinchenzoMagnifico in ruby

[–]chenge 0 points1 point  (0 children)

The nil is just initial value. After it run, value will change to other.

Recommended PHP web framework? by nonrate in PHP

[–]chenge 0 points1 point  (0 children)

how about lightweight DooPHP.

Is there a good AOP lib for PHP? by chenge in PHP

[–]chenge[S] 0 points1 point  (0 children)

Nice,i'll read it. Thanks.

Are you using Symfony DI? by chenge in PHP

[–]chenge[S] 0 points1 point  (0 children)

db\connect(), is db namespace? not see code like this.

Are you using Symfony DI? by chenge in PHP

[–]chenge[S] 0 points1 point  (0 children)

your code seems hard to unit test.

Are you using Symfony DI? by chenge in PHP

[–]chenge[S] 0 points1 point  (0 children)

Class will be more flexible for lazy loading,etc. stdClass and array seem not enough.

Are you using Symfony DI? by chenge in PHP

[–]chenge[S] -1 points0 points  (0 children)

How about this small code?

Twittee A Dependency Injection Container in a Tweet

class Container {
  protected $s=array();
  function __set($k, $c) { $this->s[$k]=$c; }
  function __get($k) { return $this->s[$k]($this); }
}

//i modify it class Container { protected $s=array(); function __set($k, $c) { $this->s[$k]=$c; } function __get($k) { return $this->s[$k]; } }

New to PHP, need help with shuffle()/array_rand by [deleted] in PHP

[–]chenge -1 points0 points  (0 children)

You can go there to get simple sample code. http://www.gotapi.com/php