Skip to content

Instantly share code, notes, and snippets.

View mrdoinel's full-sized avatar
🦜

Antoine Doury mrdoinel

🦜
View GitHub Profile
@mrdoinel
mrdoinel / gist:8860327
Created February 7, 2014 10:27
Srcset polyfill
(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;
@mrdoinel
mrdoinel / sharing_counter.js
Created November 17, 2015 16:13
Get all shares for the current page using addthis shares.json endpoint
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 November 19, 2014 11:35
Template for Spriteful : Retina + Image Dimensions
// ============================================================================
// 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]
@mrdoinel
mrdoinel / links.css
Created March 15, 2016 13:14
Underlined links in NYT : text is 20px line-height
@mrdoinel
mrdoinel / execute_script_tags.js
Created December 8, 2016 15:17
execute_script_tags : load & execute script tags inside content loaded with ajax
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 / webpack.config.js
Created October 3, 2019 14:20
TTP Webpack config
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');