Skip to content

Instantly share code, notes, and snippets.

View thom4parisot's full-sized avatar

Thomas Parisot thom4parisot

View GitHub Profile
@thom4parisot
thom4parisot / README.md
Last active August 29, 2015 14:06
Node.js usual project directory structure.
├── bin
├── config
├── data
├── dist
├── doc
├── lib
│   └── models
├── node_modules
├── src
@thom4parisot
thom4parisot / data.js
Last active August 29, 2015 14:04
requirebin sketch
srcToCanvasPalette('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAEyATIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD6kQqeeRUo2kcGlS3GM9zUgt0CdDn1ryrIzuxYl2jtU6S4BGOKZFAvdsexNWUs1c4WQZ9xSsgKbQhicj6VGIypHBrU+wyoMlQQO4pfKJGCKaEVYk3dsVYFqW6CpYoPmxjAFXoo/wDZ5FJuwGetiQvGD
@thom4parisot
thom4parisot / convert-helpers.js
Last active August 29, 2015 13:58
XML Stream Update
'use strict';
var STYLE_ATTRIBUTE = 'text-style-name';
var styleMatches = function (item, styleName) {
if (!item || item.attributes === undefined || item.attributes[STYLE_ATTRIBUTE] === undefined) {
return false;
}
return item.attributes[STYLE_ATTRIBUTE].match(styleName);
@thom4parisot
thom4parisot / index.js
Created December 10, 2013 11:04
Imager.js custom pixel ratio handler
// https://github.com/BBC-News/Imager.js/blob/0.1.0/Imager.js#L277-279
Imager.transforms.pixelRatio = function pixelRatio(ratio){
if (ratio === 1){
return '';
}
if ([1.3, 2].indexOf(ratio) === -1){
ratio = 2;
}
<style>
#mask_demo {
background: #d0d0d0;
width: 80%;
padding: 10px;
position: relative;
}
/* this may not be a better way to do it, but it is a different way.
it still used the svg for the background on browsers that don't
@thom4parisot
thom4parisot / README.md
Last active December 27, 2015 23:59
JSON vs. TXT for tld.js

For some reason, I felt I compressed the Text representation of the JSON file BUT I still when here is the breakdown I have:

  • rules.txt
  • txt.length = 63144
  • ls -l rules.txt = 63144
  • rules.json
  • json.toString().length = 59488
  • ls -l rules.json = 60140

Hence I have the feeling the Text file contains more chars, it appears this is not the case.

@thom4parisot
thom4parisot / console.log.md
Last active December 25, 2015 01:59
Tap reporter

The problem: Tap reporter notifies 32 tests hence with the dot one (any of them actually), 31 ones are reported.

Test suite location

$ > ./node_modules/.bin/mocha --ui tdd --reporter dot
  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․

  31 tests complete (243 ms)
@thom4parisot
thom4parisot / grunt-task-test.js
Last active December 21, 2015 06:59
Stubbing grunt.task.current.target.
"use strict";
var grunt = require("grunt");
var chai = require("chai");
var expect = chai.expect;
var sinon = require("sinon");
var task = require('../index.js')(grunt).sass_compile;
describe("grunt sass_compile task", function(){
var gruntTaskStub, sandbox, originalTarget;
@thom4parisot
thom4parisot / README.md
Last active December 4, 2017 02:46
Downloading daily archives of an Instagram Hashtag.

Instagram Hashtag Archiver

This script helps you to download locally the latest pictures related to a specific Instagram hashtag. It will fetch them and add them in a daily folder (like 2013-8-16 for the 16th of August 2013).

No resume feature. No extra metadata. No OAuth pain.

Install

@thom4parisot
thom4parisot / Gruntfile.js
Last active December 20, 2015 11:49
Chrome Extension Channel Example
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
manifest: grunt.file.readJSON('src/manifest.json'),
zip: {
extension: {
cwd: 'src/',
src: [