Skip to content

Instantly share code, notes, and snippets.

Julian Fell jtfell

Block or report user

Report or block jtfell

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
View keybase.md

Keybase proof

I hereby claim:

  • I am jtfell on github.
  • I am jtfell (https://keybase.io/jtfell) on keybase.
  • I have a public key ASDgcNU_Bf-9CwPZNlSSVwZ8jc5tJTOfuU7TPut4LgD05Ao

To claim this, I am signing this object:

@jtfell
jtfell / test-result.json
Created Jan 2, 2018
Sample Test Result Data
View test-result.json
{
"numFailedTests": 0,
"numPassedTests": 3,
"numPendingTests": 0,
"startTime": 1514867328411,
"success": false,
"sovereignty": "eu",
"environment": "master",
"testExecutions": [
{
View supercookie.js
var $ = require('jquery');
var DOMAIN = 'example-domain.com';
function guid() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
function bin2guid(num) {
View test.js
var fs = require('fs');
var analyse = require('../src/index.js');
var css = fs.readFileSync('./test/basic.css', 'utf8');
analyse(css);
// Prints:
// { ratio: 1.4999140493583407, fit: 0.9999999752384222 }
View calculateRatio.js
function calculateRatio(xs) {
var uniqueSizes = xs.sort().filter(onlyUnique);
return exponentialRegression(uniqueSizes);
}
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
View findFontSizeDecl.js
function findFontSizeDecl(root) {
var vals = [];
// Iterate over font-size declarations
root.walkDecls(/font-size/, function(decl) {
vals.push(convertToEm(decl.value));
});
return vals;
};
View topLevel.js
var postcss = require('postcss');
module.exports = function(css) {
var root = postcss.parse(css);
// 1. Parse the AST and collect all font-size declarations
var properties = findFontSizeDecl(root);
// 2. Calculate the ratio used and the quality of the fit
var results = calculateRatio(properties);
You can’t perform that action at this time.