Skip to content

Instantly share code, notes, and snippets.

View RobinDev's full-sized avatar

Robin Delattre RobinDev

View GitHub Profile
@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)
@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 / 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 / squidanonymousproxy.md
Last active May 4, 2024 00:19
Install a SQUID anonymous proxy
  1. Install SQUID
apt-get install squid
  1. Create an user
htpasswd -md /etc/squid3/users myuserlogin`
@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 / 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 / install
Last active January 7, 2019 09:30
Dev.piedweb.com
composer require piedweb/github
php render.php
@RobinDev
RobinDev / remove-ads-from-twitter.js
Last active January 15, 2019 15:39
Twitter Personalization : Remove Sidebar and Ads
// Share for educationnal purpose only
// --------------------
// To remove ads or sidebar from twitter, just inject this code (via cjs for example) :
// Current code work for the new Twitter TL from you favorite navigator (january 2019)
// --------------------
function removeSidebar() {
var elem = document.querySelector('[data-testid=sidebarColumn]');
if (elem) elem.parentNode.removeChild(elem);
}
@RobinDev
RobinDev / install-cke-for-piedwebcms.md
Last active March 14, 2019 12:09
Install CKE editor for PiedWeb CMS
@RobinDev
RobinDev / getCommonUtf8CharsWidth.php
Created May 9, 2020 16:11
Get width for a given font-size for common utf-8 charachters
<html>
<head>
<meta charset="UTF-8">
<style>
h3 {
font-size: 20px;
margin:0;
padding:0;
border:0;
font-weight: 400;