This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const names = [ 'Jon', 'Jacob', 'Jeff' ] | |
const copy1 = names.slice() | |
const copy2 = [].concat(names) | |
const copy3 = Object.values(names) | |
const copy4 = [...names] | |
const copy5 = Array.of(...names) | |
const copy6 = JSON.parse(JSON.stringify(names)) | |
const copy7 = names.map(i => i) | |
const copy8 = Object.assign([], names) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Doc: https://www.askapache.com/htaccess/ssl-example-usage-in-htaccess/#rewrite-http-to-https-no-mod_ssl | |
RewriteEngine on | |
# REMOVE TRAILING SLASH | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^([a-z]+)/(.*)/$ /$1/$2 [L,R=301] | |
# END REMOVE TRAILING SLASH | |
# https and www for OVH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/TonyMtz/ | |
# first: | |
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
# go to /usr/local/lib and delete any node and node_modules | |
cd /usr/local/lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(func, wait, immediate) { | |
var timeout; | |
return () => { | |
var context = this, args = arguments; | |
var later = () => { | |
timeout = null; | |
if (!immediate) func.apply(context, args); | |
}; | |
var callNow = immediate && !timeout; | |
clearTimeout(timeout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = document.querySelector('.post-content').textContent | |
var speech = new SpeechSynthesisUtterance(); | |
speech.text = text; | |
speech.volume = 1; | |
speech.rate = 1; | |
speech.pitch = 1; | |
// Start speak | |
window.speechSynthesis.speak(speech); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;/Library/Application Support/appsolute/MAMP PRO/conf/php5.6.30.ini | |
[xdebug] | |
zend_extension="/Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" | |
xdebug.remote_enable=1 | |
xdebug.remote_host=localhost | |
xdebug.remote_port=9000 | |
xdebug.remote_autostart=1 | |
xdebug.overload_var_dump=1 | |
xdebug.var_display_max_children=1024 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
html { | |
background: #aaf; | |
} | |
body { | |
margin: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//<div class="scrollometer"></div> | |
window.onscroll = function() { | |
// document.body.scrollTop ou document.documentElement.scrollTop va retourner | |
// le nombre de pixel de scroll effectués depuis le haut de la page. | |
const scrollFromTop = document.body.scrollTop || document.documentElement.scrollTop; | |
// Le calcul suivant nous permet de connaitre la hauteur en pixel du noeud | |
// principal du document HTML, c'est à dire le noeud racine moins la hauteur | |
// en pixel de la partie affichable actuellement. En gros, le résultat est la |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (class_exists('WC_Countries') { | |
$countries = new WC_Countries(); | |
$countries = $countries->__get('countries'); | |
var_dump($countries); // [code] => name | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browser = (navigator.userAgent.indexOf("Chrome") > -1) ? 'chrome' : (navigator.userAgent.indexOf("Safari") > -1) ? 'safari' : (navigator.userAgent.indexOf("Opera") > -1) ? 'opera' : (navigator.userAgent.indexOf("Firefox") > -1) ? 'firefox' : (navigator.userAgent.indexOf("MSIE") > -1 || navigator.userAgent.indexOf("Trident") > -1) ? 'ie' : 'unknow'; |