Skip to content

Instantly share code, notes, and snippets.

Miguel Castillo MiguelCastillo

View GitHub Profile
View bs-findinarray.js
function findInArray(items, value, predicate) {
predicate = predicate || contains;
var min = 0;
var max = items.length - 1;
var mid = Math.floor(items.length / 2);
var foundIndex = false;
while (foundIndex === false) {
if (predicate(items, value, min, mid)) {
View DOMReady.js
const deferred = new Promise(function(resolve) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
resolve();
}
else {
document.addEventListener('DOMContentLoaded', (/*evt*/) => resolve());
}
});
export default (fn) => deferred.then(fn);
View bundler-react-sample-config.json
{
"name": "test",
"version": "0.0.0",
"main": "index.js",
"scripts": {
"start": "run-p dev:* serve",
"build": "run-p build:*",
"serve": "3dub ./dist --watch --log false",
"build:js": "pakit src/index.js --dest dist/index.js",
"build:html": "cpx 'src/**/*.html' dist",
View bit-bundler-livereload.js
function livereload(options) {
var lr = require("tiny-lr");
var server = lr();
var port = options || 35729;
server.listen(port, function(err) {
console.log("livereload server started");
});
function bundleVisitor(cb) {
View bit-bundler-express-graphql.js
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql');
const Bitbundler = require('bit-bundler');
// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
input Module {
name: String!
version: String
View good-run.txt
[22:00:13] Using gulpfile ~//gulpfile.js
[22:00:13] Starting 'selenium'...
[22:00:15] Finished 'selenium' after 1.55 s
[22:00:15] Starting 'google'...
=======================================================================================
Selenium 2.0 / webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/api.html.
=======================================================================================
View bad-run.txt
[21:56:56] Using gulpfile ~//gulpfile.js
[21:56:56] Starting 'selenium'...
[21:56:58] Finished 'selenium' after 1.37 s
[21:56:58] Starting 'google'...
=======================================================================================
Selenium 2.0 / webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/api.html.
=======================================================================================
View goog-webdriver-not-sohappy.js
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;
View streamChain.js
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;
View xfrp.js
var stream = require("stream");
var inherits = require("util").inherits;
function thru(chunk, encoding, handler) {
handler.next(chunk);
}
function handlerWrapper(next) {
return {
next: function(chunk) {
You can’t perform that action at this time.