Skip to content

Instantly share code, notes, and snippets.

View chrisjlee's full-sized avatar
💭
🏈

Chris J. Lee chrisjlee

💭
🏈
View GitHub Profile
@chrisjlee
chrisjlee / protractor-is-present.js
Created January 22, 2016 05:34
protractor wait for item to be present with promise - stolen from http://docsplendid.com/archives/209
browser.wait(function() {
var deferred = protractor.promise.defer();
element(by.id('some-element')).isPresent()
.then(function (isPresent) {
deferred.fulfill(!isPresent);
});
return deferred.promise;
});
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
@chrisjlee
chrisjlee / 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;
@chrisjlee
chrisjlee / 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);
}
}
@chrisjlee
chrisjlee / 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,
@chrisjlee
chrisjlee / 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',