Skip to content

Instantly share code, notes, and snippets.

View MiguelCastillo's full-sized avatar

Miguel Castillo MiguelCastillo

View GitHub Profile
import { expect } from 'chai';
describe('Bad test when awaiting google Suite', () => {
beforeEach(async () => {
await browser.url('https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=bit-bundler');
});
describe('Getting all results container', () => {
var resultWithId, resultText;
function streamChain(seed) {
var accumulator = [];
var streamFacade = {
write: function() {
throw new TypeError("This is not a stream. Please call sequence or parallel to get a stream out of this.");
},
pipe: function(stream) {
if (!seed) {
seed = stream;
@MiguelCastillo
MiguelCastillo / xfrp.js
Last active August 25, 2016 17:01
stream frp
var stream = require("stream");
var inherits = require("util").inherits;
function thru(chunk, encoding, handler) {
handler.next(chunk);
}
function handlerWrapper(next) {
return {
next: function(chunk) {
function keypath(input) {
var regex = /(\w+)|\[([^\]]+)\]/g;
var result = [];
var path;
while ((path = regex.exec(input || ''))) {
if (input[path.index] === '[') {
result.push(path[2]);
}
else {
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
var chance = require("chance");
function fileStream(dest) {
mkdirp.sync(path.dirname(dest));
return fs.createWriteStream(dest);
}
@MiguelCastillo
MiguelCastillo / 0_reuse_code.js
Created March 7, 2016 18:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
function fileStream(dest) {
mkdirp.sync(path.dirname(dest));
return fs.createWriteStream(dest);
}
var writableStream = fileStream("./somecontent.js");
@MiguelCastillo
MiguelCastillo / scriptloader.js
Last active February 13, 2016 03:18
script loader
function loadScript(url) {
var head = document.getElementsByTagName("head")[0] || document.documentElement;
var script = document.createElement("script");
script.setAttribute("async", "true");
script.setAttribute("charset", "utf-8");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", url);
//
@MiguelCastillo
MiguelCastillo / configureOptionArray.js
Created January 1, 2016 17:33
configureOptionArray
function configureOptionArray(config) {
var result = [];
if (config) {
if (!Array.isArray(config)) {
result.push(config);
}
else {
result = result.concat(config);
}
@MiguelCastillo
MiguelCastillo / bit-bundler-config.js
Last active January 12, 2016 20:21
Sample bundler config
//
// http://24ways.org/2013/grunt-is-not-weird-and-hard/
//
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
var sassybits = require("sassy-bits");
var babelbits = require("babel-bits");
var jsBundler = require("bit-bundler-browserpack");