Skip to content

Instantly share code, notes, and snippets.

View RobinDev's full-sized avatar

Robin Delattre RobinDev

View GitHub Profile
@RobinDev
RobinDev / main.js
Last active November 8, 2018 11:53
Image simple lazy Loader with SEO enhancement
/**
* Simple Image Lazy Loader
* @author: Robin D. https://www.robin-d.fr/
* idea borrow from : https://davidwalsh.name/lazyload-image-fade
* Example : <span data-img="https://source.unsplash.com/collection/993239/600x400">Random Image from Unsplash</span>
* will be transform to : <img src="https://source.unsplash.com/collection/993239/600x400" alt="Random Image from Unsplash" />
*/
export function imgLazyLoad() {
[].forEach.call(document.querySelectorAll('[data-img]'), function(img) {
let newDomImg = document.createElement('img');
@RobinDev
RobinDev / README.md
Last active August 29, 2015 14:13 — forked from yckart/README.md
[jQuery Plugin] Watch class attributes

The usage is quite simple, just add a new listender to the node you want to observe and manipulate the classes as usually:

var $node = $('div')

  // listen to class-manipulations
  .on('addClass toggleClass removeClass', function (e, oldClass, newClass) {
    console.log('Changed from %s to %s due %s', oldClass, newClass, e.type);
  })
@RobinDev
RobinDev / squidanonymousproxy.md
Last active November 10, 2024 00:54
Install a SQUID anonymous proxy
  1. Install SQUID
apt-get install squid
  1. Create an user
htpasswd -md /etc/squid3/users myuserlogin`
@RobinDev
RobinDev / casper.checkParams.js
Last active August 29, 2015 14:09
CasperJS : check if params are correctly set
/**
* Check if the params exist
*
* @param array $params
*
* @return bool
*/
function checkParams($params) {
$params.forEach(function(param){
if(typeof casper.cli.options[param] == 'undefined') {
@RobinDev
RobinDev / normalizeDateKeys.php
Last active August 29, 2015 14:07
PHP function `normalizeDateKeys` wich convert a php array with date keys in a pĥp array with date keys wich are following itself day by day
<?php
/**
* Convert a php array with date in a pĥp array with date wich are following itself day by day
*
* @param array $date containing the date
* @param bool $dateInKey must be set to true if the dates are in the array's keys
* @param string $fDate relative to the date format relative to php date's function
* @return array with every one key for every day
*/
function normalizeDateArray(array $dates, $dateInKey = false, $fDate = 'Y-m-d') {
@RobinDev
RobinDev / getDomain.php
Last active August 29, 2015 14:07
PHP function : Get domain (Host to be exact) from any string (with or without pares_url)
<?php
/**
* Return (sub)domain from any string (with and without parse_url)
*
* @param $domain str
*/
function getDomain($domain) {
$host = parse_url($domain, PHP_URL_HOST);
if($host)