Skip to content

Instantly share code, notes, and snippets.

Avatar
🍭

Antoine Doury mrdoinel

🍭
View GitHub Profile
View webpack.config.js
const path = require('path');
const data = require('./frontend/manifest');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
@mrdoinel
mrdoinel / execute_script_tags.js
Created Dec 8, 2016
execute_script_tags : load & execute script tags inside content loaded with ajax
View execute_script_tags.js
A17.Helpers.execute_script_tags = function(container) {
var loaded = false;
var progress = 0;
var $container = $(container);
var current_script = null;
var head = document.getElementsByTagName('head')[0] || document.body;
var new_scripts_to_load = $('script[src]', $container);
var new_scripts_to_eval = $('script:not([src])', $container);
var existing_scripts = $('script[src]', $(head));
@mrdoinel
mrdoinel / links.css
Created Mar 15, 2016
Underlined links in NYT : text is 20px line-height
View links.css
@mrdoinel
mrdoinel / sharing_counter.js
Created Nov 17, 2015
Get all shares for the current page using addthis shares.json endpoint
View sharing_counter.js
A17.Behaviors.sharing_counter = function() {
var url = document.querySelector("link[rel='canonical']").href;
if(url) {
var script = document.createElement('script');
script.src = '//api-public.addthis.com/url/shares.json?url=' + url + '&callback=A17%2EHelpers%2Eupdate_counters';
document.getElementsByTagName('head')[0].appendChild(script);
}
};
@mrdoinel
mrdoinel / template.scss.erb
Created Nov 19, 2014
Template for Spriteful : Retina + Image Dimensions
View template.scss.erb
// ============================================================================
// This Stylesheet was generated by the 'spriteful' gem, with the following options:
<%- if Spriteful.options -%>
// 'spriteful <%= Spriteful.options.join(' ') %>'.
<%- end -%>
<%- if mixin? -%>
// Below there are several [Mixin Directives]
// (http://sass-lang.com/documentation/file.SASS_REFERENCE.html#mixins)
<%- else -%>
// Below there are several [Placeholder Selectors]
View gist:8860327
(function($,window) {
// returns an array of objects of the form {url: 'image_url', ratio: float }
// array is sorted in asending order by the pixel ratio
$.parseSrcset = function(text) {
var result = [],
items = $.trim(text).split(',');
for(var i = 0; i< items.length; i++) {
var img = $.trim(items[i]).split(/\s+/);
if (img.length < 2)
continue;