Tuesday, December 23, 2014

Mod Rewrite Generator

Mod Rewrite generator

Trés pratique pour générer des regex

http://www.generateit.net/mod-rewrite/index.php
http://www.regexr.com/

Monday, December 8, 2014

Find Out Which Process Is Listening Upon a Port

How To Create an SSL Certificate on Apache for CentOS 7

Install MailCatcher On CentOS 7

Introduction

MailCatcher is a tool that provides an easy way for developers to inspect emails that their applications send out without having to wait for an email provider. It catches all emails that it receives, and stores them for display. Both HTML and plain text messages are supported.

Installation

First update yum's repository list, then install the gcc and g++ compilers, and MailCatcher's dependencies (Ruby and SQLite).
sudo yum update
sudo yum -y install gcc gcc-c++
sudo yum -y install sqlite-devel ruby-devel
Install MailCatcher.
sudo gem install mailcatcher

Running MailCatcher

Once installed, you can run mailcatcher --help to see what options are available.
Start MailCatcher by running mailcatcher --ip [your-vultr-ip-address] on your terminal. Your output should look similar to the following:
root@install:~# mailcatcher --ip [your-vultr-ip-address]
Starting MailCatcher
==> smtp://[your-vultr-ip-address]:1025
==> http://[your-vultr-ip-address]:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.
Browse to http://[your-vultr-ip-address]:1080 and you'll see MailCatcher's web interface. Configure your application to use an SMTP host of your Vultr IP Address and port 1025 and send out some test emails. These emails will appear on MailCatcher's web interface.
NOTE: If you don't see MailCatcher's web interface, then you may have to open port 1080 and enable "http service" on CentOS firewall. Run the commands below, then try accessing http://[your-vultr-ip-address]:1080 from your web browser again.
sudo firewall-cmd --zone=public --add-port=1080/tcp --permanent
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --reload

Conclusion

MailCatcher can really ease up the development and testing workflow, as it takes out the need for a mail provider to catch and view emails. Consider trying it for your next application.

Friday, December 5, 2014

[CentOS 7] Add permanent rules to FirewallD

Someone at work wanted to know how to add rules permanently to FirewallD, CentOS 7’s dynamic firewall (iptables), so I’m posting it in case it’s useful to someone else.
Get the default zone, this is usually “public”:
firewall-cmd --get-active-zones
List services on that zone:
firewall-cmd --zone=public --list-all
Add required TCP ports (let’s do port 80):
firewall-cmd --permanent --zone=public --add-port=80/tcp
If you need a UDP port:
firewall-cmd --permanent --zone=public --add-port=123/udp
You could restart the firewall for them to take affect, or set the rules again withoutthe –permanent option to add them dynamically.
Restart firewall:
systemctl restart firewalld.service
You can also specify services, rather than ports if you like.
sudo firewall-cmd --permanent --zone=public --add-service=http
Source :

Monday, November 10, 2014

Way to get url, protocol in javascript

First get the current address
var url = window.location.href
Then just parse that string
var arr = url.split("/");
your url is:
var result = arr[0] + "//" + arr[2]

Saturday, October 25, 2014

Sunday, October 19, 2014

Mettre à jour serveur CentOS

Vérifiez la liste des composant à mettre à jour :
  • yum list updates
Lancez la mise à jour du système :
  • yum update
Une fois la mise à jour terminée, redemarrez le serveur :
  • reboot
Vérifiez que tout fonctionne :
  • cat /etc/redhat-release
  • uname -a
  • netstat -tulpn
  • tail -f /var/log/messages
Pour voir les log de la mise à jour :
  • more /var/log/yum.log

SSH command to find out the plesk version

You can check the plesk version with :
rpm -q psa

Friday, September 19, 2014

Git : 10 commandes utiles

Check this out : http://pioupioum.fr/developpement/git-10-commandes-utiles.html

Friday, April 11, 2014

Résoudre les problèmes d'encodage de putty sur Windows

Il faut régler putty comme suit:
  • Terminal → Keyboard: mettre “The Function keys and keypad” à “Linux”
  • Windows → Translation: mettre “Received data …” à “UTF-8”
    • et laisser le “Use Unicode line drawing code points” qui est par défaut
  • Connection → Data: mettre “Terminal-type string” à “linux” (il est à “xterm” par défaut)
Avec ce réglage, les lignes des programmes en ncurses sont ok.
Je suppose que ça marchera pour tous les Linux qui fonctionnent en UTF-8 par défaut comme l'opensuse.
http://linux.jpvweb.com/mesrecetteslinux/doku.php?id=encodage_putty

Monday, March 24, 2014

Comment voir les messages dans la file d'attente dans qmail ?

Pour voir les messages dans qmail

Exécuter les commandes suivantes :

1 - Lister les messages actuellement dans la file d'attente
/var/qmail/bin/qmail-qread

2 - Compter le nombre de message actuellement dans la file d'attente
/var/qmail/bin/qmail-qstat

