Skip to content

Instantly share code, notes, and snippets.

View quoidautre's full-sized avatar

3dw4rd5n0wd3n quoidautre

  • New York
View GitHub Profile
@quoidautre
quoidautre / gist:3781733
Created September 25, 2012 13:11
PHP: PDO snippets
// PDO Connection to MySQL
$conn = new PDO('mysql:host=localhost;dbname=yourdbname', 'username', 'password');
// PDO Connection to PostgreSQL
$conn = new PDO('pgsql:host=localhost;dbname=yourdbname', 'username', 'password');
// A quick Select Query with For Loop
foreach ($conn->query("SELECT * FROM profile") as $row)
echo $row['fullname'];
@quoidautre
quoidautre / gist:3761439
Created September 21, 2012 13:23
APACHE: password protection with .htaccess
AuthType Basic
AuthName "restricted area"
AuthUserFile /home/prem/html/protect-dir/.htpasswd
require valid-use
@quoidautre
quoidautre / gist:3761408
Created September 21, 2012 13:17
APACHE: add a virtual host
#!/bin/bash
### Checking for user
if [ "$(whoami)" != 'root' ]; then
echo "You have no permission to run $0 as non-root user. Use sudo !!!"
exit 1;
fi
### Configure email and vhost dir
email='[email protected]' # email address of administrator
@quoidautre
quoidautre / gist:3760392
Created September 21, 2012 08:31
PHP: Cryptage et décryptage
function crypter($maCleDeCryptage="", $maChaineACrypter){
if($maCleDeCryptage==""){
$maCleDeCryptage=$GLOBALS['PHPSESSID'];
}
$maCleDeCryptage = md5($maCleDeCryptage);
$letter = -1;
$newstr = '';
$strlen = strlen($maChaineACrypter);
for($i = 0; $i < $strlen; $i++ ){
@quoidautre
quoidautre / gist:3749617
Created September 19, 2012 13:16
JQUERY: plugin template
(function($){
var methods = {
init : function( options ) {
// Create some defaults, extending them with any options that were provided
var settings = $.extend( {
table : '',
field :'',
authentification:false
@quoidautre
quoidautre / gist:3748607
Created September 19, 2012 09:09
PHP : Supprimer tout ce qu'il y a apres un caractères précis
$carToDelimite = '@';
$string = 'this/is/a/string@text-to-delete';
$newString = substr($string, 0, strpos($string,$carToDelimite));
@quoidautre
quoidautre / gist:3741745
Created September 18, 2012 07:15
UBUNTU: Virtual Hosts
-1-
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
@quoidautre
quoidautre / gist:3727302
Created September 15, 2012 10:33
HTML5: template
<!DOCTYPE HTML>
<html>
<head>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
var els = ['article', 'footer', 'header', 'section',
'nav', 'menu'];
@quoidautre
quoidautre / gist:3714925
Created September 13, 2012 15:04
MYSQL: Changer le mot de passe admin, mode console
mysql -u root -p
USE mysql;
UPDATE user SET password = PASSWORD('new-password') WHERE user = 'root';
FLUSH PRIVILEGES;
@quoidautre
quoidautre / gist:3706669
Created September 12, 2012 13:39
WEB: Vider le cache DNS
Pour vider le cache DNS sous Microsoft Windows (Win XP, Win ME, Win 2000 et Win 98) :
Démarrer -> Exécuter -> tapez cmd
Dans la fenêtre DOS, tapez ipconfig /flushdns
Et voilà ! Votre cache DNS a été vidé.
Pour vider le cache DNS sous Linux, il suffit de relancer le processus nscd :
Tapez :