PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Ruby on zLinux
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Ruby on zLinux

Réponse
 
LinkBack Outils de la discussion
Vieux 27/05/2008, 12h20   #1
Eric K. Dickinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Ruby on zLinux

We are trying to install the MySQL gem on RH51
running under zVM.


Install MySQL gem as follows:
gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config

It errors out with

cat /mysql-2.5.1/mkmf.log | less

cc1: error: unrecognized command line option "-mesa-mzarch"

There appears to be a space missing between the -mesa and
-mzarch.

Can I add the space? and if so where?

thank you

eric


  Réponse avec citation
Vieux 28/05/2008, 12h22   #2
Eric K. Dickinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ruby on zLinux

Eric K. Dickinson wrote:
> We are trying to install the MySQL gem on RH51
> running under zVM.
>
>
> Install MySQL gem as follows:
> gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config
>
> It errors out with
>
> cat /mysql-2.5.1/mkmf.log | less
>
> cc1: error: unrecognized command line option "-mesa-mzarch"
>
> There appears to be a space missing between the -mesa and
> -mzarch.
>
> Can I add the space? and if so where?
>
> thank you
>
> eric
>
>

Am I in the right thread for this?

Should there be another group/ML that
where I should post this?

eric



  Réponse avec citation
Vieux 28/05/2008, 21h07   #3
Hassan Schroeder
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ruby on zLinux

On Wed, May 28, 2008 at 4:22 AM, Eric K. Dickinson
<eric.dickinson@nih.gov> wrote:

> Am I in the right thread for this?


Yes, but it's such a trivial issue --

>> cc1: error: unrecognized command line option "-mesa-mzarch"
>>
>> There appears to be a space missing between the -mesa and
>> -mzarch.


>> Can I add the space?


Of course; why would you even hesitate?

>> and if so where?


Wherever `find` and `grep` turn up that string, I'd think :-)

FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

  Réponse avec citation
Vieux 29/05/2008, 12h45   #4
Eric K. Dickinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ruby on zLinux

Hassan Schroeder wrote:
> On Wed, May 28, 2008 at 4:22 AM, Eric K. Dickinson
> <eric.dickinson@nih.gov> wrote:
>
>> Am I in the right thread for this?

>
> Yes, but it's such a trivial issue --
>
>>> cc1: error: unrecognized command line option "-mesa-mzarch"
>>>
>>> There appears to be a space missing between the -mesa and
>>> -mzarch.

>
>>> Can I add the space?

>
> Of course; why would you even hesitate?
>
>>> and if so where?

>
> Wherever `find` and `grep` turn up that string, I'd think :-)
>
> FWIW,


I have been looking for it with find and grep.

I have not been able to find where the line is
assembled from.

I will not hesitate once I find it.

Thank you

eric

  Réponse avec citation
Vieux 29/05/2008, 22h57   #5
S.D
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP to Ruby (associative array to Hash)

[Note: parts of this message were removed to make it a legal post.]

In the following PHP function, both 'types' and 'groups' are associative
arrays. I'm trying to rewrite this function in Ruby, using Hashes and I
haven't yet got it right. If someone with some insight into PHP and Ruby
could give it a look and see where my current code might be incorrect, I
'd appreciate any pointers that might correct the results. The PHP
function is working; the Ruby version is not (yet) working. TIA for any
tips, criticism and suggestions that you can submit.

-- Steve

The original PHP function:
$this->types = array(
'aac' => 'audio/x-aac',
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asf' => 'video/x-ms-asf',
'asx' => 'video/x-ms-asx',
'avi' => 'video/avi'
);

$groups['office'] =
array('csv','doc','dot','pdf','pot','pps','ppt','r tf','txt','xls');
$groups['image'] =
array('ai','bmp','dxf','eps','gif','ico','jpg','jp e','jpeg','pdf','png','ps','swf','tif','tiff','wmf ');
$groups['compressed'] =
array('bin','bz','bz2','gz','sit','tar','tgz','z', 'zip');
$groups['video'] =
array('asf','asx','avi','mov','mpg','mpeg','mp4',' qt','ra','ram','swf','wmv');
$groups['audio'] = array('mp3','m4a','ra','ram','wav','wma');
$groups['web'] =
array('css','gif','ico','jpg','jpeg','js','htm','h tml','pdf','php','phps','png','shtml','sql');
$groups['media'] =
array('mp3','jpg','mpg','mpeg','vob','avi','wma',' wmv','bmp','jpeg','aac','wav');

