Skip to content

Instantly share code, notes, and snippets.

[
{
"or": [
{
"and": [
{
"key": "contentType",
"term": "regular"
},
{
// The standard chrome points per pixel value
const chromePPI = 96;
function mmToInch(mm) {
return mm / 25.4;
}
// this is NZZ print specific
const columnGap = 5;
const columnWidth = 54.2;
@benib
benib / promote-to-black.js
Last active October 27, 2019 18:10
Promote mostly black pixels to K only in a CMYK TIFF
function promoteTiffBufferToBlack(tiffBuffer) {
const ifds = UTIF.decode(tiffBuffer);
// tiff tag descriptions: https://www.loc.gov/preservation/digital/formats/content/tiff_tags.shtml
// tiff image file format: http://www.fileformat.info/format/tiff/corion.htm
const bitsPerSample = ifds[0].t258;
const stripOffsets = ifds[0].t273[0];
const stripByteCounts = ifds[0].t279[0];
@benib
benib / vegaspec.json
Last active March 14, 2018 13:42
Vega Barchart autosize fit-x grid problem
{
"width": 500,
"autosize": {
"type": "fit-x",
"contains": "padding"
},
"signals": [
{
"name": "barWidth",
"value": 24
@benib
benib / .block
Created February 2, 2017 16:39 — forked from mbostock/.block
Pie Chart
license: gpl-3.0
@benib
benib / orakel.js
Created May 18, 2016 15:41
NZZ Euro 2016 Orakel Algorithmus
/*
NZZ Euro 2016 Orakel
http://nzz.ch/-ld.17757
The algorithm
this works like this:
@benib
benib / SassMeister-input.scss
Last active August 29, 2015 14:06
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
//
// use this together with modernizr feature detection
//
@mixin supports-feature($feature) {
.#{$feature} & {
@benib
benib / selectorItems.scss
Created July 29, 2014 23:24
Sass str-to-list function converts a string to a list
$selectorItems: str-to-list(#{&});
@each $selectorItem in $selectorItems {
@debug $selectorItem;
}
@benib
benib / gist:6574438
Created September 15, 2013 21:23
Replace filenames after grunt-filerev
grunt.registerMultiTask('filerevreplace', 'filerev task', function() {
var files = grunt.file.expand(this.files[0].src)
var assets = grunt.filerev.summary;
for (var i = 0, length = files.length; i < length; i++) {
var fileContent = grunt.file.read(files[i]);
for (var key in assets) {
origArr = key.split('/');
origFile = origArr[origArr.length-1];
revArr = assets[key].split('/');
revFile = revArr[revArr.length-1];
module Jekyll
class CategoryAwarePrevNextGenerator < Generator
safe true
priority :high
def generate(site)
site.categories.each_pair do |category_name, posts|
posts.sort! { |a, b| a <=> b }