Skip to content

Instantly share code, notes, and snippets.

View chrisl8888's full-sized avatar
πŸ’­
🏈

Chris Lee chrisl8888

πŸ’­
🏈
View GitHub Profile
var gulp = require('gulp');
var connect = require('gulp-connect');
var cors = function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
next();
};
gulp.task('server:test', function () {
// Define gulp before we start
var gulp = require('gulp');
// Define Sass and the autoprefixer
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
// This is an object which defines paths for the styles.
// Can add paths for javascript or images for example
// The folder, files to look for and destination are all required for sass
@chrisl8888
chrisl8888 / angularjs-inject-example.js
Last active January 13, 2016 19:20
Example angular inject es5 format.
(function (ng) {
"use strict";
function MyController($scope) {
// Use Controller As syntax
// https://github.com/johnpapa/angular-styleguide#style-y032
var vm = this;
@chrisl8888
chrisl8888 / react-component-lifecycle.js
Last active January 5, 2016 04:33
Reactjs component lifecycle
/**
* ------------------ The Life-Cycle of a Composite Component ------------------
*
* - constructor: Initialization of state. The instance is now retained.
* - componentWillMount
* - render
* - [children's constructors]
* - [children's componentWillMount and render]
* - [children's componentDidMount]
* - componentDidMount
function traverse(x, level) {
if (isArray(x)) {
traverseArray(x, level);
} else if ((typeof x === 'object') && (x !== null)) {
traverseObject(x, level);
} else {
console.log(level + x);
}
}
@chrisl8888
chrisl8888 / open-chrome-win.js
Created November 9, 2015 20:30
open chrome on windows
/*
* @TODO figure out why web security isn't working
*/
open = function (url, options) {
var uri = 'http://localhost:' + CONFIG.PORT + '/tms.html',
tempDir = 'C:/temp-chrome-eng';
var args = [
'--user-data-dir=' + tempDir,
@chrisl8888
chrisl8888 / gulp-prompt.js
Created November 9, 2015 19:51
Example gulp prompt implementation
/*
* Prompt Task
* WIP/ not integrated
*/
gulp.task('prompt', function () {
return gulp.src('')
.pipe(
$.prompt.prompt(
[{
type: 'input',
JSON.flatten = function(data) {
var result = {};
function recurse (cur, prop) {
if (Object(cur) !== cur) {
result[prop] = cur;
} else if (Array.isArray(cur)) {
for(var i=0, l=cur.length; i<l; i++)
recurse(cur[i], prop + "[" + i + "]");
if (l == 0)
result[prop] = [];