Skip to content

Instantly share code, notes, and snippets.

View ConnectedReasoning's full-sized avatar

Manuel Hernandez ConnectedReasoning

  • Southern California
View GitHub Profile
@ConnectedReasoning
ConnectedReasoning / validateAlphanumeric.js
Last active October 17, 2017 14:21
Simple alphanumeric space and underline and dash javascript validation
function validateField() {
return{
IsValidInput : function(input){
var isValid = false;
var validChars = /^[a-z\d\-_\s\/]+$/i;
if (validChars.test(input)){
isValid = true;
}
return isValid;
}
@ConnectedReasoning
ConnectedReasoning / svgfixer.js
Created July 11, 2017 20:18 — forked from leonderijke/svgfixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@ConnectedReasoning
ConnectedReasoning / insertArray.js
Last active October 17, 2017 14:20
Insert array into a Mongo collection
var MongoClient = require("mongodb").MongoClient;
var url = "mongodb://localhost:27017/yourMongoDB";
var data = require("./dataFile.json");
MongoClient.connect(url, function(err, db){
if(err){
console.log(err);
} else {
@ConnectedReasoning
ConnectedReasoning / server.js
Last active March 2, 2018 13:42
Simple Node Express server
'use strict'
const express = require('express');
const http = require('http');
const path = require('path');
let app = express();
let publicPath = path.resolve(__dirname + '/dist/');
app.use(express.static(publicPath));
@ConnectedReasoning
ConnectedReasoning / index.html
Created October 17, 2017 14:18
HTML5 Bare Bones
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
@ConnectedReasoning
ConnectedReasoning / momentToInt.js
Created February 1, 2018 15:11
current timestamp moment to integer
const date_as_int = new Date(moment().toISOString()).getTime();
chunk(fieldArray, size) {
var chunkedArray = [];
for (var i=0; i<fieldArray.length; i+=size) {
chunkedArray.push(fieldArray.slice(i, i+size));
}
return chunkedArray;
}
@ConnectedReasoning
ConnectedReasoning / react_install.txt
Last active April 27, 2018 23:11
react starting
npm install --save-dev babel-core babel-loader babel-preset-env babel-preset-react chai debug mocha request css-loader style-loader webpack-dev-server eslint eslint-loader eslint-config-airbnb eslint-plugin-react webpack webpack-cli webpack-dev-server
npm install --save body-parser cookie-parser cors express lodash morgan neo4j-driver react react-dom react-webpack serve-favicon uuid
{
"name": "packer",
"version": "0.0.1",
"private": true,
"description": "API packer",
"scripts": {
"dev": "webpack-dev-server",
"build": "webpack",
"watch": "webpack --watch"
},
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSass = new ExtractTextPlugin({
filename: "[name].[contenthash].css",
disable: process.env.NODE_ENV === "development"
});
module.exports = {