This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
# folders used for testing | |
css | |
img | |
images | |
test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// | |
// small program/library to make creation of data URIs for web content quick and easy | |
// | |
// ./base64 ../path/to/some/file.png | pbcopy | |
// | |
// may ends up in a tool to embed data URIs in HTML/CSS files. | |
// | |
// inspired by https://github.com/nzakas/cssembed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var o = {a: {b: 'c'}, d: {e: {f: 'GG'}}}; | |
assert.equal(get(o, 'a'), o.a); | |
assert.equal(get(o, 'd'), o.d); | |
assert.equal(get(o, 'd.e'), o.d.e); | |
assert.equal(get(o, 'd.e.f'), 'GG'); | |
assert.equal(get(o, 'foobar'), undefined); | |
assert.equal(get(o, 'foobar.is.not'), undefined); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var npm = nrequire('npm'); | |
if (npm) return npm.load(function(e, n) { | |
this.commands.test(function(e) { | |
process.exit(e ? 1 : 0); | |
}); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colors = require('colors'); | |
// I've got an idea.. (it happens..) What if I could log colors and style, | |
// like I would do with some markdown content... | |
// | |
// so here's the idea, a function wrapper around colors.js to escape some markers | |
// and easily compose log statement. kinda fun | |
// | |
// idea is to automatically escape some custom markers, and apply | |
// according colors style. Enable easy output, without having to rely, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script to clone a list of gists, only those with markdown files | |
var child = require('child_process'), | |
colors = require('colors'), | |
path = require('path'), | |
fs = require('fs'); | |
// set up your credentials |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spawn = function spawn(cmd, args, callback) { | |
var stderr = [], stdout = [], | |
ch = child.spawn(cmd, args); | |
ch.stdout.pipe(process.stdout, {end: false}); | |
ch.stderr.pipe(process.stderr); | |
ch.stdout.on('data', function(data) { stdout[stdout.length] = data; }); | |
ch.stderr.on('data', function(data) { stderr[stderr.length] = data; }); | |
ch.on('exit', (callback || function (code) { | |
console.log('done', arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// requires hookio-request spawned | |
// requires https://github.com/Leonidas-from-XIV/node-xml2js installed | |
// npm install xml2js | |
var Hook = require('hook.io').Hook, | |
util = require('util'), | |
xml2js = require('xml2js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports, document) { | |
// ## cdnsjs | |
// | |
// example: get the list of cdnjs hosted scripts (http://developer.github.com/v3/git/trees/) | |
// GET /repos/:user/:repo/git/trees/:sha | |
// | |
// usage: | |
// cdnjs(function(err, data) { if(err) {return console.error(err);} console.log(data); }); | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <script type="text/someunknowntype" id="logo-svg"><svg>...</svg></script> | |
var svg = $('#logo-svg')[0].innerHTML | |
// >< whitespace cleanr >< | |
.replace(/>[\s]+</g, '><') | |
.replace(/[\s]+/g, ' ') | |
// get an array of path hash object, with path/attr property | |
.match(/<(path[^\/]+)\/>/g) | |
.map(function(el) { | |
var m = el.match(/<path d="([^"]+).+style="([^"]+).+/), | |
attr = {}, |