Categories


Browse by



All Tags 6


RSS Feed

commands line script to extract views or functions or procedures from mysql

  • Mar 16
  • Posted By: Jean-Philippe Blais

This command will extract all views from MySQL (for a given DATABASE_NAME) and create one SQL file per view.

for i in $(echo "select table_name from information_schema.views where table_schema='DATABASE_NAME';" | mysql) ; do echo "select VIEW_DEFINITION from information_schema.views where table_schema='DATABASE_NAME' AND table_name='$i';" | mysql > ${i}.view.sql; done

 

This command will extract all functions from MySQL (for a given DATABASE_NAME) and create one SQL file per function.

for i in $(echo "select ROUTINE_NAME from information_schema.ROUTINES WHERE ROUTINE_SCHEMA='DATABASE_NAME' AND ROUTINE_TYPE='FUNCTION';" | mysql -N); do echo "select ROUTINE_DEFINITION from information_schema.ROUTINES WHERE ROUTINE_SCHEMA='DATABASE_NAME' AND ROUTINE_NAME='$i' AND ROUTINE_TYPE='FUNCTION';" | mysql -N > ${i}.function.sql; done

 

This command will extract all procedures from MySQL (for a given DATABASE_NAME) and create one SQL file per procedure.

for i in $(echo "select ROUTINE_NAME from information_schema.ROUTINES WHERE ROUTINE_SCHEMA='matchmak_bcbpmm' AND ROUTINE_TYPE='PROCEDURE';" | mysql -N); do echo "select ROUTINE_DEFINITION from information_schema.ROUTINES WHERE ROUTINE_SCHEMA='matchmak_bcbpmm' AND ROUTINE_NAME='$i' AND ROUTINE_TYPE='PROCEDURE';" | mysql -N > ${i}.procedure.sql; done

 

If MySQL return file containing \n or \t inside, run this little script to convert them:

for i in *; do sed -i 's/\\n/\n/g' $i; sed -i 's/\\t/\t/g' $i; done

 


Semantic Versioning

  • Mar 1
  • Posted By: Jean-Philippe Blais

Nice to know... http://semver.org/


Dynamically turning on and off MySQL general query log

  • Aug 2 '11
  • Posted By: Jean-Philippe Blais

From the MySQL command line client (or your prefered client), with a user that has privilige to do this command.

To turn it on:

mysql> set global general_log = 1;

To turn it off:

mysql> set global general_log = 0;


Site pour valider votre site Symfony avant mise en production

  • Jul 11 '11
  • Posted By: Jean-Philippe Blais

Votre liste de vérification avant mise en production... voir symfony-check.org/


Confoo 2011

  • Feb 9 '11
  • Posted By: Jean-Philippe Blais

Cette année je serai au Confoo Web Techno Conference. 9 au 11 Mars 2011. Montréal


Article sur la création d'un magasin en ligne avec Symfony

  • Jan 19 '11
  • Posted By: Jean-Philippe Blais

Voici un article/tutorial très intéréssant sur la création d'une boutique en ligne en utilisant Symfony.

http://squaresquirrel.ro/web/creating-an-online-store-with-symfony-part-1-documentation/

Bonne leçon!


Cycle de correction de bug plus vite dans les logiciels propriétaire?

  • Jan 17 '11
  • Posted By: Jean-Philippe Blais

Voici un exemple d'un bug simple qui en décembre 2007 est soulevé, 17 jours plus tard un modérateur répond, le dernier message du "thread" daté du 14 septembre 2010 et le bug n'est toujours pas résolu.

Ce "thread" est sur MSDN chez Microsoft, le bug est à propos de Outlook 2007 et est disponible ici.

Bon, certain diront que je suis déjà vendu par les logiciels libres.  Vous avez raison, mais arrêtez de sous évaluer les logiciels libres, ils sont là, sont maturent et sont là pour rester.


Nouveau site

  • Oct 6 '10
  • Posted By: Jean-Philippe Blais

Un tout nouveau site!

Étant spécialisé dans la réalisation de solutions en utilisant Symfony, nous voulions un site fait avec Symfony.  L'ajout du plugin Apostrophe CMS nous a permis tout ça et son utilisation est très simple.

 


VPN avec PPP et SSH

  • Oct 6 '09
  • Posted By: Jean-Philippe Blais

Une méthode pour créer un VPN en utilisant PPP et SSH sous Linux.  Testé sous Ubuntu 8.04 LTS, Ubuntu 8.10 et bien sûr Debian.

Sources:
http://www.faqs.org/docs/Linux-mini/ppp-ssh.html
http://www.revsys.com/writings/quicktips/nat.html

==> Setup a vpn user on the server

root@server:~# useradd -U vpn

edit /etc/passwd and change vpn default shell to /bin/bash

root@server:~# mkdir -p /home/vpn/.ssh
root@server:~# chown -R vpn.vpn /home/vpn
root@server:~# passwd vpn

==> Use a generated hard to remember password. You will use it only once.

Generate root RSA keys on the client

root@client:~# ssh-keygen

Copy the client root RSA public key to the server vpn user authorized keys

root@client:~# scp .ssh/id_rsa.pub vpn@server:./.ssh/authorized_keys
root@server:~# chmod 700 /home/vpn/.ssh
root@server:~# chmod 600 /home/vpn/.ssh/authorized_keys

Test the automatic login :

root@client:~# ssh -l vpn server

