Skip to content

Instantly share code, notes, and snippets.

View sdeluce's full-sized avatar

Stéphane Deluce sdeluce

View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@sdeluce
sdeluce / Gzip
Last active January 3, 2016 21:59
htaccess gzip
## activation ZEND optimizer
SetEnv ZEND_OPTIMIZER 1
## suppression de SESSID dans les url
SetEnv SESSION_USE_TRANS_SID 0
## serveur en PHP5
SetEnv PHP_VER 5_3
## Commenter la ligne ci-dessous si plantage
# php_flag zlib.output_compression on
## Activer le filtre
SetOutputFilter DEFLATE
<IfModule mod_headers.c>
# Images
<FilesMatch "\\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# Fonts
<FilesMatch "\\.(ttf|eot|woff|otf|svg)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# Style
# MOD_DEFLATE COMPRESSION
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
#Pour les navigateurs incompatibles
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#ne pas mettre en cache si ces fichiers le sont déjà
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
@sdeluce
sdeluce / flat_color.scss
Created January 21, 2014 20:05
Flat UI Colors Scss
/*--------------------------*\
Flat UI Colors
\*--------------------------*/
$turquoise : #1ABC9C;
$greensea : #16A085;
$emerald : #2ECC71;
$nephritis : #27AE60;
@sdeluce
sdeluce / config.rb
Created January 21, 2014 20:27
Compass config
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "img"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
environment = :development #development production
@sdeluce
sdeluce / slug.php
Last active August 12, 2021 05:45
Create a slug alias
<?php
function create_slug($string, $replace=array(), $delimiter='-') {
if( !empty($replace) ) {
$string = string_replace((array)$replace, ' ', $string);
}
$slug = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
$slug = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $slug);
$slug = stringtolower(trim($slug, '-'));
$slug = preg_replace("/[\/_|+ -]+/", $delimiter, $slug);
@sdeluce
sdeluce / get_ip.php
Last active January 4, 2016 01:19
Trouver l'IP d'un visiteur
<?php
// Function to get the client ip address
function get_client_ip() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
@sdeluce
sdeluce / db_connection.php
Last active January 4, 2016 01:28
connection base SQL
<?php
if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])) send_404();
$dbHost = "localhost"; //Location Of Database usually its localhost
$dbUser = "xxxx"; //Database User Name
$dbPass = "xxxx"; //Database Password
$dbDatabase = "xxxx"; //Database Name
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
@sdeluce
sdeluce / mail.php
Last active January 4, 2016 01:28
Envoyer un mail function PHP
<?php
$to = "viralpatel.net@gmail.com";
$subject = "VIRALPATEL.net";
$body = "Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>";
$headers = "From: Peter\r\n";
$headers .= "Reply-To: info@yoursite.com\r\n";
$headers .= "Return-Path: info@yoursite.com\r\n";
$headers .= "X-Mailer: PHP5\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";