Search this blog

mercredi 17 février 2010

Perl: how to shuffle an array

If you either have Perl 5.8.0 or later installed, or if you have Scalar-List-Utils 1.03 or later installed, you can say:

use List::Util 'shuffle'; @shuffled = shuffle(@list);

mardi 16 février 2010

VMware Player : running Windows and Lunix simultaneously

Objective: using Windows XP and Lunix Ubuntu 9.10 simultaneously.
Requirements: you must be used to linux to apply some instructions below.


General idea:

Using your default OS (ex. Win XP), you will be able to run inside a window another OS with full capabilities (ex. linux). For instance, this will allow you to use Microsoft Office and Endnote, and simultaneously a terminal connected by ssh or emacs. For that, we need a virtual machines emulator (i.e. VMware Player) and a virtual appliance (i.e. a full OS prepared for VMware).

Definitions:
  • host system: your main operating system (OS) (here Windows XP).
  • guest system: the secondary operating system installed inside and ran by the host system (here Ubuntu 9.10).
Download software for free:
  • VMware Player 3.0: 
    • go to www.vmware.com
    • register and download VMware Player 3.0 for the host OS.
  • Ubuntu 9.10 virtual appliance:
    • go to www.vmware.com/appliances/
    • search for ubuntu 9.10
    • download from LINHOST: Ubuntu 9.10 Desktop installation with VMware Tools (other OS are available)
    • don't forget to note the default user and password from the download page (may be 'vadmin' and 'sector7g' respectively).
Installation:
  • Install VMware Player in Windows XP.
  • decompress the Ubuntu file in Mes Documents\My Virtual Machines directory.
Running:
  • Run VMware Player and open Ubuntu 9.10.vmx from the Ubuntu directory.
  • Ubuntu will boot inside VMware Player, then use default user name and password to log in. Be careful of the keyboard language on the bottom of the login screen.
Configuration:
  • Configuration using the VM menu of VMware Player
    • You can activate and configure available hardware for the guest (ex. Memory and hard disk). 
    • Check Network connection. using NAT may be the simplest. 
    • In Options tab you will be able to configure a shared folder (from Windows) between the host and the guest. 
    • Some options may be available only if the virtual machine is off. 
  • Linux configuration
    • You should create a new Ubuntu user with administrative rights and delete the default one.
    • Add this line to /etc/fstab as administrator to mount the shared folder automatically:
      • .host:/         /mnt/hgfs       vmhgfs  defaults,ttl=5 0 0
      • Installing VMTools (they help the communication between the host and the guest): see details below.
      • When restarting enter the BIOS and enable Virtualization features of your CPU if available.
      Recommendations and remarks:
      • To stop the virtual machine use the VM menu and select Power/Suspend. It will be very fast to stop and to restart next time.
      • Drag and drop of files or text should work between the host and the guest. 
      • Check your Windows mouse drivers to be sure that buttons are properly configured (especially the middle click).


      Details on installing VMTools:

      Lucid Lynx Ubuntu 10.04:
      • apt-get install --no-install-recommends linux-headers-virtual open-vm-dkms open-vm-tools
      • restart
      Alternative method (Linux kernel >= 2.6.31) (http://langui.sh/2009/10/05/ubuntu-9-10-in-vmware/):
      • sudo apt-get install open-vm-tools build-essential open-vm-toolbox
      • sudo m-a
        • Choose select and activate open-vm
        • Click okay, then select build
        • Once it completes it will ask if you want to install. Choose yes, then quit out of m-a and reboot.
        • After a reboot check to see that the vm modules inserted into the kernel properly.
          • lsmod | grep vm
          • The 4 following modules should be listed: vmsync,vmmemctl, vmhgfs, vmci.
      Alternative method for LINHOST appliances:
      • sudo vmware-config-tools.pl
      • /usr/bin/vmware-user
      • then restart the virtual machine

        vendredi 12 février 2010

        Word 2007: Raccourci clavier pour coller sans mise en forme

        Créer une nouvelle macro dans le modèle global normal.dotm

        Sub PasteNoFormat()
        Selection.PasteAndFormat (wdFormatPlainText)
        End Sub
        Affecter un raccourci clavierà cette macro

        Bouton Office / Options Word / Personaliser / Raccourcis clavier Personaliser ...

        Selectionner Catégorie Macro et Commande PasteNoFormat
        Choisir nouvelle touche de raccourci, ex. Ctrl+Shift+V

        Modifier la résolution d'une diapositive que vous exportez en tant qu'image dans PowerPoint

        Cet article explique étape par étape comment modifier le nombre de points par pouce (paramètres ppp) de la résolution des diapositives exportées, par l'ajout d'une nouvelle valeur de Registre pour Microsoft Office PowerPoint 2003 ou pour Microsoft Office PowerPoint 2007. Cet article décrit également comment exporter une diapositive en tant qu'image.

        Remarque: Le tableau ci-après répertorie les paramètres par défaut pour une diapositive que vous exportez en tant qu'image.

        Pixels : 960 x 720
        Points par pouce (ppp) : 96 ppp (horizontal et vertical)

        Ajout de paramètres de Registre
        Pour exporter une diapositive en tant qu'image avec une résolution supérieure à 96 ppp (par défaut), vous devez ajouter une valeur de Registre. Pour cela, procédez comme suit :

        1. Fermez toutes les applications Microsoft Windows.
        2. Cliquez sur Démarrer, puis sur Exécuter.
        3. Dans la zone Ouvrir, tapez regedit, puis cliquez sur OK.
        4. Développez l'arborescence du Registre jusqu'à la clé concernant la version de PowerPoint que vous utilisez : 
          • PowerPoint 2003: HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\PowerPoint\Options
          • PowerPoint 2007: HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\PowerPoint\Options
        5. La clé Options étant sélectionnée, pointez sur Nouveau dans le menu Edition, puis cliquez sur Valeur DWORD.
        6. Tapez ExportBitmapResolution, puis appuyez sur ENTRÉE.
        7. Avec la valeur ExportBitmapResolution sélectionnée, cliquez sur Modifier dans le menu Edition.
        8. Dans la zone Données de la valeur, tapez la valeur de résolution de votre choix, en vous aidant du tableau ci-dessous.
        9. Cliquez sur Décimal, puis sur OK.
        10. Dans le menu Fichier, cliquez sur Quitter pour quitter l'Éditeur du Registre.

        Remarque Le paramètre de résolution maximale pour l'exportation PowerPoint 2003 est de 307 ppp.

        Valeur hexadécimale / Pixels (horizontal x vertical) / Points par pouce (horizontal et vertical)
        50 / 500 x 375 / 50 ppp
        96 (par défaut) / 960 x 720 / 96 ppp
        100 / 1000 x 750 / 100 ppp
        150 / 1 500 x 1 125 / 150 ppp
        200 / 2 000 x 1 500 / 200 ppp
        250 / 2 500 x 1 875 / 250 ppp
        300 / 3 000 x 2 250 / 300 ppp

        Exportation d'une diapositive PowerPoint en tant qu'image
        Pour exporter une diapositive PowerPoint en tant qu'image, procédez comme suit :

        1. Démarrez PowerPoint et ouvrez votre présentation de diapositives.
        2. Ouvrez la diapositive à exporter.
        3. Dans le menu Fichier, cliquez sur Enregistrer sous.
        4. Dans la zone Type, sélectionnez le type d'image dans lequel vous voulez exporter votre diapositive, puis cliquez sur Enregistrer.

        Par exemple, dans la zone Type, sélectionnez l'une des valeurs suivantes :
        • Format GIF Graphics Interchange (*.gif)
        • Fichier d'échange JPEG (*.jpg)
        • Format PNG Portable Network Graphics (*.png)
        • Format TIFF (*.tif)
        • Bitmap indépendante du périphérique (*.bmp)
        • Métafichier Windows (*.wmf)
        • Métafichier Windows amélioré (*.emf)
        Remarque Vous pouvez également modifier l'emplacement où vous enregistrez l'image dans la zone Enregistrer dans. Vous pouvez également modifier le nom de l'image dans la zone Nom du fichier.


        Restrictions
        Lorsque vous définissez la valeur de Registre ExportBitmapResolution afin de modifier la résolution d'exportation d'une image de Microsoft Office PowerPoint 2003, vous devez tenir compte d'une limitation. Le paramètre de résolution maximale utilisé par Office PowerPoint 2003 est de 3 072 pixels mesurés à partir du bord le plus long de la diapositive. Par exemple, la diapositive standard 10x7.5" aurait la valeur PPP maximale 307. (10x307) = 3070. La mesure de 3 070 pixels est dans la limite de 3 072. Tout paramètre PPP supérieur à 307 pour la diapositive standard reviendrait à la limite 3 072.
        Réduire ce tableauAgrandir ce tableau

        Valeur hexadécimale : 307
        Pixels (horizontal x vertical) : 3 072 x 2 304
        Points par pouce (horizontal et vertical) : 307 ppp

        Remarque La limite de 3 072 pixels s'applique également à l'enregistrement par programmation d'une diapositive. Le code conçu pour l'exportation d'une diapositive selon une mesure en pixels donnée sera également limité à 3 072 pixels.

        Par exemple, ActiveWindow.Selection.SlideRange(1).export "c:\filename.jpg","JPG",4000,3000 permettra l'exportation par programmation en une image à 3 072x2 304 pixels.