==> You should get the vpn user shell without password

Setup sudo on the server to allow vpn user run the pppd command

root@server:~# visudo

Add:

Cmnd_Alias VPN=/usr/sbin/pppdvpn ALL=NOPASSWD: VPN

Test sudo :

root@server:~# su – vpn
vpn@server:~$ sudo usr/sbin/pppd noauth

==> should see pppd garbage on your terminal

The vpn-pppssh Script

Use this script in the client

Change those lines for your needs :

SERVER_HOSTNAME=eldivino.domain.com
SERVER_USERNAME=vpn
SERVER_IFIPADDR=192.168.3.2
CLIENT_IFIPADDR=192.168.3.1

#!/bin/sh
# /usr/local/bin/vpn-pppssh
#
# This script initiates a ppp-ssh vpn connection.
# see the VPN PPP-SSH HOWTO on http://www.linuxdoc.org for more information.
#
# revision history:
# 1.6 11-Nov-1996 miquels@cistron.nl
# 1.7 20-Dec-1999 bart@jukie.net
# 2.0 16-May-2001 bronson@trestle.com
#
# You will need to change these variables...
#
# The host name or IP address of the SSH server that we are
# sending the connection request to:
SERVER_HOSTNAME=eldivino.domain.com
# The username on the VPN server that will run the tunnel.
# For security reasons, this should NOT be root.  (Any user
# that can use PPP can intitiate the connection on the client)
SERVER_USERNAME=vpn
# The VPN network interface on the server should use this address:
SERVER_IFIPADDR=192.168.3.2
# ...and on the client, this address:
CLIENT_IFIPADDR=192.168.3.1
# This tells ssh to use unprivileged high ports, even though it's
# running as root.  This way, you don't have to punch custom holes
# through your firewall.
LOCAL_SSH_OPTS="-P"
#
# The rest of this file should not need to be changed.
#
PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11
#
# required commands...
#
PPPD=/usr/sbin/pppd
SSH=/usr/bin/ssh
if ! test -f $PPPD  ; then echo "can't find $PPPD";  exit 3; fi
if ! test -f $SSH   ; then echo "can't find $SSH";   exit 4; fi
case "$1" in
  start)
    # echo -n "Starting vpn to $SERVER_HOSTNAME: "
    ${PPPD} updetach noauth passive pty "${SSH} ${LOCAL_SSH_OPTS} ${SERVER_HOSTNAME} -l${SERVER_USERNAME} -o Batchmode=yes sudo ${PPPD} nodetach notty noauth" ipparam vpn ${CLIENT_IFIPADDR}:${SERVER_IFIPADDR}
    # echo "connected."
    ;;
  stop)
        # echo -n "Stopping vpn to $SERVER_HOSTNAME: "
        PID=`ps ax | grep "${SSH} ${LOCAL_SSH_OPTS} ${SERVER_HOSTNAME} -l${SERVER_USERNAME} -o" | grep -v ' passive ' | grep -v 'grep ' | awk '{print $1}'`
        if [ "${PID}" != "" ]; then
          kill $PID
          echo "disconnected."
        else
          echo "Failed to find PID for the connection"
        fi
    ;;
  config)
    echo "SERVER_HOSTNAME=$SERVER_HOSTNAME"
    echo "SERVER_USERNAME=$SERVER_USERNAME"
    echo "SERVER_IFIPADDR=$SERVER_IFIPADDR"
    echo "CLIENT_IFIPADDR=$CLIENT_IFIPADDR"
  ;;
  *)
    echo "Usage: vpn {start|stop|config}"
    exit 1
    ;;
esac
exit 0

Test the VPN link

root@client:~# ./vpn-pppssh start

Should see something like :

Using interface ppp0Connect: ppp0 <--> /dev/pts/1local IP address 192.168.3.1remote IP address 192.168.3.2

Test the VPN link :

root@client:~# ping 192.168.3.1 (ping client local IP)root@client:~# ping 192.168.3.2 (ping server IP)root@server:~# ping 192.168.3.1 (ping client IP)

Setup server routing :

root@server:~# echo 1 > /proc/sys/net/ipv4/ip_forward
root@server:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
root@server:~# iptables -A FORWARD -i eth0 -o ppp0 -m state –state RELATED,ESTABLISHED -j ACCEPT
root@server:~# iptables -A FORWARD -i ppp0 -o eth0 -j ACCEPT

Add default route on the client :

root@client:~# route add -net default gw 192.168.3.2

Test if every things work from the client :

root@client:~# ping www.google.ca


Lister les fichiers et trier par...

  • Jun 27 '09
  • Posted By: Jean-Philippe Blais

Quelques petits "tips" pour lister les fichiers.

 

Liste des fichiers trié sur la grosseur (-S), ordre décroissant (-r) et afficher le format des fichiers en "human readable" (-h).

ls -lSrh

 

Liste des fichiers trié sur la date de modification (-t) et ordre décroissant (-r).

ls -ltr

 

Liste des fichiers trié par ordre alphabétique en utilisant l'extention (-X), utile pour grouper.

ls -lX

 

Liste des fichiers trié par ordre alphabétique... (do!) c'est le défaut!

ls -l

 

** L'option -l est pour le "long listing".

 

Voir "man ls" et l'option --sort pour découvrir les types de tri.


Première page Page précédente 1 2 Page suivante Dernière page
Conçu avec Apostrophe CMS
Propulsé par et