Skip to content

Instantly share code, notes, and snippets.

View nhoizey's full-sized avatar
👋

Nicolas Hoizey nhoizey

👋
View GitHub Profile
@nhoizey
nhoizey / jekyll-comments-to-eleventy-data-file.js
Created March 11, 2020 16:35
Node.js script to migrate comments from Jekyll to Eleventy
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const yfm = require('front-matter');
const rootDir = './src/_comments';
let comments = {};
@nhoizey
nhoizey / browsing-contexts.js
Last active May 28, 2021 15:31
Get screen density and viewport width, useful for responsive web design
// get device pixel ratio in dppx
// https://github.com/ryanve/res/blob/master/res.js
var screen_density =
typeof window == 'undefined'
? 0
: +window.devicePixelRatio ||
Math.sqrt(screen.deviceXDPI * screen.deviceYDPI) / 96 ||
0
// keep only 3 decimals: http://jsfiddle.net/AsRqx/
screen_density = +(Math.round(screen_density + 'e+3') + 'e-3')
@nhoizey
nhoizey / extract-largest-image.rb
Last active July 4, 2018 15:59
Extracts the url of the largest image from a `srcset-w`
url = srcset.scan(/([^, ][^ ]+)\s+([0-9]+)w/).map{ |url, size| { 'url' => url.strip, 'size' => size.to_i } }.reduce({ 'url' => '', 'size' => 0 }){ |current, new| current = new if new['size'] > current['size'] }['url']
@nhoizey
nhoizey / responsive-context.js
Created March 8, 2018 09:20
Get screen density and viewport width, useful for Analytics
// get device pixel ratio in dppx
// https://github.com/ryanve/res/blob/master/src/index.js
var screen_density =
typeof window == 'undefined'
? 0
: +window.devicePixelRatio ||
Math.sqrt(screen.deviceXDPI * screen.deviceYDPI) / 96 ||
0
// keep only 3 decimals: http://jsfiddle.net/AsRqx/
screen_density = +(Math.round(screen_density + 'e+3') + 'e-3')

Chrome

Disable touch history back/forward

defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE
@nhoizey
nhoizey / README.md
Created September 23, 2016 20:19
Restore a Firefox session backed up with to Save My Tabs

Save My Tabs is a great Firefox extension, because Firefox is great, but crashes a lot (at least mine, with hundreds of tabs).

Unfortunately, Save My Tabs doesn't have any restoration function, so you can copy/paste all URLs yourself, or try this script.

This simple Shell script for Mac OS X will launch Firefox with all URLs present in the backup file you pass as parameter:

./restore-savemytabs.sh opentabs--20160913-1900.txt
@nhoizey
nhoizey / README.md
Last active September 5, 2016 22:10
Export de forums SPIP pour import dans Disqus

ATTENTION, les articles sont supposés être des redirections vers les nouvelles URL des contenus dans cette version du squelette. Modifiez le contenu de <link> si ce n'est pas le cas.

Déposer les deux squelettes à la racine et appeler la page /?page=disqus-export

@nhoizey
nhoizey / esviji.css
Last active January 7, 2016 15:00
CSS generated from Sass source in https://github.com/nhoizey/esviji
/* ********************************************************************
* Some variables
* ********************************************************************/
/* ********************************************************************
* Mandatory font face
* ********************************************************************/
@font-face {
font-family: "SansitaOneRegular";
src: url("font/sansitaone-webfont.woff2") format("woff2"), url("font/sansitaone-webfont.woff") format("woff");
font-weight: normal;
@nhoizey
nhoizey / README.md
Last active October 27, 2015 19:00
Jekyll pagination

Keybase proof

I hereby claim:

  • I am nhoizey on github.
  • I am nhoizey (https://keybase.io/nhoizey) on keybase.
  • I have a public key whose fingerprint is C944 E2B5 8F97 6F74 A20B B47B 8124 747F 1FA5 3AFE

To claim this, I am signing this object: