Skip to content

Instantly share code, notes, and snippets.

View pietersv's full-sized avatar

Pieter Sheth-Voss pietersv

View GitHub Profile
@pietersv
pietersv / bar-color.md
Last active May 11, 2020 23:09
Change bar colors programmatically

In CSS:

.protobi .element .bar.fg {
   background-color: #688c40
}

In Javascript:

var styleSheet = _.find(document.styleSheets, {"href": "http://localhost:3000/protobi/style/protobi.css"})
@pietersv
pietersv / gist:6e8b9f40ce47494c01b09b3b07c41708
Created May 11, 2020 23:06
Set Protobi foreground bar colors
In CSS:
```css
.protobi .element .bar.fg {
background-color: #688c40
}
```
In Javascript:
```js
var styleSheet = _.find(document.styleSheets, {"href": "http://localhost:3000/protobi/style/protobi.css"})
@pietersv
pietersv / console.save.js
Created November 18, 2015 01:50
Save JSON from console
//http://bgrins.github.io/devtools-snippets/#console-save
(function(console){
console.save = function(data, filename){
if(!data) return console.error('Console.save: No data');
if(!filename) filename = 'console.json'
if(typeof data === "object") data = JSON.stringify(data, undefined, 4)
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
@pietersv
pietersv / gist:b349214cda48a124ee5b
Last active November 4, 2015 04:22
Count pages of each Microsoft Word .docx file in a directory
var JSZip = require('jszip');
var fs = require('fs');
var cheerio = require('cheerio');
fs.readdir(DIRECTORY, function (err, files) {
files.filter(function (file) {return file.substr(-5).toLowerCase() == ".docx";}).forEach(function (file) {
fs.readFile(DIRECTORY + file, function (err, content) {
var zip = new JSZip();
zip.load(content);
var xml = zip.file('word/document.xml').asText();
"use strict";
var JSZip = require('jszip');
var fs = require("fs");
var FILE1 = process.argv[2];
var FILE2 = process.argv[3];
var zip1 = new JSZip(fs.readFileSync(FILE1));
var zip2 = new JSZip(fs.readFileSync(FILE2));
Object.keys(zip1.files).forEach(function (key) {
{
"mode": "html"
}
@pietersv
pietersv / gist:53333458e834deb7a67b
Created February 26, 2015 04:39
Extract theme and styles as XML from a Microsoft Excel .xlsx spreadsheet
var AdmZip = require('adm-zip');
var zip = new AdmZip(__dirname + '/../tinker/format.xlsx');
var themeXml = zip.readAsText("xl/theme/theme1.xml");
var stylesXml = zip.readAsText("xl/styles.xml");
var xlsx = require('xlsx');
var wb = {
"Sheets": {
"Sheet1": {
"!ref": "A1:C7",
"A1": {
"t": "s",
"v": "This is a merged cell",
"r": "<t>This is a merged cell</t>",