/*
* Return array of mime types
*
* @param string/bool $group_type
* @return array
*/
public function getTypes($group_type=false) {
if(!$group_type) {
return $this->types;
}
else {
if(array_key_exists($group_type,$this->groups)) {
foreach($this->types as $key => $mt) {
if(in_array($key,$this->groups[$group_type])) {
$types[$key] = $mt;
}
}
return $types;
}
else {
return false;
}
}
}

The current Ruby translated function:
types = { 'aac' => 'audio/x-aac',
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asf' => 'video/x-ms-asf',
'asx' => 'video/x-ms-asx',
'avi' => 'video/avi'
}
groups = {'office' =>
['csv','doc','dot','pdf','pot','pps','ppt','rtf','t xt','xls'],
'image' =>
['ai','bmp','dxf','eps','gif','ico','jpg','jpe','jp eg','pdf','png','ps','swf','tif','tiff','wmf'],
'compressed' =>
['bin','bz','bz2','gz','sit','tar','tgz','z','zip'],
'video' =>
['asf','asx','avi','mov','mpg','mpeg','mp4','qt','r a','ram','swf','wmv'],
'audio' => ['mp3','m4a','ra','ram','wav','wma'],
'web' =>
['css','gif','ico','jpg','jpeg','js','htm','html',' pdf','php','phps','png','shtml','sql'],
'media' =>
['mp3','jpg','mpg','mpeg','vob','avi','wma','wmv',' bmp','jpeg','aac','wav']
}
#---------------------------------
# Return array of mime types
#---------------------------------
def getTypes(grp_type)
res_types=Hash.new
if(!grp_type) then
@types
else
if(groups.has_key?(grp_type)) then
types.each do |k,v|
if(groups[grp_type].has_value?(v)) then
res_types[k]=v
end
end
else
res_types=false
end
end
res_types
end


  Réponse avec citation
Vieux 29/05/2008, 23h44   #6
Jano Svitok
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP to Ruby (associative array to Hash)

On Thu, May 29, 2008 at 11:57 PM, S.D <s.d@comcast.net> wrote:
> In the following PHP function, both 'types' and 'groups' are associative
> arrays. I'm trying to rewrite this function in Ruby, using Hashes and I
> haven't yet got it right. If someone with some insight into PHP and Ruby
> could give it a look and see where my current code might be incorrect, I 'd
> appreciate any pointers that might correct the results. The PHP function is
> working; the Ruby version is not (yet) working. TIA for any tips, criticism
> and suggestions that you can submit.
>
> -- Steve
>
> The original PHP function:
> $this->types = array(
> 'aac' => 'audio/x-aac',
> 'ai' => 'application/postscript',
> 'aif' => 'audio/x-aiff',
> 'aiff' => 'audio/x-aiff',
> 'asf' => 'video/x-ms-asf',
> 'asx' => 'video/x-ms-asx',
> 'avi' => 'video/avi'
> );
>
> $groups['office'] =
> array('csv','doc','dot','pdf','pot','pps','ppt','r tf','txt','xls');
> $groups['image'] =
> array('ai','bmp','dxf','eps','gif','ico','jpg','jp e','jpeg','pdf','png','ps','swf','tif','tiff','wmf ');
> $groups['compressed'] =
> array('bin','bz','bz2','gz','sit','tar','tgz','z', 'zip');
> $groups['video'] =
> array('asf','asx','avi','mov','mpg','mpeg','mp4',' qt','ra','ram','swf','wmv');
> $groups['audio'] = array('mp3','m4a','ra','ram','wav','wma');
> $groups['web'] =
> array('css','gif','ico','jpg','jpeg','js','htm','h tml','pdf','php','phps','png','shtml','sql');
> $groups['media'] =
> array('mp3','jpg','mpg','mpeg','vob','avi','wma',' wmv','bmp','jpeg','aac','wav');
>
> /*
> * Return array of mime types
> *
> * @param string/bool $group_type
> * @return array
> */
> public function getTypes($group_type=false) {
> if(!$group_type) {
> return $this->types;
> }
> else {
> if(array_key_exists($group_type,$this->groups)) {
> foreach($this->types as $key => $mt) {
> if(in_array($key,$this->groups[$group_type])) {
> $types[$key] = $mt;
> }
> }
> return $types;
> }
> else {
> return false;
> }
> }
> }
>
> The current Ruby translated function:

