Skip to content

Instantly share code, notes, and snippets.

View emulsion-io's full-sized avatar
🏠
Working from home

Fabrice emulsion-io

🏠
Working from home
View GitHub Profile
@emulsion-io
emulsion-io / Géolocalisation.php
Created August 19, 2013 15:05
Géolocalisation : Calcule de distance lat/long avec Codeigniter
<?php
$this->db->select("*, ( 6371 * acos( cos( radians('".$geoc['lat']."') ) * cos( radians( geoc_adresse.lat ) ) * cos( radians( geoc_adresse.long ) - radians('".$geoc['long']."') ) + sin( radians('".$geoc['lat']."') ) * sin( radians( geoc_adresse.lat ) ) ) ) AS distance");
$this->db->join('geoc_adresse', 'geoc_adresse.id_geoc = agenda.geoc_adresse_id_geoc');
$this->db->having("distance < '".$geoc['km']."'");
$this->db->order_by('distance');
?>
@emulsion-io
emulsion-io / Media_Url_API.php
Created September 13, 2013 11:04
Parse url video pour afficher thumb et emded url
class media
{
var $CI;
function __construct()
{
$this->CI =& get_instance();
$this->CI->load->library('dmcloud');
}
@emulsion-io
emulsion-io / ckfinder_codeigniter.php
Created September 18, 2013 13:33
Charger la session de CodeIgniter dans CKFinder.
ob_start();
include('/home/webmaster/public_html/client/mylov4/index.php');
ob_end_clean();
function CheckAuthentication()
{
$CI =& get_instance();
$CI->load->library('session');
if($CI->session->userdata('connect') !== FALSE){
@emulsion-io
emulsion-io / align_left.js
Created September 25, 2013 10:16
Alignement à droite avec JSPDF
function taille(string, doc)
{
var debut_zone = 145;
var largeur_zone = 25;
var font_size = 10;
var t = doc.getStringUnitWidth(string);
var result = debut_zone + (largeur_zone - (t * font_size / ( 72 / 25.6 )));
@emulsion-io
emulsion-io / num_date.php
Created November 22, 2013 19:37
Liste toutes les dates ( debut et fin ) en fonction de leur numero de semaine ( attention si la semaine 1 ne commence pas un lundi )
<?php
for ($w=1; $w < 53; $w++) {
for($i = 1; $i <= 365; $i++) {
$week = date("W", mktime(0, 0, 0, 1, $i, 2014));
if($week == $w) {
$debut = date("Y-m-d", mktime(0, 0, 0, 1, $i, 2014));
$fin = date("Y-m-d", mktime(0, 0, 0, 1, $i+6, 2014));
@emulsion-io
emulsion-io / select_form_heure_min.php
Created December 22, 2013 11:23
Créer les select html pour heure et minute
<div class="form-group">
<label for="f_nom_arret">Heure de passage normal : </label>
<select name="heure">
<option value="h">heure</option>
<?php for ($heure = 00 ; $heure <= 23 ; $heure++):
$hour = sprintf("%02d", $heure);
?>
<option value="<?php echo $hour ?>"><?=$hour;?></option>
<?php endfor; ?>
</select>
@emulsion-io
emulsion-io / is_semaine.php
Created April 7, 2014 07:53
Bool des jours de semaine et week-end pour CodeIgniter Helper
<?php
if ( ! function_exists('isLundi'))
{
function isLundi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 1);
}
return (date('N', strtotime($date)) == 1);
}
@emulsion-io
emulsion-io / close_navigateur.js
Created July 20, 2015 09:45
Détection de la fermeture du navigateur
function checkBrowser() {
// Alt+F4 , File->Close detection
if(window.event.clientX < 0 && window.event.clientY < 0) {
// do action
}
}
@emulsion-io
emulsion-io / new_gist_file.js
Created July 20, 2015 09:53
Récupère les paramètres d'une URL en javascript.
function getUrlParam(name) {
var results = new RegExp('[\\?&]' + name + '=([^]*)').exec(window.location.href);
return (results && results[1]) || undefined;
}
@emulsion-io
emulsion-io / copypasta.js
Last active August 29, 2015 14:25
Ajoute du texte a la fin d'un c/c sur une page web avec possibilité d'envoyer la valeur c/c en ajax sur une api
jQuery(document).ready(function($)
{
function CopyPasta()
{
var commentaire = " : coucou : ";
var url = window.location.href;
var copy = window.getSelection();
var brut = copy.toString();
var divPaste = document.createElement('div');