Skip to content

Instantly share code, notes, and snippets.

Nicolas Hoizey nhoizey

Block or report user

Report or block nhoizey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nhoizey
nhoizey / browsing-contexts.js
Created Sep 13, 2018
Get screen density and viewport width, useful for responsive web design
View browsing-contexts.js
// 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')
@nhoizey
nhoizey / extract-largest-image.rb
Last active Jul 4, 2018
Extracts the url of the largest image from a `srcset-w`
View extract-largest-image.rb
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 Mar 8, 2018
Get screen density and viewport width, useful for Analytics
View responsive-context.js
// 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')
View macOS settings.md

Chrome

Disable touch history back/forward

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

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 Sep 5, 2016
Export de forums SPIP pour import dans Disqus
View README.md

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 Jan 7, 2016
CSS generated from Sass source in https://github.com/nhoizey/esviji
View esviji.css
/* ********************************************************************
* 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 Oct 27, 2015
Jekyll pagination
View README.md
View keybase.md

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:

View README.md
You can’t perform that action at this time.