Rechercher dans ce blog

jeudi 30 avril 2009

rsync super cp

Pour copier un répertoire avec rsync et en faire la synchronisation s'il existe déjà j'utilise rsync avec ces options

%rsync -au --delete dir_source dir_destination

-a archive mode, equivalent to -rlptgoD

-u, --update update only (don't overwrite newer files)

--delete delete files that don't exist on sender

le -u sert surtout à préserver les fichiers qui auraient été modifié dans le dossier de destination (ce qui en principe ne se produit pas... mais les principes...)

--delete permet de nettoyer le dir_destination des fichiers qui ne sont plus dans le dir_source.

ATTENTION --delete est une option DANGEREUSE !

Bien s'assurer de faire la copie dans le bon répertoire sans quoi tout le répertoire de destination sera effacé ainsi que les sous-répertoires.

Pour inhiber une option incluse dans a faire --no-Option

par exemple par de chown et chgrp --no-o --no-g ce qui évite d'avoir un message d'erreur quand le fichier de destination est mounté avec un owner et pas de droit pour changer de owner tandis que rsync tourne en root.

linux ubuntu 8.04 hosts.access hosts.deny

Pour autoriser le telnetd et sshd depuis l'extérieur

On autorise de façon limitée dans le allow et on interdit tout le reste dans deny. Ce qui ne matche pas dans allow est bloqué.

hosts.allow

telnetd:ALL

sshd:ALL

ALL: LOCAL 10.0.1.0/24

hosts.deny

ALL: ALL

Se souvenir que sans fichier le contrôle d'accès est off

ACCESS CONTROL FILES

   The access control software consults two files. The search stops at the  first match:

   · Access will be granted when a (daemon,client) pair matches an  entry in the /etc/hosts.allow file.

   · Otherwise, access will be denied when a (daemon,client) pair  matches an entry in the /etc/hosts.deny file.

   · Otherwise, access will be granted.

installer vim complet ubuntu 8.04 server

Pour installer une version plus complète de vim qui supporte la coloration syntaxique :

apt-get install vim

Editer ensuite

/etc/vimrc

syntax on

set visualbell pour ne pas avoir le bip sur à chaque double esc, etc.

mercredi 29 avril 2009

wordpress afficher le nombre de messages publiés dans la journée

Script php à placer dans header.php pour afficher le nombre de messages publiés le jour même.

J'ai adapté le script initial de http://www.wprecipes.com/fromtheold-asked-how-to-display-how-many-post-have-been-published-today, parce que celui-ci faisait un calcul sur les dernières 24 heures (now - 24H), ce qui n'est pas ce que je voulais.

Je fais une query sur la date des messages et compte ceux qui sont entre le début du jour et now...

Comme en même temps je voulais que le nombre de messages ne soit affiché que sur la page d'accueil, j'ai mis un test pour la home_page

<?php /* If this is the frontpage */ if ( is_home ( ) ) { ?>                 <?php $today = date ( "Y-m-d 0:0:0" ) ; //Today's date $now = date ( "Y-m-d H:i:s" ) ; //now date $numposts = $wpdb->get_var ( "SELECT COUNT ( * ) FROM $wpdb->posts WHERE post_status = 'publish' AND post_date > '$today' AND post_date < '$now'" ) ; if ( $numposts >0 ) {     echo $numposts.' bulletins post&eacute;s aujourd&#8217;hui'; } else {     echo "Pas de bulletin post&eacute; aujourd&#8217;hui";      } ?> <?php } ?>

samedi 25 avril 2009

files directory listing to html page with hyperlinks - perl script

Petit script que j'ai écrit pour créer une page htlm qui liste les entrées d'un répertoire et crée les liens vers les fichiers.

C'est un script perl rudimentaire mais qui fait ce dont j'avais besoin. Avant de l'écrire je me suis beaucoup énervé à chercher sur le net un script aussi basique et élémentaire sans rien trouver !

#!/usr/bin/perl # Script pour lister sur une page html les entrees d'un repertoire # avec hyperliens vers les fichiers # Version 0.1 - 2009_04_25 # Le href pointe toujours vers un path relatif au dir qui contient les # fichiers listes. La page html doit donc etre placee dans le meme # dossier que les fichiers sur le serveur. @ARGV or die "Usage : %dir2html somedir > liste.html\n"; $some_dir = shift @ARGV; opendir ( DIR, $some_dir ) || die "can't opendir $some_dir: $!"; # Formatage avec des paragraphes plutot que liste a bulle #@dots = map "<p><a href=\"$_\">$_<\/a><\/p>", grep ! /^\./,   readdir ( DIR ) ; # Formatage en liste # J'exclus de la liste de sortie par un simple grep html|htm la page generee # et donc du meme coup tous les fichiers avec ces extensions @dots = map "<li><a href=\"$_\">$_<\/a><\/li>^M", grep ! /.htm ( l ) ?$/, grep ! /^\./,   readdir ( DIR ) ; closedir DIR; print <<EOF; <html> <head>   <meta content="text/html; charset=UTF-8" http-equiv="content-type">   <title>Liste des fichiers du repertoire $some_dir </title>   <meta name="robots" content="noindex, nofollow, noarchive"> </head> <body> <ul> EOF print @dots; print <<EOF; </ul> </body> </html> EOF

jeudi 16 avril 2009

ffmpegX Tip - Codec type mismatch

extract from 

http://youmakemedia.com/2007/03/26/ffmpegx-tip-codec-type-mismatch/

Thanks to the author : Chris

ffmpegX is one of the most useful tools in a content producer’s arsenal. It’s fast, easy, and powerful beyond belief. Unfortunately, it has the occasional error that may make you scream! When a client needs a video in a certain format and you are getting error messages, it isn’t fun.

One such error that I frequently encounter (especially when converting files to Flash Video) is this one: Codec type mismatch for mapping #0.0 -> #0.0 See, normally video comes before audio in the layout and organization of a multimedia file. Sometimes though (and it’s happening more frequently), codec creators are switching things up for a bit of fun. They’re putting the audio first. I can only assume it’s somehow related to compression - but this switch causes ffmpegX to freak out and cease encoding. Luckily, this is a one check-box fix. Simply open your file and navigate to the audio tab. Then check the box titled “Invert Mapping”. This will let ffmpegX know about the alternate structure of your file, and make the appropriate changes. Below is a screenshot that highlights the audio tab with Invert Mapping selected. Traditional FFmpeg, for *NIX platforms, offers this feature as well, albeit in a more complex manner. From the official documentation: You can encode to several formats at the same time and define a mapping from input stream to output streams: ffmpeg -i /tmp/a.wav -ab 64k /tmp/a.mp2 -ab 128k /tmp/b.mp2 -map 0:0 -map 0:0 Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. ‘-map file:index’ specifies which input stream is used for each output stream, in the order of the definition of output streams.

mercredi 15 avril 2009

Gnumeric mac os X installer / désinstaller - macport

#port install gnumeric

########################################################### # A startup item has been generated that will aid in # starting dbus with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo launchctl load -w /Library/LaunchDaemons/org.macports.dbus.plist ########################################################### ############################################################################## # It is absolutely necessary for dbus enabled programs to work to execute # # launchctl load /Library/LaunchAgents/org.freedesktop.dbus-session.plist # # once for every user. Don't use 'sudo', else it will work only for root! # You also have to unload it before deactivating/uninstalling this software! ############################################################################## ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xml/docbook/4.1.2/catalog.xml". ###################################################################### ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xml/docbook/4.2/catalog.xml". ###################################################################### ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xml/docbook/4.3/catalog.xml". ###################################################################### ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xml/docbook/4.4/catalog.xml". ###################################################################### ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xml/docbook/4.5/catalog.xml". ###################################################################### ###################################################################### # As MacPorts does not currently have a post-deactivate hook,  # you will need to ensure that you manually remove the catalog  # entry for this port when you uninstall it. To do so, run  # "xmlcatmgr remove nextCatalog /opt/local/share/xsl/docbook-xsl/catalog.xml". ######################################################################

gnumeric most recent diff

version 1.9.0 View the most recent changes for the gnumeric port at: gnumeric.darwinports.com/diff Scroll down toward the bottom of the page to get installation instructions for gnumeric. The raw portfile for gnumeric 1.9.0 is located here: http://gnumeric.darwinports.com/dports/gnome/gnumeric/Portfile Find related portfiles with the unique DarwinPorts.com search feature. Check for any related Fink projects here: pdb.finkproject.org/pdb/package.php/gnumeric  PortSystem 1.0 Name: gnumeric Version: 1.9.0 Description: A spreadsheet with gnome support. Long Description: ${description} Maintainers: nomaintainer Category: gnome math Platform: darwin Homepage: http://www.gnome.org/projects/gnumeric/