3 - Pour lire le contenu de l'email dans la file d'attente (xxx correspond à l'ID spécifié dans la commande 1)
find /var/qmail/queue -name xxx| xargs cat | less

Source : http://support.godaddy.com/help/article/1582/how-do-i-view-messages-in-the-qmail-queue

Wednesday, March 12, 2014

Tester les filtres fail2ban

Ci joint un exemple de commande pour tester les filtres fail2ban :
fail2ban-regex /var/log/secure /etc/fail2ban/filter.d/proftpd.conf
Pour plus de lectures : 
http://admin.blogs.docilnet.fr/articles/tester-et-debuger-filtres-fail2ban.html

Monday, March 10, 2014

Friday, March 7, 2014

Quitter Telnet

Pour quitter Telnet :

  • Crtl + $ sur Windows
  • Crtl + Alt Gr + ] sur Linux

Ensuite
telnet > quit

Tuesday, January 28, 2014

5 EXEMPLES AVEC LA COMMANDE GREP SUR LINUX

La commande Linux grep est une commande très utile et fort puissante  voici un lien qui présente une série de 5 exemples courants pour bien se familiariser :

Rechercher une expression dans un fichier
grep iTx index.html

Rechercher une expression dans repertoire
grep -i iTx public_html/

Rechercher une expression dans plusieurs répertoires récursivement
grep -i -r iTx public_html/*

Mettre les résultats en couleur
export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8' grep iTx index.html

Rechercher une expression REGEX
grep  "expressions?"  index.html

http://itx-technologies.com/blog/1521-5-exemples-avec-la-commande-grep-sur-linux

Thursday, January 23, 2014

Parcourir un fichier par ligne dans un script shell

#! /bin/bash
while read ligne 
do   
   echo -e $ligne
#creer repertoire
   mkdir $ligne
done < monfichier.txt

Tuesday, January 14, 2014

Description des fichiers PDB

Le format de fichier Program database ( Base de données de programmes plus couramment nommé sous l'acronyme PDB) est un format de fichier contenant des informations de débogage (numéro de ligne, StackTrace, ect...) pour les modules exécutables (.exe ou .dll). L'extension de nom de fichier des Program database est .pdb. Ce format de fichier est un format propriétaire à Microsoft et seul l'éditeur de lien de Microsoft est apte à créer ce type de fichier.

Il n'est pas nécessaire à l’exécution et peut être ignorer lors d'une release. Il faut garder à l'esprit que ces fichiers sont à destinateur du debugger.

Pour les plus curieux, il existe des outils sur le web capable de lire son contenu comme par exemple :
pdbexplorer

Pour plus de lecture : http://www.wintellect.com/blogs/jrobbins/pdb-files-what-every-developer-must-know

Monday, January 13, 2014

Comment utiliser ILDASM ?

Un tutoriel nous expliquant le fonctionnement de l'outil ILDASM.exe qui permet  de voir le contenu d'un assembly pour chacune des classes, méthodes du framework .NET

http://www.rapidprogramming.com/tutorial/How-to-Use-ILDASM--450


Friday, January 3, 2014

Port 80 utilisé par Microsoft-HTTPAPI/2.0

Wamp ne démarre pas et testant votre port 80, vous avez ce message d'erreur :

Votre port 80 est occupé par Microsoft-HTTPAPI/2.0
Il vous faut donc arrêter le service ReportServer - SQL Server Reporting Services (MSSQLSERVER) afin de résoudre ce problème. En ligne de commande, exécuter :

NET STOP ReportServer

Thursday, January 2, 2014

Comment télécharger un fichier à partir d'un tableau de byte en C#

Page.aspx

<asp:GridView ID="GridViewTest" runat="server" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="Key" AccessibleHeaderText="Key" HeaderText="Key"/>
<asp:BoundField DataField="Value" AccessibleHeaderText="Value" HeaderText="Value" />
<asp:ButtonField AccessibleHeaderText="Test" HeaderText="Bouton" Text="Bouton" CommandName="DownloadFile" ButtonType="Button" />
</Columns>
</asp:GridView>

Page.aspx.cs

Le rôle de l'objet Response est de permettre de créer la réponse HTTP qui va être envoyée au navigateur, c'est-à-dire la page Web demandée par le client.

 protected void Page_Load(object sender, EventArgs e)
 {
    List<string> names = new List<string>();
    Dictionary<string,string> dico = new     Dictionary<string,string>();
    dico.Add("libelle","exemplelibelle");
    GridViewTest.DataSource = dico;
    GridViewTest.DataBind(); 
 }

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
    if (e.CommandName == "DownloadFile")
       {
         Response.ClearHeaders();
         Response.Clear();
         Response.Expires = 0;
         Response.Buffer = true;

         Response.AddHeader("Content-Disposition", "attachment; filename=download.txt");
         Response.ContentType = "text/plain";
                
Response.BinaryWrite(getImageByte("C:\\test\\file.txt"));
         Response.End();
        }
 }

 private byte[] getImageByte(String filename)
 {
    byte[] buffer = null;
    try
    {
       FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
       BinaryReader binaryreader = new BinaryReader(fs);
       long totalbytes = new FileInfo(filename).Length;
       buffer = binaryreader.ReadBytes((Int32)totalbytes);
       fs.Close();
       fs.Dispose();
       binaryreader.Close();

       return buffer;
     }
    catch (Exception e)
     {
       log.Error("ERREUR : " + e.ToString());
     }

       return null;
 }