- types = { 'aac' => 'audio/x-aac',
+ TYPES = { 'aac' => 'audio/x-aac', # if it won't change, make it a constant
> 'ai' => 'application/postscript',
> 'aif' => 'audio/x-aiff',
> 'aiff' => 'audio/x-aiff',
> 'asf' => 'video/x-ms-asf',
> 'asx' => 'video/x-ms-asx',
> 'avi' => 'video/avi'
> }

- groups = {'office' =>
+ GROUPS = {'office' => # the same
> ['csv','doc','dot','pdf','pot','pps','ppt','rtf','t xt','xls'],
> 'image' =>
> ['ai','bmp','dxf','eps','gif','ico','jpg','jpe','jp eg','pdf','png','ps','swf','tif','tiff','wmf'],
> 'compressed' => ['bin','bz','bz2','gz','sit','tar','tgz','z','zip'],
> 'video' =>
> ['asf','asx','avi','mov','mpg','mpeg','mp4','qt','r a','ram','swf','wmv'],
> 'audio' => ['mp3','m4a','ra','ram','wav','wma'],
> 'web' =>
> ['css','gif','ico','jpg','jpeg','js','htm','html',' pdf','php','phps','png','shtml','sql'],
> 'media' =>
> ['mp3','jpg','mpg','mpeg','vob','avi','wma','wmv',' bmp','jpeg','aac','wav']
> }
> #---------------------------------
> # Return array of mime types
> #---------------------------------

def get_types(group_type = nil) # in ruby lowercase_and_underscores
are used for methods and variables by convention
return TYPES unless group_type # == if !group_type == if group_type.nil?
return false unless GROUPS.has_key?(group_type) # no need to write
'then' or parentheses
GROUPS[group_type].inject({}) {|types, ext| types[ext] =
TYPES[ext] ; TYPES }
end

or replace the last line with

Hash[*GROUPS[group_type].collect {|ext| ext, types[ext]}.flatten] #
alternative 2

or

def ...
case group_type
when nil, false
TYPES
when *GROUP.keys
GROUPS[group_type].inject({}) {|types, ext| types[ext] =
TYPES[ext] ; TYPES }
else
false
end
end

WARNING: not tested code, might contain bugs!

  Réponse avec citation
Vieux 30/05/2008, 11h23   #7
Jörg W Mittag
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP to Ruby (associative array to Hash)

S.D wrote:
> In the following PHP function, both 'types' and 'groups' are associative
> arrays. I'm trying to rewrite this function in Ruby, using Hashes and I
> haven't yet got it right. If someone with some insight into PHP and Ruby
> could give it a look and see where my current code might be incorrect, I
> 'd appreciate any pointers that might correct the results. The PHP
> function is working; the Ruby version is not (yet) working. TIA for any
> tips, criticism and suggestions that you can submit.
>
> -- Steve
>
> The original PHP function:

[...]
> public function getTypes($group_type=false) {
> if(!$group_type) {
> return $this->types;
> }
> else {
> if(array_key_exists($group_type,$this->groups)) {
> foreach($this->types as $key => $mt) {
> if(in_array($key,$this->groups[$group_type])) {
> $types[$key] = $mt;
> }
> }
> return $types;
> }
> else {
> return false;
> }
> }
> }
>


Hi Steve!

This is my take. I shuffled things around a bit, e.g. using constants
instead of variables, but you'll figure it out ...

def types group = nil
return TYPES unless group
return nil unless GROUPS.include? group
Hash[*TYPES.select {|suffix, mime_type| GROUPS[group].include? suffix}.flatten]
end

HTH,
jwm
  Réponse avec citation
Vieux 30/05/2008, 21h46   #8
Todd Benson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP to Ruby (associative array to Hash)

On Fri, May 30, 2008 at 11:50 AM, S.D <s.d@comcast.net> wrote:
> Great example! I don't quite understand the pointer(*) notation you are
> using in ruby. How would "Hash[*TYPES.select" differ from
> "Hash[TYPES.select"?


* is not pointer notation here. One way to think about it is that it
takes an Enumerable object and turns it into a list of individual
objects, ala...

[1, 2, 3] #one thing

...becomes...

1, 2, 3 #three things

hth,
Todd

  Réponse avec citation
Vieux 30/05/2008, 21h46   #9
Jano Svitok
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP to Ruby (associative array to Hash)

On Fri, May 30, 2008 at 6:50 PM, S.D <s.d@comcast.net> wrote:
> Great example! I don't quite understand the pointer(*) notation you are
> using in ruby. How would "Hash[*TYPES.select" differ from
> "Hash[TYPES.select"?
> Is one a pointer to the Hash and the other the Hash itself? I thought Ruby
> did not have pointers.


* is not a pointer, it is so-called splat operator (google: ruby
splat). It "expands" arrays.
When you call f(*array) and array is [1,2,3] it has the same effect as
calling f(1,2,3).
Another useful pattern is:

COLORS = ['red', 'green', 'blue']
DAYS = ['monday', sunday']

case word
when *COLORS
puts "#{word} is a Color!"
when *DAYS
puts "#{word} is a Day!"
end

For better explanation see google.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18803 seconds with 17 queries