Skip to content

Instantly share code, notes, and snippets.

View kcassam's full-sized avatar
🐵
on duty

Ka (Karim Cassam Chenaï) kcassam

🐵
on duty
View GitHub Profile
@kcassam
kcassam / gist:6707152
Last active February 15, 2019 08:39
Make spotlight index any file

Make spotlight index any file

Problem :

Spotlight was not searching into certain files, even if simple text files (in my case .INI files)

Solution

Easy solution

@kcassam
kcassam / php function slug.md
Last active December 24, 2015 13:39
Fonction slug en php

Pour référence, voici la fonction slug que j'utilise en php quand j'en ai besoin

function slug($string) {
  return strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|copy|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
}

Inspiré de stackoverflow.com/questions/2103797

@kcassam
kcassam / apache sous-domaine dynamique.md
Created October 3, 2013 09:01
Permettre la création de sous-domaine dynamique

Permettre la création de sous-domaine dynamique

Je n'ai pas encore testé cette astuce, je l'ai simplement vu sur un serveur (appelons le exemple.com) :

L'admin a mis la règle suivant dans le fichier vhosts.conf (CentOS) :

# more  vhosts.conf
RewriteEngine On

RewriteMap lowercase int:tolower

@kcassam
kcassam / RecursiveIteratorIterator.md
Last active December 25, 2015 00:09
itérer récursivement sur un dossier en php

Pour itérer récursivement sur un dossier en php, vous pouvez utiliser le code suivant :

$iterator = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($pathname), 
    RecursiveIteratorIterator::SELF_FIRST
); 

Exemple : Changer les droits des éléments inclus dans un dossier :

$pathname = "/chemin/du/dossier/";

@kcassam
kcassam / aggregator.php
Last active December 25, 2015 02:19
Aggregate multiple files in one (Quick and dirty)
<?php
$pathname = __DIR__."/filestoaggregate";
$tab[0] = array("firstname","lastname","gender","email","code","newsletter","variable","giftcode");
$separator = "=";
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pathname), RecursiveIteratorIterator::SELF_FIRST);
$i = 1;
foreach($iterator as $item) {
@kcassam
kcassam / index.html
Created October 23, 2013 16:45
A Pen by Ka.
<div class = "global">
<div class = "titre">titre</div>
<div class = "left">
image
</div>
<div class = "right">
Nom agence
Adresse<p>
@kcassam
kcassam / responsive-iframe
Last active December 29, 2015 02:09
Rendre youtube -ou n'importe quel iframe- responsive
Rendre youtube (ou n'importe quel iframe responsive)
HTML :
<div class="wrapper">
<div class="h_iframe">
<!-- a transparent image is preferable -->
<img class="ratio" src="http://placehold.it/16x9"/>
<iframe src="http://www.youtube.com/embed/WsFWhL4Y84Y" frameborder="0" allowfullscreen></iframe>
</div>
@kcassam
kcassam / wordpress.md
Last active December 30, 2015 08:29
Pour références, les sites encore en ligne que j'ai fait avec Wordpress
@kcassam
kcassam / admin sys.md
Last active September 23, 2020 09:09
performance, scalability, security, admin, backup
@kcassam
kcassam / todo.md
Created January 3, 2014 09:50
Todo
  • for an empty checkbox