Skip to content

Instantly share code, notes, and snippets.

View Antoinebr's full-sized avatar
:octocat:
🔥

Antoinebr

:octocat:
🔥
  • Fastly
  • Paris / Rennes
View GitHub Profile
@Antoinebr
Antoinebr / .htaccess
Last active April 23, 2018 17:05
htaccess GZIP
# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
@Antoinebr
Antoinebr / defer-wp-scripts.php
Last active December 20, 2017 07:24
defer-wp-scripts.php
<?php
/*
function to add async and defer attributes
Will only work if the scripts are enqueued with wp_enqueue_script()
*/
function defer_js_async($tag){
## 1: list of scripts to defer.
$scripts_to_defer = array(
'owl-carousel.min.js',
@Antoinebr
Antoinebr / defer-inline-js.html
Last active June 13, 2018 06:47
Tell inlines scripts to wait, that a function is defined https://goo.gl/DF6fWn
<!-- Put this function inline on the header -->
<script>
function whenAvailable(name, callback) {
var interval = 10; // ms
window.setTimeout(function() {
if (window[name]) {
callback(window[name]);
} else {
window.setTimeout(arguments.callee, interval);
}
@Antoinebr
Antoinebr / nginx-gzip-browser-caching.conf
Last active February 16, 2017 10:13
browser-caching / Gzip
#
# Gzip Config
#
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
#
# Browser Caching config
#
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
@Antoinebr
Antoinebr / app.js
Last active July 26, 2017 19:24
node mysql db connect and record
var dataBase = require('./db.js');
/*
* Instatiations
*/
var db = new dataBase();
try {
@Antoinebr
Antoinebr / ESP8266 WiFi.c++
Created August 27, 2017 16:12
ESP8266 WiFi
/*
* ESP8266 (WeMosD1) WiFi Relay Control
*
* learnelectronics
* 05 JUN 2017
*
* www.youtube.com/c/learnelectronics
* [email protected]
* https://www.youtube.com/watch?v=3bFs_MZVFxw
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
const char* ssid = "myWifiSSID";
const char* password = "myWifiPassWord";
ESP8266WebServer server(80);
@Antoinebr
Antoinebr / espruino-DHT22.js
Created September 8, 2017 10:15
espruino-DHT22.js
var pin = NodeMCU.D2;
var dht = require("DHT22").connect(pin);
var data = {};
setInterval( () =>{
@Antoinebr
Antoinebr / abGAsendTime.js
Created October 20, 2017 15:28
Get speed Metrics and send them to Google Analytics
abGAsendTime = function(){
this.getLoadTime = function() {
return performance.timing.loadEventStart - performance.timing.navigationStart;
}
@Antoinebr
Antoinebr / arduino-mqtt-payload-decode.h
Last active November 28, 2017 21:50
arduino-mqtt-payload-decode.h
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
char message[length + 1];
// copy contents of payload to message
memcpy(message, payload, length);