Skip to content

Instantly share code, notes, and snippets.

@jdx
jdx / app.js
Last active October 16, 2015 21:10
'use strict';
angular.module('app', []);
angular.module('app')
.controller('TodoCtrl', function ($scope, TodoSvc) {
$scope.todos = [{title: 'Get paper'}, {title:'Mail rent check'}];
$scope.addTodo = function () {
TodoSvc.add($scope.newTodo)
'use strict';
let express = require('express');
let app = express();
app.get('/', function (req, res) {
// render out the angular bootstrap page
res.render('index.html.ejs');
});
@jdx
jdx / app.js
Last active October 15, 2015 21:08
'use strict';
angular.module('app', []);
angular.module('app')
.controller('TodoCtrl', function ($scope) {
$scope.todos = [{title: 'Get paper'}, {title: 'Mail rent check'}];
$scope.addTodo = function () {
$scope.todos.push($scope.newTodo);
@jdx
jdx / index.html
Last active October 16, 2015 21:09
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta charset="UTF-8">
<title>simple-mean</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.js"></script>
<script src="/scripts/app.js"></script>
</head>
<body>
<div ng-controller="TodoCtrl">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>simple-mean</title>
</head>
<body>
It works!
</body>
</html>
'use strict';
let express = require('express');
let app = express();
app.get('/', function (req, res) {
// render out the angular bootstrap page
res.render('index.html.ejs');
});
@jdx
jdx / express.js
Created October 14, 2015 19:29
Express.js example
'use strict';
let express = require('express');
let app = express();
app.get('/statuscheck', function (req, res) {
res.json({status: 'success'});
});
app.listen(process.env.PORT || 3000);
@jdx
jdx / koa.js
Last active October 16, 2015 14:28
koa example
app.get('/user/:id', function* (id) {
let user = yield db.get(id);
res.json(user);
});
@jdx
jdx / wrap.js
Created August 13, 2015 19:01
wrap inquirer in es6 promise
yield new Promise(function (resolve, reject) {
inquirer.prompt( questions, function ( answers ) {
if (answers.pipeline) resolve(answers.pipeline);
else reject('Must pick a pipeline');
});
});
@jdx
jdx / request.js
Last active August 29, 2015 14:24
simple node json http request function with promises and no dependencies
'use strict';
let http = require('http');
let https = require('https');
let parseUrl = require('url').parse;
function concat (stream, callback) {
var strings = [];
stream.on('data', function (data) {
strings.push(data);