Skip to content

Instantly share code, notes, and snippets.

Miguel Castillo MiguelCastillo

Block or report user

Report or block MiguelCastillo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keypath parser.js
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 {
View http2-test.js
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 Mar 7, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View node-writing-stream.js
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");
View scriptloader.js
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);
//
View configureOptionArray.js
function configureOptionArray(config) {
var result = [];
if (config) {
if (!Array.isArray(config)) {
result.push(config);
}
else {
result = result.concat(config);
}
View bit-bundler-config.js
//
// 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");
View rulematcher-libarry.js
/**
* RuleMatcher is a helper class to define groups of rules. It provides methods
* to execute a particular criteria against one rule, a set of rules, or all
* rules.
*
* @class
*/
function RuleMatcher(config) {
if (!(this instanceof RuleMatcher)) {
return new RuleMatcher(config);
@MiguelCastillo
MiguelCastillo / bitloder-logger.js
Last active Aug 29, 2015
sample default Logger stream and serializer
View bitloder-logger.js
Bitloader.Logger.default.enable();
Bitloader.Logger.default.stream = {
write: function(buffer) {
console.log(buffer);
}
};
Bitloader.Logger.default.serialize = function(packet) {
return JSON.stringify({
@MiguelCastillo
MiguelCastillo / imports-plugin-config.js
Last active Aug 29, 2015
Sample config for bit-imports
View imports-plugin-config.js
//https://github.com/MiguelCastillo/bit-loader
//https://github.com/MiguelCastillo/bit-imports
/* jshint -W098 */
var require = (function() {
/* jshint +W098 */
var importer = bitimports.config({
"baseUrl": "../",
"paths": {
"chai": "../node_modules/chai/chai",
You can’t perform that action at this time.