Snippets populaires
Downgrader un package sous Ubuntu
On peut forcer la version d'un paquet à installer :
$ sudo aptitude install nomdupaquet=1.2.3-version2
Récupérer la taille d'une vidéo en PHP avec ffmpeg
On a besoin de http://ffmpeg-php.sourceforge.net/, puis :
extension_loaded('ffmpeg') or die('ffmpeg extension not loaded'); $ffmpegInstance = new ffmpeg_movie('/path/to/movie.avi'); $ffmpegInstance->getDuration(); // Gets the duration in secs. $ffmpegInstance->getVideoCodec(); // What type of compression/codec used
Redirect HTTP -> HTTPS requests in a VirtualHost
<VirtualHost 100.101.102.103:80> ServerName subdomain.domain.tld DocumentRoot /path/to/docroot <IfModule mod_rewrite.c> RewriteEngine on RewriteLog /var/log/apache2/https_rewrite.log RewriteLogLevel 1 RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{SERVER_NAME} ^subdomain.domain.tld$ RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R] </IfModule> </VirtualHost> <VirtualHost 100.101.102.103:443> ServerName subdomain.domain.tld DocumentRoot /path/to/docroot SSLEngine On SSLCertificateFile /etc/apache2/ssl_conf/myservicename.crt SSLCertificateKeyFile /etc/apache2/ssl_conf/myservicename.key </VirtualHost>
Changer l'éditeur par défaut sous Ubuntu
$ sudo update-alternatives --config editor
Et là, choisir vi :-)
Effacer les lignes vides d'un fichier
$ sed '/^$/d' fichier.txt
Installer DBDesigner4 sur Ubuntu
$ wget -c http://213.115.162.124/external/DBDesigner4/DBDesigner4-0.5.4-0.i586.rpm
$ wget -c http://prdownloads.sourceforge.net/skychart/libborqt-6.9.0-2.i386.rpm?use_mirror=switch
$ sudo alien DBDesigner4-0.5.4-0.i586.rpm
$ sudo alien libborqt-6.9.0-2.i386.rpm
$ sudo dpkg -i dbdesigner4_0.5.4-1_i386.deb
$ sudo dpkg -i libborqt_6.9.0-3_i386.deb
$ sudo ln -sf /usr/lib/DBDesigner4/*.so /usr/lib
Une dernière chose :
http://forums.mysql.com/read.php?113,59885,59926#msg-59926
[Symfony] Executer une requête spécifique (custom query) avec Propel
$con = Propel::getConnection(); $stmt = $con->prepareStatement('SELECT foo, bar FROM baz WHERE name=? AND active=?'); $stmt->setString(1, 'MyName'); $stmt->setString(2, '1'); $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
Ou encore plus con :
Propel::getConnection()->executeUpdate('SET FOREIGN_KEY_CHECKS=0');
Foreach et les variables passées en référence
Merci Thibs ;)
$arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } print_r($arr); // $arr vaut maintenant array (2, 4, 6, 8)
[Symfony] Utiliser un helper dans une action
sfLoader::loadHelpers(array('First', 'Second'));
Simple !
Lister les process arboressentiels sous nunux
Au choix :
$ pstree
ou :
$ ps afx





